Skip to content

Commit

Permalink
[Paywalls V2] Adds StackComponent (#1930)
Browse files Browse the repository at this point in the history
  • Loading branch information
JayShortway authored Nov 22, 2024
1 parent 0563f9c commit 39f4944
Show file tree
Hide file tree
Showing 6 changed files with 580 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.revenuecat.purchases.paywalls.components

import com.revenuecat.purchases.paywalls.components.properties.Border
import com.revenuecat.purchases.paywalls.components.properties.ColorScheme
import com.revenuecat.purchases.paywalls.components.properties.Dimension
import com.revenuecat.purchases.paywalls.components.properties.Dimension.Vertical
import com.revenuecat.purchases.paywalls.components.properties.FlexDistribution.START
import com.revenuecat.purchases.paywalls.components.properties.HorizontalAlignment.CENTER
import com.revenuecat.purchases.paywalls.components.properties.Padding
import com.revenuecat.purchases.paywalls.components.properties.Padding.Companion.zero
import com.revenuecat.purchases.paywalls.components.properties.Shadow
import com.revenuecat.purchases.paywalls.components.properties.Shape
import com.revenuecat.purchases.paywalls.components.properties.Size
import com.revenuecat.purchases.paywalls.components.properties.SizeConstraint
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
@SerialName("stack")
internal data class StackComponent(
val components: List<PaywallComponent>,
val dimension: Dimension = Vertical(CENTER, START),
val size: Size = Size(width = SizeConstraint.Fill, height = SizeConstraint.Fit),
val spacing: Float? = null,
@SerialName("background_color")
val backgroundColor: ColorScheme? = null,
val padding: Padding = zero,
val margin: Padding = zero,
val shape: Shape? = null,
val border: Border? = null,
val shadow: Shadow? = null,
val overrides: ComponentOverrides<PartialStackComponent>? = null,
) : PaywallComponent

@Serializable
internal data class PartialStackComponent(
val visible: Boolean? = true,
val dimension: Dimension? = null,
val size: Size? = null,
val spacing: Float? = null,
@SerialName("background_color")
val backgroundColor: ColorScheme? = null,
val padding: Padding? = null,
val margin: Padding? = null,
val shape: Shape? = null,
val border: Border? = null,
val shadow: Shadow? = null,
) : PartialComponent
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.revenuecat.purchases.paywalls.components.properties

import kotlinx.serialization.Serializable

@Serializable
internal data class Border(
val color: ColorScheme,
val width: Double,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.revenuecat.purchases.paywalls.components.properties

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
internal sealed interface Dimension {

@Serializable
@SerialName("vertical")
data class Vertical(
val alignment: HorizontalAlignment,
val distribution: FlexDistribution,
) : Dimension

@Serializable
@SerialName("horizontal")
data class Horizontal(
val alignment: VerticalAlignment,
val distribution: FlexDistribution,
) : Dimension

@Serializable
@SerialName("zlayer")
data class ZLayer(
val alignment: TwoDimensionalAlignment,
) : Dimension
}
Loading

0 comments on commit 39f4944

Please sign in to comment.