-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Paywalls V2] Moves validation logic to the Loading phase (#2007)
- Loading branch information
1 parent
842e85f
commit 178b07a
Showing
20 changed files
with
780 additions
and
291 deletions.
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.