Merge pull request #5588 from element-hq/feature/bma/iconPreviewDuplicate

Remove icon preview duplicate
This commit is contained in:
Benoit Marty 2025-10-23 10:40:41 +02:00 committed by GitHub
commit 0cff0e6f81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 11 additions and 91 deletions

View file

@ -41,13 +41,13 @@ import io.element.android.compound.tokens.generated.CompoundIcons
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
@Preview(widthDp = 730, heightDp = 1800)
@Preview(widthDp = 730, heightDp = 1920)
@Composable
internal fun IconsCompoundPreviewLight() = ElementTheme {
IconsCompoundPreview()
}
@Preview(widthDp = 730, heightDp = 1800)
@Preview(widthDp = 730, heightDp = 1920)
@Composable
internal fun IconsCompoundPreviewRtl() = ElementTheme {
CompositionLocalProvider(
@ -59,7 +59,7 @@ internal fun IconsCompoundPreviewRtl() = ElementTheme {
}
}
@Preview(widthDp = 730, heightDp = 1800)
@Preview(widthDp = 730, heightDp = 1920)
@Composable
internal fun IconsCompoundPreviewDark() = ElementTheme(darkTheme = true) {
IconsCompoundPreview()

View file

@ -15,4 +15,5 @@ internal val iconsOther = listOf(
R.drawable.ic_notification,
R.drawable.ic_stop,
R.drawable.pin,
R.drawable.ic_winner,
)

View file

@ -18,11 +18,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import androidx.compose.ui.unit.dp
import io.element.android.compound.theme.ElementTheme
import io.element.android.compound.tokens.generated.CompoundIcons
import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
import io.element.android.libraries.designsystem.theme.components.Icon
@ -30,53 +27,12 @@ import io.element.android.libraries.designsystem.theme.components.Text
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
internal class CompoundIconChunkProvider : PreviewParameterProvider<IconChunk> {
override val values: Sequence<IconChunk>
get() {
val chunks = CompoundIcons.allResIds.chunked(36)
return chunks.mapIndexed { index, chunk ->
IconChunk(index = index + 1, total = chunks.size, icons = chunk.toImmutableList())
}
.asSequence()
}
}
internal class OtherIconChunkProvider : PreviewParameterProvider<IconChunk> {
override val values: Sequence<IconChunk>
get() {
val chunks = iconsOther.chunked(36)
return chunks.mapIndexed { index, chunk ->
IconChunk(index = index + 1, total = chunks.size, icons = chunk.toImmutableList())
}
.asSequence()
}
}
internal data class IconChunk(
val index: Int,
val total: Int,
val icons: ImmutableList<Int>,
)
@PreviewsDayNight
@Composable
internal fun IconsCompoundPreview(@PreviewParameter(CompoundIconChunkProvider::class) chunk: IconChunk) = ElementPreview {
internal fun IconsOtherPreview() = ElementPreview {
IconsPreview(
title = "R.drawable.ic_compound_* ${chunk.index}/${chunk.total}",
iconsList = chunk.icons,
iconNameTransform = { name ->
name.removePrefix("ic_compound_")
.replace("_", " ")
}
)
}
@PreviewsDayNight
@Composable
internal fun IconsOtherPreview(@PreviewParameter(OtherIconChunkProvider::class) iconChunk: IconChunk) = ElementPreview {
IconsPreview(
title = "R.drawable.ic_* ${iconChunk.index}/${iconChunk.total}",
iconsList = iconChunk.icons,
title = "Other icons",
iconsList = iconsOther.toImmutableList(),
iconNameTransform = { name ->
name.removePrefix("ic_")
.replace("_", " ")

View file

@ -86,7 +86,6 @@ class KonsistPreviewTest {
"FocusedEventPreview",
"GradientFloatingActionButtonCircleShapePreview",
"HeaderFooterPageScrollablePreview",
"IconsCompoundPreview",
"IconsOtherPreview",
"MarkdownTextComposerEditPreview",
"MatrixBadgeAtomInfoPreview",

View file

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5c68e00a3f0697a9f179fe8541876fbd371da1d8b55e72c02fbb92d64814863a
size 67653

View file

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0332e0bbea7856b02adb7a660c758a313235351891428fdfb1816d0fa26df4d6
size 68540

View file

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4c798bec96147f50016dad808d51de76c24339a8b9afe0119993dadd7dbff845
size 73047

View file

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5cf492cd78477c2ce4c296fb6baa2af8baed6549fb51f58c06da9d4181aa8ac9
size 73796

View file

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a3ab14628f86c883effa49f51c02255a96a0050a9b4261322b2cf596ed5298ed
size 73233

View file

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f2151c4bbd49af17c8af90b946c94ec40b3f51edd25157abc5e87e1b4f7b7922
size 53698

View file

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:50113ec351ed12a7ee31b5b9333dabbcce242bf762d9d09d41301484e04f33ff
size 64549

View file

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:78f6f70dbc14f5b035f6f7d3cc042328be0894771443f188c9bf5581e40bcf59
size 65190

View file

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:cab2c2d5b07a795080fc887c6c8776a9a8630d9b2f6e5fde7ebb9f5f462fc41c
size 69708

View file

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ffb53277e999c57096a8d11a03b2835d30ba7f0e8b83db85d5d1a417bbe35502
size 70680

View file

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d21b4e71d6d52f1e9d844dbff96dcec86f5a04871b861ce0b619f173edca66cd
size 69772

View file

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f209a674db2371d1e85ec2b6d92468f92595f6b87948db19dd7aba8432221b67
size 51793

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e71f4f5c0d8f299ff91699612604f5b285160f5830a2b1e3e0c4092e85bd8aa7
size 14064
oid sha256:49f3e81d0a713630723c463c8705463e1ba04266624f71d6e29cd7d3a693c115
size 13789

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e526b48b8f340e5e5c31e0e976286a5d64f27928d3cdf00b3175e5840bc494f3
size 13282
oid sha256:76ecf55d5a354374db7b9ac14fb64fae7637b35b2908efcf73163b514710fcb0
size 13127