Skip to content

Commit

Permalink
Revert "[Customer Center]: fix navigation when embedded in `Navigatio…
Browse files Browse the repository at this point in the history
…nStack` …" (#4681)
  • Loading branch information
vegaro authored Jan 17, 2025
1 parent 7bca3bc commit bf3aa83
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 119 deletions.
4 changes: 0 additions & 4 deletions RevenueCat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -2034,7 +2033,6 @@
57EAE526274324C60060EB74 /* Lock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Lock.swift; sourceTree = "<group>"; };
57EAE52A274332830060EB74 /* Obsoletions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Obsoletions.swift; sourceTree = "<group>"; };
57EAE52C274468900060EB74 /* RawDataContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RawDataContainer.swift; sourceTree = "<group>"; };
57ED352C2D37B625007DEA30 /* CustomerCenterNavigationLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomerCenterNavigationLink.swift; sourceTree = "<group>"; };
57EFDC6A27BC1F370057EC39 /* ProductType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductType.swift; sourceTree = "<group>"; };
57F2C60B29784C11009EE527 /* SwiftVersionCheck.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftVersionCheck.swift; sourceTree = "<group>"; };
57F3C10429B7B22E0004FD7E /* CustomerInfo+ActiveDates.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CustomerInfo+ActiveDates.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,16 @@ import SwiftUI
@available(watchOS, unavailable)
struct CompatibilityNavigationStack<Content: View>: 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
}
}
}
Expand Down

This file was deleted.

43 changes: 8 additions & 35 deletions RevenueCatUI/CustomerCenter/Views/CustomerCenterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) })
}
Expand Down

0 comments on commit bf3aa83

Please sign in to comment.