-
Notifications
You must be signed in to change notification settings - Fork 104
Add new HeaderComponent #3290
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
Open
vegaro
wants to merge
10
commits into
main
Choose a base branch
from
cesar/wfl-15-header-component
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add new HeaderComponent #3290
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
46ee73e
add new HeaderComponent
vegaro 0f445b8
tests
vegaro 9a3e4df
fix: apply window insets correctly when HeaderComponent is present
vegaro 581a07c
fix transparency
vegaro fcf4401
no CompositionLocalProvider
vegaro b15fceb
size
vegaro f73b97d
Merge branch 'main' into cesar/wfl-15-header-component
vegaro 2894f15
prevent shadowing
vegaro 6cac2d1
add density to remember
vegaro e57d603
add doc
vegaro 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
17 changes: 17 additions & 0 deletions
17
purchases/src/main/kotlin/com/revenuecat/purchases/paywalls/components/HeaderComponent.kt
This file contains hidden or 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,17 @@ | ||
| package com.revenuecat.purchases.paywalls.components | ||
|
|
||
| import androidx.compose.runtime.Immutable | ||
| import com.revenuecat.purchases.InternalRevenueCatAPI | ||
| import dev.drewhamilton.poko.Poko | ||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @InternalRevenueCatAPI | ||
| @Poko | ||
| @Serializable | ||
| @SerialName("header") | ||
| @Immutable | ||
| public class HeaderComponent( | ||
| @get:JvmSynthetic | ||
| public val stack: StackComponent, | ||
| ) : PaywallComponent |
This file contains hidden or 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 hidden or 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 hidden or 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
129 changes: 129 additions & 0 deletions
129
purchases/src/test/java/com/revenuecat/purchases/paywalls/components/HeaderComponentTests.kt
This file contains hidden or 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,129 @@ | ||
| package com.revenuecat.purchases.paywalls.components | ||
|
|
||
| import com.revenuecat.purchases.ColorAlias | ||
| import com.revenuecat.purchases.JsonTools | ||
| import com.revenuecat.purchases.paywalls.components.common.LocalizationKey | ||
| import com.revenuecat.purchases.paywalls.components.properties.ColorInfo | ||
| import com.revenuecat.purchases.paywalls.components.properties.ColorScheme | ||
| import org.intellij.lang.annotations.Language | ||
| import org.junit.Test | ||
| import org.junit.runner.RunWith | ||
| import org.junit.runners.Parameterized | ||
|
|
||
| @RunWith(Parameterized::class) | ||
| internal class HeaderComponentTests( | ||
| @Suppress("UNUSED_PARAMETER") name: String, | ||
| private val args: Args, | ||
| ) { | ||
|
|
||
| class Args( | ||
| @Language("json") | ||
| val json: String, | ||
| val expected: HeaderComponent, | ||
| ) | ||
|
|
||
| companion object { | ||
|
|
||
| @Suppress("LongMethod") | ||
| @JvmStatic | ||
| @Parameterized.Parameters(name = "{0}") | ||
| fun parameters(): Collection<*> = listOf( | ||
| arrayOf( | ||
| "non-empty stack", | ||
| Args( | ||
| json = """ | ||
| { | ||
| "type": "header", | ||
| "stack": { | ||
| "type": "stack", | ||
| "components": [ | ||
| { | ||
| "color": { | ||
| "light": { | ||
| "type": "alias", | ||
| "value": "primary" | ||
| } | ||
| }, | ||
| "components": [], | ||
| "id": "xmpgCrN9Rb", | ||
| "name": "Text", | ||
| "text_lid": "7bkohQjzIE", | ||
| "type": "text" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| """.trimIndent(), | ||
| expected = HeaderComponent( | ||
| stack = StackComponent( | ||
| components = listOf( | ||
| TextComponent( | ||
| text = LocalizationKey("7bkohQjzIE"), | ||
| color = ColorScheme(light = ColorInfo.Alias(ColorAlias("primary"))) | ||
| ) | ||
| ), | ||
| ) | ||
| ) | ||
| ), | ||
| ), | ||
| arrayOf( | ||
| "empty stack", | ||
| Args( | ||
| json = """ | ||
| { | ||
| "type": "header", | ||
| "stack": { | ||
| "type": "stack", | ||
| "components": [] | ||
| } | ||
| } | ||
| """.trimIndent(), | ||
| expected = HeaderComponent( | ||
| stack = StackComponent( | ||
| components = emptyList(), | ||
| ) | ||
| ) | ||
| ), | ||
| ), | ||
| arrayOf( | ||
| "extra fields ignored", | ||
| Args( | ||
| json = """ | ||
| { | ||
| "type": "header", | ||
| "id": "header_1", | ||
| "name": "My Header", | ||
| "stack": { | ||
| "type": "stack", | ||
| "components": [] | ||
| } | ||
| } | ||
| """.trimIndent(), | ||
| expected = HeaderComponent( | ||
| stack = StackComponent( | ||
| components = emptyList(), | ||
| ) | ||
| ) | ||
| ), | ||
| ), | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| fun `Should properly deserialize HeaderComponent as HeaderComponent`() { | ||
| // Arrange, Act | ||
| val actual = JsonTools.json.decodeFromString<HeaderComponent>(args.json) | ||
|
|
||
| // Assert | ||
| assert(actual == args.expected) | ||
| } | ||
|
|
||
| @Test | ||
| fun `Should properly deserialize HeaderComponent as PaywallComponent`() { | ||
| // Arrange, Act | ||
| val actual = JsonTools.json.decodeFromString<PaywallComponent>(args.json) | ||
|
|
||
| // Assert | ||
| assert(actual == args.expected) | ||
| } | ||
| } |
This file contains hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.