mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Rename PreviewParameterProvider subclasses to the PreviewParam suffix
The `Provider` suffix reads as a dependency provider rather than as preview
data, and it collides with the real providers in the codebase — `StringProvider`,
`PickerProvider`, the login feature's `AccountProvider` — so the name says
nothing about which of the two a class is. `PreviewParam` says it.
195 classes are renamed, along with the 185 files named after them, the konsist
rule that enforces the convention, the presentation-class file templates and the
onboarding documentation.
This cannot be split. `Konsist.scopeFromProduction()` scans the whole project, so
flipping the assertion before every class has moved leaves the rule red, and a
rule that accepted either suffix during a transition would be exactly the kind of
compatibility layer this convention change is meant to remove.
Two judgement calls in the rule itself. The `name.endsWith("PreviewProvider")`
exclusion is dropped: its only job was to reject a redundant `Preview` before
`Provider`, and the new suffix already contains it; no class currently ends with
`PreviewProvider`, so removing it changes nothing today. And
`EditableAvatarViewUriProvider` is renamed rather than deleted from the exclusion
list even though no such class exists in this repository, since it presumably
comes from the modules overlaid for the enterprise build.
Nothing keyed off the old suffix: no snapshot filename contains a provider class
name, so no Paparazzi image changes, and the Kover variants match on `*Presenter`,
`*State` and `*ViewKt`, so coverage bounds are unaffected.
This commit is contained in:
+1
-1
@@ -134,7 +134,7 @@ enum class ComposerAlertLevel {
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun ComposerAlertMoleculePreview(
|
||||
@PreviewParameter(ComposerAlertMoleculeParamsProvider::class) params: ComposerAlertMoleculeParams,
|
||||
@PreviewParameter(ComposerAlertMoleculeParamsPreviewParam::class) params: ComposerAlertMoleculeParams,
|
||||
) = ElementPreview {
|
||||
ComposerAlertMolecule(
|
||||
avatar = params.avatar,
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ internal data class ComposerAlertMoleculeParams(
|
||||
val showIcon: Boolean = false,
|
||||
)
|
||||
|
||||
internal class ComposerAlertMoleculeParamsProvider : PreviewParameterProvider<ComposerAlertMoleculeParams> {
|
||||
internal class ComposerAlertMoleculeParamsPreviewParam : PreviewParameterProvider<ComposerAlertMoleculeParams> {
|
||||
private val allLevels = sequenceOf(
|
||||
ComposerAlertLevel.Info,
|
||||
ComposerAlertLevel.Critical
|
||||
+2
-2
@@ -160,7 +160,7 @@ internal fun BigIconPreview() = ElementPreview {
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp),
|
||||
) {
|
||||
items(BigIconStyleProvider().values.toList()) { style ->
|
||||
items(BigIconStylePreviewParam().values.toList()) { style ->
|
||||
Box(
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
@@ -170,7 +170,7 @@ internal fun BigIconPreview() = ElementPreview {
|
||||
}
|
||||
}
|
||||
|
||||
internal class BigIconStyleProvider : PreviewParameterProvider<BigIcon.Style> {
|
||||
internal class BigIconStylePreviewParam : PreviewParameterProvider<BigIcon.Style> {
|
||||
override val values: Sequence<BigIcon.Style>
|
||||
get() = sequenceOf(
|
||||
BigIcon.Style.Default(Icons.Filled.CatchingPokemon),
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ package io.element.android.libraries.designsystem.components.async
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import io.element.android.libraries.architecture.AsyncAction
|
||||
|
||||
open class AsyncActionProvider : PreviewParameterProvider<AsyncAction<Unit>> {
|
||||
open class AsyncActionPreviewParam : PreviewParameterProvider<AsyncAction<Unit>> {
|
||||
override val values: Sequence<AsyncAction<Unit>>
|
||||
get() = sequenceOf(
|
||||
AsyncAction.Uninitialized,
|
||||
+1
-1
@@ -82,7 +82,7 @@ object AsyncActionViewDefaults {
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun AsyncActionViewPreview(
|
||||
@PreviewParameter(AsyncActionProvider::class) async: AsyncAction<Unit>,
|
||||
@PreviewParameter(AsyncActionPreviewParam::class) async: AsyncAction<Unit>,
|
||||
) = ElementPreview {
|
||||
AsyncActionView(
|
||||
async = async,
|
||||
|
||||
+5
-5
@@ -24,7 +24,7 @@ import androidx.compose.ui.platform.LocalLayoutDirection
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.unit.LayoutDirection
|
||||
import androidx.compose.ui.unit.dp
|
||||
import io.element.android.libraries.designsystem.components.avatar.internal.OverlapRatioProvider
|
||||
import io.element.android.libraries.designsystem.components.avatar.internal.OverlapRatioPreviewParam
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
import io.element.android.libraries.designsystem.text.toPx
|
||||
@@ -110,7 +110,7 @@ fun AvatarRow(
|
||||
|
||||
@Composable
|
||||
@PreviewsDayNight
|
||||
internal fun AvatarRowPreview(@PreviewParameter(OverlapRatioProvider::class) overlapRatio: Float) {
|
||||
internal fun AvatarRowPreview(@PreviewParameter(OverlapRatioPreviewParam::class) overlapRatio: Float) {
|
||||
ElementPreview {
|
||||
ContentToPreview(overlapRatio)
|
||||
}
|
||||
@@ -118,7 +118,7 @@ internal fun AvatarRowPreview(@PreviewParameter(OverlapRatioProvider::class) ove
|
||||
|
||||
@Composable
|
||||
@PreviewsDayNight
|
||||
internal fun AvatarRowLastOnTopPreview(@PreviewParameter(OverlapRatioProvider::class) overlapRatio: Float) {
|
||||
internal fun AvatarRowLastOnTopPreview(@PreviewParameter(OverlapRatioPreviewParam::class) overlapRatio: Float) {
|
||||
ElementPreview {
|
||||
ContentToPreview(
|
||||
overlapRatio = overlapRatio,
|
||||
@@ -129,7 +129,7 @@ internal fun AvatarRowLastOnTopPreview(@PreviewParameter(OverlapRatioProvider::c
|
||||
|
||||
@Composable
|
||||
@PreviewsDayNight
|
||||
internal fun AvatarRowRtlPreview(@PreviewParameter(OverlapRatioProvider::class) overlapRatio: Float) {
|
||||
internal fun AvatarRowRtlPreview(@PreviewParameter(OverlapRatioPreviewParam::class) overlapRatio: Float) {
|
||||
CompositionLocalProvider(
|
||||
LocalLayoutDirection provides LayoutDirection.Rtl,
|
||||
) {
|
||||
@@ -141,7 +141,7 @@ internal fun AvatarRowRtlPreview(@PreviewParameter(OverlapRatioProvider::class)
|
||||
|
||||
@Composable
|
||||
@PreviewsDayNight
|
||||
internal fun AvatarRowLastOnTopRtlPreview(@PreviewParameter(OverlapRatioProvider::class) overlapRatio: Float) {
|
||||
internal fun AvatarRowLastOnTopRtlPreview(@PreviewParameter(OverlapRatioPreviewParam::class) overlapRatio: Float) {
|
||||
CompositionLocalProvider(
|
||||
LocalLayoutDirection provides LayoutDirection.Rtl,
|
||||
) {
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ package io.element.android.libraries.designsystem.components.avatar.internal
|
||||
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
|
||||
class OverlapRatioProvider : PreviewParameterProvider<Float> {
|
||||
class OverlapRatioPreviewParam : PreviewParameterProvider<Float> {
|
||||
override val values: Sequence<Float> = sequenceOf(
|
||||
0f,
|
||||
0.25f,
|
||||
+1
-1
@@ -13,7 +13,7 @@ import androidx.compose.material.icons.filled.BugReport
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
|
||||
open class ImageVectorProvider : PreviewParameterProvider<ImageVector?> {
|
||||
open class ImageVectorPreviewParam : PreviewParameterProvider<ImageVector?> {
|
||||
override val values: Sequence<ImageVector?>
|
||||
get() = sequenceOf(
|
||||
Icons.Default.BugReport,
|
||||
+2
-2
@@ -86,7 +86,7 @@ private fun PreferenceIcon(
|
||||
|
||||
@Preview(group = PreviewGroup.Preferences)
|
||||
@Composable
|
||||
internal fun PreferenceIconPreview(@PreviewParameter(ImageVectorProvider::class) content: ImageVector?) =
|
||||
internal fun PreferenceIconPreview(@PreviewParameter(ImageVectorPreviewParam::class) content: ImageVector?) =
|
||||
ElementThemedPreview {
|
||||
PreferenceIcon(
|
||||
icon = content,
|
||||
@@ -96,7 +96,7 @@ internal fun PreferenceIconPreview(@PreviewParameter(ImageVectorProvider::class)
|
||||
|
||||
@Preview(group = PreviewGroup.Preferences)
|
||||
@Composable
|
||||
internal fun PreferenceIconWithBadgePreview(@PreviewParameter(ImageVectorProvider::class) content: ImageVector?) =
|
||||
internal fun PreferenceIconWithBadgePreview(@PreviewParameter(ImageVectorPreviewParam::class) content: ImageVector?) =
|
||||
ElementThemedPreview {
|
||||
PreferenceIcon(
|
||||
icon = content,
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ package io.element.android.libraries.designsystem.utils
|
||||
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
|
||||
open class BooleanProvider : PreviewParameterProvider<Boolean> {
|
||||
open class BooleanPreviewParam : PreviewParameterProvider<Boolean> {
|
||||
override val values: Sequence<Boolean>
|
||||
get() = sequenceOf(true, false)
|
||||
}
|
||||
Reference in New Issue
Block a user