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
+11
-7
@@ -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
|
||||||
lineHeightStyle = LineHeightStyle(
|
val baseTextStyle = remember(colorScheme, typography) {
|
||||||
alignment = LineHeightStyle.Alignment.Proportional,
|
typography.bodyLarge.copy(
|
||||||
trim = LineHeightStyle.Trim.Both,
|
color = colorScheme.onSurface,
|
||||||
),
|
lineHeightStyle = LineHeightStyle(
|
||||||
)
|
alignment = LineHeightStyle.Alignment.Proportional,
|
||||||
|
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)
|
||||||
|
|||||||
Reference in new issue
Block a user