RichTextThemeProvider(
// // Overrides every other style in BasicRichText
// textStyleProvider = {
// TextStyle.Default.copy(
// fontSize = 18.sp,
// lineHeight = 22.sp
// )
// },
// textStyleBackProvider = { style, content ->
// ProvideTextStyle(style.copy(color = Color.Red)) {
// Box(modifier = Modifier.border(1.dp, Color.Green).padding(8.dp)) {
// content()
// }
// }
// },
// contentColorProvider = {
// // This is Text Color
// Color(0xffFF8F00)
// },
// contentColorBackProvider = { color, content ->
// Box(modifier = Modifier.border(3.dp, Color.Red)) {
// content()
// }
// }
) {
BasicRichText(
modifier = Modifier,
style = RichTextStyle.Default
.copy(
paragraphSpacing = 16.sp,
codeBlockStyle = CodeBlockStyle(
textStyle = TextStyle.Default.copy(color = Color.Blue)
),
headingStyle = { index, textStyle ->
when (index) {
1 -> textStyle.copy(
fontSize = 26.sp,
fontWeight = FontWeight.SemiBold,
lineHeight = 32.sp,
color = Color(0xffF44336)
)
2 -> textStyle.copy(
fontSize = 22.sp,
fontWeight = FontWeight.SemiBold,
lineHeight = 28.sp,
color = Color(0xff8E24AA)
)
3 -> textStyle.copy(
fontSize = 20.sp,
fontWeight = FontWeight.Medium,
lineHeight = 26.sp,
color = Color(0xff1E88E5)
)
4 -> textStyle.copy(
fontSize = 18.sp,
fontWeight = FontWeight.Medium,
lineHeight = 24.sp,
color = Color(0xff43A047)
)
5 -> textStyle.copy(
fontSize = 16.sp,
fontWeight = FontWeight.Medium,
lineHeight = 22.sp,
color = Color(0xff546E7A)
)
else -> textStyle.copy(
fontSize = 14.sp,
fontWeight = FontWeight.Medium,
lineHeight = 20.sp,
color = Color(0xff6D4C41)
)
}
},
stringStyle = RichTextStringStyle(
boldStyle = SpanStyle(
color = Color.Magenta,
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
)
)
) {
BasicMarkdown(astNode = astNode)
}
}
If i set text style in
textStyleProvideri'm not able to set header style, they are overridden by this style, all of them have same size and color, etc. Is there a way to set header styles and text style independent of each other?Is there a style to set text style in
BasicRichTextwithstringStyle?Sample to try ti out