Skip to content

Commit 7b7fcb6

Browse files
Merge pull request #19816 from wordpress-mobile/task/19810-simplify-ui
Jetpack Focus: Remove Jetpack features during phase 4
2 parents 3eb3666 + c0ad158 commit 7b7fcb6

19 files changed

+242
-53
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Foundation
2+
3+
/// `MySitesCoordinator` is used as the root presenter when Jetpack features are disabled
4+
/// and the app's UI is simplified.
5+
extension MySitesCoordinator: RootViewPresenter {
6+
7+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import Foundation
2+
3+
class RootViewControllerCoordinator {
4+
5+
// MARK: Static shared variables
6+
7+
static let shared = RootViewControllerCoordinator()
8+
static var sharedPresenter: RootViewPresenter {
9+
shared.rootViewPresenter
10+
}
11+
12+
// MARK: Private instance variables
13+
14+
private var rootViewPresenter: RootViewPresenter
15+
16+
// MARK: Initializer
17+
18+
init() {
19+
if JetpackFeaturesRemovalCoordinator.shouldRemoveJetpackFeatures() {
20+
let meScenePresenter = MeScenePresenter()
21+
self.rootViewPresenter = MySitesCoordinator(meScenePresenter: meScenePresenter, onBecomeActiveTab: {})
22+
}
23+
else {
24+
self.rootViewPresenter = WPTabBarController.sharedInstance() // TODO: Remove shared instance and create an instance here
25+
}
26+
}
27+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Foundation
2+
3+
protocol RootViewPresenter {
4+
var rootViewController: UIViewController { get }
5+
func showBlogDetails(for blog: Blog)
6+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Foundation
2+
3+
/// `WPTabBarController` is used as the root presenter when Jetpack features are enabled
4+
/// and the app's UI is normal.
5+
extension WPTabBarController: RootViewPresenter {
6+
var rootViewController: UIViewController {
7+
return self
8+
}
9+
}

WordPress/Classes/System/WindowManager.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ class WindowManager: NSObject {
5757
///
5858
@objc func showAppUI(for blog: Blog? = nil, completion: Completion? = nil) {
5959
isShowingFullscreenSignIn = false
60-
show(WPTabBarController.sharedInstance(), completion: completion)
60+
show(RootViewControllerCoordinator.sharedPresenter.rootViewController, completion: completion)
6161

6262
guard let blog = blog else {
6363
return
6464
}
6565

66-
WPTabBarController.sharedInstance()?.showBlogDetails(for: blog)
66+
RootViewControllerCoordinator.sharedPresenter.showBlogDetails(for: blog)
6767
}
6868

6969
/// Shows the initial UI for unauthenticated users.

WordPress/Classes/Utility/BuildInformation/FeatureFlag.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ enum FeatureFlag: Int, CaseIterable, OverrideableFlag {
1717
case weeklyRoundupBGProcessingTask
1818
case domains
1919
case timeZoneSuggester
20-
case mySiteDashboard
2120
case mediaPickerPermissionsNotice
2221
case notificationCommentDetails
2322
case siteIntentQuestion
@@ -83,8 +82,6 @@ enum FeatureFlag: Int, CaseIterable, OverrideableFlag {
8382
return true
8483
case .timeZoneSuggester:
8584
return true
86-
case .mySiteDashboard:
87-
return true
8885
case .mediaPickerPermissionsNotice:
8986
return true
9087
case .notificationCommentDetails:
@@ -203,8 +200,6 @@ extension FeatureFlag {
203200
return "Domain Purchases"
204201
case .timeZoneSuggester:
205202
return "TimeZone Suggester"
206-
case .mySiteDashboard:
207-
return "My Site Dashboard"
208203
case .mediaPickerPermissionsNotice:
209204
return "Media Picker Permissions Notice"
210205
case .notificationCommentDetails:

WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController+Dashboard.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import Foundation
33
extension BlogDetailsViewController {
44

55
@objc func isDashboardEnabled() -> Bool {
6-
return FeatureFlag.mySiteDashboard.enabled && blog.isAccessibleThroughWPCom()
6+
return JetpackFeaturesRemovalCoordinator.jetpackFeaturesEnabled() && blog.isAccessibleThroughWPCom()
77
}
88
}

WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController+QuickActions.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import UIKit
22

3+
// TODO: Consider completely removing all Quick Action logic
34
extension BlogDetailsViewController {
45

56
@objc func quickActionsSectionViewModel() -> BlogDetailsSection {

WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController+SectionHelpers.swift

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,63 @@ extension BlogDetailsViewController {
3939
@objc func sectionCategory(subsection: BlogDetailsSubsection, blog: Blog) -> BlogDetailsSectionCategory {
4040
return subsection.sectionCategory(for: blog)
4141
}
42+
43+
@objc func defaultSubsection() -> BlogDetailsSubsection {
44+
if JetpackFeaturesRemovalCoordinator.shouldRemoveJetpackFeatures() {
45+
return .posts
46+
}
47+
if shouldShowDashboard() {
48+
return .home
49+
}
50+
return .stats
51+
}
52+
53+
@objc func shouldShowStats() -> Bool {
54+
return JetpackFeaturesRemovalCoordinator.jetpackFeaturesEnabled()
55+
}
56+
57+
@objc func shouldAddJetpackSection() -> Bool {
58+
guard JetpackFeaturesRemovalCoordinator.jetpackFeaturesEnabled() else {
59+
return false
60+
}
61+
return blog.shouldShowJetpackSection
62+
}
63+
64+
@objc func shouldAddGeneralSection() -> Bool {
65+
guard JetpackFeaturesRemovalCoordinator.jetpackFeaturesEnabled() else {
66+
return false
67+
}
68+
return blog.shouldShowJetpackSection == false
69+
}
70+
71+
@objc func shouldAddPersonalizeSection() -> Bool {
72+
guard JetpackFeaturesRemovalCoordinator.jetpackFeaturesEnabled() else {
73+
return false
74+
}
75+
return blog.supports(.themeBrowsing) || blog.supports(.menus)
76+
}
77+
78+
@objc func shouldAddSharingRow() -> Bool {
79+
guard JetpackFeaturesRemovalCoordinator.jetpackFeaturesEnabled() else {
80+
return false
81+
}
82+
return blog.supports(.sharing)
83+
}
84+
85+
@objc func shouldAddPeopleRow() -> Bool {
86+
guard JetpackFeaturesRemovalCoordinator.jetpackFeaturesEnabled() else {
87+
return false
88+
}
89+
return blog.supports(.people)
90+
}
91+
92+
@objc func shouldAddPluginsRow() -> Bool {
93+
return blog.supports(.pluginManagement)
94+
}
95+
96+
@objc func shouldAddDomainRegistrationRow() -> Bool {
97+
return FeatureFlag.domains.enabled
98+
&& AppConfiguration.allowsDomainRegistration
99+
&& blog.supports(.domains)
100+
}
42101
}

WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.m

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ - (NSIndexPath *)restorableSelectedIndexPath
599599
{
600600
if (!_restorableSelectedIndexPath) {
601601
// If nil, default to stats subsection.
602-
BlogDetailsSubsection subsection = [self shouldShowDashboard] ? BlogDetailsSubsectionHome : BlogDetailsSubsectionStats;
602+
BlogDetailsSubsection subsection = [self defaultSubsection];
603603
self.selectedSectionCategory = [self sectionCategoryWithSubsection:subsection blog: self.blog];
604604
NSUInteger section = [self findSectionIndexWithSections:self.tableSections category:self.selectedSectionCategory];
605605
_restorableSelectedIndexPath = [NSIndexPath indexPathForRow:0 inSection:section];
@@ -703,7 +703,7 @@ - (void)reloadTableViewPreservingSelection
703703
case BlogDetailsSectionCategoryQuickStart:
704704
case BlogDetailsSectionCategoryJetpackBrandingCard:
705705
case BlogDetailsSectionCategoryDomainCredit: {
706-
BlogDetailsSubsection subsection = [self shouldShowDashboard] ? BlogDetailsSubsectionHome : BlogDetailsSubsectionStats;
706+
BlogDetailsSubsection subsection = [self defaultSubsection];
707707
BlogDetailsSectionCategory category = [self sectionCategoryWithSubsection:subsection blog: self.blog];
708708
sectionIndex = [self findSectionIndexWithSections:self.tableSections category:category];
709709
}
@@ -738,9 +738,6 @@ - (void)configureTableViewData
738738
{
739739
NSMutableArray *marr = [NSMutableArray array];
740740

741-
if (AppConfiguration.showsQuickActions && ![self isDashboardEnabled]) {
742-
[marr addObject:[self quickActionsSectionViewModel]];
743-
}
744741
if (MigrationSuccessCardView.shouldShowMigrationSuccessCard == YES) {
745742
[marr addObject:[self migrationSuccessSectionViewModel]];
746743
}
@@ -761,16 +758,20 @@ - (void)configureTableViewData
761758
if ([self isDashboardEnabled] && ![self splitViewControllerIsHorizontallyCompact]) {
762759
[marr addObject:[self homeSectionViewModel]];
763760
}
764-
if (self.blog.shouldShowJetpackSection) {
761+
if ([self shouldAddJetpackSection]) {
765762
[marr addObject:[self jetpackSectionViewModel]];
766-
} else {
763+
}
764+
765+
if ([self shouldAddGeneralSection]) {
767766
[marr addObject:[self generalSectionViewModel]];
768767
}
769768

770769
[marr addObject:[self publishTypeSectionViewModel]];
771-
if ([self.blog supports:BlogFeatureThemeBrowsing] || [self.blog supports:BlogFeatureMenus]) {
770+
771+
if ([self shouldAddPersonalizeSection]) {
772772
[marr addObject:[self personalizeSectionViewModel]];
773773
}
774+
774775
[marr addObject:[self configurationSectionViewModel]];
775776
[marr addObject:[self externalSectionViewModel]];
776777
if ([self.blog supports:BlogFeatureRemovable]) {
@@ -969,7 +970,7 @@ - (BlogDetailsSection *)configurationSectionViewModel
969970
__weak __typeof(self) weakSelf = self;
970971
NSMutableArray *rows = [NSMutableArray array];
971972

972-
if ([self.blog supports:BlogFeatureSharing]) {
973+
if ([self shouldAddSharingRow]) {
973974
BlogDetailsRow *row = [[BlogDetailsRow alloc] initWithTitle:NSLocalizedString(@"Sharing", @"Noun. Title. Links to a blog's sharing options.")
974975
image:[UIImage gridiconOfType:GridiconTypeShare]
975976
callback:^{
@@ -979,15 +980,15 @@ - (BlogDetailsSection *)configurationSectionViewModel
979980
[rows addObject:row];
980981
}
981982

982-
if ([self.blog supports:BlogFeaturePeople]) {
983+
if ([self shouldAddPeopleRow]) {
983984
[rows addObject:[[BlogDetailsRow alloc] initWithTitle:NSLocalizedString(@"People", @"Noun. Title. Links to the people management feature.")
984985
image:[UIImage gridiconOfType:GridiconTypeUser]
985986
callback:^{
986987
[weakSelf showPeople];
987988
}]];
988989
}
989990

990-
if ([self.blog supports:BlogFeaturePluginManagement]) {
991+
if ([self shouldAddPluginsRow]) {
991992
[rows addObject:[[BlogDetailsRow alloc] initWithTitle:NSLocalizedString(@"Plugins", @"Noun. Title. Links to the plugin management feature.")
992993
image:[UIImage gridiconOfType:GridiconTypePlugins]
993994
callback:^{
@@ -1005,7 +1006,7 @@ - (BlogDetailsSection *)configurationSectionViewModel
10051006

10061007
[rows addObject:row];
10071008

1008-
if ([self shouldShowDomainRegistration]) {
1009+
if ([self shouldAddDomainRegistrationRow]) {
10091010
BlogDetailsRow *domainsRow = [[BlogDetailsRow alloc] initWithTitle:NSLocalizedString(@"Domains", @"Noun. Title. Links to the Domains screen.")
10101011
identifier:BlogDetailsSettingsCellIdentifier
10111012
accessibilityIdentifier:@"Domains Row"
@@ -1112,11 +1113,19 @@ - (void)showInitialDetailsForBlog
11121113

11131114
WPSplitViewController *splitViewController = (WPSplitViewController *)self.splitViewController;
11141115
splitViewController.isShowingInitialDetail = YES;
1115-
1116-
if ([self shouldShowDashboard]) {
1117-
[self showDetailViewForSubsection:BlogDetailsSubsectionHome];
1118-
} else {
1119-
[self showDetailViewForSubsection:BlogDetailsSubsectionStats];
1116+
BlogDetailsSubsection subsection = [self defaultSubsection];
1117+
switch (subsection) {
1118+
case BlogDetailsSubsectionHome:
1119+
[self showDetailViewForSubsection:BlogDetailsSubsectionHome];
1120+
break;
1121+
case BlogDetailsSubsectionStats:
1122+
[self showDetailViewForSubsection:BlogDetailsSubsectionStats];
1123+
break;
1124+
case BlogDetailsSubsectionPosts:
1125+
[self showDetailViewForSubsection: BlogDetailsSubsectionPosts];
1126+
break;
1127+
default:
1128+
break;
11201129
}
11211130
}
11221131

@@ -1399,7 +1408,7 @@ - (void)preloadMetadata
13991408

14001409
- (void)preloadDomains
14011410
{
1402-
if (![self shouldShowDomainRegistration]) {
1411+
if (![self shouldAddDomainRegistrationRow]) {
14031412
return;
14041413
}
14051414

@@ -1408,13 +1417,6 @@ - (void)preloadDomains
14081417
failure:nil];
14091418
}
14101419

1411-
- (BOOL)shouldShowDomainRegistration
1412-
{
1413-
return [Feature enabled:FeatureFlagDomains]
1414-
&& [AppConfiguration allowsDomainRegistration]
1415-
&& [self.blog supports:BlogFeatureDomains];
1416-
}
1417-
14181420
- (void)scrollToElement:(QuickStartTourElement) element
14191421
{
14201422
int sectionCount = 0;
@@ -1750,10 +1752,15 @@ - (void)handleDataModelChange:(NSNotification *)note
17501752

17511753
- (UIViewController *)initialDetailViewControllerForSplitView:(WPSplitViewController *)splitView
17521754
{
1753-
StatsViewController *statsView = [StatsViewController new];
1754-
statsView.blog = self.blog;
1755-
1756-
return statsView;
1755+
if ([self shouldShowStats]) {
1756+
StatsViewController *statsView = [StatsViewController new];
1757+
statsView.blog = self.blog;
1758+
return statsView;
1759+
} else {
1760+
PostListViewController *postsView = [PostListViewController controllerWithBlog:self.blog];
1761+
postsView.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever;
1762+
return postsView;
1763+
}
17571764
}
17581765

17591766
#pragma mark - UIViewControllerTransitioningDelegate

0 commit comments

Comments
 (0)