Skip to content

Commit

Permalink
[Winback] Link row to Help & Feedback (#2469)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielebogo authored Nov 21, 2024
2 parents 380818e + c973a07 commit ce26211
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 53 deletions.
4 changes: 4 additions & 0 deletions podcasts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -2007,6 +2008,7 @@
102864A82CECEDB20098B2A9 /* CancelSubscriptionViewRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CancelSubscriptionViewRow.swift; sourceTree = "<group>"; };
102864AA2CED1F990098B2A9 /* CancelSubscription.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = CancelSubscription.xcassets; sourceTree = "<group>"; };
102D1C872C7648680088DB89 /* PlusPaywallFeatureCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlusPaywallFeatureCard.swift; sourceTree = "<group>"; };
1035FFEC2CEE5F4E00C1E80D /* CancelSubscriptionOption.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CancelSubscriptionOption.swift; sourceTree = "<group>"; };
10756F822C57D00B0089D34F /* KidsProfileThankYouScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = KidsProfileThankYouScreen.swift; path = "Kids Profile/KidsProfileThankYouScreen.swift"; sourceTree = "<group>"; };
10756F842C5944660089D34F /* Podcast+Sortable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Podcast+Sortable.swift"; sourceTree = "<group>"; };
10756F872C59449C0089D34F /* Folder+Sortable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Folder+Sortable.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3906,6 +3908,7 @@
100C99512CE7B7A2008D73E9 /* Cancel Subscription */ = {
isa = PBXGroup;
children = (
1035FFEC2CEE5F4E00C1E80D /* CancelSubscriptionOption.swift */,
109446752CEB3A7E00977161 /* CancelSubscriptionViewModel.swift */,
100C99542CE7B801008D73E9 /* CancelSubscriptionView.swift */,
102864A82CECEDB20098B2A9 /* CancelSubscriptionViewRow.swift */,
Expand Down Expand Up @@ -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 */,
Expand Down
44 changes: 44 additions & 0 deletions podcasts/Cancel Subscription/CancelSubscriptionOption.swift
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
8 changes: 5 additions & 3 deletions podcasts/Cancel Subscription/CancelSubscriptionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions podcasts/Cancel Subscription/CancelSubscriptionViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
}
Expand Down
66 changes: 16 additions & 50 deletions podcasts/Cancel Subscription/CancelSubscriptionViewRow.swift
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
}
}
}
}

Expand All @@ -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)
Expand Down

0 comments on commit ce26211

Please sign in to comment.