Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 5 additions & 3 deletions WordPress/Classes/System/ReaderPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class ReaderPresenter: NSObject, SplitViewDisplayable {
var secondary: UINavigationController

/// The navigation controller for the main content when shown using tabs.
private let mainNavigationController = UINavigationController()
private var mainNavigationController = UINavigationController()
private var latestContentVC: UIViewController?

private var viewContext: NSManagedObjectContext {
Expand All @@ -37,12 +37,14 @@ final class ReaderPresenter: NSObject, SplitViewDisplayable {

// TODO: (reader) update to allow seamless transitions between split view and tabs
@objc func prepareForTabBarPresentation() -> UINavigationController {
sidebar.onViewDidLoad = { [weak self] in
self?.showInitialSelection()
}
sidebarViewModel.isCompact = true
sidebarViewModel.restoreSelection(defaultValue: nil)
mainNavigationController.navigationBar.prefersLargeTitles = true
mainNavigationController.viewControllers = [sidebar]
mainNavigationController = UINavigationController(rootViewController: sidebar) // Loads sidebar lazily
sidebar.navigationItem.backButtonDisplayMode = .minimal
showInitialSelection()
return mainNavigationController
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ final class ReaderSidebarViewController: UIHostingController<AnyView> {
private var viewContext: NSManagedObjectContext { ContextManager.shared.mainContext }
var didAppear = false

var onViewDidLoad: (() -> Void)?

init(viewModel: ReaderSidebarViewModel) {
self.viewModel = viewModel
// - warning: The `managedObjectContext` has to be set here in order for
Expand All @@ -25,6 +27,12 @@ final class ReaderSidebarViewController: UIHostingController<AnyView> {
fatalError("init(coder:) has not been implemented")
}

override func viewDidLoad() {
super.viewDidLoad()

onViewDidLoad?()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

Expand Down