Skip to content

Commit

Permalink
Reorder more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed Sep 16, 2024
1 parent f72ebe4 commit 9edd5d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
2 changes: 1 addition & 1 deletion WordPress/Classes/System/RootViewPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ protocol RootViewPresenter: AnyObject {

var rootViewController: UIViewController { get }
func currentlySelectedScreen() -> String
func currentlyVisibleBlog() -> Blog?

// MARK: Sites

var mySitesCoordinator: MySitesCoordinator { get }
func currentlyVisibleBlog() -> Blog?
func showBlogDetails(for blog: Blog, then subsection: BlogDetailsSubsection?, userInfo: [AnyHashable: Any])
func showMySitesTab()

Expand Down
38 changes: 16 additions & 22 deletions WordPress/Classes/System/SplitViewRootPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,27 +240,24 @@ final class SplitViewRootPresenter: RootViewPresenter {

var rootViewController: UIViewController { splitVC }

// MARK: RootViewPresenter (Sites)

func currentlySelectedScreen() -> String {
if splitVC.isCollapsed {
return tabBarViewController.currentlySelectedScreen()
} else {
switch sidebarViewModel.selection {
case .welcome:
return "Welcome"
case .blog:
return WPTabBarCurrentlySelectedScreenSites
case .notifications:
return WPTabBarCurrentlySelectedScreenNotifications
case .reader:
return WPTabBarCurrentlySelectedScreenReader
default:
return ""
case .welcome: return "Welcome"
case .blog: return WPTabBarCurrentlySelectedScreenSites
case .notifications: return WPTabBarCurrentlySelectedScreenNotifications
case .reader: return WPTabBarCurrentlySelectedScreenReader
default: return ""
}
}
}

// MARK: RootViewPresenter (Sites)

var mySitesCoordinator: MySitesCoordinator

func currentlyVisibleBlog() -> Blog? {
assert(Thread.isMainThread)
return siteContent?.blog
Expand All @@ -278,6 +275,11 @@ final class SplitViewRootPresenter: RootViewPresenter {
}
}

func showMySitesTab() {
guard let blog = currentlyVisibleBlog() else { return }
sidebarViewModel.selection = .blog(TaggedManagedObjectID(blog))
}

// MARK: RootViewPresenter (Reader)

func showReaderTab() {
Expand Down Expand Up @@ -320,15 +322,7 @@ final class SplitViewRootPresenter: RootViewPresenter {
fatalError()
}

var mySitesCoordinator: MySitesCoordinator

func showMySitesTab() {
guard let blog = currentlyVisibleBlog() else {
// Do nothing.
return
}
sidebarViewModel.selection = .blog(TaggedManagedObjectID(blog))
}
// MARK: Notifications

func showNotificationsTab(completion: ((NotificationsViewController) -> Void)?) {
sidebarViewModel.selection = .notifications
Expand All @@ -338,7 +332,7 @@ final class SplitViewRootPresenter: RootViewPresenter {
}
}

var meViewController: MeViewController?
// MARK: Me

func showMeScreen(completion: ((MeViewController) -> Void)?) {
if isDisplayingTabBar {
Expand Down

0 comments on commit 9edd5d2

Please sign in to comment.