mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-27 19:06:34 +02:00
found a place where image gallery was used for single images
This commit is contained in:
@@ -404,10 +404,9 @@ private fun RenderSingleParagraphWithFlowRow(
|
|||||||
FlowRow(
|
FlowRow(
|
||||||
horizontalArrangement = Arrangement.spacedBy(spaceWidth),
|
horizontalArrangement = Arrangement.spacedBy(spaceWidth),
|
||||||
) {
|
) {
|
||||||
RenderWordsWithImageGallery(
|
words.forEach { word ->
|
||||||
words,
|
RenderWordWithPreview(word, context)
|
||||||
context,
|
}
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -797,7 +796,7 @@ fun CoreSecretMessage(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (localSecretContent.paragraphs.size == 1) {
|
if (localSecretContent.paragraphs.size == 1) {
|
||||||
RenderWordsWithImageGallery(
|
RenderSecretParagraphOptimized(
|
||||||
localSecretContent.paragraphs[0].words.toImmutableList(),
|
localSecretContent.paragraphs[0].words.toImmutableList(),
|
||||||
context,
|
context,
|
||||||
)
|
)
|
||||||
@@ -806,18 +805,48 @@ fun CoreSecretMessage(
|
|||||||
|
|
||||||
Column(CashuCardBorders) {
|
Column(CashuCardBorders) {
|
||||||
localSecretContent.paragraphs.forEach { paragraph ->
|
localSecretContent.paragraphs.forEach { paragraph ->
|
||||||
FlowRow(
|
RenderSecretParagraphOptimized(
|
||||||
modifier = Modifier.align(if (paragraph.isRTL) Alignment.End else Alignment.Start),
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(spaceWidth),
|
|
||||||
) {
|
|
||||||
RenderWordsWithImageGallery(
|
|
||||||
paragraph.words.toImmutableList(),
|
paragraph.words.toImmutableList(),
|
||||||
context,
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
Reference in New Issue
Block a user