Skip to content

Commit 2d38edf

Browse files
JZDesigncursoragentjacob.rakidzich
authored
Chore: Add default size to Fit size constraints (#3778)
<!-- CURSOR_AGENT_PR_BODY_BEGIN --> ### Checklist - [x] If applicable, unit tests - [ ] If applicable, create follow-up issues for `purchases-ios` and hybrids ### Motivation Mirrors [purchases-ios#7226](RevenueCat/purchases-ios#7226). We're adding a new component that needs to take up space while it loads. ### Description Adds an optional `default` value to `SizeConstraint.Fit` and updates existing call sites for compilation. Needed for https://linear.app/revenuecat/issue/PWENG-98 - `SizeConstraint.Fit` is now a class with optional `default: UInt?` (JSON field `"default"`) - Decoding still accepts fit payloads without `default` (falls back to `Fit()` / `null`) - Call sites updated from `Fit` to `Fit()`; stack layout checks use `is Fit` / `!is Fit` - Layout does not yet consume the default value Verified with `:purchases:testDefaultsDebugUnitTest` (`SizeTests`, component decode tests) and `:ui:revenuecatui` compile. > [!NOTE] > This is not yet used anywhere. <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-e2697e46-8860-431e-adc6-7b6f2f2530b4"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/background-agent?bcId=bc-e2697e46-8860-431e-adc6-7b6f2f2530b4"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: jacob.rakidzich <jacob.rakidzich@revenuecat.com>
1 parent fd4ba00 commit 2d38edf

41 files changed

Lines changed: 333 additions & 259 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/paywall-tester/src/main/java/com/revenuecat/paywallstester/SamplePaywalls.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -854,63 +854,63 @@ object SamplePaywalls {
854854
fontWeight = FontWeight.BOLD,
855855
fontSize = 28,
856856
horizontalAlignment = LEADING,
857-
size = Size(width = Fill, height = Fit),
857+
size = Size(width = Fill, height = Fit()),
858858
margin = Padding(top = 0.0, bottom = 40.0, leading = 0.0, trailing = 0.0),
859859
),
860860
TextComponent(
861861
text = LocalizationKey("feature-1"),
862862
color = textColor,
863863
fontName = font,
864864
horizontalAlignment = LEADING,
865-
size = Size(width = Fill, height = Fit),
865+
size = Size(width = Fill, height = Fit()),
866866
margin = Padding(top = 8.0, bottom = 8.0, leading = 0.0, trailing = 0.0),
867867
),
868868
TextComponent(
869869
text = LocalizationKey("feature-2"),
870870
color = textColor,
871871
fontName = font,
872872
horizontalAlignment = LEADING,
873-
size = Size(width = Fill, height = Fit),
873+
size = Size(width = Fill, height = Fit()),
874874
margin = Padding(top = 8.0, bottom = 8.0, leading = 0.0, trailing = 0.0),
875875
),
876876
TextComponent(
877877
text = LocalizationKey("feature-3"),
878878
color = textColor,
879879
fontName = font,
880880
horizontalAlignment = LEADING,
881-
size = Size(width = Fill, height = Fit),
881+
size = Size(width = Fill, height = Fit()),
882882
margin = Padding(top = 8.0, bottom = 8.0, leading = 0.0, trailing = 0.0),
883883
),
884884
TextComponent(
885885
text = LocalizationKey("feature-4"),
886886
color = textColor,
887887
fontName = font,
888888
horizontalAlignment = LEADING,
889-
size = Size(width = Fill, height = Fit),
889+
size = Size(width = Fill, height = Fit()),
890890
margin = Padding(top = 8.0, bottom = 8.0, leading = 0.0, trailing = 0.0),
891891
),
892892
TextComponent(
893893
text = LocalizationKey("feature-5"),
894894
color = textColor,
895895
fontName = font,
896896
horizontalAlignment = LEADING,
897-
size = Size(width = Fill, height = Fit),
897+
size = Size(width = Fill, height = Fit()),
898898
margin = Padding(top = 8.0, bottom = 8.0, leading = 0.0, trailing = 0.0),
899899
),
900900
TextComponent(
901901
text = LocalizationKey("feature-6"),
902902
color = textColor,
903903
fontName = font,
904904
horizontalAlignment = LEADING,
905-
size = Size(width = Fill, height = Fit),
905+
size = Size(width = Fill, height = Fit()),
906906
margin = Padding(top = 8.0, bottom = 8.0, leading = 0.0, trailing = 0.0),
907907
),
908908
TextComponent(
909909
text = LocalizationKey("offer"),
910910
color = textColor,
911911
fontName = font,
912912
horizontalAlignment = LEADING,
913-
size = Size(width = Fill, height = Fit),
913+
size = Size(width = Fill, height = Fit()),
914914
margin = Padding(top = 48.0, bottom = 8.0, leading = 0.0, trailing = 0.0),
915915
),
916916
ButtonComponent(
@@ -927,7 +927,7 @@ object SamplePaywalls {
927927
),
928928
),
929929
dimension = ZLayer(alignment = TwoDimensionalAlignment.CENTER),
930-
size = Size(width = Fit, height = Fit),
930+
size = Size(width = Fit(), height = Fit()),
931931
backgroundColor = ColorScheme(
932932
light = ColorInfo.Hex(
933933
Color(red = 5, green = 124, blue = 91).toArgb(),

examples/paywall-tester/src/main/java/com/revenuecat/paywallstester/paywalls/TabsWithButtons.kt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ internal fun tabsWithButtons(font: FontAlias? = null): SampleData.Components {
8383
fontWeight = FontWeight.BOLD,
8484
fontSize = 28,
8585
horizontalAlignment = LEADING,
86-
size = Size(width = Fill, height = Fit),
86+
size = Size(width = Fill, height = Fit()),
8787
margin = Padding(top = 32.0, bottom = 40.0, leading = 16.0, trailing = 16.0),
8888
),
8989
// Tabs
@@ -99,7 +99,7 @@ internal fun tabsWithButtons(font: FontAlias? = null): SampleData.Components {
9999
TextComponent(
100100
text = LocalizationKey("tab-$index"),
101101
color = textColor,
102-
size = Size(width = Fit, height = Fit),
102+
size = Size(width = Fit(), height = Fit()),
103103
fontName = font,
104104
overrides = listOf(boldWhenSelectedOverride),
105105
padding = Padding(
@@ -110,13 +110,13 @@ internal fun tabsWithButtons(font: FontAlias? = null): SampleData.Components {
110110
),
111111
),
112112
),
113-
size = Size(width = Fit, height = Fit),
113+
size = Size(width = Fit(), height = Fit()),
114114
overrides = listOf(cyanBackgroundWhenSelectedOverride),
115115
),
116116
)
117117
},
118118
dimension = Horizontal(alignment = VerticalAlignment.CENTER, CENTER),
119-
size = Size(width = Fit, height = Fit),
119+
size = Size(width = Fit(), height = Fit()),
120120
shape = Shape.Pill,
121121
backgroundColor = ColorScheme(
122122
light = ColorInfo.Hex(Color.LightGray.toArgb()),
@@ -136,7 +136,7 @@ internal fun tabsWithButtons(font: FontAlias? = null): SampleData.Components {
136136
color = textColor,
137137
fontName = font,
138138
horizontalAlignment = LEADING,
139-
size = Size(width = Fill, height = Fit),
139+
size = Size(width = Fill, height = Fit()),
140140
margin = Padding(
141141
top = 8.0,
142142
bottom = 8.0,
@@ -149,7 +149,7 @@ internal fun tabsWithButtons(font: FontAlias? = null): SampleData.Components {
149149
color = textColor,
150150
fontName = font,
151151
horizontalAlignment = LEADING,
152-
size = Size(width = Fill, height = Fit),
152+
size = Size(width = Fill, height = Fit()),
153153
margin = Padding(
154154
top = 8.0,
155155
bottom = 8.0,
@@ -187,7 +187,7 @@ internal fun tabsWithButtons(font: FontAlias? = null): SampleData.Components {
187187
color = textColor,
188188
fontName = font,
189189
horizontalAlignment = LEADING,
190-
size = Size(width = Fill, height = Fit),
190+
size = Size(width = Fill, height = Fit()),
191191
margin = Padding(
192192
top = 8.0,
193193
bottom = 8.0,
@@ -200,7 +200,7 @@ internal fun tabsWithButtons(font: FontAlias? = null): SampleData.Components {
200200
color = textColor,
201201
fontName = font,
202202
horizontalAlignment = LEADING,
203-
size = Size(width = Fill, height = Fit),
203+
size = Size(width = Fill, height = Fit()),
204204
margin = Padding(
205205
top = 8.0,
206206
bottom = 8.0,
@@ -238,7 +238,7 @@ internal fun tabsWithButtons(font: FontAlias? = null): SampleData.Components {
238238
color = textColor,
239239
fontName = font,
240240
horizontalAlignment = LEADING,
241-
size = Size(width = Fill, height = Fit),
241+
size = Size(width = Fill, height = Fit()),
242242
margin = Padding(
243243
top = 8.0,
244244
bottom = 8.0,
@@ -251,7 +251,7 @@ internal fun tabsWithButtons(font: FontAlias? = null): SampleData.Components {
251251
color = textColor,
252252
fontName = font,
253253
horizontalAlignment = LEADING,
254-
size = Size(width = Fill, height = Fit),
254+
size = Size(width = Fill, height = Fit()),
255255
margin = Padding(
256256
top = 8.0,
257257
bottom = 8.0,
@@ -288,7 +288,7 @@ internal fun tabsWithButtons(font: FontAlias? = null): SampleData.Components {
288288
color = textColor,
289289
fontName = font,
290290
horizontalAlignment = LEADING,
291-
size = Size(width = Fill, height = Fit),
291+
size = Size(width = Fill, height = Fit()),
292292
margin = Padding(top = 48.0, bottom = 8.0, leading = 0.0, trailing = 0.0),
293293
),
294294
StackComponent(
@@ -303,7 +303,7 @@ internal fun tabsWithButtons(font: FontAlias? = null): SampleData.Components {
303303
),
304304
),
305305
dimension = ZLayer(alignment = TwoDimensionalAlignment.CENTER),
306-
size = Size(width = Fit, height = Fit),
306+
size = Size(width = Fit(), height = Fit()),
307307
backgroundColor = ColorScheme(
308308
light = ColorInfo.Hex(Color(red = 5, green = 124, blue = 91).toArgb()),
309309
),
@@ -318,7 +318,7 @@ internal fun tabsWithButtons(font: FontAlias? = null): SampleData.Components {
318318
),
319319
),
320320
dimension = Vertical(alignment = LEADING, distribution = END),
321-
size = Size(width = Fill, height = Fit),
321+
size = Size(width = Fill, height = Fit()),
322322
padding = Padding(top = 16.0, bottom = 16.0, leading = 32.0, trailing = 32.0),
323323
),
324324
),

0 commit comments

Comments
 (0)