found a place where image gallery was used for single images

This commit is contained in:
davotoula
2025-09-12 12:14:05 +02:00
parent ee9e102eb2
commit 16e3cba651

View File

@@ -404,10 +404,9 @@ private fun RenderSingleParagraphWithFlowRow(
FlowRow(
horizontalArrangement = Arrangement.spacedBy(spaceWidth),
) {
RenderWordsWithImageGallery(
words,
context,
)
words.forEach { word ->
RenderWordWithPreview(word, context)
}
}
}
}
@@ -797,7 +796,7 @@ fun CoreSecretMessage(
)
if (localSecretContent.paragraphs.size == 1) {
RenderWordsWithImageGallery(
RenderSecretParagraphOptimized(
localSecretContent.paragraphs[0].words.toImmutableList(),
context,
)
@@ -806,14 +805,44 @@ fun CoreSecretMessage(
Column(CashuCardBorders) {
localSecretContent.paragraphs.forEach { paragraph ->
FlowRow(
modifier = Modifier.align(if (paragraph.isRTL) Alignment.End else Alignment.Start),
horizontalArrangement = Arrangement.spacedBy(spaceWidth),
) {
RenderWordsWithImageGallery(
paragraph.words.toImmutableList(),
context,
)
RenderSecretParagraphOptimized(
paragraph.words.toImmutableList(),
context,
spaceWidth,
paragraph.isRTL,
)
}
}
}
}
@OptIn(ExperimentalLayoutApi::class)
@Composable
private fun RenderSecretParagraphOptimized(
words: ImmutableList<Segment>,
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)
}
}
}