diff --git a/RevenueCat.xcodeproj/project.pbxproj b/RevenueCat.xcodeproj/project.pbxproj index 77f2248d63..463438d6a5 100644 --- a/RevenueCat.xcodeproj/project.pbxproj +++ b/RevenueCat.xcodeproj/project.pbxproj @@ -758,7 +758,6 @@ 57EAE527274324C60060EB74 /* Lock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57EAE526274324C60060EB74 /* Lock.swift */; }; 57EAE52B274332830060EB74 /* Obsoletions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57EAE52A274332830060EB74 /* Obsoletions.swift */; }; 57EAE52D274468900060EB74 /* RawDataContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57EAE52C274468900060EB74 /* RawDataContainer.swift */; }; - 57ED352D2D37B625007DEA30 /* CustomerCenterNavigationLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57ED352C2D37B625007DEA30 /* CustomerCenterNavigationLink.swift */; }; 57EFDC6B27BC1F370057EC39 /* ProductType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57EFDC6A27BC1F370057EC39 /* ProductType.swift */; }; 57F2C60C29784C11009EE527 /* SwiftVersionCheck.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57F2C60B29784C11009EE527 /* SwiftVersionCheck.swift */; }; 57F3C10529B7B22E0004FD7E /* CustomerInfo+ActiveDates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57F3C10429B7B22E0004FD7E /* CustomerInfo+ActiveDates.swift */; }; @@ -2034,7 +2033,6 @@ 57EAE526274324C60060EB74 /* Lock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Lock.swift; sourceTree = ""; }; 57EAE52A274332830060EB74 /* Obsoletions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Obsoletions.swift; sourceTree = ""; }; 57EAE52C274468900060EB74 /* RawDataContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RawDataContainer.swift; sourceTree = ""; }; - 57ED352C2D37B625007DEA30 /* CustomerCenterNavigationLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomerCenterNavigationLink.swift; sourceTree = ""; }; 57EFDC6A27BC1F370057EC39 /* ProductType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductType.swift; sourceTree = ""; }; 57F2C60B29784C11009EE527 /* SwiftVersionCheck.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftVersionCheck.swift; sourceTree = ""; }; 57F3C10429B7B22E0004FD7E /* CustomerInfo+ActiveDates.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CustomerInfo+ActiveDates.swift"; sourceTree = ""; }; @@ -3682,7 +3680,6 @@ 2D2AFE8E2C6A9D8700D1B0B4 /* CompatibilityContentUnavailableView.swift */, 2C4C36122C6FBA8B00AE959B /* CompatibilityTopBarTrailing.swift */, 3537565B2C382C2800A1B8D6 /* CustomerCenterView.swift */, - 57ED352C2D37B625007DEA30 /* CustomerCenterNavigationLink.swift */, 35C200B02C39254100B9778B /* FeedbackSurveyView.swift */, 3537565C2C382C2800A1B8D6 /* ManageSubscriptionsView.swift */, 3537565D2C382C2800A1B8D6 /* NoSubscriptionsView.swift */, @@ -6626,7 +6623,6 @@ files = ( 03E37BED2D30B73400CD9678 /* TabsComponentViewModel.swift in Sources */, 88B1BB132C81479F001B7EE5 /* PaywallComponentTypeTransformers.swift in Sources */, - 57ED352D2D37B625007DEA30 /* CustomerCenterNavigationLink.swift in Sources */, 88B1BB042C813A3C001B7EE5 /* StackComponentViewModel.swift in Sources */, 1E5F8F782C46BBD90041EECD /* CustomerCenterAction.swift in Sources */, 1ED4CA9F2CC25A5F0021AB8F /* SafariView.swift in Sources */, diff --git a/RevenueCatUI/CustomerCenter/Views/CompatibilityNavigationStack.swift b/RevenueCatUI/CustomerCenter/Views/CompatibilityNavigationStack.swift index a0412bf39f..2b5e0ef6eb 100644 --- a/RevenueCatUI/CustomerCenter/Views/CompatibilityNavigationStack.swift +++ b/RevenueCatUI/CustomerCenter/Views/CompatibilityNavigationStack.swift @@ -23,20 +23,16 @@ import SwiftUI @available(watchOS, unavailable) struct CompatibilityNavigationStack: View { - @ViewBuilder var content: () -> Content - - init(@ViewBuilder content: @escaping () -> Content) { - self.content = content - } + @ViewBuilder var content: Content var body: some View { if #available(iOS 16.0, *) { NavigationStack { - content() + content } } else { NavigationView { - content() + content } } } diff --git a/RevenueCatUI/CustomerCenter/Views/CustomerCenterNavigationLink.swift b/RevenueCatUI/CustomerCenter/Views/CustomerCenterNavigationLink.swift deleted file mode 100644 index 2b7309edd8..0000000000 --- a/RevenueCatUI/CustomerCenter/Views/CustomerCenterNavigationLink.swift +++ /dev/null @@ -1,73 +0,0 @@ -// -// CustomerCenterNavigationLink.swift -// RevenueCat -// -// Created by Facundo Menzella on 14/1/25. -// - -import RevenueCat -import SwiftUI - -#if os(iOS) - -/// A view that provides a navigation link to `CustomerCenterView` with a customizable label. -/// -/// This is the **preferred way** to integrate `CustomerCenterView` into your `NavigationStack`, -/// ensuring proper navigation behavior by setting `isEmbededInNavigation` to `true`. -/// -/// -/// Example: -/// ```swift -/// CustomerCenterNavigationLink { -/// HStack { -/// Image(systemName: "person.circle") -/// Text("Customer Center") -/// } -/// } -/// -/// CustomerCenterNavigationLink(Text("Customer Center")) -/// ``` -@available(iOS 15.0, *) -@available(macOS, unavailable) -@available(tvOS, unavailable) -@available(watchOS, unavailable) -public struct CustomerCenterNavigationLink: View { - - private let customerCenterActionHandler: CustomerCenterActionHandler? - @ViewBuilder private let label: () -> Label - - /// Initializes the navigation link with a label view provided by a closure. - /// - /// Use this initializer when the label requires dynamic content or complex logic. - /// - /// Example: - /// ```swift - /// CustomerCenterNavigationLink { - /// HStack { - /// Image(systemName: "person.circle") - /// Text("Customer Center") - /// } - /// } - /// ``` - /// - /// - Parameter label: A closure that returns the view to display as the navigation link’s label. - public init( - customerCenterActionHandler: CustomerCenterActionHandler? = nil, - @ViewBuilder label: @escaping () -> Label) { - self.customerCenterActionHandler = customerCenterActionHandler - self.label = label - } - - /// The content and behavior of the navigation link. - public var body: some View { - NavigationLink { - CustomerCenterView( - customerCenterActionHandler: customerCenterActionHandler, - isEmbeddedInNavigationStack: true) - } label: { - label() - } - } -} - -#endif diff --git a/RevenueCatUI/CustomerCenter/Views/CustomerCenterView.swift b/RevenueCatUI/CustomerCenter/Views/CustomerCenterView.swift index cc8d2f6067..88dc1a8b15 100644 --- a/RevenueCatUI/CustomerCenter/Views/CustomerCenterView.swift +++ b/RevenueCatUI/CustomerCenter/Views/CustomerCenterView.swift @@ -43,50 +43,29 @@ public struct CustomerCenterView: View { private let mode: CustomerCenterPresentationMode - /// A flag indicating whether the view is already embedded in a navigation stack. - /// - /// - When set to `true`, the view must be part of an existing `NavigationStack` / `NavigationView`. - /// - When set to `false`, the view is not part of an external `NavigationStack` / `NavigationView` - /// and uses one internally. - private let isEmbeddedInNavigationStack: Bool - /// Create a view to handle common customer support tasks /// - Parameters: /// - customerCenterActionHandler: An optional `CustomerCenterActionHandler` to handle actions /// from the Customer Center. - /// - isEmbeddedInNavigationStack: Whether this view is already inside a `NavigationStack` / `NavigationView` - public init( - customerCenterActionHandler: CustomerCenterActionHandler? = nil, - isEmbeddedInNavigationStack: Bool = false) { - self.init( - customerCenterActionHandler: customerCenterActionHandler, - mode: .default, - isEmbeddedInNavigationStack: isEmbeddedInNavigationStack - ) + public init(customerCenterActionHandler: CustomerCenterActionHandler? = nil) { + self.init(customerCenterActionHandler: customerCenterActionHandler, mode: .default) } /// Create a view to handle common customer support tasks /// - Parameters: /// - customerCenterActionHandler: An optional `CustomerCenterActionHandler` to handle actions /// from the Customer Center. - /// - mode: The presentation mode for the Customer Center - /// - isEmbeddedInNavigationStack: Whether this view is already inside a navigation stack - init( - customerCenterActionHandler: CustomerCenterActionHandler? = nil, - mode: CustomerCenterPresentationMode, - isEmbeddedInNavigationStack: Bool = false) { + init(customerCenterActionHandler: CustomerCenterActionHandler? = nil, + mode: CustomerCenterPresentationMode) { self._viewModel = .init(wrappedValue: CustomerCenterViewModel(customerCenterActionHandler: customerCenterActionHandler)) self.mode = mode - self.isEmbeddedInNavigationStack = isEmbeddedInNavigationStack } - fileprivate init( - viewModel: CustomerCenterViewModel, - mode: CustomerCenterPresentationMode = CustomerCenterPresentationMode.default) { + fileprivate init(viewModel: CustomerCenterViewModel, + mode: CustomerCenterPresentationMode = CustomerCenterPresentationMode.default) { self._viewModel = .init(wrappedValue: viewModel) self.mode = mode - self.isEmbeddedInNavigationStack = false } // swiftlint:disable:next missing_docs @@ -178,14 +157,8 @@ private extension CustomerCenterView { let accentColor = Color.from(colorInformation: configuration.appearance.accentColor, for: self.colorScheme) - Group { - if isEmbeddedInNavigationStack { - destinationContent(configuration: configuration) - } else { - CompatibilityNavigationStack { - destinationContent(configuration: configuration) - } - } + CompatibilityNavigationStack { + destinationContent(configuration: configuration) } .applyIf(accentColor != nil, apply: { $0.tint(accentColor) }) }