Skip to content

Commit

Permalink
[Paywalls V2] Fixes various deserialization issues (#2018)
Browse files Browse the repository at this point in the history
  • Loading branch information
JayShortway authored Jan 3, 2025
1 parent af72255 commit 07b8391
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ enum class FontWeight {
@SerialName("medium")
MEDIUM,

@SerialName("semi_bold")
@SerialName("semibold")
SEMI_BOLD,

@SerialName("bold")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ class Padding(
/**
* The top padding, in dp.
*/
@get:JvmSynthetic val top: Double,
@get:JvmSynthetic val top: Double = 0.0,
/**
* The bottom padding, in dp.
*/
@get:JvmSynthetic val bottom: Double,
@get:JvmSynthetic val bottom: Double = 0.0,
/**
* The leading, or start, padding, in dp.
*/
@get:JvmSynthetic val leading: Double,
@get:JvmSynthetic val leading: Double = 0.0,
/**
* The trailing, or end, padding, in dp.
*/
@get:JvmSynthetic val trailing: Double,
@get:JvmSynthetic val trailing: Double = 0.0,
) {
companion object {
@get:JvmSynthetic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,44 @@ internal class StackComponentTests {
)
),
),
arrayOf(
"empty margin and padding",
Args(
json = """
{
"components": [
{
"color": {
"light": {
"type": "alias",
"value": "primary"
}
},
"components": [],
"id": "xmpgCrN9Rb",
"name": "Text",
"text_lid": "7bkohQjzIE",
"type": "text"
}
],
"margin": {},
"name": "Stack",
"padding": {},
"type": "stack"
}
""".trimIndent(),
expected = StackComponent(
components = listOf(
TextComponent(
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(light = ColorInfo.Alias("primary"))
)
),
margin = Padding.zero,
padding = Padding.zero,
)
),
),
)
}

Expand Down Expand Up @@ -326,6 +364,21 @@ internal class StackComponentTests {
expected = PartialStackComponent()
)
),
arrayOf(
"empty padding and margin",
Args(
json = """
{
"padding": {},
"margin": {}
}
""".trimIndent(),
expected = PartialStackComponent(
padding = Padding.zero,
margin = Padding.zero,
)
)
),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,36 @@ internal class TextComponentTests {
)
)
),
arrayOf(
"empty margin and padding",
Args(
json = """
{
"color": {
"light": {
"type": "hex",
"value": "#ffffff"
}
},
"components": [],
"id": "xmpgCrN9Rb",
"margin": {},
"name": "Text",
"padding": {},
"text_lid": "7bkohQjzIE",
"type": "text"
}
""".trimIndent(),
expected = TextComponent(
text = LocalizationKey("7bkohQjzIE"),
color = ColorScheme(
light = ColorInfo.Hex(colorInt(alpha = 0xff, red = 0xff, green = 0xff, blue = 0xff))
),
padding = Padding.zero,
margin = Padding.zero,
)
)
),
)
}

Expand Down Expand Up @@ -244,6 +274,21 @@ internal class TextComponentTests {
expected = PartialTextComponent()
)
),
arrayOf(
"empty margin and padding",
Args(
json = """
{
"margin": {},
"padding": {}
}
""".trimIndent(),
expected = PartialTextComponent(
padding = Padding.zero,
margin = Padding.zero,
)
)
),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal class FontTests {
FontWeight.LIGHT -> "\"light\""
FontWeight.REGULAR -> "\"regular\""
FontWeight.MEDIUM -> "\"medium\""
FontWeight.SEMI_BOLD -> "\"semi_bold\""
FontWeight.SEMI_BOLD -> "\"semibold\""
FontWeight.BOLD -> "\"bold\""
FontWeight.EXTRA_BOLD -> "\"extra_bold\""
FontWeight.BLACK -> "\"black\""
Expand Down

0 comments on commit 07b8391

Please sign in to comment.