Merge pull request #184 from JMR-dev/feat-71-strikethrough
feat(compose): add strikethrough to the formatting toolbar
This commit was merged in pull request #184.
This commit is contained in:
@@ -190,6 +190,13 @@ private fun FormattingToolbar(
|
||||
underline = true,
|
||||
onClick = { onToggleStyle(RichStyle.Underline) },
|
||||
)
|
||||
FormatButton(
|
||||
label = "S",
|
||||
description = stringResource(R.string.format_strikethrough),
|
||||
active = RichTextEditing.isStyled(content, start, end, RichStyle.Strikethrough),
|
||||
strikethrough = true,
|
||||
onClick = { onToggleStyle(RichStyle.Strikethrough) },
|
||||
)
|
||||
FormatButton(
|
||||
label = "•",
|
||||
description = stringResource(R.string.format_bullet_list),
|
||||
@@ -226,6 +233,7 @@ private fun FormatButton(
|
||||
fontWeight: FontWeight? = null,
|
||||
fontStyle: FontStyle? = null,
|
||||
underline: Boolean = false,
|
||||
strikethrough: Boolean = false,
|
||||
) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val background = if (active) colors.secondaryContainer else Color.Transparent
|
||||
@@ -244,7 +252,11 @@ private fun FormatButton(
|
||||
style = LocalTextStyle.current.copy(
|
||||
fontWeight = fontWeight,
|
||||
fontStyle = fontStyle,
|
||||
textDecoration = if (underline) TextDecoration.Underline else null,
|
||||
textDecoration = when {
|
||||
underline -> TextDecoration.Underline
|
||||
strikethrough -> TextDecoration.LineThrough
|
||||
else -> null
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@
|
||||
<string name="format_bold">Bold</string>
|
||||
<string name="format_italic">Italic</string>
|
||||
<string name="format_underline">Underline</string>
|
||||
<string name="format_strikethrough">Strikethrough</string>
|
||||
<string name="format_bullet_list">Bulleted list</string>
|
||||
<string name="format_numbered_list">Numbered list</string>
|
||||
<string name="format_quote">Block quote</string>
|
||||
|
||||
Reference in New Issue
Block a user