[Paywalls V2] Updating UIConfig aliased colors to contain both light and dark#4650
Merged
Merged
Conversation
JayShortway
approved these changes
Jan 13, 2025
JayShortway
left a comment
Member
There was a problem hiding this comment.
This makes a lot of sense! ![]()
Comment on lines
+121
to
+126
| // Throwing error if alias has an alias | ||
| // This should NEVER happen though | ||
| case .alias(let name): | ||
| Logger.error("Aliased color '\(name)' has an aliased value which is not allowed.") | ||
| throw PaywallColorError.aliasedColorIsAliased(name) | ||
| } |
Member
There was a problem hiding this comment.
Famous last words 😅
This will move to the ViewModel validation/initialization too, right?
cb94a09 to
5c70b03
Compare
This was referenced Jan 15, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
DisplayableColorSchemeobject that has types ofhex,linear, andradial...PaywallComponent.ColorScheme ->DisplayableColorScheme->Color/Gradient`Issue
We have
.aliasas a value onColorInfobut we need to alias an entire set of light/dark colors (akaColorScheme).Our logic right now directly converts
ColorInfointo a SwiftUI/UI color (for foreground, background, etc). This works fine forhex,linear, andradialbut will not work well for alias. We need to perform the alias lookup at theColorSchemelevel (near the view model layer instead of at the render layer)Solution
Create a new
DisplayableColorSchemeandDisplayableColorInfostruct. These new data structures only have values forhex,linear, andradial.ColorScheme(andColorInfo) get mapped toDisplayableColorScheme(andDisplayableColorInfo) and in this mapping is where thealiaslook up happens. This makes it safer/cleaner at the render level because everything has a specific color now.The converting to
DisplayableColorSchemecurrently 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.