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

Revert changes to public Customer Center API #4681

Merged
merged 3 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
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