Skip to content

Commit 06ccd12

Browse files
Add: Func to present overlay in JetpackFeaturesRemovalCoordinator
1 parent 7c1034e commit 06ccd12

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

WordPress/Classes/ViewRelated/Jetpack/Branding/Coordinator/JetpackFeaturesRemovalCoordinator.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ class JetpackFeaturesRemovalCoordinator {
2020
case two
2121
}
2222

23+
enum OverlaySource: String {
24+
case stats
25+
case notifications
26+
case reader
27+
case card
28+
case login
29+
case appOpen = "app_open"
30+
}
31+
2332
static func generalPhase(featureFlagStore: RemoteFeatureFlagStore = RemoteFeatureFlagStore()) -> GeneralPhase {
2433
if AppConfiguration.isJetpack {
2534
return .normal // Always return normal for Jetpack
@@ -61,4 +70,26 @@ class JetpackFeaturesRemovalCoordinator {
6170

6271
return .normal
6372
}
73+
74+
/// Used to display feature-specific or feature-collection overlays.
75+
/// - Parameters:
76+
/// - source: The source that triggers the display of the overlay.
77+
/// - viewController: View controller where the overlay should be presented in.
78+
static func presentOverlay(from source: OverlaySource, in viewController: UIViewController) {
79+
let phase = generalPhase()
80+
let config = JetpackFullscreenOverlayGeneralConfig(phase: phase, source: source)
81+
let frequencyTracker = JetpackOverlayFrequencyTracker(phase: phase, source: source)
82+
guard config.shouldShowOverlay, frequencyTracker.shouldShow() else {
83+
return
84+
}
85+
createAndPresentOverlay(with: config, in: viewController)
86+
frequencyTracker.track()
87+
}
88+
89+
private static func createAndPresentOverlay(with config: JetpackFullscreenOverlayConfig, in viewController: UIViewController) {
90+
let overlay = JetpackFullscreenOverlayViewController(with: config)
91+
let navigationViewController = UINavigationController(rootViewController: overlay)
92+
navigationViewController.modalPresentationStyle = .formSheet
93+
viewController.present(navigationViewController, animated: true)
94+
}
6495
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Foundation
2+
3+
struct JetpackOverlayFrequencyTracker {
4+
let phase: JetpackFeaturesRemovalCoordinator.GeneralPhase // TODO: Do we need this?
5+
let source: JetpackFeaturesRemovalCoordinator.OverlaySource
6+
7+
func shouldShow() -> Bool {
8+
// TODO: To be implemented
9+
// Show once for login and app open
10+
// Always show for card
11+
// Check frequency for features
12+
return true
13+
}
14+
15+
func track() {
16+
// TODO: To be implemented
17+
// record that the overlay was displayed
18+
}
19+
}

WordPress/WordPress.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,8 @@
15161516
801D9513291AB3CF0051993E /* JetpackStatsLogoAnimation_rtl.json in Resources */ = {isa = PBXBuildFile; fileRef = 801D950A291AB3CE0051993E /* JetpackStatsLogoAnimation_rtl.json */; };
15171517
801D9515291AB3CF0051993E /* JetpackNotificationsLogoAnimation_rtl.json in Resources */ = {isa = PBXBuildFile; fileRef = 801D950B291AB3CE0051993E /* JetpackNotificationsLogoAnimation_rtl.json */; };
15181518
801D9517291AB3CF0051993E /* JetpackNotificationsLogoAnimation_ltr.json in Resources */ = {isa = PBXBuildFile; fileRef = 801D950C291AB3CF0051993E /* JetpackNotificationsLogoAnimation_ltr.json */; };
1519+
801D951A291AC0B00051993E /* JetpackOverlayFrequencyTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 801D9519291AC0B00051993E /* JetpackOverlayFrequencyTracker.swift */; };
1520+
801D951B291AC0B00051993E /* JetpackOverlayFrequencyTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 801D9519291AC0B00051993E /* JetpackOverlayFrequencyTracker.swift */; };
15191521
803C493B283A7C0C00003E9B /* QuickStartChecklistHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 803C493A283A7C0C00003E9B /* QuickStartChecklistHeader.swift */; };
15201522
803C493C283A7C0C00003E9B /* QuickStartChecklistHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 803C493A283A7C0C00003E9B /* QuickStartChecklistHeader.swift */; };
15211523
803C493E283A7C2200003E9B /* QuickStartChecklistHeader.xib in Resources */ = {isa = PBXBuildFile; fileRef = 803C493D283A7C2200003E9B /* QuickStartChecklistHeader.xib */; };
@@ -6759,6 +6761,7 @@
67596761
801D950A291AB3CE0051993E /* JetpackStatsLogoAnimation_rtl.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = JetpackStatsLogoAnimation_rtl.json; sourceTree = "<group>"; };
67606762
801D950B291AB3CE0051993E /* JetpackNotificationsLogoAnimation_rtl.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = JetpackNotificationsLogoAnimation_rtl.json; sourceTree = "<group>"; };
67616763
801D950C291AB3CF0051993E /* JetpackNotificationsLogoAnimation_ltr.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = JetpackNotificationsLogoAnimation_ltr.json; sourceTree = "<group>"; };
6764+
801D9519291AC0B00051993E /* JetpackOverlayFrequencyTracker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JetpackOverlayFrequencyTracker.swift; sourceTree = "<group>"; };
67626765
80293CF6284450AD0083F946 /* WordPress-Swift.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "WordPress-Swift.h"; sourceTree = "<group>"; };
67636766
803C493A283A7C0C00003E9B /* QuickStartChecklistHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickStartChecklistHeader.swift; sourceTree = "<group>"; };
67646767
803C493D283A7C2200003E9B /* QuickStartChecklistHeader.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = QuickStartChecklistHeader.xib; sourceTree = "<group>"; };
@@ -10516,6 +10519,7 @@
1051610519
children = (
1051710520
3F43704328932F0100475B6E /* JetpackBrandingCoordinator.swift */,
1051810521
803DE820290642B4007D4E9C /* JetpackFeaturesRemovalCoordinator.swift */,
10522+
801D9519291AC0B00051993E /* JetpackOverlayFrequencyTracker.swift */,
1051910523
);
1052010524
path = Coordinator;
1052110525
sourceTree = "<group>";
@@ -21162,6 +21166,7 @@
2116221166
E66969E01B9E648100EC9C00 /* ReaderTopicToReaderDefaultTopic37to38.swift in Sources */,
2116321167
F1DB8D2B2288C24500906E2F /* UploadsManager.swift in Sources */,
2116421168
9856A3E4261FD27A008D6354 /* UserProfileSectionHeader.swift in Sources */,
21169+
801D951A291AC0B00051993E /* JetpackOverlayFrequencyTracker.swift in Sources */,
2116521170
FEF4DC5528439357003806BE /* ReminderScheduleCoordinator.swift in Sources */,
2116621171
82A062DE2017BCBA0084CE7C /* ActivityListSectionHeaderView.swift in Sources */,
2116721172
73FEC871220B358500CEF791 /* WPAccount+RestApi.swift in Sources */,
@@ -23119,6 +23124,7 @@
2311923124
FABB23B42602FC2C00C8785C /* BlogListViewController.m in Sources */,
2312023125
FABB23B52602FC2C00C8785C /* JetpackScanStatusCell.swift in Sources */,
2312123126
FABB23B62602FC2C00C8785C /* NoteBlockCommentTableViewCell.swift in Sources */,
23127+
801D951B291AC0B00051993E /* JetpackOverlayFrequencyTracker.swift in Sources */,
2312223128
C7F7ACBE261E4F0600CE547F /* JetpackErrorViewModel.swift in Sources */,
2312323129
FABB23B72602FC2C00C8785C /* Notifiable.swift in Sources */,
2312423130
80EF672627F3D63B0063B138 /* DashboardStatsStackView.swift in Sources */,

0 commit comments

Comments
 (0)