diff --git a/podcasts.xcodeproj/project.pbxproj b/podcasts.xcodeproj/project.pbxproj index 8072bf623e..5c3dba45a8 100644 --- a/podcasts.xcodeproj/project.pbxproj +++ b/podcasts.xcodeproj/project.pbxproj @@ -34,6 +34,7 @@ 102864A92CECEDB20098B2A9 /* CancelSubscriptionViewRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 102864A82CECEDB20098B2A9 /* CancelSubscriptionViewRow.swift */; }; 102864AB2CED1F990098B2A9 /* CancelSubscription.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 102864AA2CED1F990098B2A9 /* CancelSubscription.xcassets */; }; 102D1C882C7648680088DB89 /* PlusPaywallFeatureCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 102D1C872C7648680088DB89 /* PlusPaywallFeatureCard.swift */; }; + 1035FFED2CEE5F4E00C1E80D /* CancelSubscriptionOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1035FFEC2CEE5F4E00C1E80D /* CancelSubscriptionOption.swift */; }; 105A6C422BAA0B2C0025B855 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 10B558EB2BA471DF0061847C /* PrivacyInfo.xcprivacy */; }; 105A6C432BAA0B3B0025B855 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 10B558EA2BA364420061847C /* PrivacyInfo.xcprivacy */; }; 105A6C442BAA0B3E0025B855 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 10B558EC2BA472E80061847C /* PrivacyInfo.xcprivacy */; }; @@ -2007,6 +2008,7 @@ 102864A82CECEDB20098B2A9 /* CancelSubscriptionViewRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CancelSubscriptionViewRow.swift; sourceTree = ""; }; 102864AA2CED1F990098B2A9 /* CancelSubscription.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = CancelSubscription.xcassets; sourceTree = ""; }; 102D1C872C7648680088DB89 /* PlusPaywallFeatureCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlusPaywallFeatureCard.swift; sourceTree = ""; }; + 1035FFEC2CEE5F4E00C1E80D /* CancelSubscriptionOption.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CancelSubscriptionOption.swift; sourceTree = ""; }; 10756F822C57D00B0089D34F /* KidsProfileThankYouScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = KidsProfileThankYouScreen.swift; path = "Kids Profile/KidsProfileThankYouScreen.swift"; sourceTree = ""; }; 10756F842C5944660089D34F /* Podcast+Sortable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Podcast+Sortable.swift"; sourceTree = ""; }; 10756F872C59449C0089D34F /* Folder+Sortable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Folder+Sortable.swift"; sourceTree = ""; }; @@ -3906,6 +3908,7 @@ 100C99512CE7B7A2008D73E9 /* Cancel Subscription */ = { isa = PBXGroup; children = ( + 1035FFEC2CEE5F4E00C1E80D /* CancelSubscriptionOption.swift */, 109446752CEB3A7E00977161 /* CancelSubscriptionViewModel.swift */, 100C99542CE7B801008D73E9 /* CancelSubscriptionView.swift */, 102864A82CECEDB20098B2A9 /* CancelSubscriptionViewRow.swift */, @@ -9994,6 +9997,7 @@ C7AF7B992926B307002F0025 /* OnboardingHostingViewController.swift in Sources */, 462EE0AD26FCC081003D67DC /* ZenDeskHelpers.swift in Sources */, 403B5B0621812E6000821A54 /* AppDelegate+SiriShortcuts.swift in Sources */, + 1035FFED2CEE5F4E00C1E80D /* CancelSubscriptionOption.swift in Sources */, BD9086AC204E413800C0C78D /* PodcastSearchCell.swift in Sources */, BD2F3BA42366C0F900416633 /* PlayerContainerViewController+Gestures.swift in Sources */, BDDA72D21C9B898C003A3BEB /* StorageAndDataUseViewController.swift in Sources */, diff --git a/podcasts/Cancel Subscription/CancelSubscriptionOption.swift b/podcasts/Cancel Subscription/CancelSubscriptionOption.swift new file mode 100644 index 0000000000..06a448a9bd --- /dev/null +++ b/podcasts/Cancel Subscription/CancelSubscriptionOption.swift @@ -0,0 +1,44 @@ +enum CancelSubscriptionOption: CaseIterable, Hashable, Identifiable { + static var allCases: [CancelSubscriptionOption] = [.promotion(price: ""), .availablePlans, .help] + + case promotion(price: String) + case availablePlans + case help + + var id: Self { + return self + } + + var title: String { + switch self { + case .promotion: + return L10n.cancelSubscriptionPromotionTitle + case .availablePlans: + return L10n.cancelSubscriptionNewPlanTitle + case .help: + return L10n.cancelSubscriptionHelpTitle + } + } + + var subtitle: String { + switch self { + case .promotion(let price): + return L10n.cancelSubscriptionPromotionDescription(price) + case .availablePlans: + return L10n.cancelSubscriptionNewPlanDescription + case .help: + return L10n.cancelSubscriptionHelpDescription + } + } + + var icon: String { + switch self { + case .promotion: + return "cs-heart" + case .availablePlans: + return "cs-skipbackward" + case .help: + return "cs-help" + } + } +} diff --git a/podcasts/Cancel Subscription/CancelSubscriptionView.swift b/podcasts/Cancel Subscription/CancelSubscriptionView.swift index e6f81e2ef7..d0445c76b4 100644 --- a/podcasts/Cancel Subscription/CancelSubscriptionView.swift +++ b/podcasts/Cancel Subscription/CancelSubscriptionView.swift @@ -23,9 +23,11 @@ struct CancelSubscriptionView: View { .padding(.horizontal, 34.0) ForEach(CancelSubscriptionOption.allCases, id: \.id) { option in - if case .promotion = option, let price = viewModel.monthlyPrice() { - CancelSubscriptionViewRow(option: .promotion(price: price), - viewModel: viewModel) + if case .promotion = option { + if viewModel.isEligibleForOffer, case .promotion = option, let price = viewModel.monthlyPrice() { + CancelSubscriptionViewRow(option: .promotion(price: price), + viewModel: viewModel) + } } else { CancelSubscriptionViewRow(option: option, viewModel: viewModel) diff --git a/podcasts/Cancel Subscription/CancelSubscriptionViewModel.swift b/podcasts/Cancel Subscription/CancelSubscriptionViewModel.swift index ad9d7dbae2..b75e0b56f3 100644 --- a/podcasts/Cancel Subscription/CancelSubscriptionViewModel.swift +++ b/podcasts/Cancel Subscription/CancelSubscriptionViewModel.swift @@ -4,6 +4,10 @@ import PocketCastsServer class CancelSubscriptionViewModel: PlusPurchaseModel { let navigationController: UINavigationController + var isEligibleForOffer: Bool { + purchaseHandler.isEligibleForOffer + } + init(purchaseHandler: IAPHelper = .shared, navigationController: UINavigationController) { self.navigationController = navigationController @@ -32,6 +36,16 @@ class CancelSubscriptionViewModel: PlusPurchaseModel { //TODO: Apply one month free } + func showPlans() { + //TODO: Show plans + } + + func showHelp() { + let controller = OnlineSupportController() + navigationController.navigationBar.isHidden = false + navigationController.pushViewController(controller, animated: true) + } + override func didAppear() { //TODO: Implement analytics } diff --git a/podcasts/Cancel Subscription/CancelSubscriptionViewRow.swift b/podcasts/Cancel Subscription/CancelSubscriptionViewRow.swift index 200a18d36a..75fd584d47 100644 --- a/podcasts/Cancel Subscription/CancelSubscriptionViewRow.swift +++ b/podcasts/Cancel Subscription/CancelSubscriptionViewRow.swift @@ -1,56 +1,11 @@ import SwiftUI -enum CancelSubscriptionOption: CaseIterable, Hashable, Identifiable { - static var allCases: [CancelSubscriptionOption] = [.promotion(price: ""), .newPlan, .help] - - case promotion(price: String) - case newPlan - case help - - var id: Self { - return self - } - - var title: String { - switch self { - case .promotion: - return L10n.cancelSubscriptionPromotionTitle - case .newPlan: - return L10n.cancelSubscriptionNewPlanTitle - case .help: - return L10n.cancelSubscriptionHelpTitle - } - } - - var subtitle: String { - switch self { - case .promotion(let price): - return L10n.cancelSubscriptionPromotionDescription(price) - case .newPlan: - return L10n.cancelSubscriptionNewPlanDescription - case .help: - return L10n.cancelSubscriptionHelpDescription - } - } - - var icon: String { - switch self { - case .promotion: - return "cs-heart" - case .newPlan: - return "cs-skipbackward" - case .help: - return "cs-help" - } - } -} - struct CancelSubscriptionViewRow: View { - let option: CancelSubscriptionOption - let viewModel: CancelSubscriptionViewModel - @EnvironmentObject var theme: Theme + private let option: CancelSubscriptionOption + private let viewModel: CancelSubscriptionViewModel + init(option: CancelSubscriptionOption, viewModel: CancelSubscriptionViewModel) { self.option = option self.viewModel = viewModel @@ -134,11 +89,22 @@ struct CancelSubscriptionViewRow: View { } .padding(.top, 24.0) - if option == .newPlan || option == .help { + if option == .availablePlans || option == .help { chevron .padding(.trailing, 20.0) } } + .contentShape(Rectangle()) + .onTapGesture { + switch option { + case .help: + viewModel.showHelp() + case .availablePlans: + viewModel.showPlans() + default: + break + } + } } } @@ -148,7 +114,7 @@ struct CancelSubscriptionViewRow_Previews: PreviewProvider { VStack(spacing: 0) { CancelSubscriptionViewRow(option: .promotion(price: "$3.99"), viewModel: viewModel) .environmentObject(Theme.sharedTheme) - CancelSubscriptionViewRow(option: .newPlan, viewModel: viewModel) + CancelSubscriptionViewRow(option: .availablePlans, viewModel: viewModel) .environmentObject(Theme.sharedTheme) CancelSubscriptionViewRow(option: .help, viewModel: viewModel) .environmentObject(Theme.sharedTheme)