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 V2] Navigation bar component #4775

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 28 additions & 4 deletions RevenueCat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
030F918A2D55C1D20085103F /* LocaleFinder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 030F91892D55C1AB0085103F /* LocaleFinder.swift */; };
030F918C2D55C9DC0085103F /* LocaleFinderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 030F918B2D55C9D80085103F /* LocaleFinderTests.swift */; };
030F918E2D5664410085103F /* LocaleExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 030F918D2D5664410085103F /* LocaleExtensions.swift */; };
030F91E32D56C4FD0085103F /* PaywallNavigationBarComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 030F91E22D56C4FD0085103F /* PaywallNavigationBarComponent.swift */; };
030F91E62D56F0850085103F /* NavigationBarComponentViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 030F91E52D56F07F0085103F /* NavigationBarComponentViewModel.swift */; };
030F91FA2D57F1E70085103F /* NavigationViewIfNeeded.swift in Sources */ = {isa = PBXBuildFile; fileRef = 030F91F92D57F1E20085103F /* NavigationViewIfNeeded.swift */; };
030F91FC2D5945C10085103F /* NavigationBarPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 030F91FB2D5945AF0085103F /* NavigationBarPreview.swift */; };
030F920D2D595FE60085103F /* NavigationBarModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 030F920C2D595FDF0085103F /* NavigationBarModifier.swift */; };
0313FD41268A506400168386 /* DateProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0313FD40268A506400168386 /* DateProvider.swift */; };
0354AA462D4029C300F9E330 /* TabControlButtonComponentViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0354AA3E2D4029C300F9E330 /* TabControlButtonComponentViewModel.swift */; };
0354AA472D4029C300F9E330 /* TabControlComponentViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0354AA402D4029C300F9E330 /* TabControlComponentViewModel.swift */; };
Expand Down Expand Up @@ -804,7 +809,6 @@
777FB4882C661C0600CD4749 /* SemanticVersionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 777FB4872C661C0600CD4749 /* SemanticVersionTests.swift */; };
7783606D2CCA7E14000785B8 /* PaywallStickyFooterComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7783606C2CCA7E14000785B8 /* PaywallStickyFooterComponent.swift */; };
778360792CCA85E4000785B8 /* StickyFooterComponentViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 778360782CCA85E4000785B8 /* StickyFooterComponentViewModel.swift */; };
7783607B2CCA88E4000785B8 /* StickyFooterComponentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7783607A2CCA88E4000785B8 /* StickyFooterComponentView.swift */; };
77BA1AB12CCBAB80009BF0EA /* RootViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77BA1AB02CCBAB80009BF0EA /* RootViewModel.swift */; };
77BA1AB32CCBB6EE009BF0EA /* RootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77BA1AB22CCBB6EE009BF0EA /* RootView.swift */; };
805B60C97993B311CEC93EAF /* ProductsFetcherSK2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3628C1F100BB3C1782860D24 /* ProductsFetcherSK2.swift */; };
Expand Down Expand Up @@ -1289,6 +1293,11 @@
030F91892D55C1AB0085103F /* LocaleFinder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocaleFinder.swift; sourceTree = "<group>"; };
030F918B2D55C9D80085103F /* LocaleFinderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocaleFinderTests.swift; sourceTree = "<group>"; };
030F918D2D5664410085103F /* LocaleExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocaleExtensions.swift; sourceTree = "<group>"; };
030F91E22D56C4FD0085103F /* PaywallNavigationBarComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaywallNavigationBarComponent.swift; sourceTree = "<group>"; };
030F91E52D56F07F0085103F /* NavigationBarComponentViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationBarComponentViewModel.swift; sourceTree = "<group>"; };
030F91F92D57F1E20085103F /* NavigationViewIfNeeded.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationViewIfNeeded.swift; sourceTree = "<group>"; };
030F91FB2D5945AF0085103F /* NavigationBarPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationBarPreview.swift; sourceTree = "<group>"; };
030F920C2D595FDF0085103F /* NavigationBarModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationBarModifier.swift; sourceTree = "<group>"; };
0313FD40268A506400168386 /* DateProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateProvider.swift; sourceTree = "<group>"; };
0354AA3D2D4029C300F9E330 /* TabControlButtonComponentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabControlButtonComponentView.swift; sourceTree = "<group>"; };
0354AA3E2D4029C300F9E330 /* TabControlButtonComponentViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabControlButtonComponentViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2101,7 +2110,6 @@
777FB4872C661C0600CD4749 /* SemanticVersionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SemanticVersionTests.swift; sourceTree = "<group>"; };
7783606C2CCA7E14000785B8 /* PaywallStickyFooterComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaywallStickyFooterComponent.swift; sourceTree = "<group>"; };
778360782CCA85E4000785B8 /* StickyFooterComponentViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickyFooterComponentViewModel.swift; sourceTree = "<group>"; };
7783607A2CCA88E4000785B8 /* StickyFooterComponentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickyFooterComponentView.swift; sourceTree = "<group>"; };
77BA1AB02CCBAB80009BF0EA /* RootViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootViewModel.swift; sourceTree = "<group>"; };
77BA1AB22CCBB6EE009BF0EA /* RootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootView.swift; sourceTree = "<group>"; };
80E80EF026970DC3008F245A /* ReceiptFetcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReceiptFetcher.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2563,6 +2571,14 @@
path = Localizations;
sourceTree = "<group>";
};
030F91E42D56F0750085103F /* NavigationBar */ = {
isa = PBXGroup;
children = (
030F91E52D56F07F0085103F /* NavigationBarComponentViewModel.swift */,
);
path = NavigationBar;
sourceTree = "<group>";
};
0354AA452D4029C300F9E330 /* Tabs */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -2637,6 +2653,7 @@
2C2AEB0D2CA64DA900A50F38 /* TemplateComponentsViewPreviews */ = {
isa = PBXGroup;
children = (
030F91FB2D5945AF0085103F /* NavigationBarPreview.swift */,
03A98CF02D222F53009BCA61 /* FallbackComponentPreview.swift */,
2C2AEB0E2CA64E0E00A50F38 /* Template1Preview.swift */,
2C8EC6DA2CCC23B700D6CCF8 /* MultiTierPreview.swift */,
Expand Down Expand Up @@ -2666,6 +2683,7 @@
0354AA452D4029C300F9E330 /* Tabs */,
4D3BA5B12D47AB4400668AFC /* Timeline */,
88B1BADC2C813A3C001B7EE5 /* Text */,
030F91E42D56F0750085103F /* NavigationBar */,
778360772CCA85D1000785B8 /* StickyFooter */,
778360742CCA84FA000785B8 /* Root */,
);
Expand All @@ -2675,6 +2693,8 @@
2C7457442CEA652B004ACE52 /* ViewHelpers */ = {
isa = PBXGroup;
children = (
030F920C2D595FDF0085103F /* NavigationBarModifier.swift */,
030F91F92D57F1E20085103F /* NavigationViewIfNeeded.swift */,
2C7457872CEDF7AC004ACE52 /* BackgroundStyle.swift */,
77089F9D2CD39EC100848CD5 /* ShadowModifier.swift */,
4D6F4BCF2CF69DE300353AF6 /* ForegroundColorScheme.swift */,
Expand Down Expand Up @@ -4585,7 +4605,6 @@
isa = PBXGroup;
children = (
778360782CCA85E4000785B8 /* StickyFooterComponentViewModel.swift */,
7783607A2CCA88E4000785B8 /* StickyFooterComponentView.swift */,
);
path = StickyFooter;
sourceTree = "<group>";
Expand Down Expand Up @@ -4963,6 +4982,7 @@
2C2AEB3A2CA7209F00A50F38 /* PaywallPackageComponent.swift */,
2C2AEB3E2CA7235300A50F38 /* PaywallPurchaseButtonComponent.swift */,
7783606C2CCA7E14000785B8 /* PaywallStickyFooterComponent.swift */,
030F91E22D56C4FD0085103F /* PaywallNavigationBarComponent.swift */,
);
path = Components;
sourceTree = "<group>";
Expand Down Expand Up @@ -6199,6 +6219,7 @@
5736267B2D3E76C1003C9665 /* ProductPaidPrice.swift in Sources */,
5712BE9029241EB500A83F15 /* TimingUtil.swift in Sources */,
B3B5FBC1269E17CE00104A0C /* DeviceCache.swift in Sources */,
030F91E32D56C4FD0085103F /* PaywallNavigationBarComponent.swift in Sources */,
F5BE424226965F9F00254A30 /* ProductRequestData+Initialization.swift in Sources */,
2DDF41AD24F6F37C005BC22D /* ASN1ObjectIdentifier.swift in Sources */,
35549323269E298B005F9AE9 /* OfferingsFactory.swift in Sources */,
Expand Down Expand Up @@ -6759,6 +6780,7 @@
887A607F2C1D037000E1A461 /* Optional+Extensions.swift in Sources */,
2C08B3172CDA44440024857B /* ViewModelFactory.swift in Sources */,
356979E02CCFDAA100EE6A9E /* CustomerInfoFixtures.swift in Sources */,
030F91FC2D5945C10085103F /* NavigationBarPreview.swift in Sources */,
3511088F2C47F6DA0048C4D8 /* CustomerInfo+CurrentEntitlement.swift in Sources */,
887A60752C1D037000E1A461 /* TemplateViewConfiguration.swift in Sources */,
03C72FC32D349BAE00297FEC /* IconComponentView.swift in Sources */,
Expand All @@ -6779,6 +6801,7 @@
574BA26B2D3E762E009B8EA6 /* PurchaseInfo.swift in Sources */,
887A60C92C1D037000E1A461 /* PurchaseButton.swift in Sources */,
88B1BAF02C813A3C001B7EE5 /* TextComponentViewModel.swift in Sources */,
030F91E62D56F0850085103F /* NavigationBarComponentViewModel.swift in Sources */,
2D2AFE912C6A9EF500D1B0B4 /* Binding+Extensions.swift in Sources */,
2C7457242CE713E5004ACE52 /* PreviewMock.swift in Sources */,
7706ED3E2C6E374D0004B9F9 /* ButtonStyles.swift in Sources */,
Expand All @@ -6797,6 +6820,7 @@
03A98CF12D222F5F009BCA61 /* FallbackComponentPreview.swift in Sources */,
887A60862C1D037000E1A461 /* FooterHidingModifier.swift in Sources */,
4D3BA5882D432E5900668AFC /* Fill.swift in Sources */,
030F920D2D595FE60085103F /* NavigationBarModifier.swift in Sources */,
FDAD6AC72D132DD900FB047E /* CustomerCenterStoreKitUtilitiesType.swift in Sources */,
887A60C02C1D037000E1A461 /* AsyncButton.swift in Sources */,
887A60892C1D037000E1A461 /* PaywallPurchasesType.swift in Sources */,
Expand Down Expand Up @@ -6839,7 +6863,6 @@
2C4C36132C6FBA8B00AE959B /* CompatibilityTopBarTrailing.swift in Sources */,
3546355C2C391F38001D7E85 /* FeedbackSurveyViewModel.swift in Sources */,
353756692C382C2800A1B8D6 /* CustomerCenterViewState.swift in Sources */,
7783607B2CCA88E4000785B8 /* StickyFooterComponentView.swift in Sources */,
887A608B2C1D037000E1A461 /* PurchaseHandler+TestData.swift in Sources */,
35F249CE2C493E3D0058993A /* CustomerCenterPurchases.swift in Sources */,
353756672C382C2800A1B8D6 /* PurchaseInformation.swift in Sources */,
Expand Down Expand Up @@ -6877,6 +6900,7 @@
887A60CE2C1D037000E1A461 /* View+PresentPaywall.swift in Sources */,
357CEC702C5940CE00A80837 /* ColorFromAppearance.swift in Sources */,
887A60832C1D037000E1A461 /* VersionDetector.swift in Sources */,
030F91FA2D57F1E70085103F /* NavigationViewIfNeeded.swift in Sources */,
574D1C702D3E75F9005840CD /* PurchaseDetailView.swift in Sources */,
574D1C712D3E75F9005840CD /* PurchaseHistoryView.swift in Sources */,
574D1C722D3E75F9005840CD /* PurchaseLinkView.swift in Sources */,
Expand Down
2 changes: 0 additions & 2 deletions RevenueCatUI/Templates/V2/Components/ComponentsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ struct ComponentsView: View {
PackageComponentView(viewModel: viewModel, onDismiss: onDismiss)
case .purchaseButton(let viewModel):
PurchaseButtonComponentView(viewModel: viewModel)
case .stickyFooter(let viewModel):
StickyFooterComponentView(viewModel: viewModel)
Comment on lines -65 to -66
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sticky footer is not a standalone component (not in the component tree) so removed it from here. I did this in this PR since the navigation bar fell in the same category 🤷‍♂️

case .timeline(let viewModel):
TimelineComponentView(viewModel: viewModel)
case .tabs(let viewModel):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Copyright RevenueCat Inc. All Rights Reserved.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/MIT
//
// NavigationBarComponentViewModel.swift
//
// Created by Josh Holtz on 2/7/25.

import RevenueCat
import SwiftUI

#if !os(macOS) && !os(tvOS) // For Paywalls V2

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
class NavigationBarComponentViewModel {

let component: PaywallComponent.NavigationBarComponent

let leadingStackViewModel: StackComponentViewModel?
let trailingStackViewModel: StackComponentViewModel?

init(
component: PaywallComponent.NavigationBarComponent,
leadingStackViewModel: StackComponentViewModel?,
trailingStackViewModel: StackComponentViewModel?
) {
self.component = component
self.leadingStackViewModel = leadingStackViewModel
self.trailingStackViewModel = trailingStackViewModel
}

}

#endif
3 changes: 3 additions & 0 deletions RevenueCatUI/Templates/V2/Components/Root/RootViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@ class RootViewModel {
}

let stackViewModel: StackComponentViewModel
let navigationBarViewModel: NavigationBarComponentViewModel?
let stickyFooterViewModel: StickyFooterComponentViewModel?
let firstImageInfo: FirstImageInfo?

init(
stackViewModel: StackComponentViewModel,
navigationBarViewModel: NavigationBarComponentViewModel?,
stickyFooterViewModel: StickyFooterComponentViewModel?,
firstImageInfo: FirstImageInfo?
) {
self.stackViewModel = stackViewModel
self.navigationBarViewModel = navigationBarViewModel
self.stickyFooterViewModel = stickyFooterViewModel
self.firstImageInfo = firstImageInfo
}
Expand Down

This file was deleted.

2 changes: 2 additions & 0 deletions RevenueCatUI/Templates/V2/PaywallsV2View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ struct PaywallsV2View: View {
.task {
await self.introOfferEligibilityContext.computeEligibility(for: paywallState.packages)
}
// Needs to be last since this can wrap the view in a NavigationView/NavigationStack if needed
.navigationBarIfNeeded(paywallState.rootViewModel.navigationBarViewModel, onDismiss: self.onDismiss)
case .failure(let error):
// Show fallback paywall and debug error message that
// occurred while validating data and view models
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ private enum FamilySharingTogglePreview {
.stack(stack)
]
),
navigationBar: nil,
stickyFooter: nil,
background: .color(.init(light: .hex("#ffffff")))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ private enum MultiTierPreview {
.stack(stack)
]
),
navigationBar: nil,
stickyFooter: nil,
background: .color(.init(light: .hex("#ffffff")))
)
Expand Down
Loading