Skip to content

Commit

Permalink
[Paywalls V2] LocalizationKey is an inline value class now. (#1936)
Browse files Browse the repository at this point in the history
  • Loading branch information
JayShortway authored Nov 25, 2024
1 parent 8cb7bdb commit 10ff9df
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import kotlinx.serialization.encoding.Encoder
@JvmInline
internal value class LocaleId(val value: String)

internal typealias LocalizationKey = String
@Serializable
@JvmInline
internal value class LocalizationKey(val value: String)

internal typealias LocalizationDictionary = Map<LocalizationKey, LocalizationData>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ internal class ButtonComponentTests {
stack = StackComponent(
components = listOf(
TextComponent(
text = "7bkohQjzIE",
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(light = ColorInfo.Alias("primary"))
)
),
Expand Down Expand Up @@ -104,7 +104,7 @@ internal class ButtonComponentTests {
stack = StackComponent(
components = listOf(
TextComponent(
text = "7bkohQjzIE",
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(light = ColorInfo.Alias("primary"))
)
),
Expand Down Expand Up @@ -149,7 +149,7 @@ internal class ButtonComponentTests {
stack = StackComponent(
components = listOf(
TextComponent(
text = "7bkohQjzIE",
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(light = ColorInfo.Alias("primary"))
)
),
Expand Down Expand Up @@ -201,7 +201,7 @@ internal class ButtonComponentTests {
stack = StackComponent(
components = listOf(
TextComponent(
text = "7bkohQjzIE",
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(light = ColorInfo.Alias("primary"))
)
),
Expand Down Expand Up @@ -253,7 +253,7 @@ internal class ButtonComponentTests {
stack = StackComponent(
components = listOf(
TextComponent(
text = "7bkohQjzIE",
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(light = ColorInfo.Alias("primary"))
)
),
Expand Down Expand Up @@ -305,7 +305,7 @@ internal class ButtonComponentTests {
stack = StackComponent(
components = listOf(
TextComponent(
text = "7bkohQjzIE",
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(light = ColorInfo.Alias("primary"))
)
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ internal class ComponentOverridesTests {
}
""".trimIndent(),
expected = ComponentOverrides(
introOffer = PartialImageComponent(overrideSourceLid = "intro"),
introOffer = PartialImageComponent(overrideSourceLid = LocalizationKey("intro")),
states = ComponentStates(
selected = PartialImageComponent(overrideSourceLid = "selected")
selected = PartialImageComponent(overrideSourceLid = LocalizationKey("selected"))
),
conditions = ComponentConditions(
compact = PartialImageComponent(overrideSourceLid = "compact"),
medium = PartialImageComponent(overrideSourceLid = "medium"),
expanded = PartialImageComponent(overrideSourceLid = "expanded"),
compact = PartialImageComponent(overrideSourceLid = LocalizationKey("compact")),
medium = PartialImageComponent(overrideSourceLid = LocalizationKey("medium")),
expanded = PartialImageComponent(overrideSourceLid = LocalizationKey("expanded")),
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal class ComponentsConfigTests {
stack = StackComponent(
components = listOf(
TextComponent(
text = "7bkohQjzIE",
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(light = ColorInfo.Alias("primary"))
)
),
Expand Down Expand Up @@ -154,7 +154,7 @@ internal class ComponentsConfigTests {
stack = StackComponent(
components = listOf(
TextComponent(
text = "7bkohQjzIE",
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(light = ColorInfo.Alias("primary"))
)
),
Expand All @@ -168,7 +168,7 @@ internal class ComponentsConfigTests {
stack = StackComponent(
components = listOf(
TextComponent(
text = "7bkohQjzIE",
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(light = ColorInfo.Alias("primary"))
)
),
Expand Down Expand Up @@ -215,7 +215,7 @@ internal class ComponentsConfigTests {
stack = StackComponent(
components = listOf(
TextComponent(
text = "7bkohQjzIE",
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(light = ColorInfo.Alias("primary"))
)
),
Expand Down Expand Up @@ -267,7 +267,7 @@ internal class ComponentsConfigTests {
stack = StackComponent(
components = listOf(
TextComponent(
text = "7bkohQjzIE",
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(light = ColorInfo.Alias("primary"))
)
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ internal class ImageComponentTests {
)
),
size = Size(width = SizeConstraint.Fill, height = SizeConstraint.Fit),
overrideSourceLid = "abc123",
overrideSourceLid = LocalizationKey("abc123"),
maskShape = MaskShape.Rectangle(
corners = CornerRadiuses(
topLeading = 3.0,
Expand Down Expand Up @@ -248,7 +248,7 @@ internal class ImageComponentTests {
)
),
size = Size(width = SizeConstraint.Fill, height = SizeConstraint.Fit),
overrideSourceLid = "abc123",
overrideSourceLid = LocalizationKey("abc123"),
fitMode = FitMode.FILL,
maskShape = MaskShape.Rectangle(
corners = CornerRadiuses(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ internal class PackageComponentTests(@Suppress("UNUSED_PARAMETER") name: String,
stack = StackComponent(
components = listOf(
TextComponent(
text = "7bkohQjzIE",
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(light = ColorInfo.Alias("primary"))
)
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ internal class PaywallComponentsDataTests(
),
componentsLocalizations = mapOf(
LocaleId("en_US") to mapOf(
"ZvS4Ck5hGM" to LocalizationData.Text("Hello")
LocalizationKey("ZvS4Ck5hGM") to LocalizationData.Text("Hello")
)
),
defaultLocaleIdentifier = LocaleId("en_US"),
Expand Down Expand Up @@ -136,7 +136,7 @@ internal class PaywallComponentsDataTests(
),
componentsLocalizations = mapOf(
LocaleId("en_US") to mapOf(
"ZvS4Ck5hGM" to LocalizationData.Text("Hello")
LocalizationKey("ZvS4Ck5hGM") to LocalizationData.Text("Hello")
)
),
defaultLocaleIdentifier = LocaleId("en_US"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal class PurchaseButtonComponentTests(
stack = StackComponent(
components = listOf(
TextComponent(
text = "7bkohQjzIE",
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(light = ColorInfo.Alias("primary"))
)
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ internal class StackComponentTests {
expected = StackComponent(
components = listOf(
TextComponent(
text = "7bkohQjzIE",
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(light = ColorInfo.Alias("primary"))
)
),
Expand Down Expand Up @@ -179,7 +179,7 @@ internal class StackComponentTests {
expected = StackComponent(
components = listOf(
TextComponent(
text = "7bkohQjzIE",
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(light = ColorInfo.Alias("primary"))
)
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal class StickyFooterComponentTests(
stack = StackComponent(
components = listOf(
TextComponent(
text = "7bkohQjzIE",
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(light = ColorInfo.Alias("primary"))
)
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ internal class TextComponentTests {
}
""".trimIndent(),
expected = TextComponent(
text = "7bkohQjzIE",
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(
light = ColorInfo.Hex(colorInt(alpha = 0xff, red = 0, green = 0, blue = 0))
),
Expand Down Expand Up @@ -121,7 +121,7 @@ internal class TextComponentTests {
}
""".trimIndent(),
expected = TextComponent(
text = "7bkohQjzIE",
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(
light = ColorInfo.Hex(colorInt(alpha = 0xff, red = 0xff, green = 0xff, blue = 0xff))
),
Expand Down Expand Up @@ -217,7 +217,7 @@ internal class TextComponentTests {
""".trimIndent(),
expected = PartialTextComponent(
visible = false,
text = "7bkohQjzIE",
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(
light = ColorInfo.Hex(colorInt(alpha = 0xff, red = 0, green = 0, blue = 0))
),
Expand Down

0 comments on commit 10ff9df

Please sign in to comment.