File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ final class ReaderPresenter: NSObject, SplitViewDisplayable {
1414 var secondary : UINavigationController
1515
1616 /// The navigation controller for the main content when shown using tabs.
17- private let mainNavigationController = UINavigationController ( )
17+ private var mainNavigationController = UINavigationController ( )
1818 private var latestContentVC : UIViewController ?
1919
2020 private var viewContext : NSManagedObjectContext {
@@ -37,12 +37,14 @@ final class ReaderPresenter: NSObject, SplitViewDisplayable {
3737
3838 // TODO: (reader) update to allow seamless transitions between split view and tabs
3939 @objc func prepareForTabBarPresentation( ) -> UINavigationController {
40+ sidebar. onViewDidLoad = { [ weak self] in
41+ self ? . showInitialSelection ( )
42+ }
4043 sidebarViewModel. isCompact = true
4144 sidebarViewModel. restoreSelection ( defaultValue: nil )
4245 mainNavigationController. navigationBar. prefersLargeTitles = true
43- mainNavigationController. viewControllers = [ sidebar]
46+ mainNavigationController = UINavigationController ( rootViewController : sidebar) // Loads sidebar lazily
4447 sidebar. navigationItem. backButtonDisplayMode = . minimal
45- showInitialSelection ( )
4648 return mainNavigationController
4749 }
4850
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ final class ReaderSidebarViewController: UIHostingController<AnyView> {
99 private var viewContext : NSManagedObjectContext { ContextManager . shared. mainContext }
1010 var didAppear = false
1111
12+ var onViewDidLoad : ( ( ) -> Void ) ?
13+
1214 init ( viewModel: ReaderSidebarViewModel ) {
1315 self . viewModel = viewModel
1416 // - warning: The `managedObjectContext` has to be set here in order for
@@ -25,6 +27,12 @@ final class ReaderSidebarViewController: UIHostingController<AnyView> {
2527 fatalError ( " init(coder:) has not been implemented " )
2628 }
2729
30+ override func viewDidLoad( ) {
31+ super. viewDidLoad ( )
32+
33+ onViewDidLoad ? ( )
34+ }
35+
2836 override func viewWillAppear( _ animated: Bool ) {
2937 super. viewWillAppear ( animated)
3038
You can’t perform that action at this time.
0 commit comments