From 8e39da347aa8d12eeb5ebc25b2a630077cef3f14 Mon Sep 17 00:00:00 2001 From: davotoula Date: Sat, 13 Sep 2025 18:16:43 +0200 Subject: [PATCH] don't use image gallery for secret message --- .../amethyst/ui/components/RichTextViewer.kt | 58 +++++-------------- 1 file changed, 16 insertions(+), 42 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt index 051289452..e1bfa656b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt @@ -796,53 +796,27 @@ fun CoreSecretMessage( ) if (localSecretContent.paragraphs.size == 1) { - RenderSecretParagraphOptimized( - localSecretContent.paragraphs[0].words.toImmutableList(), - context, - ) + localSecretContent.paragraphs[0].words.forEach { word -> + RenderWordWithPreview( + word, + context, + ) + } } else if (localSecretContent.paragraphs.size > 1) { val spaceWidth = measureSpaceWidth(LocalTextStyle.current) Column(CashuCardBorders) { localSecretContent.paragraphs.forEach { paragraph -> - RenderSecretParagraphOptimized( - paragraph.words.toImmutableList(), - context, - spaceWidth, - paragraph.isRTL, - ) - } - } - } -} - -@OptIn(ExperimentalLayoutApi::class) -@Composable -private fun RenderSecretParagraphOptimized( - words: ImmutableList, - context: RenderContext, - spaceWidth: Dp? = null, - isRTL: Boolean = false, -) { - // Check if we need single-image optimization - val imageSegments = words.filter { it is ImageSegment || it is Base64Segment } - - if (imageSegments.size > 1) { - // Multiple images - use gallery logic - RenderWordsWithImageGallery(words, context) - } else { - // Single or no images - render directly with FlowRow for optimal performance - val actualSpaceWidth = spaceWidth ?: measureSpaceWidth(LocalTextStyle.current) - - CompositionLocalProvider( - LocalLayoutDirection provides if (isRTL) LayoutDirection.Rtl else LayoutDirection.Ltr, - LocalTextStyle provides LocalTextStyle.current, - ) { - FlowRow( - horizontalArrangement = Arrangement.spacedBy(actualSpaceWidth), - ) { - words.forEach { word -> - RenderWordWithPreview(word, context) + FlowRow( + modifier = Modifier.align(if (paragraph.isRTL) Alignment.End else Alignment.Start), + horizontalArrangement = Arrangement.spacedBy(spaceWidth), + ) { + paragraph.words.forEach { word -> + RenderWordWithPreview( + word, + context, + ) + } } } }