Skip to content

Commit

Permalink
[Paywalls V2] Minimizes Java API (#1942)
Browse files Browse the repository at this point in the history
  • Loading branch information
JayShortway authored Nov 27, 2024
1 parent ba75c52 commit 991f8f7
Show file tree
Hide file tree
Showing 22 changed files with 137 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import kotlinx.serialization.encoding.Encoder
@Serializable
@SerialName("button")
internal data class ButtonComponent(
val action: Action,
val stack: StackComponent,
@get:JvmSynthetic val action: Action,
@get:JvmSynthetic val stack: StackComponent,
) : PaywallComponent {

@InternalRevenueCatAPI
Expand All @@ -31,7 +31,7 @@ internal data class ButtonComponent(
object NavigateBack : Action

@Serializable
data class NavigateTo(val destination: Destination) : Action
data class NavigateTo(@get:JvmSynthetic val destination: Destination) : Action
}

@InternalRevenueCatAPI
Expand All @@ -43,13 +43,16 @@ internal data class ButtonComponent(
object CustomerCenter : Destination

@Serializable
data class PrivacyPolicy(val urlLid: String, val method: UrlMethod) : Destination
data class PrivacyPolicy(
@get:JvmSynthetic val urlLid: String,
@get:JvmSynthetic val method: UrlMethod,
) : Destination

@Serializable
data class Terms(val urlLid: String, val method: UrlMethod) : Destination
data class Terms(@get:JvmSynthetic val urlLid: String, @get:JvmSynthetic val method: UrlMethod) : Destination

@Serializable
data class Url(val urlLid: String, val method: UrlMethod) : Destination
data class Url(@get:JvmSynthetic val urlLid: String, @get:JvmSynthetic val method: UrlMethod) : Destination
}

@InternalRevenueCatAPI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,45 @@ import kotlinx.serialization.Serializable
@Serializable
@SerialName("image")
internal data class ImageComponent(
@get:JvmSynthetic
val source: ThemeImageUrls,
@get:JvmSynthetic
val size: Size = Size(width = Fill, height = Fit),
@get:JvmSynthetic
@SerialName("override_source_lid")
val overrideSourceLid: LocalizationKey? = null,
@get:JvmSynthetic
@SerialName("mask_shape")
val maskShape: MaskShape? = null,
@get:JvmSynthetic
@SerialName("color_overlay")
val colorOverlay: ColorScheme? = null,
@get:JvmSynthetic
@SerialName("fit_mode")
val fitMode: FitMode = FIT,
@get:JvmSynthetic
val overrides: ComponentOverrides<PartialImageComponent>? = null,
) : PaywallComponent

@InternalRevenueCatAPI
@Serializable
internal data class PartialImageComponent(
@get:JvmSynthetic
val visible: Boolean? = true,
@get:JvmSynthetic
val source: ThemeImageUrls? = null,
@get:JvmSynthetic
val size: Size? = null,
@get:JvmSynthetic
@SerialName("override_source_lid")
val overrideSourceLid: LocalizationKey? = null,
@get:JvmSynthetic
@SerialName("fit_mode")
val fitMode: FitMode? = null,
@get:JvmSynthetic
@SerialName("mask_shape")
val maskShape: MaskShape? = null,
@get:JvmSynthetic
@SerialName("color_overlay")
val colorOverlay: ColorScheme? = null,
) : PartialComponent
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import kotlinx.serialization.Serializable
@Serializable
@SerialName("package")
internal data class PackageComponent(
@get:JvmSynthetic
@SerialName("package_id")
val packageId: String,
@get:JvmSynthetic
@SerialName("is_selected_by_default")
val isSelectedByDefault: Boolean,
@get:JvmSynthetic
val stack: StackComponent,
) : PaywallComponent
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ import kotlinx.serialization.Serializable
@Serializable
@SerialName("purchase_button")
internal data class PurchaseButtonComponent(
val stack: StackComponent,
@get:JvmSynthetic val stack: StackComponent,
) : PaywallComponent
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,53 @@ import kotlinx.serialization.Serializable
@Serializable
@SerialName("stack")
internal data class StackComponent(
@get:JvmSynthetic
val components: List<PaywallComponent>,
@get:JvmSynthetic
val dimension: Dimension = Vertical(CENTER, START),
@get:JvmSynthetic
val size: Size = Size(width = SizeConstraint.Fill, height = SizeConstraint.Fit),
@get:JvmSynthetic
val spacing: Float? = null,
@get:JvmSynthetic
@SerialName("background_color")
val backgroundColor: ColorScheme? = null,
@get:JvmSynthetic
val padding: Padding = zero,
@get:JvmSynthetic
val margin: Padding = zero,
@get:JvmSynthetic
val shape: Shape? = null,
@get:JvmSynthetic
val border: Border? = null,
@get:JvmSynthetic
val shadow: Shadow? = null,
@get:JvmSynthetic
val overrides: ComponentOverrides<PartialStackComponent>? = null,
) : PaywallComponent

@InternalRevenueCatAPI
@Serializable
internal data class PartialStackComponent(
@get:JvmSynthetic
val visible: Boolean? = true,
@get:JvmSynthetic
val dimension: Dimension? = null,
@get:JvmSynthetic
val size: Size? = null,
@get:JvmSynthetic
val spacing: Float? = null,
@get:JvmSynthetic
@SerialName("background_color")
val backgroundColor: ColorScheme? = null,
@get:JvmSynthetic
val padding: Padding? = null,
@get:JvmSynthetic
val margin: Padding? = null,
@get:JvmSynthetic
val shape: Shape? = null,
@get:JvmSynthetic
val border: Border? = null,
@get:JvmSynthetic
val shadow: Shadow? = null,
) : PartialComponent
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ import kotlinx.serialization.Serializable
@Serializable
@SerialName("sticky_footer")
internal data class StickyFooterComponent(
@get:JvmSynthetic
val stack: StackComponent,
) : PaywallComponent
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,33 @@ import kotlinx.serialization.Serializable
class TextComponent
@Suppress("LongParameterList")
internal constructor(
@get:JvmSynthetic
@SerialName("text_lid")
val text: LocalizationKey,
@get:JvmSynthetic
val color: ColorScheme,
@get:JvmSynthetic
@SerialName("background_color")
val backgroundColor: ColorScheme? = null,
@get:JvmSynthetic
@SerialName("font_name")
val fontName: String? = null,
@get:JvmSynthetic
@SerialName("font_weight")
val fontWeight: FontWeight = REGULAR,
@get:JvmSynthetic
@SerialName("font_size")
val fontSize: FontSize = BODY_M,
@get:JvmSynthetic
@SerialName("horizontal_alignment")
val horizontalAlignment: HorizontalAlignment = CENTER,
@get:JvmSynthetic
val size: Size = Size(width = Fill, height = Fit),
@get:JvmSynthetic
val padding: Padding = zero,
@get:JvmSynthetic
val margin: Padding = zero,
@get:JvmSynthetic
val overrides: ComponentOverrides<PartialTextComponent>? = null,
) : PaywallComponent

Expand All @@ -51,21 +62,32 @@ internal constructor(
class PartialTextComponent
@Suppress("LongParameterList")
internal constructor(
@get:JvmSynthetic
val visible: Boolean? = true,
@get:JvmSynthetic
@SerialName("text_lid")
val text: LocalizationKey? = null,
@get:JvmSynthetic
val color: ColorScheme? = null,
@get:JvmSynthetic
@SerialName("background_color")
val backgroundColor: ColorScheme? = null,
@get:JvmSynthetic
@SerialName("font_name")
val fontName: String? = null,
@get:JvmSynthetic
@SerialName("font_weight")
val fontWeight: FontWeight? = null,
@get:JvmSynthetic
@SerialName("font_size")
val fontSize: FontSize? = null,
@get:JvmSynthetic
@SerialName("horizontal_alignment")
val horizontalAlignment: HorizontalAlignment? = null,
@get:JvmSynthetic
val size: Size? = null,
@get:JvmSynthetic
val padding: Padding? = null,
@get:JvmSynthetic
val margin: Padding? = null,
) : PartialComponent
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import kotlinx.serialization.Serializable
internal sealed interface Background {
@Serializable
@SerialName("color")
data class Color(val value: ColorScheme) : Background
data class Color(@get:JvmSynthetic val value: ColorScheme) : Background

@Serializable
@SerialName("image")
data class Image(val value: ThemeImageUrls) : Background
data class Image(@get:JvmSynthetic val value: ThemeImageUrls) : Background
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ import kotlinx.serialization.Serializable
@Poko
@Serializable
class ComponentOverrides<T : PartialComponent> internal constructor(
val introOffer: T? = null,
val states: ComponentStates<T>? = null,
val conditions: ComponentConditions<T>? = null,
@get:JvmSynthetic val introOffer: T? = null,
@get:JvmSynthetic val states: ComponentStates<T>? = null,
@get:JvmSynthetic val conditions: ComponentConditions<T>? = null,
)

@InternalRevenueCatAPI
@Poko
@Serializable
class ComponentStates<T : PartialComponent> internal constructor(
val selected: T? = null,
@get:JvmSynthetic val selected: T? = null,
)

@InternalRevenueCatAPI
@Poko
@Serializable
class ComponentConditions<T : PartialComponent> internal constructor(
val compact: T? = null,
val medium: T? = null,
val expanded: T? = null,
@get:JvmSynthetic val compact: T? = null,
@get:JvmSynthetic val medium: T? = null,
@get:JvmSynthetic val expanded: T? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import kotlinx.serialization.Serializable
@InternalRevenueCatAPI
@Serializable
internal data class ComponentsConfig(
val base: PaywallComponentsConfig,
@get:JvmSynthetic val base: PaywallComponentsConfig,
)

@InternalRevenueCatAPI
@Serializable
internal data class PaywallComponentsConfig(
val stack: StackComponent,
val background: Background,
@get:JvmSynthetic val stack: StackComponent,
@get:JvmSynthetic val background: Background,
@get:JvmSynthetic
@SerialName("sticky_footer")
val stickyFooter: StickyFooterComponent? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import kotlinx.serialization.encoding.Encoder
@InternalRevenueCatAPI
@Serializable
@JvmInline
internal value class LocaleId(val value: String)
internal value class LocaleId(@get:JvmSynthetic val value: String)

@InternalRevenueCatAPI
@Serializable
@JvmInline
value class LocalizationKey internal constructor(val value: String)
value class LocalizationKey internal constructor(@get:JvmSynthetic val value: String)

@InternalRevenueCatAPI
internal typealias LocalizationDictionary = Map<LocalizationKey, LocalizationData>
Expand All @@ -34,11 +34,11 @@ internal typealias LocalizationDictionary = Map<LocalizationKey, LocalizationDat
internal sealed interface LocalizationData {
@Serializable
@JvmInline
value class Text(val value: String) : LocalizationData
value class Text(@get:JvmSynthetic val value: String) : LocalizationData

@Serializable
@JvmInline
value class Image(val value: ThemeImageUrls) : LocalizationData
value class Image(@get:JvmSynthetic val value: ThemeImageUrls) : LocalizationData
}

@OptIn(InternalRevenueCatAPI::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@ import java.net.URL
@InternalRevenueCatAPI
@Serializable
internal data class PaywallComponentsData(
@get:JvmSynthetic
@SerialName("template_name")
val templateName: String,
@get:JvmSynthetic
@Serializable(with = URLSerializer::class)
@SerialName("asset_base_url")
val assetBaseURL: URL,
@get:JvmSynthetic
@SerialName("components_config")
val componentsConfig: ComponentsConfig,
@get:JvmSynthetic
@SerialName("components_localizations")
val componentsLocalizations: Map<LocaleId, LocalizationDictionary>,
@get:JvmSynthetic
@SerialName("default_locale")
val defaultLocaleIdentifier: LocaleId,
@get:JvmSynthetic
val revision: Int = 0,
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import kotlinx.serialization.Serializable
@InternalRevenueCatAPI
@Serializable
internal data class Border(
@get:JvmSynthetic
val color: ColorScheme,
@get:JvmSynthetic
val width: Double,
)
Loading

0 comments on commit 991f8f7

Please sign in to comment.