Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Foundation

/// `MySitesCoordinator` is used as the root presenter when Jetpack features are disabled
/// and the app's UI is simplified.
extension MySitesCoordinator: RootViewPresenter {

}
27 changes: 27 additions & 0 deletions WordPress/Classes/System/RootViewControllerCoordinator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Foundation

class RootViewControllerCoordinator {

// MARK: Static shared variables

static let shared = RootViewControllerCoordinator()
static var sharedPresenter: RootViewPresenter {
shared.rootViewPresenter
}

// MARK: Private instance variables

private var rootViewPresenter: RootViewPresenter

// MARK: Initializer

init() {
if JetpackFeaturesRemovalCoordinator.shouldRemoveJetpackFeatures() {
let meScenePresenter = MeScenePresenter()
self.rootViewPresenter = MySitesCoordinator(meScenePresenter: meScenePresenter, onBecomeActiveTab: {})
}
else {
self.rootViewPresenter = WPTabBarController.sharedInstance() // TODO: Remove shared instance and create an instance here
}
}
}
6 changes: 6 additions & 0 deletions WordPress/Classes/System/RootViewPresenter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Foundation

protocol RootViewPresenter {
var rootViewController: UIViewController { get }
func showBlogDetails(for blog: Blog)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Foundation

/// `WPTabBarController` is used as the root presenter when Jetpack features are enabled
/// and the app's UI is normal.
extension WPTabBarController: RootViewPresenter {
var rootViewController: UIViewController {
return self
}
}
4 changes: 2 additions & 2 deletions WordPress/Classes/System/WindowManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ class WindowManager: NSObject {
///
@objc func showAppUI(for blog: Blog? = nil, completion: Completion? = nil) {
isShowingFullscreenSignIn = false
show(WPTabBarController.sharedInstance(), completion: completion)
show(RootViewControllerCoordinator.sharedPresenter.rootViewController, completion: completion)

guard let blog = blog else {
return
}

WPTabBarController.sharedInstance()?.showBlogDetails(for: blog)
RootViewControllerCoordinator.sharedPresenter.showBlogDetails(for: blog)
}

/// Shows the initial UI for unauthenticated users.
Expand Down
5 changes: 0 additions & 5 deletions WordPress/Classes/Utility/BuildInformation/FeatureFlag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ enum FeatureFlag: Int, CaseIterable, OverrideableFlag {
case weeklyRoundupBGProcessingTask
case domains
case timeZoneSuggester
case mySiteDashboard
case mediaPickerPermissionsNotice
case notificationCommentDetails
case siteIntentQuestion
Expand Down Expand Up @@ -83,8 +82,6 @@ enum FeatureFlag: Int, CaseIterable, OverrideableFlag {
return true
case .timeZoneSuggester:
return true
case .mySiteDashboard:
return true
case .mediaPickerPermissionsNotice:
return true
case .notificationCommentDetails:
Expand Down Expand Up @@ -203,8 +200,6 @@ extension FeatureFlag {
return "Domain Purchases"
case .timeZoneSuggester:
return "TimeZone Suggester"
case .mySiteDashboard:
return "My Site Dashboard"
case .mediaPickerPermissionsNotice:
return "Media Picker Permissions Notice"
case .notificationCommentDetails:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import Foundation
extension BlogDetailsViewController {

@objc func isDashboardEnabled() -> Bool {
return FeatureFlag.mySiteDashboard.enabled && blog.isAccessibleThroughWPCom()
return JetpackFeaturesRemovalCoordinator.jetpackFeaturesEnabled() && blog.isAccessibleThroughWPCom()
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import UIKit

// TODO: Consider completely removing all Quick Action logic
extension BlogDetailsViewController {

@objc func quickActionsSectionViewModel() -> BlogDetailsSection {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,63 @@ extension BlogDetailsViewController {
@objc func sectionCategory(subsection: BlogDetailsSubsection, blog: Blog) -> BlogDetailsSectionCategory {
return subsection.sectionCategory(for: blog)
}

@objc func defaultSubsection() -> BlogDetailsSubsection {
if JetpackFeaturesRemovalCoordinator.shouldRemoveJetpackFeatures() {
return .posts
}
if shouldShowDashboard() {
return .home
}
return .stats
}

@objc func shouldShowStats() -> Bool {
return JetpackFeaturesRemovalCoordinator.jetpackFeaturesEnabled()
}

@objc func shouldAddJetpackSection() -> Bool {
guard JetpackFeaturesRemovalCoordinator.jetpackFeaturesEnabled() else {
return false
}
return blog.shouldShowJetpackSection
}

@objc func shouldAddGeneralSection() -> Bool {
guard JetpackFeaturesRemovalCoordinator.jetpackFeaturesEnabled() else {
return false
}
return blog.shouldShowJetpackSection == false
}

@objc func shouldAddPersonalizeSection() -> Bool {
guard JetpackFeaturesRemovalCoordinator.jetpackFeaturesEnabled() else {
return false
}
return blog.supports(.themeBrowsing) || blog.supports(.menus)
}

@objc func shouldAddSharingRow() -> Bool {
guard JetpackFeaturesRemovalCoordinator.jetpackFeaturesEnabled() else {
return false
}
return blog.supports(.sharing)
}

@objc func shouldAddPeopleRow() -> Bool {
guard JetpackFeaturesRemovalCoordinator.jetpackFeaturesEnabled() else {
return false
}
return blog.supports(.people)
}

@objc func shouldAddPluginsRow() -> Bool {
return blog.supports(.pluginManagement)
}

@objc func shouldAddDomainRegistrationRow() -> Bool {
return FeatureFlag.domains.enabled
&& AppConfiguration.allowsDomainRegistration
&& blog.supports(.domains)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ - (NSIndexPath *)restorableSelectedIndexPath
{
if (!_restorableSelectedIndexPath) {
// If nil, default to stats subsection.
BlogDetailsSubsection subsection = [self shouldShowDashboard] ? BlogDetailsSubsectionHome : BlogDetailsSubsectionStats;
BlogDetailsSubsection subsection = [self defaultSubsection];
self.selectedSectionCategory = [self sectionCategoryWithSubsection:subsection blog: self.blog];
NSUInteger section = [self findSectionIndexWithSections:self.tableSections category:self.selectedSectionCategory];
_restorableSelectedIndexPath = [NSIndexPath indexPathForRow:0 inSection:section];
Expand Down Expand Up @@ -703,7 +703,7 @@ - (void)reloadTableViewPreservingSelection
case BlogDetailsSectionCategoryQuickStart:
case BlogDetailsSectionCategoryJetpackBrandingCard:
case BlogDetailsSectionCategoryDomainCredit: {
BlogDetailsSubsection subsection = [self shouldShowDashboard] ? BlogDetailsSubsectionHome : BlogDetailsSubsectionStats;
BlogDetailsSubsection subsection = [self defaultSubsection];
BlogDetailsSectionCategory category = [self sectionCategoryWithSubsection:subsection blog: self.blog];
sectionIndex = [self findSectionIndexWithSections:self.tableSections category:category];
}
Expand Down Expand Up @@ -738,9 +738,6 @@ - (void)configureTableViewData
{
NSMutableArray *marr = [NSMutableArray array];

if (AppConfiguration.showsQuickActions && ![self isDashboardEnabled]) {
[marr addObject:[self quickActionsSectionViewModel]];
}
if (MigrationSuccessCardView.shouldShowMigrationSuccessCard == YES) {
[marr addObject:[self migrationSuccessSectionViewModel]];
}
Expand All @@ -761,16 +758,20 @@ - (void)configureTableViewData
if ([self isDashboardEnabled] && ![self splitViewControllerIsHorizontallyCompact]) {
[marr addObject:[self homeSectionViewModel]];
}
if (self.blog.shouldShowJetpackSection) {
if ([self shouldAddJetpackSection]) {
[marr addObject:[self jetpackSectionViewModel]];
} else {
}

if ([self shouldAddGeneralSection]) {
[marr addObject:[self generalSectionViewModel]];
}

[marr addObject:[self publishTypeSectionViewModel]];
if ([self.blog supports:BlogFeatureThemeBrowsing] || [self.blog supports:BlogFeatureMenus]) {

if ([self shouldAddPersonalizeSection]) {
[marr addObject:[self personalizeSectionViewModel]];
}

[marr addObject:[self configurationSectionViewModel]];
[marr addObject:[self externalSectionViewModel]];
if ([self.blog supports:BlogFeatureRemovable]) {
Expand Down Expand Up @@ -969,7 +970,7 @@ - (BlogDetailsSection *)configurationSectionViewModel
__weak __typeof(self) weakSelf = self;
NSMutableArray *rows = [NSMutableArray array];

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

if ([self.blog supports:BlogFeaturePeople]) {
if ([self shouldAddPeopleRow]) {
[rows addObject:[[BlogDetailsRow alloc] initWithTitle:NSLocalizedString(@"People", @"Noun. Title. Links to the people management feature.")
image:[UIImage gridiconOfType:GridiconTypeUser]
callback:^{
[weakSelf showPeople];
}]];
}

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

[rows addObject:row];

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

WPSplitViewController *splitViewController = (WPSplitViewController *)self.splitViewController;
splitViewController.isShowingInitialDetail = YES;

if ([self shouldShowDashboard]) {
[self showDetailViewForSubsection:BlogDetailsSubsectionHome];
} else {
[self showDetailViewForSubsection:BlogDetailsSubsectionStats];
BlogDetailsSubsection subsection = [self defaultSubsection];
switch (subsection) {
case BlogDetailsSubsectionHome:
[self showDetailViewForSubsection:BlogDetailsSubsectionHome];
break;
case BlogDetailsSubsectionStats:
[self showDetailViewForSubsection:BlogDetailsSubsectionStats];
break;
case BlogDetailsSubsectionPosts:
[self showDetailViewForSubsection: BlogDetailsSubsectionPosts];
break;
default:
break;
}
}

Expand Down Expand Up @@ -1399,7 +1408,7 @@ - (void)preloadMetadata

- (void)preloadDomains
{
if (![self shouldShowDomainRegistration]) {
if (![self shouldAddDomainRegistrationRow]) {
return;
}

Expand All @@ -1408,13 +1417,6 @@ - (void)preloadDomains
failure:nil];
}

- (BOOL)shouldShowDomainRegistration
{
return [Feature enabled:FeatureFlagDomains]
&& [AppConfiguration allowsDomainRegistration]
&& [self.blog supports:BlogFeatureDomains];
}

- (void)scrollToElement:(QuickStartTourElement) element
{
int sectionCount = 0;
Expand Down Expand Up @@ -1750,10 +1752,15 @@ - (void)handleDataModelChange:(NSNotification *)note

- (UIViewController *)initialDetailViewControllerForSplitView:(WPSplitViewController *)splitView
{
StatsViewController *statsView = [StatsViewController new];
statsView.blog = self.blog;

return statsView;
if ([self shouldShowStats]) {
StatsViewController *statsView = [StatsViewController new];
statsView.blog = self.blog;
return statsView;
} else {
PostListViewController *postsView = [PostListViewController controllerWithBlog:self.blog];
postsView.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever;
return postsView;
}
}

#pragma mark - UIViewControllerTransitioningDelegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class MySiteViewController: UIViewController, NoResultsViewHost {
private func updateSegmentedControl(for blog: Blog, switchTabsIfNeeded: Bool = false) {
// The segmented control should be hidden if the blog is not a WP.com/Atomic/Jetpack site, or if the device doesn't have a horizontally compact view
let hideSegmentedControl =
!FeatureFlag.mySiteDashboard.enabled ||
JetpackFeaturesRemovalCoordinator.shouldRemoveJetpackFeatures() ||
!blog.isAccessibleThroughWPCom() ||
!splitViewControllerIsHorizontallyCompact

Expand Down Expand Up @@ -357,7 +357,7 @@ class MySiteViewController: UIViewController, NoResultsViewHost {
}

private func setupNavigationItem() {
navigationItem.largeTitleDisplayMode = FeatureFlag.mySiteDashboard.enabled ? .never : .always
navigationItem.largeTitleDisplayMode = .never
navigationItem.title = Strings.mySite
navigationItem.backButtonTitle = Strings.mySite

Expand All @@ -382,11 +382,10 @@ class MySiteViewController: UIViewController, NoResultsViewHost {
}

private func setupNavBarAppearance() {
navigationController?.navigationBar.scrollEdgeAppearance?.configureWithTransparentBackground()
if FeatureFlag.mySiteDashboard.enabled {
let transparentTitleAttributes = [NSAttributedString.Key.foregroundColor: UIColor.clear]
navigationController?.navigationBar.scrollEdgeAppearance?.titleTextAttributes = transparentTitleAttributes
}
let scrollEdgeAppearance = navigationController?.navigationBar.scrollEdgeAppearance
let transparentTitleAttributes = [NSAttributedString.Key.foregroundColor: UIColor.clear]
scrollEdgeAppearance?.titleTextAttributes = transparentTitleAttributes
scrollEdgeAppearance?.configureWithTransparentBackground()
}

private func resetNavBarAppearance() {
Expand Down Expand Up @@ -653,7 +652,7 @@ class MySiteViewController: UIViewController, NoResultsViewHost {
trailingAnchor: view.safeAreaLayoutGuide.trailingAnchor,
bottomAnchor: view.safeAreaLayoutGuide.bottomAnchor)

if let blog = blog, tabBarController is WPTabBarController,
if let blog = blog,
noResultsViewController.view.superview == nil {
createButtonCoordinator?.showCreateButton(for: blog)
}
Expand Down
Loading