From 60a8e7df1b51da983917f637dde8a327c8d49202 Mon Sep 17 00:00:00 2001 From: Jason Ross Date: Thu, 2 Jul 2026 19:19:14 -0500 Subject: [PATCH] feat(compose): add strikethrough to the formatting toolbar The rich-text engine already fully supported RichStyle.Strikethrough (HTML serialization, parsing, and rendering); only the toolbar control was missing. Adds an "S" FormatButton next to Bold/Italic/Underline, wired the same way (onToggleStyle + isStyled toggle state), plus the format_strikethrough string resource for its onClickLabel. Co-Authored-By: Claude Opus 4.8 --- .../org/libremail/ui/compose/RichTextEditor.kt | 14 +++++++++++++- app/src/main/res/values/strings.xml | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/org/libremail/ui/compose/RichTextEditor.kt b/app/src/main/kotlin/org/libremail/ui/compose/RichTextEditor.kt index 4f30d49..f97dae1 100644 --- a/app/src/main/kotlin/org/libremail/ui/compose/RichTextEditor.kt +++ b/app/src/main/kotlin/org/libremail/ui/compose/RichTextEditor.kt @@ -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 + }, ), ) } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 529f981..0554cde 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -97,6 +97,7 @@ Bold Italic Underline + Strikethrough Bulleted list Numbered list Block quote -- 2.47.3