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:
1 parent
97eeae5876
commit
c051ba9585
1 file changed
+6
-2
@@ -118,13 +118,17 @@ fun ArticleContent(
|
||||
}
|
||||
is ArticleState.Success -> {
|
||||
val articleSaveKey = "${articleState.dictionaryPath}:${articleState.title}"
|
||||
val baseTextStyle = MaterialTheme.typography.bodyLarge.copy(
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
val colorScheme = MaterialTheme.colorScheme
|
||||
val typography = MaterialTheme.typography
|
||||
val baseTextStyle = remember(colorScheme, typography) {
|
||||
typography.bodyLarge.copy(
|
||||
color = colorScheme.onSurface,
|
||||
lineHeightStyle = LineHeightStyle(
|
||||
alignment = LineHeightStyle.Alignment.Proportional,
|
||||
trim = LineHeightStyle.Trim.Both,
|
||||
),
|
||||
)
|
||||
}
|
||||
val indentStep = 16.dp
|
||||
|
||||
// Use scroll position from ArticleState if available (for back navigation)
|
||||
|
||||
Reference in new issue
Block a user