Remove icon preview duplication.
We now have IconsCompoundPreview with the same content in only one image.
This commit is contained in:
parent
570c1ebdb4
commit
5437a5738f
1 changed files with 3 additions and 47 deletions
|
|
@ -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