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

End of Year: add prompt #377

Merged
merged 13 commits into from
Oct 11, 2022
Merged
1 change: 1 addition & 0 deletions PocketCastsTests/UnitTests.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
}
],
"defaultOptions" : {
"codeCoverage" : false,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add this to make SwiftUI previews work. 🀷

More details on the commit: 3142e08

"environmentVariableEntries" : [
{
"key" : "BUILDKITE_ANALYTICS_TOKEN",
Expand Down
24 changes: 24 additions & 0 deletions podcasts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@
8BA55A1328CA7425002BECC5 /* XCTestCase+eventually.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BA55A1228CA7425002BECC5 /* XCTestCase+eventually.swift */; };
8BA55A1528CA8FEB002BECC5 /* PrivacySettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BA55A1428CA8FEB002BECC5 /* PrivacySettingsViewController.swift */; };
8BA55A1728CA92A7002BECC5 /* PrivacySettingsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8BA55A1628CA92A7002BECC5 /* PrivacySettingsViewController.xib */; };
8BCB22B228F47F44001A0315 /* EndOfYearModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BCB22B128F47F44001A0315 /* EndOfYearModal.swift */; };
8BCB22B428F48282001A0315 /* EndOfYear.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BCB22B328F48282001A0315 /* EndOfYear.swift */; };
8BE36DE8287352A100E35313 /* PocketCastsServer in Frameworks */ = {isa = PBXBuildFile; productRef = 8BE36DE7287352A100E35313 /* PocketCastsServer */; };
8BE36DEB287352F200E35313 /* PocketCastsDataModel in Frameworks */ = {isa = PBXBuildFile; productRef = 8BE36DEA287352F200E35313 /* PocketCastsDataModel */; };
8BE36DEC287352F200E35313 /* PocketCastsDataModel in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 8BE36DEA287352F200E35313 /* PocketCastsDataModel */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
Expand Down Expand Up @@ -1973,6 +1975,8 @@
8BA55A1228CA7425002BECC5 /* XCTestCase+eventually.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCTestCase+eventually.swift"; sourceTree = "<group>"; };
8BA55A1428CA8FEB002BECC5 /* PrivacySettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacySettingsViewController.swift; sourceTree = "<group>"; };
8BA55A1628CA92A7002BECC5 /* PrivacySettingsViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PrivacySettingsViewController.xib; sourceTree = "<group>"; };
8BCB22B128F47F44001A0315 /* EndOfYearModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EndOfYearModal.swift; sourceTree = "<group>"; };
8BCB22B328F48282001A0315 /* EndOfYear.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EndOfYear.swift; sourceTree = "<group>"; };
8BE36DCA28734F7000E35313 /* DataModel */ = {isa = PBXFileReference; lastKnownFileType = text; name = DataModel; path = Modules/DataModel; sourceTree = SOURCE_ROOT; };
8BE36DCB28734F7000E35313 /* Utils */ = {isa = PBXFileReference; lastKnownFileType = text; name = Utils; path = Modules/Utils; sourceTree = SOURCE_ROOT; };
8BE36DCC28734F7000E35313 /* Server */ = {isa = PBXFileReference; lastKnownFileType = text; name = Server; path = Modules/Server; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -3614,9 +3618,27 @@
path = Extensions;
sourceTree = "<group>";
};
8BCB22AE28F47EFC001A0315 /* End of Year */ = {
isa = PBXGroup;
children = (
8BCB22B528F48A4E001A0315 /* Views */,
8BCB22B328F48282001A0315 /* EndOfYear.swift */,
);
path = "End of Year";
sourceTree = "<group>";
};
8BCB22B528F48A4E001A0315 /* Views */ = {
isa = PBXGroup;
children = (
8BCB22B128F47F44001A0315 /* EndOfYearModal.swift */,
);
path = Views;
sourceTree = "<group>";
};
8BE36DC928734F6500E35313 /* Modules */ = {
isa = PBXGroup;
children = (
8BCB22AE28F47EFC001A0315 /* End of Year */,
8BE36DCA28734F7000E35313 /* DataModel */,
8BE36DCC28734F7000E35313 /* Server */,
8BE36DCB28734F7000E35313 /* Utils */,
Expand Down Expand Up @@ -7470,6 +7492,7 @@
BD1C46DD27B9DD9C00B1D8BB /* FolderListCell.swift in Sources */,
BD998AD127B25A3300B38857 /* PodcastPickerModel.swift in Sources */,
BDD6297F200EE26200168DF7 /* PlaybackActionHelper.swift in Sources */,
8BCB22B228F47F44001A0315 /* EndOfYearModal.swift in Sources */,
408ADBD022B87FF800E10AE6 /* TopShadowView.swift in Sources */,
BDA2065B1BB3AF1B00D38389 /* DownloadProgressManager.swift in Sources */,
BD27B8C52756F486007A0EA7 /* UIColor+SwiftUI.swift in Sources */,
Expand Down Expand Up @@ -7540,6 +7563,7 @@
BD3334501FC65A510017C3A8 /* EpisodeTableHelper.swift in Sources */,
BD2DE2321E65224900BE21A4 /* ShowNotesUpdater.swift in Sources */,
BDA0E2A322DDB5550029EBEB /* ThemeColor.swift in Sources */,
8BCB22B428F48282001A0315 /* EndOfYear.swift in Sources */,
BDCC55141CD0A448006BE239 /* AEXML.swift in Sources */,
40484F0122F1507F007DBD55 /* ThemeableRoundedButton.swift in Sources */,
BDEBD3A91BA0108800AD038F /* BufferedAudio.swift in Sources */,
Expand Down
25 changes: 25 additions & 0 deletions podcasts/End of Year/EndOfYear.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import SwiftUI
import MaterialComponents.MaterialBottomSheet

struct EndOfYear {
func showPrompt(in viewController: UIViewController) {
guard FeatureFlag.endOfYear else {
return
}

let endfOfYearModalViewController = UIHostingController(rootView: EndOfYearModal().environmentObject(Theme.sharedTheme))
let bottomSheet = MDCBottomSheetController(contentViewController: endfOfYearModalViewController)
viewController.present(bottomSheet, animated: true, completion: nil)
}

func showStories(in viewController: UIViewController) {
guard FeatureFlag.endOfYear else {
return
}

let storiesViewController = UIViewController()
storiesViewController.view.backgroundColor = .systemBackground
storiesViewController.modalPresentationStyle = .fullScreen
viewController.present(storiesViewController, animated: true, completion: nil)
}
}
50 changes: 50 additions & 0 deletions podcasts/End of Year/Views/EndOfYearModal.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import SwiftUI

struct EndOfYearModal: View {
@EnvironmentObject var theme: Theme

@Environment(\.presentationMode) var presentationMode

var body: some View {
VStack(alignment: .center, spacing: 20) {
Text("Your Year in Podcasts").font(.title3)
Text("See your top podcasts, categories, listening stats, and more. Share with friends and shout out your favorite creators!")
.multilineTextAlignment(.center)

Button(action: {
presentationMode.wrappedValue.dismiss()
NavigationManager.sharedManager.navigateTo(NavigationManager.endOfYearStories, data: nil)
}) {
HStack {
Spacer()
Text("View My 2022")
Spacer()
}
}
.textStyle(RoundedButton())
.contentShape(Rectangle())


leandroalonso marked this conversation as resolved.
Show resolved Hide resolved
Button(action: {
presentationMode.wrappedValue.dismiss()
}) {
HStack {
Spacer()
Text("Not Now")
Spacer()
}
}
.textStyle(RoundedButton())
.contentShape(Rectangle())
}
.padding()
.applyDefaultThemeOptions()
}
}

struct EndOfYearModal_Previews: PreviewProvider {
static var previews: some View {
EndOfYearModal()
.environmentObject(Theme(previewTheme: .light))
}
}
2 changes: 2 additions & 0 deletions podcasts/FeatureFlag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ enum FeatureFlag {

/// Whether logging of Firebase events in console are enabled
static let firebaseLoggingEnabled = false

static let endOfYear = false
leandroalonso marked this conversation as resolved.
Show resolved Hide resolved
}
8 changes: 8 additions & 0 deletions podcasts/MainTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class MainTabBarController: UITabBarController, NavigationProtocol {

let playPauseCommand = UIKeyCommand(title: L10n.keycommandPlayPause, action: #selector(handlePlayPauseKey), input: " ", modifierFlags: [])

private lazy var endOfYear = EndOfYear()

override func viewDidLoad() {
super.viewDidLoad()

Expand Down Expand Up @@ -51,6 +53,8 @@ class MainTabBarController: UITabBarController, NavigationProtocol {
checkSubscriptionStatusChanged()
checkPromotionFinishedAcknowledged()
checkWhatsNewAcknowledged()

endOfYear.showPrompt(in: self)
}

override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
Expand Down Expand Up @@ -336,6 +340,10 @@ class MainTabBarController: UITabBarController, NavigationProtocol {
}
}

func showEndOfYearStories() {
endOfYear.showStories(in: self)
}

private func topController() -> UIViewController {
var topController: UIViewController = self
while let presentedViewController = topController.presentedViewController {
Expand Down
4 changes: 4 additions & 0 deletions podcasts/NavigationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class NavigationManager {
static let settingsProfileKey = "profilePage"
static let signInPage = "signInPage"

static let endOfYearStories = "endOfYearStories"

static let sharedManager = NavigationManager()

private weak var mainController: NavigationProtocol?
Expand Down Expand Up @@ -182,6 +184,8 @@ class NavigationManager {
if let data = data, let urlString = data[NavigationManager.safariVCUrlKey] as? String {
mainController?.showInSafariViewController(urlString: urlString)
}
} else if place == NavigationManager.endOfYearStories {
mainController?.showEndOfYearStories()
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions podcasts/NavigationProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ protocol NavigationProtocol: AnyObject {
func showWhatsNew(whatsNewInfo: WhatsNewInfo)

func showInSafariViewController(urlString: String)

func showEndOfYearStories()
}
6 changes: 6 additions & 0 deletions podcasts/Styles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ extension Text {
}
}

extension Button {
func textStyle<Style: ViewModifier>(_ style: Style) -> some View {
ModifiedContent(content: self, modifier: style)
}
}

struct HiddenListDividers: ViewModifier {
@EnvironmentObject var theme: Theme

Expand Down