-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Paywalls V2] Moves validation logic to the Loading phase #2007
Merged
Merged
Changes from all commits
Commits
Show all changes
119 commits
Select commit
Hold shift + click to select a range
15ee579
Adds PaywallComponentsData to Offering, and has PaywallViewModel use …
JayShortway 97a6d2a
Renames PaywallDataValidationTest to LegacyPaywallDataValidationTest.
JayShortway f039302
LoadingPaywall calls toLegacyPaywallState.
JayShortway 9153fc0
OfferingParser parses paywall_components.
JayShortway 0a07fd5
Adds Paywalls V2 support to PaywallsTester.
JayShortway 8616a26
Adds missing circle MaskShape.
JayShortway bbe72eb
LoadedPaywallComponents will always fill the maximum available size.
JayShortway 27837e2
ImageUrls width and height are optional.
JayShortway 0e60bd3
Merge branch 'main' into pw2-offerings-data
JayShortway 3d6fd64
Merge branch 'pw2-offerings-data' into pw2-tester
JayShortway da94c38
Reverts Constants.
JayShortway f849520
Merge branch 'pw2-tester' into pw2-various-fixes
JayShortway b669421
Fixes lint.
JayShortway 07cfc1c
Merge branch 'pw2-offerings-data' into pw2-tester
JayShortway 442b479
Merge branch 'pw2-tester' into pw2-various-fixes
JayShortway 49e604a
StackComponentView changes background color when the theme changes.
JayShortway 2b5574d
Adds a failing test to StackComponentViewTests.
JayShortway 7271506
Adds 2 previews.
JayShortway dc58101
Ensures MDParagraph uses the correct fontSize.
JayShortway 4f4bc41
Merge branch 'main' into pw2-offerings-data
JayShortway c7657da
Merge branch 'pw2-offerings-data' into pw2-tester
JayShortway 4b54f33
Merge branch 'pw2-tester' into pw2-various-fixes
JayShortway 831854a
Merge branch 'pw2-various-fixes' into pw2-fix-fontsize
JayShortway 7bc2786
Adds another failing test to StackComponentViewTests.
JayShortway 38401ed
Removing some redundant parameters.
JayShortway 65affb8
Fixes the border test.
JayShortway 453b5cf
Fixes the shadow test.
JayShortway 4c189ee
Some cleanup.
JayShortway 7952c6a
Merge branch 'pw2-fix-fontsize' into pw2-stack-tests
JayShortway a342ed8
Merge branch 'main' into pw2-tester
JayShortway 2cc6c97
Merge branch 'pw2-tester' into pw2-various-fixes
JayShortway 7cca77b
Merge branch 'pw2-various-fixes' into pw2-fix-fontsize
JayShortway c43525e
Merge branch 'pw2-fix-fontsize' into pw2-stack-tests
JayShortway 914d9da
Adds a regression test.
JayShortway 9abcb6a
Excludes Paywalls V1 from new font size behavior.
JayShortway 870c577
Merge branch 'main' into pw2-fix-fontsize
JayShortway d5c4ae9
Merge branch 'pw2-fix-fontsize' into pw2-stack-tests
JayShortway 43f1ecf
TextComponentStyle no longer needs a Composable context to be created.
JayShortway 412312e
TextComponentStyle just has a single constructor now.
JayShortway 9a6bab4
Merge branch 'main' into pw2-stack-tests
JayShortway 8bcb10d
Moves rememberProcessedText from StyleFactory to TextComponentView.
JayShortway 524ae3b
Removes unused StyleFactory parameters.
JayShortway 7adc5d3
StyleFactory no longer needs a Composable context.
JayShortway d57b87a
Merge branch 'pw2-stack-tests' into pw2-simplify-textstyle
JayShortway 7ef7d46
Locale and LocalizationDictionary are part of PaywallState now.
JayShortway ea77f24
Adds LoadedPaywallComponentsLocaleTests.
JayShortway 8237323
Adds isEligibleForIntroOffer to PaywallState.
JayShortway 68f3c38
Removes braces from a Preview annotation to please lint.
JayShortway f18ea32
Moves PackageContext to PaywallState.
JayShortway 81bb7a6
Renames VariableContextTests to MostExpensivePricePerMonthMicrosTests.
JayShortway d7a1367
Moves MostExpensivePricePerMonthMicrosTests to the data package.
JayShortway dfc5024
TextComponentView uses PaywallState.
JayShortway f69c7b9
MostExpensivePricePerMonthMicrosTests uses FakePaywallState.
JayShortway 2fdc87c
Merge branch 'main' into pw2-more-paywallstate
JayShortway 5544518
Reorders imports in ButtonComponentView.
JayShortway cb25d3a
Adds TextComponentState.
JayShortway 895f085
Adds PresentedOverrides to TextComponentStyle, and makes use of TextC…
JayShortway fb75780
Fixes ButtonComponentViewTests.
JayShortway 7a7e944
Merge branch 'pw2-more-paywallstate' into pw2-component-state
JayShortway d1373ba
Fixes ButtonComponentViewTests once more.
JayShortway 900a58d
Adds TextComponentViewWindowTests.
JayShortway 0fe9f49
Adds windowChangingTest.
JayShortway 77efa21
Adds WithoutActivityRecreationTests to TextComponentViewWindowTests.
JayShortway ce73645
Updates a comment.
JayShortway ececc0e
Adds a selected overrides test.
JayShortway c2bbc4f
Adds an intro offer overrides test.
JayShortway 0d49f83
Fixes LoadedPaywallComponentsLocaleTests.
JayShortway 7023710
Merge branch 'main' into pw2-component-state
JayShortway f94592a
Adds StackComponentState.
JayShortway 1319e15
Removes unused properties from StyleFactory.
JayShortway 5e02c05
StackComponentView uses StackComponentState.
JayShortway e19390d
Moves assertSquareBorderColor to assertPixelColorEquals.kt and rename…
JayShortway 063307b
Adds assertApproximatePixelColorPercentage().
JayShortway f9cae41
Adds StackComponentViewWindowTests.
JayShortway cc60503
Merge branch 'main' into pw2-component-state
JayShortway 4032112
Merge branch 'pw2-component-state' into pw2-stack-component-state
JayShortway ad96d64
Fixes StackComponentView.
JayShortway 5cc8e1e
Adds 2 tests to StackComponentViewTests.
JayShortway cd5984e
Removes unused PackageContext.kt.
JayShortway b3ee332
Aligns shadow assertions.
JayShortway 036d745
Merge branch 'main' into pw2-stack-component-state
JayShortway bf27e45
Removes `visible` property from TextComponentStyle and StackComponent…
JayShortway c96beb4
TextComponentStyle contains all translations for its text. TextCompon…
JayShortway 581168e
Fixes LoadedPaywallComponents.
JayShortway 23afaed
Updates a property name.
JayShortway 5ce1f5d
Merge branch 'main' into pw2-stack-component-state
JayShortway 7b51b52
Merge branch 'pw2-stack-component-state' into pw2-minor-cleanup
JayShortway 1810317
Merge branch 'pw2-minor-cleanup' into pw2-localization-state
JayShortway 575ff12
Adds NonEmptyMap.
JayShortway 7ce9006
Localizations are now a NonEmptyMap.
JayShortway e6e6a77
Moves the LocalizationDictionary typealias to revenuecatui.
JayShortway 08f8e8d
LocalizationDictionary is a NonEmptyMap now.
JayShortway eb54346
Adds locale to missing localization errors.
JayShortway 657170a
Merge branch 'pw2-localization-state' into pw2-nonemptymap
JayShortway a2a031b
Adds a few more Result extensions.
JayShortway a4d350a
Adds NonEmptySet.
JayShortway 49bf6ab
Adds AllLocalizationsMissing error.
JayShortway eb7b728
Adds validation of PaywallComponentsData.
JayShortway bba53e2
Adds PaywallComponentDataValidationTests.
JayShortway 455183c
Merge branch 'main' into pw2-stack-component-state
JayShortway 4f973ec
Merge branch 'pw2-stack-component-state' into pw2-minor-cleanup
JayShortway 78370f5
Merge branch 'pw2-minor-cleanup' into pw2-localization-state
JayShortway 383d721
Merge branch 'pw2-localization-state' into pw2-nonemptymap
JayShortway b5a1364
Merge branch 'pw2-nonemptymap' into pw2-validate-loading-phase
JayShortway 86eff62
Fixes some compiler errors.
JayShortway 55b8781
Fixes some compiler errors.
JayShortway 1d8b505
Merge branch 'pw2-stack-component-state' into pw2-minor-cleanup
JayShortway 495b996
Merge branch 'pw2-minor-cleanup' into pw2-localization-state
JayShortway 18470a9
Merge branch 'pw2-localization-state' into pw2-nonemptymap
JayShortway 1aed5d9
Merge branch 'pw2-nonemptymap' into pw2-validate-loading-phase
JayShortway 444aec5
Merge branch 'main' into pw2-localization-state
JayShortway b230d9e
Merge branch 'pw2-localization-state' into pw2-nonemptymap
JayShortway 6066ec6
Merge branch 'pw2-nonemptymap' into pw2-validate-loading-phase
JayShortway 5f703c3
Merge branch 'main' into pw2-nonemptymap
JayShortway 2bb0b1d
Merge branch 'pw2-nonemptymap' into pw2-validate-loading-phase
JayShortway ab86ede
Fixes tests.
JayShortway 7fb11a9
Merge branch 'pw2-nonemptymap' into pw2-validate-loading-phase
JayShortway 80a2917
Merge branch 'main' into pw2-validate-loading-phase
JayShortway 7755855
Merge branch 'main' into pw2-validate-loading-phase
JayShortway File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
427 changes: 204 additions & 223 deletions
427
...ain/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/LoadedPaywallComponents.kt
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...enuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/helpers/NonEmptySet.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
@file:JvmSynthetic | ||
|
||
package com.revenuecat.purchases.ui.revenuecatui.helpers | ||
|
||
/** | ||
* A Set that is guaranteed to have at least 1 element. Inspired by Arrow. Use [nonEmptySetOf] or | ||
* [toNonEmptySetOrNull] to construct. | ||
*/ | ||
internal class NonEmptySet<out A> private constructor( | ||
@get:JvmSynthetic | ||
val head: A, | ||
private val all: Set<A>, | ||
) : Set<A> by all { | ||
|
||
constructor(head: A, rest: Iterable<A>) : this(head, all = rest.toSet() + head) | ||
|
||
@JvmSynthetic | ||
fun toSet(): Set<A> = all | ||
|
||
@JvmSynthetic | ||
override fun isEmpty(): Boolean = false | ||
|
||
override fun equals(other: Any?): Boolean = when (other) { | ||
is NonEmptySet<*> -> this.all == other.all | ||
else -> this.all == other | ||
} | ||
|
||
override fun hashCode(): Int = all.hashCode() | ||
|
||
override fun toString(): String = | ||
"NonEmptySet(${all.joinToString()})" | ||
} | ||
|
||
@JvmSynthetic | ||
internal fun <A> nonEmptySetOf(head: A, vararg t: A): NonEmptySet<A> = | ||
NonEmptySet(head, t.asIterable()) | ||
|
||
@JvmSynthetic | ||
internal fun <A> Iterable<A>.toNonEmptySetOrNull(): NonEmptySet<A>? { | ||
val iterator = iterator() | ||
if (!iterator.hasNext()) return null | ||
return NonEmptySet(iterator.next(), Iterable { iterator }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This chain is not complex, but it's a bit hard to read, it takes some time to fully understand what's going on. I think extracting into some private functions could help
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I agree. And we'll have to spend that time every time we need to read this code. Private functions is a good idea. I was also thinking of adding some early returns. I'll have a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decided to do this separately to minimize the conflicts, as I ended up making some changes to these lines in follow-up PRs. Have a look here: #2017