Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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,49 @@ extension BlogDetailsViewController {
@objc func sectionCategory(subsection: BlogDetailsSubsection, blog: Blog) -> BlogDetailsSectionCategory {
return subsection.sectionCategory(for: blog)
}

@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 @@ -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 @@ -1399,7 +1400,7 @@ - (void)preloadMetadata

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

Expand All @@ -1408,13 +1409,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
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class DomainCreditEligibilityChecker: NSObject {
@objc static func canRedeemDomainCredit(blog: Blog) -> Bool {
return (blog.isHostedAtWPcom || blog.isAtomic()) && blog.hasDomainCredit
return (blog.isHostedAtWPcom || blog.isAtomic()) && blog.hasDomainCredit && JetpackFeaturesRemovalCoordinator.jetpackFeaturesEnabled()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,22 @@ class JetpackFeaturesRemovalCoordinator {
return formatter.date(from: dateString)
}

/// Used to determine if the Jetpack features should be removed based on the removal phase.
static func shouldRemoveJetpackFeatures() -> Bool {
switch generalPhase() {
case .four, .newUsers:
return true
default:
return false
}
}

/// Inverse of `shouldRemoveJetpackFeatures`.
/// Added to enhance verbosity in some areas of the code.
static func jetpackFeaturesEnabled() -> Bool {
!shouldRemoveJetpackFeatures()
}

/// Used to display feature-specific or feature-collection overlays.
/// - Parameters:
/// - source: The source that triggers the display of the overlay.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ private extension AppSettingsViewController {
rows.insert(iconRow, at: 0)
}

if FeatureFlag.mySiteDashboard.enabled {
if JetpackFeaturesRemovalCoordinator.jetpackFeaturesEnabled() {
let initialScreen = NavigationItemRow(title: NSLocalizedString("Initial Screen", comment: "Title of the option to change the default initial screen"), detail: MySiteSettings().defaultSection.title, action: pushInitialScreenSettings())

rows.append(initialScreen)
Expand Down
Loading