fix(article): stabilize baseTextStyle across recompositions

TextStyle.copy() returned a new instance on every recomposition, so the
remember() cache for the rendered blocks never hit. A text selection re-ran
block merging and recreated all article text nodes, rebuilding their
StaticLayouts repeatedly. Hoist the theme values and remember the style.
This commit is contained in:
OneWay committed 2026-10-06 09:42:54 +08:00
1 parent 9de47c7f0f
commit 87dccb4993
1 file changed
+6 -2
@@ -118,13 +118,17 @@ fun ArticleContent(
} }
is ArticleState.Success -> { is ArticleState.Success -> {
val articleSaveKey = "${articleState.dictionaryPath}:${articleState.title}" val articleSaveKey = "${articleState.dictionaryPath}:${articleState.title}"
val baseTextStyle = MaterialTheme.typography.bodyLarge.copy( val colorScheme = MaterialTheme.colorScheme
color = MaterialTheme.colorScheme.onSurface, val typography = MaterialTheme.typography
val baseTextStyle = remember(colorScheme, typography) {
typography.bodyLarge.copy(
color = colorScheme.onSurface,
lineHeightStyle = LineHeightStyle( lineHeightStyle = LineHeightStyle(
alignment = LineHeightStyle.Alignment.Proportional, alignment = LineHeightStyle.Alignment.Proportional,
trim = LineHeightStyle.Trim.Both, trim = LineHeightStyle.Trim.Both,
), ),
) )
}
val indentStep = 16.dp val indentStep = 16.dp
// Use scroll position from ArticleState if available (for back navigation) // Use scroll position from ArticleState if available (for back navigation)