Skip to content
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

Paywalls Components Packages and Selected State #4249

Open
wants to merge 142 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 141 commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
29f4506
New PaywallComopnentViewModels to support localization needs
joshdholtz Aug 28, 2024
6c69a69
Remove duplicate extension
jamesrb1 Aug 28, 2024
5b49cfb
PublicForExternalTesting
jamesrb1 Aug 29, 2024
7b4ecad
Make ComponentType Sendable
jamesrb1 Aug 29, 2024
1151d76
Need to revisit how we’re doing defaults
jamesrb1 Aug 29, 2024
cbba781
Move recursive VM creation into stack initializer
jamesrb1 Aug 29, 2024
f0acb4e
Safely unwrap text localizations
jamesrb1 Aug 29, 2024
2903331
Gettin’ those VMs movin’! (text component)
jamesrb1 Aug 29, 2024
588016f
Missing from last commit
jamesrb1 Aug 29, 2024
f15f28b
needs mainactor
jamesrb1 Aug 29, 2024
750e38d
Get rid of main actor (for now)
jamesrb1 Aug 29, 2024
ebf76c9
Restore clobbered code
jamesrb1 Aug 29, 2024
b7779b8
unlocalized fallbacks in text
jamesrb1 Aug 29, 2024
205cc83
Image Component VM
jamesrb1 Aug 29, 2024
c912c70
Spacer VM
jamesrb1 Aug 29, 2024
0a803f3
LinkButtonComponentViewModel
jamesrb1 Aug 29, 2024
8e50c37
viewmodel’s url
jamesrb1 Aug 29, 2024
19383a7
Move last of SwiftUI out of model data
jamesrb1 Aug 29, 2024
bbd3535
Missing from last commit
jamesrb1 Aug 29, 2024
526a905
Viewmodel view
jamesrb1 Aug 29, 2024
7b46b9a
Add public for external
jamesrb1 Aug 29, 2024
9e72bad
ViewModels into separate files
jamesrb1 Aug 29, 2024
a5c08a3
Rename file
jamesrb1 Aug 29, 2024
11c4204
File rename
jamesrb1 Aug 29, 2024
9e28652
Move various structs into separate file
jamesrb1 Aug 29, 2024
3c4ff47
Project file file changes
jamesrb1 Aug 29, 2024
020ddbd
No more data
jamesrb1 Aug 29, 2024
a7be7af
Project file
jamesrb1 Aug 29, 2024
a30f20d
PaywallComponent code organization
jamesrb1 Aug 29, 2024
9a20721
Not needed
jamesrb1 Aug 29, 2024
b1114b5
Move PaywallComponentViewModel to own file
jamesrb1 Aug 29, 2024
9fb7d47
File rename
jamesrb1 Aug 29, 2024
0422fbe
Wrap in flag
jamesrb1 Aug 29, 2024
246cb02
File org
jamesrb1 Aug 29, 2024
f16c726
Style
jamesrb1 Aug 29, 2024
9f0f0bd
Color decoding
jamesrb1 Aug 29, 2024
f013edd
Log color conversione errors
jamesrb1 Aug 30, 2024
f7f9c6c
Revert accidental commit
jamesrb1 Aug 30, 2024
eefdc52
Fix file module inclusion
jamesrb1 Aug 30, 2024
7baea72
Collor fallback
jamesrb1 Aug 30, 2024
7b59dcd
Sample data compiles
jamesrb1 Aug 30, 2024
e37b9f4
linting
jamesrb1 Aug 30, 2024
2faca09
more
jamesrb1 Aug 30, 2024
38ec338
Some review changes
jamesrb1 Aug 30, 2024
2bb448d
Couple more
jamesrb1 Aug 30, 2024
41ae885
lint
jamesrb1 Aug 30, 2024
b08effe
Mid-stream, re-eneabling local paywall component view; image max heig…
jamesrb1 Aug 30, 2024
e375293
Mid-stream adding properties, fixing sample data
jamesrb1 Aug 28, 2024
3436414
Internal working again
jamesrb1 Aug 30, 2024
1fc76d3
🐍case
jamesrb1 Aug 30, 2024
9baabcd
New localization code WIP
jamesrb1 Sep 2, 2024
6cf0152
Move validation into VM creation
jamesrb1 Sep 2, 2024
88c02fe
Add missing trys
jamesrb1 Sep 2, 2024
8223ba9
Move localization out of map
jamesrb1 Sep 2, 2024
4f9cd77
Organization localization code
jamesrb1 Sep 3, 2024
61c8016
Clarify steps
jamesrb1 Sep 3, 2024
4952924
More of the same
jamesrb1 Sep 3, 2024
fc336ad
Handles default locale; Refactor locale choosing
jamesrb1 Sep 3, 2024
d204b10
Switch to guard
jamesrb1 Sep 3, 2024
6bdf8f2
Name change
jamesrb1 Sep 3, 2024
8343fc6
Revert // @PublicForExternalTesting clobbering
jamesrb1 Sep 3, 2024
747c988
localization dictionary typealias and name consistency with CustomerC…
jamesrb1 Sep 3, 2024
5141b64
Line breaking
jamesrb1 Sep 3, 2024
3e68bdf
Error strings
jamesrb1 Sep 3, 2024
51578c0
Swifty name
jamesrb1 Sep 3, 2024
90553d1
Uses explicit localization property validation, no more locale in mos…
jamesrb1 Sep 3, 2024
788b284
Got clobbered by preprocessing script…
jamesrb1 Sep 3, 2024
ec107eb
Identation
jamesrb1 Sep 3, 2024
e62231d
Better error message
jamesrb1 Sep 3, 2024
cbf5336
Line length
jamesrb1 Sep 3, 2024
f6f0988
function parameter order
jamesrb1 Sep 3, 2024
cc067fd
Offline paywalls use localization dicts
jamesrb1 Sep 3, 2024
fde7bd7
Add missing strings
jamesrb1 Sep 3, 2024
2e4d2ff
Move localization stuff into a separate file
jamesrb1 Sep 3, 2024
f882696
Missing from before
jamesrb1 Sep 3, 2024
0524cbd
Project file updates
jamesrb1 Sep 3, 2024
0ddff27
Move typealiases to property type file
jamesrb1 Sep 3, 2024
12150bb
remove whitespace
jamesrb1 Sep 3, 2024
82fff3f
Remove redundant public
jamesrb1 Sep 3, 2024
5868cc6
Move outside struct…
jamesrb1 Sep 3, 2024
45bd87a
lint
jamesrb1 Sep 3, 2024
581e1ed
Remove todo
jamesrb1 Sep 4, 2024
7037cd9
lint
jamesrb1 Sep 4, 2024
5f66ab6
Make `LocalizationKey` properties non-optional
jamesrb1 Sep 4, 2024
1c93359
Don’t use keypath for dictionary access
jamesrb1 Sep 4, 2024
fc11253
Remove observable paywall component viewmodels
jamesrb1 Sep 4, 2024
8a91f3a
Missing from last commit
jamesrb1 Sep 4, 2024
ece1b5a
Make all components private
jamesrb1 Sep 4, 2024
6dff9ad
lint
jamesrb1 Sep 4, 2024
3354b5a
jamesrb1 Sep 4, 2024
9554b37
Merge branch 'main' of https://github.com/RevenueCat/purchases-ios in…
jamesrb1 Sep 4, 2024
86a9404
Remove offering from LinkButton
jamesrb1 Sep 4, 2024
eeb8e9b
Move `printComponents` into element-specific array extension
jamesrb1 Sep 4, 2024
8c3917b
Add ability to output localizations as json
jamesrb1 Sep 4, 2024
d7c8af9
style
jamesrb1 Sep 4, 2024
5344225
Change enum case name
jamesrb1 Sep 4, 2024
3bc2c7d
Move PaywallComponents into struct for namespacing.
jamesrb1 Sep 5, 2024
be6f45f
Add missing scopes
jamesrb1 Sep 5, 2024
0246e70
Move PaywallComponent Array/Dict extensions to own file
jamesrb1 Sep 5, 2024
e57ea74
Remove old ColorHex and delete TierId type aliases
jamesrb1 Sep 5, 2024
f6c9f0e
Remove redundant public
jamesrb1 Sep 5, 2024
9afccdc
Project update
jamesrb1 Sep 5, 2024
f743a2a
fallbackLocale -> defaultLocale
jamesrb1 Sep 5, 2024
3662564
Revert accidental clobber
jamesrb1 Sep 5, 2024
f20f460
File name matches comment’s file name.
jamesrb1 Sep 5, 2024
1b0ef6d
packages
jamesrb1 Sep 5, 2024
93ad62d
Initial packages/package components
jamesrb1 Sep 6, 2024
e4aeaa1
Merge branch 'main' of https://github.com/RevenueCat/purchases-ios in…
jamesrb1 Sep 6, 2024
1f6b217
Commented file names
jamesrb1 Sep 6, 2024
85d3ffc
Purchase button
jamesrb1 Sep 6, 2024
4348db3
Purchase button
jamesrb1 Sep 6, 2024
830f991
[POC] Components have selected version of themselves (#4251)
jamesrb1 Sep 11, 2024
c134846
Starting on better package visuals
jamesrb1 Sep 11, 2024
18d371f
StackComponentView switches components based on selection
jamesrb1 Sep 11, 2024
7d1ab91
text switches on selection
jamesrb1 Sep 11, 2024
fdf5d37
fitness chooser wip
jamesrb1 Sep 11, 2024
f53f541
More WIP
jamesrb1 Sep 11, 2024
833c80e
Validate package exists
jamesrb1 Sep 12, 2024
5742b6a
Update comments in TemplateComponentsView
jamesrb1 Sep 12, 2024
6ada91d
Merge branch 'main' of https://github.com/RevenueCat/purchases-ios in…
jamesrb1 Sep 12, 2024
15e328e
Move protocol methods into extension
jamesrb1 Sep 12, 2024
262c447
Remove package component’s vstack
jamesrb1 Sep 12, 2024
a0e3b5c
Give PackageView access to Package
jamesrb1 Sep 12, 2024
b4655cf
Can be private
jamesrb1 Sep 12, 2024
8988ae8
Spacing
jamesrb1 Sep 12, 2024
bf7ffae
PackagesComponent -> PackageGroupComponent
jamesrb1 Sep 12, 2024
b091274
File names Packages -> PackageGroup
jamesrb1 Sep 12, 2024
a241e93
Tidy up comments
jamesrb1 Sep 12, 2024
27adc5b
Option to not have PackageComponent be a button
jamesrb1 Sep 12, 2024
03bcf14
enum case packages -> packageGroup
jamesrb1 Sep 12, 2024
8665cd8
Sync `selectedPackageID` back to viewmodel
jamesrb1 Sep 12, 2024
998513c
Demo code wip
jamesrb1 Sep 12, 2024
cff2779
Close to demo…
jamesrb1 Sep 12, 2024
9c7c413
samples ahoy
jamesrb1 Sep 13, 2024
f972ef5
No more need to sync to VM, remove package group label
jamesrb1 Sep 13, 2024
e1f048d
PackageGroupComponentView no stack wrapping
jamesrb1 Sep 13, 2024
13351d3
Lint
jamesrb1 Sep 13, 2024
c22d8a1
Tidy, style, access
jamesrb1 Sep 13, 2024
49ee52f
Tidy, lint
jamesrb1 Sep 13, 2024
68cf245
Lint
jamesrb1 Sep 13, 2024
60043f0
Last lint
jamesrb1 Sep 13, 2024
b2ecdb3
Paywalls samples - a bit of tidying
jamesrb1 Sep 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions RevenueCat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,9 @@
777FB4882C661C0600CD4749 /* SemanticVersionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 777FB4872C661C0600CD4749 /* SemanticVersionTests.swift */; };
805B60C97993B311CEC93EAF /* ProductsFetcherSK2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3628C1F100BB3C1782860D24 /* ProductsFetcherSK2.swift */; };
80E80EF226970E04008F245A /* ReceiptFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80E80EF026970DC3008F245A /* ReceiptFetcher.swift */; };
88132E762C8BC76100D919C1 /* PaywallPurchaseButtonComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88132E752C8BC76100D919C1 /* PaywallPurchaseButtonComponent.swift */; };
88132E7A2C8BC87F00D919C1 /* PurchaseButtonComponentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88132E772C8BC87F00D919C1 /* PurchaseButtonComponentView.swift */; };
88132E7B2C8BC87F00D919C1 /* PurchaseButtonComponentViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88132E782C8BC87F00D919C1 /* PurchaseButtonComponentViewModel.swift */; };
8834AFA52C2B9375005A72FE /* PresentIfNeededTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 887A62222C1D168B00E1A461 /* PresentIfNeededTests.swift */; };
887A5FBD2C1D036200E1A461 /* RevenueCatUIDev.h in Headers */ = {isa = PBXBuildFile; fileRef = 887A5FBC2C1D036200E1A461 /* RevenueCatUIDev.h */; settings = {ATTRIBUTES = (Public, ); }; };
887A60672C1D037000E1A461 /* PaywallError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 887A5FC72C1D037000E1A461 /* PaywallError.swift */; };
Expand Down Expand Up @@ -810,6 +813,12 @@
887A634E2C1D17EF00E1A461 /* OHHTTPStubsSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 887A634D2C1D17EF00E1A461 /* OHHTTPStubsSwift */; };
887A63502C1D17EF00E1A461 /* SnapshotTesting in Frameworks */ = {isa = PBXBuildFile; productRef = 887A634F2C1D17EF00E1A461 /* SnapshotTesting */; };
887E7B592C13CD2C002977DE /* PurchasesAreCompletedBy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 887E7B582C13CD2C002977DE /* PurchasesAreCompletedBy.swift */; };
88809D522C937246008084B2 /* PackageGroupComponentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88809D4F2C937246008084B2 /* PackageGroupComponentView.swift */; };
88809D532C937246008084B2 /* PackageGroupComponentViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88809D502C937246008084B2 /* PackageGroupComponentViewModel.swift */; };
889383A02C8B8F4300922B8A /* PaywallPackageComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8893839F2C8B8F4300922B8A /* PaywallPackageComponent.swift */; };
889383A22C8B8F4A00922B8A /* PaywallPackageGroupComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 889383A12C8B8F4900922B8A /* PaywallPackageGroupComponent.swift */; };
889383A62C8B922D00922B8A /* PackageComponentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 889383A32C8B922D00922B8A /* PackageComponentView.swift */; };
889383A72C8B922D00922B8A /* PackageComponentViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 889383A42C8B922D00922B8A /* PackageComponentViewModel.swift */; };
8893C9B52C7D1F090060B030 /* PaywallLinkButtonComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8893C9B42C7D1F090060B030 /* PaywallLinkButtonComponent.swift */; };
88A543DF2C37A45B0039C6A5 /* TemplatePackageSetting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88A543DE2C37A45B0039C6A5 /* TemplatePackageSetting.swift */; };
88A543E12C37A4820039C6A5 /* TemplateView+MultiTier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88A543E02C37A4820039C6A5 /* TemplateView+MultiTier.swift */; };
Expand Down Expand Up @@ -1814,6 +1823,9 @@
777FB4872C661C0600CD4749 /* SemanticVersionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SemanticVersionTests.swift; sourceTree = "<group>"; };
80E80EF026970DC3008F245A /* ReceiptFetcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReceiptFetcher.swift; sourceTree = "<group>"; };
84C3F1AC1D7E1E64341D3936 /* Pods_RevenueCat_PurchasesTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RevenueCat_PurchasesTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
88132E752C8BC76100D919C1 /* PaywallPurchaseButtonComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PaywallPurchaseButtonComponent.swift; sourceTree = "<group>"; };
88132E772C8BC87F00D919C1 /* PurchaseButtonComponentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PurchaseButtonComponentView.swift; sourceTree = "<group>"; };
88132E782C8BC87F00D919C1 /* PurchaseButtonComponentViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PurchaseButtonComponentViewModel.swift; sourceTree = "<group>"; };
887A5FB42C1D024300E1A461 /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; };
887A5FBA2C1D036200E1A461 /* RevenueCatUI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RevenueCatUI.framework; sourceTree = BUILT_PRODUCTS_DIR; };
887A5FBC2C1D036200E1A461 /* RevenueCatUIDev.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RevenueCatUIDev.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1971,6 +1983,12 @@
887A63212C1D174200E1A461 /* RevenueCatUITestsDev.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RevenueCatUITestsDev.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
887A63482C1D17A200E1A461 /* RevenueCatUIDev.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = RevenueCatUIDev.xctestplan; path = RevenueCatUI/RevenueCatUIDev.xctestplan; sourceTree = SOURCE_ROOT; };
887E7B582C13CD2C002977DE /* PurchasesAreCompletedBy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PurchasesAreCompletedBy.swift; sourceTree = "<group>"; };
88809D4F2C937246008084B2 /* PackageGroupComponentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PackageGroupComponentView.swift; sourceTree = "<group>"; };
88809D502C937246008084B2 /* PackageGroupComponentViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PackageGroupComponentViewModel.swift; sourceTree = "<group>"; };
8893839F2C8B8F4300922B8A /* PaywallPackageComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PaywallPackageComponent.swift; sourceTree = "<group>"; };
889383A12C8B8F4900922B8A /* PaywallPackageGroupComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PaywallPackageGroupComponent.swift; sourceTree = "<group>"; };
889383A32C8B922D00922B8A /* PackageComponentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PackageComponentView.swift; sourceTree = "<group>"; };
889383A42C8B922D00922B8A /* PackageComponentViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PackageComponentViewModel.swift; sourceTree = "<group>"; };
8893C9B42C7D1F090060B030 /* PaywallLinkButtonComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PaywallLinkButtonComponent.swift; sourceTree = "<group>"; };
88A543DE2C37A45B0039C6A5 /* TemplatePackageSetting.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TemplatePackageSetting.swift; path = RevenueCatUI/Views/TemplatePackageSetting.swift; sourceTree = SOURCE_ROOT; };
88A543E02C37A4820039C6A5 /* TemplateView+MultiTier.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "TemplateView+MultiTier.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3892,6 +3910,15 @@
path = Security;
sourceTree = "<group>";
};
88132E792C8BC87F00D919C1 /* PurchaseButton */ = {
isa = PBXGroup;
children = (
88132E772C8BC87F00D919C1 /* PurchaseButtonComponentView.swift */,
88132E782C8BC87F00D919C1 /* PurchaseButtonComponentViewModel.swift */,
);
path = PurchaseButton;
sourceTree = "<group>";
};
887A5FBB2C1D036200E1A461 /* RevenueCatUIDev */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -4241,6 +4268,24 @@
path = Tests/RevenueCatUITests;
sourceTree = SOURCE_ROOT;
};
88809D512C937246008084B2 /* PackageGroup */ = {
isa = PBXGroup;
children = (
88809D4F2C937246008084B2 /* PackageGroupComponentView.swift */,
88809D502C937246008084B2 /* PackageGroupComponentViewModel.swift */,
);
path = PackageGroup;
sourceTree = "<group>";
};
889383A52C8B922D00922B8A /* Package */ = {
isa = PBXGroup;
children = (
889383A32C8B922D00922B8A /* PackageComponentView.swift */,
889383A42C8B922D00922B8A /* PackageComponentViewModel.swift */,
);
path = Package;
sourceTree = "<group>";
};
88AD010B2C740CF400AA1F2B /* Components */ = {
isa = PBXGroup;
children = (
Expand All @@ -4251,7 +4296,10 @@
88AD01062C740CF400AA1F2B /* PaywallSpacerComponent.swift */,
88E679462C7503C1007E69D5 /* PaywallStackComponent.swift */,
8893C9B42C7D1F090060B030 /* PaywallLinkButtonComponent.swift */,
889383A12C8B8F4900922B8A /* PaywallPackageGroupComponent.swift */,
8893839F2C8B8F4300922B8A /* PaywallPackageComponent.swift */,
88AD01072C740CF400AA1F2B /* PaywallTextComopnent.swift */,
88132E752C8BC76100D919C1 /* PaywallPurchaseButtonComponent.swift */,
);
path = Components;
sourceTree = "<group>";
Expand All @@ -4263,6 +4311,9 @@
88B1BAE22C813A3C001B7EE5 /* LinkButton */,
88B1BAE72C813A3C001B7EE5 /* PaywallComponentTypeTransformers.swift */,
88B1BAD92C813A3C001B7EE5 /* PaywallComponentViewModel.swift */,
889383A52C8B922D00922B8A /* Package */,
88809D512C937246008084B2 /* PackageGroup */,
88132E792C8BC87F00D919C1 /* PurchaseButton */,
88B1BADF2C813A3C001B7EE5 /* Spacer */,
88B1BAEA2C813A3C001B7EE5 /* Stack */,
88B1BAE32C813A3C001B7EE5 /* TemplateComponentsView.swift */,
Expand Down Expand Up @@ -5264,6 +5315,7 @@
5766AA3E283C750300FA6091 /* Operators+Extensions.swift in Sources */,
4FFCED892AA941D200118EF4 /* PaywallHTTPRequestPath.swift in Sources */,
FDAADFD12BE2B87000BD1659 /* StoreKit2ObserverModePurchaseDetector.swift in Sources */,
889383A22C8B8F4A00922B8A /* PaywallPackageGroupComponent.swift in Sources */,
4F6BEDE22A26B69500CD9322 /* DebugContentViews.swift in Sources */,
B3B5FBBC269D121B00104A0C /* Offerings.swift in Sources */,
9A65E03B25918B0900DE00B0 /* CustomerInfoStrings.swift in Sources */,
Expand Down Expand Up @@ -5327,6 +5379,7 @@
5753ED8E294A662400CBAB54 /* DateFormatter+Extensions.swift in Sources */,
4F174F472B07EA7E00FE538E /* StorefrontProvider.swift in Sources */,
B3AA6238268B926F00894871 /* SystemInfo.swift in Sources */,
889383A02C8B8F4300922B8A /* PaywallPackageComponent.swift in Sources */,
5746508E275949F20053AB09 /* DispatchTimeInterval+Extensions.swift in Sources */,
35109DB92BC8143E001030C8 /* DiagnosticsEventsRequest.swift in Sources */,
2D294E5C26DECFD500B8FE4F /* StoreKit2TransactionListener.swift in Sources */,
Expand Down Expand Up @@ -5463,6 +5516,7 @@
4F6ABC7E2A81700900250E63 /* PaywallsStrings.swift in Sources */,
575137CF27F50D2F0064AB2C /* HTTPResponseBody.swift in Sources */,
573E7F092819B989007C9128 /* StoreKitWorkarounds.swift in Sources */,
88132E762C8BC76100D919C1 /* PaywallPurchaseButtonComponent.swift in Sources */,
88AD01122C740CF400AA1F2B /* PaywallSpacerComponent.swift in Sources */,
5791FCF32992D3EC00F1FEDA /* SigningStrings.swift in Sources */,
1E473B662AC42D34008B07F9 /* StoreMessagesHelper.swift in Sources */,
Expand Down Expand Up @@ -5948,6 +6002,7 @@
887A60882C1D037000E1A461 /* MockPurchases.swift in Sources */,
887A60BC2C1D037000E1A461 /* Template5View.swift in Sources */,
887A60BE2C1D037000E1A461 /* PaywallFooterViewController.swift in Sources */,
889383A72C8B922D00922B8A /* PackageComponentViewModel.swift in Sources */,
887A608A2C1D037000E1A461 /* PurchaseHandler.swift in Sources */,
2D2AFE8D2C6A834D00D1B0B4 /* TestData.swift in Sources */,
887A60C92C1D037000E1A461 /* PurchaseButton.swift in Sources */,
Expand All @@ -5964,6 +6019,7 @@
887A60892C1D037000E1A461 /* PaywallPurchasesType.swift in Sources */,
3537566F2C382C2800A1B8D6 /* WrongPlatformView.swift in Sources */,
887A60C22C1D037000E1A461 /* ErrorDisplay.swift in Sources */,
889383A62C8B922D00922B8A /* PackageComponentView.swift in Sources */,
2D2AFE8F2C6A9D8700D1B0B4 /* CompatibilityContentUnavailableView.swift in Sources */,
3537566E2C382C2800A1B8D6 /* RestorePurchasesAlert.swift in Sources */,
887A60692C1D037000E1A461 /* IntroEligibilityViewModel.swift in Sources */,
Expand All @@ -5990,6 +6046,7 @@
887A608B2C1D037000E1A461 /* PurchaseHandler+TestData.swift in Sources */,
35F249CE2C493E3D0058993A /* CustomerCenterPurchases.swift in Sources */,
353756672C382C2800A1B8D6 /* SubscriptionInformation.swift in Sources */,
88809D532C937246008084B2 /* PackageGroupComponentViewModel.swift in Sources */,
887A60682C1D037000E1A461 /* TemplateError.swift in Sources */,
887A60792C1D037000E1A461 /* UserInterfaceIdiom.swift in Sources */,
C3AD12BC2C6EA69D00A4F86F /* SubscriptionDetailsView.swift in Sources */,
Expand All @@ -6015,6 +6072,7 @@
887A60802C1D037000E1A461 /* Package+VariableDataProvider.swift in Sources */,
887A60CE2C1D037000E1A461 /* View+PresentPaywall.swift in Sources */,
357CEC702C5940CE00A80837 /* ColorFromAppearance.swift in Sources */,
88132E7A2C8BC87F00D919C1 /* PurchaseButtonComponentView.swift in Sources */,
887A60832C1D037000E1A461 /* VersionDetector.swift in Sources */,
88B1BAFC2C813A3C001B7EE5 /* ImageComponentView.swift in Sources */,
887A60872C1D037000E1A461 /* ViewExtensions.swift in Sources */,
Expand All @@ -6040,9 +6098,11 @@
88A543DF2C37A45B0039C6A5 /* TemplatePackageSetting.swift in Sources */,
3546355D2C391F38001D7E85 /* PromotionalOfferViewModel.swift in Sources */,
88B1BAF62C813A3C001B7EE5 /* LinkButtonComponentView.swift in Sources */,
88809D522C937246008084B2 /* PackageGroupComponentView.swift in Sources */,
35F249CA2C493D970058993A /* LoadPromotionalOfferUseCase.swift in Sources */,
887A60762C1D037000E1A461 /* TemplateViewConfiguration+Extensions.swift in Sources */,
887A607A2C1D037000E1A461 /* Variables.swift in Sources */,
88132E7B2C8BC87F00D919C1 /* PurchaseButtonComponentViewModel.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
12 changes: 7 additions & 5 deletions RevenueCatUI/Templates/Components/Image/ImageComponentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,24 @@ import SwiftUI
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct ImageComponentView: View {

@Environment(\.selectionState) var selectionState

let viewModel: ImageComponentViewModel

var body: some View {
RemoteImage(url: viewModel.url) { image in
RemoteImage(url: viewModel.url(for: selectionState)) { image in
image
.resizable()
.aspectRatio(contentMode: viewModel.contentMode)
.frame(maxHeight: viewModel.maxHeight)
.aspectRatio(contentMode: viewModel.contentMode(for: selectionState))
.frame(maxHeight: viewModel.maxHeight(for: selectionState))
.overlay(
LinearGradient(
gradient: Gradient(colors: viewModel.gradientColors),
gradient: Gradient(colors: viewModel.gradientColors(for: selectionState)),
startPoint: .top,
endPoint: .bottom
)
)
.cornerRadius(viewModel.cornerRadius)
.cornerRadius(viewModel.cornerRadius(for: selectionState))
}
.clipped()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,33 @@ public class ImageComponentViewModel {
self.component = component
}

public var url: URL {
component.url
private func currentComponent(for selectionState: SelectionState) -> PaywallComponent.ImageComponent {
switch selectionState {
case .selected:
return component.selectedComponent ?? component
case .unselected:
return component
}
}
public var cornerRadius: Double {
component.cornerRadius

func url(for selectionState: SelectionState) -> URL {
currentComponent(for: selectionState).url
}

func cornerRadius(for selectionState: SelectionState) -> Double {
currentComponent(for: selectionState).cornerRadius
}
public var gradientColors: [Color] {
component.gradientColors.compactMap { $0.toColor(fallback: Color.clear) }

func gradientColors(for selectionState: SelectionState) -> [Color] {
currentComponent(for: selectionState).gradientColors.compactMap { $0.toColor(fallback: Color.clear) }
}
public var contentMode: ContentMode {
component.fitMode.contentMode

func contentMode(for selectionState: SelectionState) -> ContentMode {
currentComponent(for: selectionState).fitMode.contentMode
}
public var maxHeight: CGFloat? {
component.maxHeight

func maxHeight(for selectionState: SelectionState) -> CGFloat? {
currentComponent(for: selectionState).maxHeight
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ import SwiftUI
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
struct LinkButtonComponentView: View {

@Environment(\.selectionState) var selectionState

let viewModel: LinkButtonComponentViewModel

var url: URL {
viewModel.url
viewModel.url(for: selectionState)
}

var body: some View {
EmptyView()
Link(destination: url) {
Link(destination: self.url) {
TextComponentView(viewModel: viewModel.textComponentViewModel)
.cornerRadius(25)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ public class LinkButtonComponentViewModel {
let textComponentViewModel: TextComponentViewModel
private let component: PaywallComponent.LinkButtonComponent

public var url: URL {
component.url
}
public var textComponent: PaywallComponent.TextComponent {
component.textComponent
}

init(component: PaywallComponent.LinkButtonComponent,
localizedStrings: PaywallComponent.LocalizationDictionary
) throws {
Expand All @@ -33,6 +26,19 @@ public class LinkButtonComponentViewModel {
component: component.textComponent)
}

private func currentComponent(for selectionState: SelectionState) -> PaywallComponent.LinkButtonComponent {
switch selectionState {
case .selected:
return component.selectedComponent ?? component
case .unselected:
return component
}
}

func url(for selectionState: SelectionState) -> URL {
currentComponent(for: selectionState).url
}

}

#endif
Loading