From 841eb75d197c2decf51192709bb5f58c3b865d71 Mon Sep 17 00:00:00 2001 From: Cody Kerns Date: Fri, 9 Aug 2024 12:37:40 -0400 Subject: [PATCH 1/8] Improve button styles, add explicit dismiss buttons --- ...nsButtonStyle.swift => ButtonStyles.swift} | 42 ++++++++++++++++--- .../Views/FeedbackSurveyView.swift | 2 +- .../Views/ManageSubscriptionsView.swift | 15 ++++++- .../Views/NoSubscriptionsView.swift | 7 ++-- .../Views/PromotionalOfferView.swift | 2 +- .../Views/WrongPlatformView.swift | 14 +++++++ 6 files changed, 71 insertions(+), 11 deletions(-) rename RevenueCatUI/CustomerCenter/{ManageSubscriptionsButtonStyle.swift => ButtonStyles.swift} (53%) diff --git a/RevenueCatUI/CustomerCenter/ManageSubscriptionsButtonStyle.swift b/RevenueCatUI/CustomerCenter/ButtonStyles.swift similarity index 53% rename from RevenueCatUI/CustomerCenter/ManageSubscriptionsButtonStyle.swift rename to RevenueCatUI/CustomerCenter/ButtonStyles.swift index 2af8da64c9..7b1cfe89b5 100644 --- a/RevenueCatUI/CustomerCenter/ManageSubscriptionsButtonStyle.swift +++ b/RevenueCatUI/CustomerCenter/ButtonStyles.swift @@ -7,7 +7,7 @@ // // https://opensource.org/licenses/MIT // -// ManageSubscriptionsButtonStyle.swift +// ButtonStyles.swift // // // Created by Cesar de la Vega on 28/5/24. @@ -25,7 +25,7 @@ import SwiftUI @available(macOS, unavailable) @available(tvOS, unavailable) @available(watchOS, unavailable) -struct ManageSubscriptionsButtonStyle: PrimitiveButtonStyle { +struct ProminentButtonStyle: PrimitiveButtonStyle { @Environment(\.appearance) private var appearance: CustomerCenterConfigData.Appearance @Environment(\.colorScheme) private var colorScheme @@ -37,14 +37,39 @@ struct ManageSubscriptionsButtonStyle: PrimitiveButtonStyle { Button(action: { configuration.trigger() }, label: { configuration.label.frame(maxWidth: .infinity) }) + .font(.body.weight(.medium)) .buttonStyle(.borderedProminent) .controlSize(.large) + .buttonBorderShape(.roundedRectangle(radius: 16)) .applyIf(background != nil, apply: { $0.tint(background) }) .applyIf(textColor != nil, apply: { $0.foregroundColor(textColor) }) } } +@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) +@available(macOS, unavailable) +@available(tvOS, unavailable) +@available(watchOS, unavailable) +struct SubtleButtonStyle: PrimitiveButtonStyle { + + @Environment(\.appearance) private var appearance: CustomerCenterConfigData.Appearance + @Environment(\.colorScheme) private var colorScheme + + func makeBody(configuration: PrimitiveButtonStyleConfiguration) -> some View { + let background = color(from: appearance.buttonBackgroundColor, for: colorScheme) + + Button(action: { configuration.trigger() }, label: { + configuration.label.frame(maxWidth: .infinity) + }) + .font(.body.weight(.medium)) + .controlSize(.large) + .padding(.vertical) + .applyIf(background != nil, apply: { $0.foregroundColor(background) }) + } + +} + @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) @available(macOS, unavailable) @available(tvOS, unavailable) @@ -52,9 +77,16 @@ struct ManageSubscriptionsButtonStyle: PrimitiveButtonStyle { struct ManageSubscriptionsButtonStyle_Previews: PreviewProvider { static var previews: some View { - Button("Didn't receive purchase") {} - .buttonStyle(ManageSubscriptionsButtonStyle()) - .environment(\.appearance, CustomerCenterConfigTestData.standardAppearance) + VStack(spacing: 16.0) { + Button("Didn't receive purchase") {} + .buttonStyle(ProminentButtonStyle()) + .environment(\.appearance, CustomerCenterConfigTestData.standardAppearance) + + Button("Cancel") {} + .buttonStyle(SubtleButtonStyle()) + .environment(\.appearance, CustomerCenterConfigTestData.standardAppearance) + + }.padding() } } diff --git a/RevenueCatUI/CustomerCenter/Views/FeedbackSurveyView.swift b/RevenueCatUI/CustomerCenter/Views/FeedbackSurveyView.swift index 6d2ec236f6..d5a3bad4e9 100644 --- a/RevenueCatUI/CustomerCenter/Views/FeedbackSurveyView.swift +++ b/RevenueCatUI/CustomerCenter/Views/FeedbackSurveyView.swift @@ -94,7 +94,7 @@ struct FeedbackSurveyButtonsView: View { Text(option.title) } }) - .buttonStyle(ManageSubscriptionsButtonStyle()) + .buttonStyle(ProminentButtonStyle()) .disabled(self.loadingState != nil) } } diff --git a/RevenueCatUI/CustomerCenter/Views/ManageSubscriptionsView.swift b/RevenueCatUI/CustomerCenter/Views/ManageSubscriptionsView.swift index 1ed6a4de94..8f15d007ed 100644 --- a/RevenueCatUI/CustomerCenter/Views/ManageSubscriptionsView.swift +++ b/RevenueCatUI/CustomerCenter/Views/ManageSubscriptionsView.swift @@ -26,6 +26,9 @@ import SwiftUI @available(watchOS, unavailable) struct ManageSubscriptionsView: View { + @Environment(\.dismiss) + var dismiss + @Environment(\.appearance) private var appearance: CustomerCenterConfigData.Appearance @Environment(\.localization) @@ -107,6 +110,16 @@ struct ManageSubscriptionsView: View { .task { await loadInformationIfNeeded() } + .toolbar { + ToolbarItem(placement: .topBarLeading) { + Button(role: .cancel) { + dismiss() + } label: { + Text(localization.commonLocalizedString(for: .dismiss)) + } + + } + } .navigationTitle(self.viewModel.screen.title) .navigationBarTitleDisplayMode(.inline) } @@ -319,7 +332,7 @@ struct ManageSubscriptionButton: View { Text(path.title) } }) - .buttonStyle(ManageSubscriptionsButtonStyle()) + .buttonStyle(ProminentButtonStyle()) .disabled(self.viewModel.loadingPath != nil) .restorePurchasesAlert(isPresented: self.$viewModel.showRestoreAlert) .sheet(item: self.$viewModel.promotionalOfferData, diff --git a/RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift b/RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift index 871e80d34e..0152b7b065 100644 --- a/RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift +++ b/RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift @@ -70,12 +70,13 @@ struct NoSubscriptionsView: View { showRestoreAlert = true } .restorePurchasesAlert(isPresented: $showRestoreAlert) - .buttonStyle(ManageSubscriptionsButtonStyle()) + .buttonStyle(ProminentButtonStyle()) - Button(localization.commonLocalizedString(for: .cancel)) { + Button(localization.commonLocalizedString(for: .dismiss)) { dismiss() } - .padding(.vertical) + .buttonStyle(SubtleButtonStyle()) + } .padding(.horizontal) .applyIf(textColor != nil, apply: { $0.foregroundColor(textColor) }) diff --git a/RevenueCatUI/CustomerCenter/Views/PromotionalOfferView.swift b/RevenueCatUI/CustomerCenter/Views/PromotionalOfferView.swift index 3b8dc97ff1..e75d7c82c9 100644 --- a/RevenueCatUI/CustomerCenter/Views/PromotionalOfferView.swift +++ b/RevenueCatUI/CustomerCenter/Views/PromotionalOfferView.swift @@ -144,7 +144,7 @@ struct PromoOfferButtonView: View { .font(.subheadline) } }) - .buttonStyle(ManageSubscriptionsButtonStyle()) + .buttonStyle(ProminentButtonStyle()) .padding(.horizontal) } } diff --git a/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift b/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift index 4fff043cd9..506c73cf92 100644 --- a/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift +++ b/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift @@ -30,6 +30,11 @@ struct WrongPlatformView: View { @State private var store: Store? + @Environment(\.dismiss) + var dismiss + + @Environment(\.localization) + private var localization: CustomerCenterConfigData.Localization @Environment(\.appearance) private var appearance: CustomerCenterConfigData.Appearance @Environment(\.colorScheme) @@ -58,6 +63,15 @@ struct WrongPlatformView: View { systemImage: "exclamationmark.triangle.fill" ) + Spacer() + + Button { + dismiss() + } label: { + Text(localization.commonLocalizedString(for: .dismiss)) + } + .buttonStyle(SubtleButtonStyle()) + } .applyIf(textColor != nil, apply: { $0.foregroundColor(textColor) }) } From a525f44e1ab4b2c4906ba554e318ae68d36d79dd Mon Sep 17 00:00:00 2001 From: Cody Kerns Date: Fri, 9 Aug 2024 13:46:21 -0400 Subject: [PATCH 2/8] lint for line count --- .../CustomerCenter/Views/ManageSubscriptionsView.swift | 6 ------ 1 file changed, 6 deletions(-) diff --git a/RevenueCatUI/CustomerCenter/Views/ManageSubscriptionsView.swift b/RevenueCatUI/CustomerCenter/Views/ManageSubscriptionsView.swift index 8f15d007ed..7ee50a5fb3 100644 --- a/RevenueCatUI/CustomerCenter/Views/ManageSubscriptionsView.swift +++ b/RevenueCatUI/CustomerCenter/Views/ManageSubscriptionsView.swift @@ -350,13 +350,11 @@ struct ManageSubscriptionButton: View { } #if DEBUG - @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) @available(macOS, unavailable) @available(tvOS, unavailable) @available(watchOS, unavailable) struct ManageSubscriptionsView_Previews: PreviewProvider { - static var previews: some View { let viewModelMonthlyRenewing = ManageSubscriptionsViewModel( screen: CustomerCenterConfigTestData.customerCenterData.screens[.management]!, @@ -367,12 +365,10 @@ struct ManageSubscriptionsView_Previews: PreviewProvider { .previewDisplayName("Monthly renewing") .environment(\.localization, CustomerCenterConfigTestData.customerCenterData.localization) .environment(\.appearance, CustomerCenterConfigTestData.customerCenterData.appearance) - let viewModelYearlyExpiring = ManageSubscriptionsViewModel( screen: CustomerCenterConfigTestData.customerCenterData.screens[.management]!, subscriptionInformation: CustomerCenterConfigTestData.subscriptionInformationYearlyExpiring, customerCenterActionHandler: nil) - ManageSubscriptionsView(viewModel: viewModelYearlyExpiring) .previewDisplayName("Yearly expiring") .environment(\.localization, CustomerCenterConfigTestData.customerCenterData.localization) @@ -386,7 +382,6 @@ struct ManageSubscriptionsView_Previews: PreviewProvider { @available(tvOS, unavailable) @available(watchOS, unavailable) struct SubscriptionDetailsView_Previews: PreviewProvider { - static var previews: some View { SubscriptionDetailsView( subscriptionInformation: CustomerCenterConfigTestData.subscriptionInformationMonthlyRenewing, @@ -395,7 +390,6 @@ struct SubscriptionDetailsView_Previews: PreviewProvider { ) .previewDisplayName("Subscription Details - Monthly") .padding() - } } #endif From 1658a0b03b840590d8c98ef1446c04ea7f9b64a4 Mon Sep 17 00:00:00 2001 From: Cody Kerns Date: Mon, 12 Aug 2024 15:33:19 -0400 Subject: [PATCH 3/8] fix subtle button style padding --- RevenueCatUI/CustomerCenter/ButtonStyles.swift | 1 - RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift | 1 + RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift | 2 ++ 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/RevenueCatUI/CustomerCenter/ButtonStyles.swift b/RevenueCatUI/CustomerCenter/ButtonStyles.swift index 7b1cfe89b5..0140c24766 100644 --- a/RevenueCatUI/CustomerCenter/ButtonStyles.swift +++ b/RevenueCatUI/CustomerCenter/ButtonStyles.swift @@ -64,7 +64,6 @@ struct SubtleButtonStyle: PrimitiveButtonStyle { }) .font(.body.weight(.medium)) .controlSize(.large) - .padding(.vertical) .applyIf(background != nil, apply: { $0.foregroundColor(background) }) } diff --git a/RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift b/RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift index 0152b7b065..f46d36b3a8 100644 --- a/RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift +++ b/RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift @@ -76,6 +76,7 @@ struct NoSubscriptionsView: View { dismiss() } .buttonStyle(SubtleButtonStyle()) + .padding(.vertical) } .padding(.horizontal) diff --git a/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift b/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift index 506c73cf92..5344c90ead 100644 --- a/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift +++ b/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift @@ -71,8 +71,10 @@ struct WrongPlatformView: View { Text(localization.commonLocalizedString(for: .dismiss)) } .buttonStyle(SubtleButtonStyle()) + .padding(.vertical) } + .padding(.horizontal) .applyIf(textColor != nil, apply: { $0.foregroundColor(textColor) }) } .task { From 838845e18d4a48b377d1f260f8a0f4a07764fcc3 Mon Sep 17 00:00:00 2001 From: Cody Kerns Date: Tue, 13 Aug 2024 11:40:00 -0400 Subject: [PATCH 4/8] use custom dismiss button --- .../CustomerCenter/ButtonStyles.swift | 46 +++++++++++-------- .../Views/ManageSubscriptionsView.swift | 13 ++---- .../Views/NoSubscriptionsView.swift | 29 ++++++++---- .../Views/WrongPlatformView.swift | 32 ++++++++----- 4 files changed, 72 insertions(+), 48 deletions(-) diff --git a/RevenueCatUI/CustomerCenter/ButtonStyles.swift b/RevenueCatUI/CustomerCenter/ButtonStyles.swift index 0140c24766..de670e8b88 100644 --- a/RevenueCatUI/CustomerCenter/ButtonStyles.swift +++ b/RevenueCatUI/CustomerCenter/ButtonStyles.swift @@ -51,41 +51,47 @@ struct ProminentButtonStyle: PrimitiveButtonStyle { @available(macOS, unavailable) @available(tvOS, unavailable) @available(watchOS, unavailable) -struct SubtleButtonStyle: PrimitiveButtonStyle { - - @Environment(\.appearance) private var appearance: CustomerCenterConfigData.Appearance - @Environment(\.colorScheme) private var colorScheme - - func makeBody(configuration: PrimitiveButtonStyleConfiguration) -> some View { - let background = color(from: appearance.buttonBackgroundColor, for: colorScheme) - - Button(action: { configuration.trigger() }, label: { - configuration.label.frame(maxWidth: .infinity) - }) - .font(.body.weight(.medium)) - .controlSize(.large) - .applyIf(background != nil, apply: { $0.foregroundColor(background) }) +struct DismissCircleButton: View { + @Environment(\.localization) private var localization + + var action: () -> Void + + var body: some View { + Button { + action() + } label: { + Circle() + .fill(Color(uiColor: .secondarySystemFill)) + .frame(width: 28, height: 28) + .overlay( + Image(systemName: "xmark") + .font(.system(size: 14, weight: .bold)) + .foregroundStyle(.secondary) + .imageScale(.medium) + ) + } + .buttonStyle(.plain) + .accessibilityLabel(Text(localization.commonLocalizedString(for: .dismiss))) } - } @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) @available(macOS, unavailable) @available(tvOS, unavailable) @available(watchOS, unavailable) -struct ManageSubscriptionsButtonStyle_Previews: PreviewProvider { +struct ButtonStyles_Previews: PreviewProvider { static var previews: some View { VStack(spacing: 16.0) { Button("Didn't receive purchase") {} .buttonStyle(ProminentButtonStyle()) - .environment(\.appearance, CustomerCenterConfigTestData.standardAppearance) - Button("Cancel") {} - .buttonStyle(SubtleButtonStyle()) - .environment(\.appearance, CustomerCenterConfigTestData.standardAppearance) + DismissCircleButton { + } }.padding() + .environment(\.appearance, CustomerCenterConfigTestData.standardAppearance) + .environment(\.localization, CustomerCenterConfigTestData.customerCenterData.localization) } } diff --git a/RevenueCatUI/CustomerCenter/Views/ManageSubscriptionsView.swift b/RevenueCatUI/CustomerCenter/Views/ManageSubscriptionsView.swift index 7ee50a5fb3..945301b4df 100644 --- a/RevenueCatUI/CustomerCenter/Views/ManageSubscriptionsView.swift +++ b/RevenueCatUI/CustomerCenter/Views/ManageSubscriptionsView.swift @@ -107,19 +107,16 @@ struct ManageSubscriptionsView: View { .frame(maxWidth: 400) } } - .task { - await loadInformationIfNeeded() - } .toolbar { - ToolbarItem(placement: .topBarLeading) { - Button(role: .cancel) { + ToolbarItem(placement: .topBarTrailing) { + DismissCircleButton { dismiss() - } label: { - Text(localization.commonLocalizedString(for: .dismiss)) } - } } + .task { + await loadInformationIfNeeded() + } .navigationTitle(self.viewModel.screen.title) .navigationBarTitleDisplayMode(.inline) } diff --git a/RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift b/RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift index f46d36b3a8..adf3e3adf4 100644 --- a/RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift +++ b/RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift @@ -46,7 +46,8 @@ struct NoSubscriptionsView: View { self.configuration = configuration } - var body: some View { + @ViewBuilder + var content: some View { let background = color(from: appearance.backgroundColor, for: colorScheme) let textColor = color(from: appearance.textColor, for: colorScheme) @@ -71,18 +72,30 @@ struct NoSubscriptionsView: View { } .restorePurchasesAlert(isPresented: $showRestoreAlert) .buttonStyle(ProminentButtonStyle()) - - Button(localization.commonLocalizedString(for: .dismiss)) { - dismiss() - } - .buttonStyle(SubtleButtonStyle()) - .padding(.vertical) - } .padding(.horizontal) .applyIf(textColor != nil, apply: { $0.foregroundColor(textColor) }) } + .toolbar { + ToolbarItem(placement: .topBarTrailing) { + DismissCircleButton { + dismiss() + } + } + } + + } + var body: some View { + if #available(iOS 16.0, *) { + NavigationStack { + content + } + } else { + NavigationView { + content + } + } } } diff --git a/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift b/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift index 5344c90ead..85a926258f 100644 --- a/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift +++ b/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift @@ -47,7 +47,7 @@ struct WrongPlatformView: View { self._store = State(initialValue: store) } - var body: some View { + @ViewBuilder var content: some View { ZStack { if let background = color(from: appearance.backgroundColor, for: colorScheme) { background.edgesIgnoringSafeArea(.all) @@ -62,21 +62,17 @@ struct WrongPlatformView: View { description: platformInstructions.1, systemImage: "exclamationmark.triangle.fill" ) - - Spacer() - - Button { - dismiss() - } label: { - Text(localization.commonLocalizedString(for: .dismiss)) - } - .buttonStyle(SubtleButtonStyle()) - .padding(.vertical) - } .padding(.horizontal) .applyIf(textColor != nil, apply: { $0.foregroundColor(textColor) }) } + .toolbar { + ToolbarItem(placement: .topBarTrailing) { + DismissCircleButton { + dismiss() + } + } + } .task { if store == nil { if let customerInfo = try? await Purchases.shared.customerInfo(), @@ -87,6 +83,18 @@ struct WrongPlatformView: View { } } + var body: some View { + if #available(iOS 16.0, *) { + NavigationStack { + content + } + } else { + NavigationView { + content + } + } + } + private func humanReadablePlatformName(store: Store) -> String { switch store { case .appStore, .macAppStore: From 2bb2f7ec5d0d03d48d74c6eb51f8e9b6c1c5597b Mon Sep 17 00:00:00 2001 From: Cody Kerns Date: Wed, 14 Aug 2024 15:47:48 -0400 Subject: [PATCH 5/8] merge fix --- RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift b/RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift index a55d4ef259..793dcfd858 100644 --- a/RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift +++ b/RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift @@ -46,7 +46,8 @@ struct NoSubscriptionsView: View { self.configuration = configuration } - var body: some View { + @ViewBuilder + var content: some View { let background = Color.from(colorInformation: appearance.backgroundColor, for: colorScheme) let textColor = Color.from(colorInformation: appearance.textColor, for: colorScheme) From 95fa76d68936e4df4ead697a55eea5a1f9107ddf Mon Sep 17 00:00:00 2001 From: Cody Kerns Date: Wed, 14 Aug 2024 17:21:31 -0400 Subject: [PATCH 6/8] Style guide --- RevenueCatUI/CustomerCenter/ButtonStyles.swift | 2 ++ .../Views/ManageSubscriptionsView.swift | 11 +++++++---- .../CustomerCenter/Views/WrongPlatformView.swift | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/RevenueCatUI/CustomerCenter/ButtonStyles.swift b/RevenueCatUI/CustomerCenter/ButtonStyles.swift index ea34f0bf79..05052c8eda 100644 --- a/RevenueCatUI/CustomerCenter/ButtonStyles.swift +++ b/RevenueCatUI/CustomerCenter/ButtonStyles.swift @@ -52,6 +52,7 @@ struct ProminentButtonStyle: PrimitiveButtonStyle { @available(tvOS, unavailable) @available(watchOS, unavailable) struct DismissCircleButton: View { + @Environment(\.localization) private var localization var action: () -> Void @@ -73,6 +74,7 @@ struct DismissCircleButton: View { .buttonStyle(.plain) .accessibilityLabel(Text(localization.commonLocalizedString(for: .dismiss))) } + } @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) diff --git a/RevenueCatUI/CustomerCenter/Views/ManageSubscriptionsView.swift b/RevenueCatUI/CustomerCenter/Views/ManageSubscriptionsView.swift index 55ff6ab29e..1c390be321 100644 --- a/RevenueCatUI/CustomerCenter/Views/ManageSubscriptionsView.swift +++ b/RevenueCatUI/CustomerCenter/Views/ManageSubscriptionsView.swift @@ -120,6 +120,7 @@ struct ManageSubscriptionsView: View { .navigationTitle(self.viewModel.screen.title) .navigationBarTitleDisplayMode(.inline) } + } @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) @@ -224,7 +225,6 @@ struct SubscriptionDetailsView: View { } if let nextRenewal = subscriptionInformation.expirationDateString { - let expirationString = subscriptionInformation.active ? ( subscriptionInformation.willRenew ? localization.commonLocalizedString(for: .nextBillingDate) : @@ -262,14 +262,12 @@ struct SubscriptionDetailsView: View { } } } - } .padding(24.0) .background(Color(UIColor.tertiarySystemBackground)) .cornerRadius(20) .shadow(color: .black.opacity(0.1), radius: 10, x: 0.0, y: 10) - .padding(.top) - .padding(.bottom) + .padding([.top, .bottom]) .padding(.bottom) } @@ -344,6 +342,7 @@ struct ManageSubscriptionButton: View { promoOfferDetails: promotionalOfferData.promoOfferDetails) }) } + } #if DEBUG @@ -352,6 +351,7 @@ struct ManageSubscriptionButton: View { @available(tvOS, unavailable) @available(watchOS, unavailable) struct ManageSubscriptionsView_Previews: PreviewProvider { + static var previews: some View { let viewModelMonthlyRenewing = ManageSubscriptionsViewModel( screen: CustomerCenterConfigTestData.customerCenterData.screens[.management]!, @@ -362,6 +362,7 @@ struct ManageSubscriptionsView_Previews: PreviewProvider { .previewDisplayName("Monthly renewing") .environment(\.localization, CustomerCenterConfigTestData.customerCenterData.localization) .environment(\.appearance, CustomerCenterConfigTestData.customerCenterData.appearance) + let viewModelYearlyExpiring = ManageSubscriptionsViewModel( screen: CustomerCenterConfigTestData.customerCenterData.screens[.management]!, subscriptionInformation: CustomerCenterConfigTestData.subscriptionInformationYearlyExpiring, @@ -379,6 +380,7 @@ struct ManageSubscriptionsView_Previews: PreviewProvider { @available(tvOS, unavailable) @available(watchOS, unavailable) struct SubscriptionDetailsView_Previews: PreviewProvider { + static var previews: some View { SubscriptionDetailsView( subscriptionInformation: CustomerCenterConfigTestData.subscriptionInformationMonthlyRenewing, @@ -388,6 +390,7 @@ struct SubscriptionDetailsView_Previews: PreviewProvider { .previewDisplayName("Subscription Details - Monthly") .padding() } + } #endif diff --git a/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift b/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift index 5affe800df..c0c7b6729d 100644 --- a/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift +++ b/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift @@ -47,7 +47,8 @@ struct WrongPlatformView: View { self._store = State(initialValue: store) } - @ViewBuilder var content: some View { + @ViewBuilder + var content: some View { ZStack { if let background = Color.from(colorInformation: appearance.backgroundColor, for: colorScheme) { background.edgesIgnoringSafeArea(.all) From 1081d7a4f239242d8516781b1caac7b6688d2867 Mon Sep 17 00:00:00 2001 From: Cody Kerns Date: Wed, 14 Aug 2024 17:25:21 -0400 Subject: [PATCH 7/8] lint --- RevenueCatUI/CustomerCenter/ButtonStyles.swift | 2 +- RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/RevenueCatUI/CustomerCenter/ButtonStyles.swift b/RevenueCatUI/CustomerCenter/ButtonStyles.swift index 05052c8eda..38a6806d62 100644 --- a/RevenueCatUI/CustomerCenter/ButtonStyles.swift +++ b/RevenueCatUI/CustomerCenter/ButtonStyles.swift @@ -74,7 +74,7 @@ struct DismissCircleButton: View { .buttonStyle(.plain) .accessibilityLabel(Text(localization.commonLocalizedString(for: .dismiss))) } - + } @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) diff --git a/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift b/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift index c0c7b6729d..0882350697 100644 --- a/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift +++ b/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift @@ -47,7 +47,7 @@ struct WrongPlatformView: View { self._store = State(initialValue: store) } - @ViewBuilder + @ViewBuilder var content: some View { ZStack { if let background = Color.from(colorInformation: appearance.backgroundColor, for: colorScheme) { From d0fa75a5bbce5fcfa6e5936117dce1ff98660c30 Mon Sep 17 00:00:00 2001 From: Cody Kerns Date: Wed, 14 Aug 2024 17:28:05 -0400 Subject: [PATCH 8/8] remove availability checks --- RevenueCatUI/CustomerCenter/ButtonStyles.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RevenueCatUI/CustomerCenter/ButtonStyles.swift b/RevenueCatUI/CustomerCenter/ButtonStyles.swift index 38a6806d62..4f767db2d6 100644 --- a/RevenueCatUI/CustomerCenter/ButtonStyles.swift +++ b/RevenueCatUI/CustomerCenter/ButtonStyles.swift @@ -21,7 +21,7 @@ import SwiftUI #if os(iOS) -@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) +@available(iOS 15.0, *) @available(macOS, unavailable) @available(tvOS, unavailable) @available(watchOS, unavailable) @@ -47,7 +47,7 @@ struct ProminentButtonStyle: PrimitiveButtonStyle { } -@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) +@available(iOS 15.0, *) @available(macOS, unavailable) @available(tvOS, unavailable) @available(watchOS, unavailable) @@ -77,7 +77,7 @@ struct DismissCircleButton: View { } -@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) +@available(iOS 15.0, *) @available(macOS, unavailable) @available(tvOS, unavailable) @available(watchOS, unavailable)