Skip to content
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
43f6e46
Update: replace Reader-related WPTabBarController.sharedInstance usages
hassaanelgarem Dec 27, 2022
5866206
Refactor: MeNavigation as an extension on RootViewPresenter for reusa…
hassaanelgarem Dec 27, 2022
0dfbf89
Fix: remove white spaces
hassaanelgarem Dec 27, 2022
9a66698
Update: replace Search-related WPTabBarController.sharedInstance usages
hassaanelgarem Dec 27, 2022
ca886bb
Update: replace usages of `showNotificationsTab`
hassaanelgarem Dec 27, 2022
493a27f
Update: replace usage of `showReaderTab(forPost:)`
hassaanelgarem Dec 27, 2022
14fa3a5
Update: replace usages of `WPTabBarController.sharedInstance` in Me n…
hassaanelgarem Dec 27, 2022
831de53
Update: replace usage of `showMedia(for:)`
hassaanelgarem Dec 27, 2022
3e38635
Update: replace usage of `showPosts(for:)`
hassaanelgarem Dec 27, 2022
1882ea1
Update: replace usages of `present()` and `dismiss()`
hassaanelgarem Dec 27, 2022
8bab975
Update: replace usages of `WPTabBarController.sharedInstance()` in `P…
hassaanelgarem Dec 27, 2022
8fbfd1b
Update: replace usages of `currentlySelectedScreen()`
hassaanelgarem Dec 27, 2022
cd976e8
Update: replace usages of `showBlogDetails()`
hassaanelgarem Dec 27, 2022
19f48de
Update: replace usage of `WPTabBarController.sharedInstance()` in Sup…
hassaanelgarem Dec 27, 2022
e571333
Update: replace usages of some reader-related function
hassaanelgarem Dec 27, 2022
fb98daf
Update: remove unneeded optional casting
hassaanelgarem Dec 27, 2022
dc3bfca
Update: replace usages of `WPTabBarController.sharedInstance` related…
hassaanelgarem Dec 27, 2022
2a33e0b
Update: replace usages of `WPTabBarController.sharedInstance` as a VC
hassaanelgarem Dec 27, 2022
43862d6
Update: replace usages of `WPTabBarController.mySitesCoordinator`
hassaanelgarem Dec 27, 2022
fb65edc
Update: replace usages of `WPTabBarController.sharedInstance()` by ca…
hassaanelgarem Dec 27, 2022
9ea1a36
Update: move `currentOrLastBlog` to `RootViewPresenter`
hassaanelgarem Dec 27, 2022
57e4609
Refactor: add a new file for editor navigation extension
hassaanelgarem Dec 27, 2022
51a6982
Refactor: move showPostTab functions to `RootViewPresenter`
hassaanelgarem Dec 27, 2022
2ecdd7b
Refactor: move ShowTab functions to `RootViewPresenter`
hassaanelgarem Dec 27, 2022
ffcac18
Remove: Unneeded `WPTabBarController+ShowTab` file
hassaanelgarem Dec 27, 2022
f17c60f
Update: Replace usages of `WPTabBar.sharedInstance` in 3D touch handler
hassaanelgarem Dec 27, 2022
77fb5c6
Update: replace editor navigation usages of `WPTabBar.sharedInstance`
hassaanelgarem Dec 27, 2022
1119446
Update: replace usages of `tabBarController` with RootViewPresenter
hassaanelgarem Dec 27, 2022
fe3bd34
Refactor: move whats new logic to `RootViewControllerCoordinator`
hassaanelgarem Dec 27, 2022
2a9a886
Refactor: move blogging prompts logic to `RootViewControllerCoordinator`
hassaanelgarem Dec 27, 2022
67c8786
Update: remove usage of `WPTabBar.sharedInstance` in `BlogDetailsVC.m`
hassaanelgarem Dec 27, 2022
c450a6f
Update: Completely remove `WPTabBarController.sharedInstance()`
hassaanelgarem Dec 27, 2022
fde1ace
Update: Fix incorrect documentation
hassaanelgarem Dec 27, 2022
476a929
Merge branch 'task/19810-simplify-ui' into task/19812-handle-simplifi…
hassaanelgarem Dec 28, 2022
2b07177
Add: track incorrectly accessed jetpack functions
hassaanelgarem Dec 28, 2022
2f68760
Merge branch 'task/19810-simplify-ui' into task/19812-handle-simplifi…
hassaanelgarem Dec 28, 2022
d16a995
Refactor: rename `RootViewControllerCoordinator` to `RootViewCoordina…
hassaanelgarem Dec 28, 2022
d3f07f3
Add: release note
hassaanelgarem Dec 28, 2022
fb960a3
Update: make `RootViewPresenter.mySitesCoordinator` optional
hassaanelgarem Dec 29, 2022
f03e6c2
Update: Make `WPTabBarController.mySitesCoordinator` nullable
hassaanelgarem Dec 29, 2022
5a44295
Update: Add readerCoordinator to RootViewPresenter
hassaanelgarem Dec 29, 2022
9b95aa5
Update: Specify nullability identifiers for `WPTabBarController`
hassaanelgarem Dec 29, 2022
d897810
Update: Add `readerNavigationController` to RootViewPresenter
hassaanelgarem Dec 29, 2022
f3f2794
Update: Add `notificationsViewController` to RootViewPresenter
hassaanelgarem Dec 29, 2022
e619798
Update: Use `RootViewPresenter.readerTabVC` instead of accessing the …
hassaanelgarem Dec 29, 2022
c17f29e
Update: call `fallbackBehavior()` when accessing unsupported variables
hassaanelgarem Dec 29, 2022
9d7ec3c
Update: remove `shouldRemoveJetpackFeatures()` and depend on `jetpack…
hassaanelgarem Dec 29, 2022
3dcf3f7
Merge branch 'task/19810-simplify-ui' into task/19812-handle-simplifi…
hassaanelgarem Jan 1, 2023
aea0501
Fix: Replace deprecated `shouldRemoveJetpackFeatures` to fix build er…
hassaanelgarem Jan 1, 2023
1af613b
Update: make `mySitesCoordinator` non-optional
hassaanelgarem Jan 1, 2023
1775563
Merge branch 'trunk' into task/19812-handle-simplified-ui
hassaanelgarem Jan 2, 2023
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
4 changes: 4 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
21.5
-----
* [***] [internal] A significant refactor to the app’s architecture was made to allow for the new simplified UI. Regression testing on the app’s main flows is needed. [#19817]

21.4
-----
* [*] Fixed an issue where publishing Posts and Pages could fail under certain conditions. [#19717]
Expand Down
10 changes: 5 additions & 5 deletions WordPress/Classes/System/3DTouch/WP3DTouchShortcutHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,31 @@ open class WP3DTouchShortcutHandler: NSObject {
@objc static let applicationShortcutUserInfoIconKey = "applicationShortcutUserInfoIconKey"

@objc open func handleShortcutItem(_ shortcutItem: UIApplicationShortcutItem) -> Bool {
let tabBarController: WPTabBarController = WPTabBarController.sharedInstance()
let rootViewPresenter = RootViewCoordinator.sharedPresenter

switch shortcutItem.type {
case ShortcutIdentifier.LogIn.type:
WPAnalytics.track(.shortcutLogIn)
return true
case ShortcutIdentifier.NewPost.type:
WPAnalytics.track(.shortcutNewPost)
tabBarController.showPostTab(animated: false, toMedia: false)
rootViewPresenter.showPostTab(animated: false, toMedia: false)
return true
case ShortcutIdentifier.NewPhotoPost.type:
WPAnalytics.track(.shortcutNewPhotoPost)
tabBarController.showPostTab(animated: false, toMedia: true)
rootViewPresenter.showPostTab(animated: false, toMedia: true)
return true
case ShortcutIdentifier.Stats.type:
WPAnalytics.track(.shortcutStats)
clearCurrentViewController()
if let mainBlog = Blog.lastUsedOrFirst(in: ContextManager.sharedInstance().mainContext) {
tabBarController.mySitesCoordinator.showStats(for: mainBlog)
rootViewPresenter.mySitesCoordinator.showStats(for: mainBlog)
}
return true
case ShortcutIdentifier.Notifications.type:
WPAnalytics.track(.shortcutNotifications)
clearCurrentViewController()
tabBarController.showNotificationsTab()
rootViewPresenter.showNotificationsTab()
return true
default:
return false
Expand Down
112 changes: 112 additions & 0 deletions WordPress/Classes/System/MySitesCoordinator+RootViewPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,116 @@ import Foundation
/// and the app's UI is simplified.
extension MySitesCoordinator: RootViewPresenter {

// MARK: General

var currentViewController: UIViewController? {
return rootViewController
}

func getMeScenePresenter() -> ScenePresenter {
meScenePresenter
}

func currentlySelectedScreen() -> String! {
return "Blog List"
}

func currentlyVisibleBlog() -> Blog? {
currentBlog
}

// MARK: Reader

var readerTabViewController: ReaderTabViewController? {
return nil
}

func showReaderTab() {
fallbackBehavior()
}

func switchToDiscover() {
fallbackBehavior()
}

func switchToSavedPosts() {
fallbackBehavior()
}

func resetReaderDiscoverNudgeFlow() {
fallbackBehavior()
}

func resetReaderTab() {
fallbackBehavior()
}

func navigateToReaderSearch() {
fallbackBehavior()
}

func switchToTopic(where predicate: (ReaderAbstractTopic) -> Bool) {
fallbackBehavior()
}

func switchToMyLikes() {
fallbackBehavior()
}

func switchToFollowedSites() {
fallbackBehavior()
}

func navigateToReaderSite(_ topic: ReaderSiteTopic) {
fallbackBehavior()
}

func navigateToReaderTag(_ topic: ReaderTagTopic) {
fallbackBehavior()
}

func navigateToReader(_ pushControlller: UIViewController?) {
fallbackBehavior()
}

func showReaderTab(forPost: NSNumber!, onBlog: NSNumber!) {
fallbackBehavior()
}

// MARK: My Site

var mySitesCoordinator: MySitesCoordinator! {
return self
}

func showMySitesTab() {
// Do nothing
// Landing here means we're trying to show the My Sites, but it's already showing.
}

// MARK: Notifications

func showNotificationsTab() {
fallbackBehavior()
}

func switchNotificationsTabToNotificationSettings() {
fallbackBehavior()
}

func showNotificationsTabForNote(withID notificationID: String!) {
fallbackBehavior()
}

func popNotificationsTabToRoot() {
fallbackBehavior()
}

// MARK: Helpers

/// Default implementation for functions that are not supported by the simplified UI.
private func fallbackBehavior(callingFunction: String = #function) {
let properties = ["calling_function": callingFunction]
WPAnalytics.track(.jetpackFeatureIncorrectlyAccessed, properties: properties)
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
import Foundation

class RootViewControllerCoordinator {
class RootViewCoordinator {

// MARK: Static shared variables

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

// MARK: Public Variables

lazy var whatIsNewScenePresenter: ScenePresenter = {
return makeWhatIsNewPresenter()
}()

lazy var bloggingPromptCoordinator: BloggingPromptCoordinator = {
return makeBloggingPromptCoordinator()
}()

// MARK: Private instance variables

private var rootViewPresenter: RootViewPresenter
private(set) var rootViewPresenter: RootViewPresenter

// MARK: Initializer

Expand All @@ -21,7 +31,8 @@ class RootViewControllerCoordinator {
self.rootViewPresenter = MySitesCoordinator(meScenePresenter: meScenePresenter, onBecomeActiveTab: {})
}
else {
self.rootViewPresenter = WPTabBarController.sharedInstance() // TODO: Remove shared instance and create an instance here
self.rootViewPresenter = WPTabBarController()
}
updatePromptsIfNeeded()
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,65 @@
extension WPTabBarController {
import Foundation

func showBlogDetails(for blog: Blog) {
mySitesCoordinator.showBlogDetails(for: blog)
extension RootViewPresenter {
func currentOrLastBlog() -> Blog? {
if let blog = currentlyVisibleBlog() {
return blog
}
let context = ContextManager.shared.mainContext
return Blog.lastUsedOrFirst(in: context)
}

func showPostTab() {
showPostTab(completion: nil)
}

func showPostTab(completion afterDismiss: (() -> Void)?) {
let context = ContextManager.shared.mainContext
// Ignore taps on the post tab and instead show the modal.
if Blog.count(in: context) == 0 {
mySitesCoordinator.showAddNewSite()
} else {
showPostTab(animated: true, toMedia: false, completion: afterDismiss)
}
}

func showPostTab(for blog: Blog) {
let context = ContextManager.shared.mainContext
if Blog.count(in: context) == 0 {
mySitesCoordinator.showAddNewSite()
} else {
showPostTab(animated: true, toMedia: false, blog: blog)
}
}

func showPostTab(animated: Bool,
toMedia openToMedia: Bool,
blog: Blog? = nil,
completion afterDismiss: (() -> Void)? = nil) {
if rootViewController.presentedViewController != nil {
rootViewController.dismiss(animated: false)
}

guard let blog = blog ?? currentOrLastBlog() else {
return
}

let editor = EditPostViewController(blog: blog)
editor.modalPresentationStyle = .fullScreen
editor.showImmediately = !animated
editor.openWithMediaPicker = openToMedia
editor.afterDismiss = afterDismiss

let properties = [WPAppAnalyticsKeyTapSource: "create_button", WPAppAnalyticsKeyPostType: "post"]
WPAppAnalytics.track(.editorCreatedPost, withProperties: properties, with: blog)
rootViewController.present(editor, animated: false)
}

@objc func showPageEditor(forBlog: Blog? = nil) {
func showPageEditor(forBlog: Blog? = nil) {
showPageEditor(blog: forBlog)
}

@objc func showStoryEditor(forBlog: Blog? = nil) {
func showStoryEditor(forBlog: Blog? = nil) {
showStoryEditor(blog: forBlog)
}

Expand All @@ -17,8 +68,8 @@ extension WPTabBarController {
func showPageEditor(blog inBlog: Blog? = nil, title: String? = nil, content: String? = nil, source: String = "create_button") {

// If we are already showing a view controller, dismiss and show the editor afterward
guard presentedViewController == nil else {
dismiss(animated: true) { [weak self] in
guard rootViewController.presentedViewController == nil else {
rootViewController.dismiss(animated: true) { [weak self] in
self?.showPageEditor(blog: inBlog, title: title, content: content, source: source)
}
return
Expand All @@ -32,22 +83,22 @@ extension WPTabBarController {
let blogID = blog.dotComID?.intValue ?? 0 as Any
WPAnalytics.track(WPAnalyticsEvent.editorCreatedPage, properties: [WPAppAnalyticsKeyTapSource: source, WPAppAnalyticsKeyBlogID: blogID, WPAppAnalyticsKeyPostType: "page"])

PageCoordinator.showLayoutPickerIfNeeded(from: self, forBlog: blog) { [weak self] (selectedLayout) in
PageCoordinator.showLayoutPickerIfNeeded(from: rootViewController, forBlog: blog) { [weak self] (selectedLayout) in
self?.showEditor(blog: blog, title: selectedLayout?.title, content: selectedLayout?.content, templateKey: selectedLayout?.slug)
}
}

private func showEditor(blog: Blog, title: String?, content: String?, templateKey: String?) {
let editorViewController = EditPageViewController(blog: blog, postTitle: title, content: content, appliedTemplate: templateKey)
present(editorViewController, animated: false)
rootViewController.present(editorViewController, animated: false)
}

/// Show the story editor
/// - Parameter blog: Blog to a add a story to. Uses the current or last blog if not provided
func showStoryEditor(blog inBlog: Blog? = nil, title: String? = nil, content: String? = nil, source: String = "create_button") {
// If we are already showing a view controller, dismiss and show the editor afterward
guard presentedViewController == nil else {
dismiss(animated: true) { [weak self] in
guard rootViewController.presentedViewController == nil else {
rootViewController.dismiss(animated: true) { [weak self] in
self?.showStoryEditor(blog: inBlog, title: title, content: content, source: source)
}
return
Expand All @@ -61,10 +112,10 @@ extension WPTabBarController {
}, openURL: { [weak self] url in
let webViewController = WebViewControllerFactory.controller(url: url, source: "show_story_example")
let navController = UINavigationController(rootViewController: webViewController)
self?.presentedViewController?.present(navController, animated: true)
self?.rootViewController.presentedViewController?.present(navController, animated: true)
})

present(intro, animated: true, completion: {
rootViewController.present(intro, animated: true, completion: {
StoriesIntroViewController.trackShown()
})
} else {
Expand All @@ -75,7 +126,7 @@ extension WPTabBarController {

do {
let controller = try StoryEditor.editor(blog: blog, context: ContextManager.shared.mainContext, updated: {_ in })
present(controller, animated: true, completion: nil)
rootViewController.present(controller, animated: true, completion: nil)
} catch {
assertionFailure("Story editor should not fail since this button is hidden on iPads.")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@

import UIKit

/// Methods to access the Me Scene and sub levels
extension WPTabBarController {
extension RootViewPresenter {
/// removes all but the primary viewControllers from the stack
@objc func popMeTabToRoot() {
func popMeTabToRoot() {
getNavigationController()?.popToRootViewController(animated: false)
}
/// presents the Me scene. If the feature flag is disabled, replaces the previously defined `showMeTab`
@objc func showMeScene(animated: Bool = true, completion: (() -> Void)? = nil) {
meScenePresenter.present(on: self, animated: animated, completion: completion)
func showMeScene(animated: Bool = true, completion: (() -> Void)? = nil) {
let meScenePresenter = getMeScenePresenter()
meScenePresenter.present(on: rootViewController, animated: animated, completion: completion)
}
/// access to sub levels
@objc func navigateToAccountSettings() {
func navigateToAccountSettings() {
showMeScene(animated: false) {
self.popMeTabToRoot()
self.getMeViewController()?.navigateToAccountSettings()
}
}

@objc func navigateToAppSettings() {
func navigateToAppSettings() {
showMeScene() {
self.popMeTabToRoot()
self.getMeViewController()?.navigateToAppSettings()
}
}

@objc func navigateToSupport() {
func navigateToSupport() {
showMeScene() {
self.popMeTabToRoot()
self.getMeViewController()?.navigateToHelpAndSupport()
Expand All @@ -35,6 +35,7 @@ extension WPTabBarController {

/// obtains a reference to the navigation controller of the presented MeViewController
private func getNavigationController() -> UINavigationController? {
let meScenePresenter = getMeScenePresenter()
guard let splitController = meScenePresenter.presentedViewController as? WPSplitViewController,
let navigationController = splitController.viewControllers.first as? UINavigationController else {
return nil
Expand Down
Loading