State restoration
This commit is contained in:
parent
b7a4f369f6
commit
7d4f5ccba3
|
@ -27,7 +27,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||
window = UIWindow(windowScene: windowScene)
|
||||
window!.tintColor = .appTintColor
|
||||
|
||||
var activity = connectionOptions.userActivities.first
|
||||
var activity = connectionOptions.userActivities.first ?? session.stateRestorationActivity
|
||||
|
||||
var account = LocalData.mostRecentAccount()
|
||||
|
||||
|
@ -108,6 +108,10 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||
// to restore the scene back to its current state.
|
||||
}
|
||||
|
||||
func stateRestorationActivity(for scene: UIScene) -> NSUserActivity? {
|
||||
return (window!.rootViewController as! AppSplitViewController).stateRestorationActivity()
|
||||
}
|
||||
|
||||
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
|
||||
Task { @MainActor in
|
||||
await setupUI(from: userActivity)
|
||||
|
|
|
@ -54,6 +54,27 @@ class AppSplitViewController: UISplitViewController {
|
|||
setViewController(nav, for: .compact)
|
||||
}
|
||||
|
||||
func stateRestorationActivity() -> NSUserActivity? {
|
||||
if traitCollection.horizontalSizeClass == .compact {
|
||||
let nav = viewController(for: .compact) as! UINavigationController
|
||||
let top = nav.topViewController!
|
||||
if top is ReadViewController || top is ItemsViewController {
|
||||
print(top.userActivity?.activityType)
|
||||
return top.userActivity
|
||||
}
|
||||
} else {
|
||||
if let read = secondaryNav.topViewController {
|
||||
return read.userActivity
|
||||
} else {
|
||||
let homeNav = viewController(for: .primary) as! UINavigationController
|
||||
if homeNav.topViewController is ItemsViewController {
|
||||
return homeNav.topViewController!.userActivity
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func showItemList(_ type: ItemListType) {
|
||||
let column: Column
|
||||
if traitCollection.horizontalSizeClass == .compact {
|
||||
|
|
Loading…
Reference in New Issue