Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
bdc7967
Add: configure title for phases 2 & 3
hassaanelgarem Dec 1, 2022
5ce9275
Add: configure subtitle for phases 2 & 3
hassaanelgarem Dec 1, 2022
620c2b7
Add: configure learn more button for phases 2 & 3
hassaanelgarem Dec 1, 2022
8642162
Update: fix code spacing issues
hassaanelgarem Dec 1, 2022
23d1a10
Add: configure footnote for phases 2 & 3
hassaanelgarem Dec 1, 2022
236ebc7
Add: configure switch button for phases 2 & 3
hassaanelgarem Dec 1, 2022
ca1a361
Add: configure close button for all phases
hassaanelgarem Dec 1, 2022
9092392
Update: make the subtitle an attributed string
hassaanelgarem Dec 1, 2022
926794a
Add: inject date into phase 2 & 3 subtitle
hassaanelgarem Dec 1, 2022
69e56b2
Update: configure the style of deadline inside the subtitle
hassaanelgarem Dec 1, 2022
d8a2c5e
Add: define new config parameters for blog posts
hassaanelgarem Dec 1, 2022
884e98e
Update: configure learn more URL
hassaanelgarem Dec 1, 2022
b44b826
Update: use dynamic learn more link
hassaanelgarem Dec 1, 2022
7421489
Update: enable fullscreen overlays for phases 2 & 3
hassaanelgarem Dec 1, 2022
3c91594
To be reverted: Disable overlay frequency logic
hassaanelgarem Dec 1, 2022
7994448
To be reverted: Provide default deadline
hassaanelgarem Dec 1, 2022
fa56eae
To be reverted: Provide default blog post urls for phases 2 and 3
hassaanelgarem Dec 1, 2022
40b1392
Revert "To be reverted: Provide default blog post urls for phases 2 a…
hassaanelgarem Dec 7, 2022
f7619cc
Revert "To be reverted: Provide default deadline"
hassaanelgarem Dec 7, 2022
eebdca3
Revert "To be reverted: Disable overlay frequency logic"
hassaanelgarem Dec 7, 2022
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
23 changes: 22 additions & 1 deletion WordPress/Classes/Utility/BuildInformation/RemoteConfig.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Foundation

/// A struct that holds all remote config parameters.
/// This is where all remote config parameters should be defined.
struct RemoteConfig {

// MARK: Private Variables
Expand All @@ -16,6 +17,26 @@ struct RemoteConfig {
// MARK: Remote Config Parameters

var jetpackDeadline: RemoteConfigParameter<String> {
RemoteConfigParameter<String>(key: "jp-deadline", defaultValue: nil, store: store)
RemoteConfigParameter<String>(key: "jp-deadline", defaultValue: "2022-12-31", store: store) // TODO: Revert this
}

var phaseTwoBlogPostUrl: RemoteConfigParameter<String> {
RemoteConfigParameter<String>(key: "phase-two-blog-post", defaultValue: "https://jetpack.com/mobile", store: store) // TODO: Revert this
}

var phaseThreeBlogPostUrl: RemoteConfigParameter<String> {
RemoteConfigParameter<String>(key: "phase-three-blog-post", defaultValue: "https://jetpack.com/mobile", store: store) // TODO: Revert this
}

var phaseFourBlogPostUrl: RemoteConfigParameter<String> {
RemoteConfigParameter<String>(key: "phase-four-blog-post", defaultValue: nil, store: store)
}

var phaseNewUsersBlogPostUrl: RemoteConfigParameter<String> {
RemoteConfigParameter<String>(key: "phase-new-users-blog-post", defaultValue: nil, store: store)
}

var phaseSelfHostedBlogPostUrl: RemoteConfigParameter<String> {
RemoteConfigParameter<String>(key: "phase-self-hosted-blog-post", defaultValue: nil, store: store)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ extension JetpackOverlayFrequencyTracker {

// MARK: Static Variables
static let defaultConfig = FrequencyConfig(featureSpecificInDays: 0, generalInDays: 0)
private static let secondsInDay: TimeInterval = 86_400
private static let secondsInDay: TimeInterval = 0 // TODO: Revert this

// MARK: Computed Variables
var featureSpecificInSeconds: TimeInterval {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ struct JetpackFullscreenOverlayGeneralViewModel: JetpackFullscreenOverlayViewMod
case (.two, .notifications):
fallthrough
case (.two, .reader):
return false // TODO: Change this to true when other phase 2 tasks are ready
return true

// Phase Three: Show all overlays
case (.three, _):
return false // TODO: Change this to true when other phase 3 tasks are ready
return true

// Phase Four: Show feature-collection overlays. Features are removed by this point so they are irrelevant.
case (.four, _):
Expand All @@ -54,22 +54,46 @@ struct JetpackFullscreenOverlayGeneralViewModel: JetpackFullscreenOverlayViewMod
return Strings.PhaseOne.Notifications.title
case (.one, .reader):
return Strings.PhaseOne.Reader.title

// Phase Two
case (.two, .stats):
return Strings.PhaseTwoAndThree.statsTitle
case (.two, .notifications):
return Strings.PhaseTwoAndThree.notificationsTitle
case (.two, .reader):
return Strings.PhaseTwoAndThree.readerTitle

// Phase Three
case (.three, .stats):
return Strings.PhaseTwoAndThree.statsTitle
case (.three, .notifications):
return Strings.PhaseTwoAndThree.notificationsTitle
case (.three, .reader):
return Strings.PhaseTwoAndThree.readerTitle
default:
return ""
}
}

var subtitle: String {
var subtitle: NSAttributedString {
switch (phase, source) {
// Phase One
case (.one, .stats):
return Strings.PhaseOne.Stats.subtitle
return .init(string: Strings.PhaseOne.Stats.subtitle)
case (.one, .notifications):
return Strings.PhaseOne.Notifications.subtitle
return .init(string: Strings.PhaseOne.Notifications.subtitle)
case (.one, .reader):
return Strings.PhaseOne.Reader.subtitle
return .init(string: Strings.PhaseOne.Reader.subtitle)

// Phase Two
case (.two, _):
fallthrough

// Phase Three
case (.three, _):
return phaseTwoAndThreeSubtitle()
default:
return ""
return .init(string: "")
}
}

Expand Down Expand Up @@ -111,24 +135,40 @@ struct JetpackFullscreenOverlayGeneralViewModel: JetpackFullscreenOverlayViewMod
switch phase {
case .one:
return nil
case .two:
return nil
case .three:
return Strings.PhaseTwoAndThree.footnote
default:
return nil
}
}

var shouldShowLearnMoreButton: Bool {
var learnMoreButtonURL: String? {
switch phase {
case .one:
return false
return nil
case .two:
return RemoteConfig().phaseTwoBlogPostUrl.value
case .three:
return RemoteConfig().phaseThreeBlogPostUrl.value
case .four:
return RemoteConfig().phaseFourBlogPostUrl.value
case .newUsers:
return RemoteConfig().phaseNewUsersBlogPostUrl.value
default:
return false
return nil
}
}

var switchButtonText: String {
switch phase {
case .one:
return Strings.General.earlyPhasesSwitchButtonTitle
case .two:
return Strings.General.earlyPhasesSwitchButtonTitle
case .three:
return Strings.General.latePhasesSwitchButtonTitle
default:
return ""
}
Expand All @@ -150,7 +190,9 @@ struct JetpackFullscreenOverlayGeneralViewModel: JetpackFullscreenOverlayViewMod
var shouldShowCloseButton: Bool {
switch phase {
case .one:
return true
fallthrough
case .two:
return true // Only show close button in phases 1 & 2
default:
return false
}
Expand All @@ -163,6 +205,35 @@ struct JetpackFullscreenOverlayGeneralViewModel: JetpackFullscreenOverlayViewMod
var onDismiss: JetpackOverlayDismissCallback?
}

// MARK: Helpers

private extension JetpackFullscreenOverlayGeneralViewModel {
static let dateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "MMMM d, yyyy"
return formatter
}()

func phaseTwoAndThreeSubtitle() -> NSAttributedString {
guard let deadline = JetpackFeaturesRemovalCoordinator.removalDeadline() else {
return NSAttributedString(string: Strings.PhaseTwoAndThree.fallbackSubtitle)
}

let formattedDate = Self.dateFormatter.string(from: deadline)
let subtitle = String.localizedStringWithFormat(Strings.PhaseTwoAndThree.subtitle, formattedDate)

let rangeOfDate = (subtitle as NSString).range(of: formattedDate)
let plainFont = WPStyleGuide.fontForTextStyle(.body, fontWeight: .regular)
let boldFont = WPStyleGuide.fontForTextStyle(.body, fontWeight: .bold)
let attributedSubtitle = NSMutableAttributedString(string: subtitle, attributes: [.font: plainFont])
attributedSubtitle.addAttribute(.font, value: boldFont, range: rangeOfDate)

return attributedSubtitle
}
}

// MARK: Constants

private extension JetpackFullscreenOverlayGeneralViewModel {
enum Constants {
static let statsLogoAnimationLtr = "JetpackStatsLogoAnimation_ltr"
Expand All @@ -179,6 +250,9 @@ private extension JetpackFullscreenOverlayGeneralViewModel {
static let earlyPhasesSwitchButtonTitle = NSLocalizedString("jetpack.fullscreen.overlay.early.switch.title",
value: "Switch to the new Jetpack app",
comment: "Title of a button that navigates the user to the Jetpack app if installed, or to the app store.")
static let latePhasesSwitchButtonTitle = NSLocalizedString("jetpack.fullscreen.overlay.late.switch.title",
value: "Switch to the Jetpack app",
comment: "Title of a button that navigates the user to the Jetpack app if installed, or to the app store.")
static let statsContinueButtonTitle = NSLocalizedString("jetpack.fullscreen.overlay.stats.continue.title",
value: "Continue to Stats",
comment: "Title of a button that dismisses an overlay and displays the Stats screen.")
Expand Down Expand Up @@ -219,5 +293,26 @@ private extension JetpackFullscreenOverlayGeneralViewModel {
comment: "Subtitle of a screen displayed when the user accesses the Notifications screen from the WordPress app. The screen showcases the Jetpack app.")
}
}

enum PhaseTwoAndThree {
static let statsTitle = NSLocalizedString("jetpack.fullscreen.overlay.phaseTwoAndThree.stats.title",
value: "Stats are moving to the Jetpack app",
comment: "Title of a screen displayed when the user accesses the Stats screen from the WordPress app. The screen showcases the Jetpack app.")
static let readerTitle = NSLocalizedString("jetpack.fullscreen.overlay.phaseTwoAndThree.reader.title",
value: "Reader is moving to the Jetpack app",
comment: "Title of a screen displayed when the user accesses the Reader screen from the WordPress app. The screen showcases the Jetpack app.")
static let notificationsTitle = NSLocalizedString("jetpack.fullscreen.overlay.phaseTwoAndThree.notifications.title",
value: "Notifications are moving to Jetpack",
comment: "Title of a screen displayed when the user accesses the Notifications screen from the WordPress app. The screen showcases the Jetpack app.")
static let subtitle = NSLocalizedString("jetpack.fullscreen.overlay.phaseTwoAndThree.subtitle",
value: "Stats, Reader, Notifications and other Jetpack powered features will be removed from the WordPress app on %@.",
comment: "Subtitle of a screen displayed when the user accesses a Jetpack-powered feature from the WordPress app. The '%@' characters are a placeholder for the date the features will be removed.")
static let fallbackSubtitle = NSLocalizedString("jetpack.fullscreen.overlay.phaseTwoAndThree.fallbackSubtitle",
value: "Stats, Reader, Notifications and other Jetpack powered features will be removed from the WordPress app soon.",
comment: "Subtitle of a screen displayed when the user accesses a Jetpack-powered feature from the WordPress app.")
static let footnote = NSLocalizedString("jetpack.fullscreen.overlay.phaseThree.footnote",
value: "Switching is free and only takes a minute.",
comment: "A footnote in a screen displayed when the user accesses a Jetpack powered feature from the WordPress app. The screen showcases the Jetpack app.")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ struct JetpackFullscreenOverlaySiteCreationViewModel: JetpackFullscreenOverlayVi
return Strings.title
}

var subtitle: String {
var subtitle: NSAttributedString {
switch phase {
case .one:
return Strings.phaseOneSubtitle
return .init(string: Strings.phaseOneSubtitle)
case .two:
return Strings.phaseTwoSubtitle
return .init(string: Strings.phaseTwoSubtitle)
default:
return ""
return .init(string: "")
}
}

Expand All @@ -45,8 +45,8 @@ struct JetpackFullscreenOverlaySiteCreationViewModel: JetpackFullscreenOverlayVi
return nil
}

var shouldShowLearnMoreButton: Bool {
return false
var learnMoreButtonURL: String? {
return nil
}

var switchButtonText: String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class JetpackFullscreenOverlayViewController: UIViewController {
private func setupContent() {
animationView.animation = animation
setTitle()
subtitleLabel.text = viewModel.subtitle
subtitleLabel.attributedText = viewModel.subtitle
footnoteLabel.text = viewModel.footnote
switchButton.setTitle(viewModel.switchButtonText, for: .normal)
continueButton.setTitle(viewModel.continueButtonText, for: .normal)
Expand Down Expand Up @@ -159,7 +159,6 @@ class JetpackFullscreenOverlayViewController: UIViewController {
private func setupFonts() {
titleLabel.font = WPStyleGuide.fontForTextStyle(.largeTitle, fontWeight: .bold)
titleLabel.adjustsFontForContentSizeCategory = true
subtitleLabel.font = WPStyleGuide.fontForTextStyle(.body, fontWeight: .regular)
subtitleLabel.adjustsFontForContentSizeCategory = true
footnoteLabel.font = WPStyleGuide.fontForTextStyle(.body, fontWeight: .regular)
footnoteLabel.adjustsFontForContentSizeCategory = true
Expand Down Expand Up @@ -232,7 +231,8 @@ class JetpackFullscreenOverlayViewController: UIViewController {
}

@IBAction func learnMoreButtonPressed(_ sender: Any) {
guard let url = URL(string: Constants.learnMoreURLString) else {
guard let urlString = viewModel.learnMoreButtonURL,
let url = URL(string: urlString) else {
return
}

Expand Down Expand Up @@ -269,8 +269,6 @@ private extension JetpackFullscreenOverlayViewController {
}

enum Constants {
// TODO: Update link
static let learnMoreURLString = "https://jetpack.com/blog/"
static let closeButtonSystemName = "xmark.circle.fill"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ typealias JetpackOverlayDismissCallback = () -> Void
/// Protocol used to configure `JetpackFullscreenOverlayViewController`
protocol JetpackFullscreenOverlayViewModel {
var title: String { get }
var subtitle: String { get }
var subtitle: NSAttributedString { get }
var animationLtr: String { get }
var animationRtl: String { get }
var footnote: String? { get }
var shouldShowLearnMoreButton: Bool { get }
var learnMoreButtonURL: String? { get }
var switchButtonText: String { get }
var continueButtonText: String? { get }
var shouldShowCloseButton: Bool { get }
Expand All @@ -25,7 +25,7 @@ protocol JetpackFullscreenOverlayViewModel {

extension JetpackFullscreenOverlayViewModel {
var learnMoreButtonIsHidden: Bool {
!shouldShowLearnMoreButton
learnMoreButtonURL == nil
}

var footnoteIsHidden: Bool {
Expand Down