[Paywalls V2] Updating UIConfig aliased colors to contain both light and dark #4650
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.
Motivation
Aliased color will be both light and dark
Description
This ended up being a whole thing...
TL;DR - Added a new
DisplayableColorScheme
object that has types ofhex
,linear
, andradial
...PaywallComponent.ColorScheme ->
DisplayableColorScheme->
Color/
Gradient`Issue
We have
.alias
as a value onColorInfo
but we need to alias an entire set of light/dark colors (akaColorScheme
).Our logic right now directly converts
ColorInfo
into a SwiftUI/UI color (for foreground, background, etc). This works fine forhex
,linear
, andradial
but will not work well for alias. We need to perform the alias lookup at theColorScheme
level (near the view model layer instead of at the render layer)Solution
Create a new
DisplayableColorScheme
andDisplayableColorInfo
struct. These new data structures only have values forhex
,linear
, andradial
.ColorScheme
(andColorInfo
) get mapped toDisplayableColorScheme
(andDisplayableColorInfo
) and in this mapping is where thealias
look up happens. This makes it safer/cleaner at the render level because everything has a specific color now.The converting to
DisplayableColorScheme
currently will fallback to a clear color if there is an error and log an error. We will EVENTUALLY AND SOON (in a follow up PR) add this validation that the alias exists in the creation of the view models so that we can error out early if needed.NOTE: We will also add big backend validation that the alias colors exist so the SDKs will never (🤞) have to encounter an alias color not existing.