I created the view as below:
@Composable
fun DynamicMessageBanner(
title: String,
message: String,
clickableText: AnnotatedString,
onClickableTextClicked: () -> Unit,
onCloseClicked: () -> Unit
) {
Card(
modifier = Modifier
.fillMaxWidth()
.border(width = 1.dp, color = UIBlue, shape = RoundedCornerShape(size = 4.dp)),
backgroundColor = UIBlue20,
shape = RoundedCornerShape(4.dp),
elevation = 0.dp
) {
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) {
Box(contentAlignment = Alignment.TopEnd) {
IconButton(onClick = onCloseClicked) {
Icon(
painterResource(id = R.drawable.ic_cross), null,
modifier = Modifier
.width(24.dp)
.height(24.dp),
tint = Color.Unspecified
)
}
}
}
Column(
modifier = Modifier
.fillMaxWidth()
.padding(12.dp, 0.dp)
) {
Spacer(modifier = Modifier.height(12.dp))
Text(text = title, style = MercuryTheme.typography.headline50)
Spacer(modifier = Modifier.height(12.dp))
Text(
text = message,
style = MercuryTheme.typography.paragraph500Medium,
)
Spacer(modifier = Modifier.height(8.dp))
ClickableText(
modifier = Modifier.align(Alignment.Start),
text = clickableText,
style = MercuryTheme.typography.paragraph400Medium,
) {
onClickableTextClicked()
}
Spacer(modifier = Modifier.height(12.dp))
}
}
}
The problem I have at the moment is that, the title text will overlap the X button on the right corner if the text is too long. Is there any best practice creating this kind of view with adding the button to the top right corner first before generating the text?
Currently the view looks like this (text overlaps button on top right corner):
Thanks.