Merge pull request #5588 from element-hq/feature/bma/iconPreviewDuplicate
Remove icon preview duplicate
This commit is contained in:
commit
d3feb237a1
18 changed files with 11 additions and 91 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -15,4 +15,5 @@ internal val iconsOther = listOf(
|
|||
R.drawable.ic_notification,
|
||||
R.drawable.ic_stop,
|
||||
R.drawable.pin,
|
||||
R.drawable.ic_winner,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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("_", " ")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue