Skip to content

Commit

Permalink
Improve Markdown readme sample
Browse files Browse the repository at this point in the history
  • Loading branch information
rock3r committed Feb 14, 2024
1 parent 90f5f34 commit 056b1a9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions markdown/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,18 @@ The second pass is done in the composition, and essentially renders a series of
@Composable
fun Markdown(blocks: List<MarkdownBlock>) {
val isDark = JewelTheme.isDark
val markdownStyling =
remember(isDark) { if (isDark) MarkdownStyling.dark() else MarkdownStyling.light() }
val blockRenderer = remember(markdownStyling, isDark) {
if (isDark) MarkdownBlockRenderer.dark() else MarkdownBlockRenderer.light()
}

val scrollState = rememberScrollState()
SelectionContainer(Modifier.fillMaxSize()) {
Column(
state = scrollState,
modifier = Modifier.verticalScroll(rememberScrollState()),
verticalArrangement = Arrangement.spacedBy(markdownStyling.blockVerticalSpacing),
) {
items(markdownBlocks) { blockRenderer.render(it) }
blockRenderer.render(blocks)
}
}
}
Expand Down

0 comments on commit 056b1a9

Please sign in to comment.