Closed tSquaredd closed 1 year ago
Hi there! Using this library and have a use case that might be useful for others.
I need to be able to set a max lines value of X and if the markdown is longer than X lines I need to display a "Show More" button.
X
So I need 2 things:
MarkdownText
Example Usage with X = 3:
X = 3
var isExpanded by remember { mutableStateOf(false) } var showMoreButton by remember { mutableStateOf(false) } Column { MarkdownText( markdown = descriptionMarkdown, maxLines = if (isExpanded) Int.MAX_VALUE else 3, onTextLayout = { lineCount -> if (lineCount > 3) { showMoreButton = true } } ) if (showMoreButton) { Spacer(modifier = Modifier.height(8.dp)) TextButton( state = TextButtonState(text = stringResource(id = R.string.show_more)), onClick = { isExpanded = !isExpanded } ) } }
Hi, @tSquaredd! Thanks for contributing!
@jeziellago no problem! Thank you for providing this library to use 🙃
Hi there! Using this library and have a use case that might be useful for others.
I need to be able to set a max lines value of
X
and if the markdown is longer thanX
lines I need to display a "Show More" button.So I need 2 things:
X
lines is needed to display the full markdown textMarkdownText
update.Example Usage with
X = 3
: