Uses SceneCoordinator
Adds a `func` to SceneCoordinator to handle dismisses vis-a-vis using notifications.
This commit is contained in:
parent
0469d81c62
commit
8b39dc4abb
@ -211,9 +211,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|||||||
if let sceneDelegate = response.targetScene?.delegate as? SceneDelegate {
|
if let sceneDelegate = response.targetScene?.delegate as? SceneDelegate {
|
||||||
sceneDelegate.handle(response)
|
sceneDelegate.handle(response)
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
|
||||||
NotificationCenter.default.post(name: .DidLaunchFromExternalAction, object: nil)
|
sceneDelegate.coordinator.dismissIfLaunchingFromExternalAction()
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,6 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
|||||||
NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange), name: UIContentSizeCategory.didChangeNotification, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange), name: UIContentSizeCategory.didChangeNotification, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground(_:)), name: UIApplication.willEnterForegroundNotification, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground(_:)), name: UIApplication.willEnterForegroundNotification, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(configureContextMenu(_:)), name: .ActiveExtensionPointsDidChange, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(configureContextMenu(_:)), name: .ActiveExtensionPointsDidChange, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(didLaunchFromExternalAction), name: .DidLaunchFromExternalAction, object: nil)
|
|
||||||
|
|
||||||
refreshControl = UIRefreshControl()
|
refreshControl = UIRefreshControl()
|
||||||
refreshControl!.addTarget(self, action: #selector(refreshAccounts(_:)), for: .valueChanged)
|
refreshControl!.addTarget(self, action: #selector(refreshAccounts(_:)), for: .valueChanged)
|
||||||
@ -689,12 +688,6 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func didLaunchFromExternalAction() {
|
|
||||||
guard let presentedController = presentedViewController as? SFSafariViewController else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
presentedController.dismiss(animated: true, completion: nil)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: UIContextMenuInteractionDelegate
|
// MARK: UIContextMenuInteractionDelegate
|
||||||
|
@ -1327,6 +1327,23 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This will dismiss the foremost view controller if the user
|
||||||
|
/// has launched from an external action (i.e., a widget tap, or
|
||||||
|
/// selecting an artice via a notification).
|
||||||
|
///
|
||||||
|
/// The dismiss is only applicable if the view controller is a
|
||||||
|
/// `SFSafariViewController` or `SettingsViewController`,
|
||||||
|
/// otherwise, this function does nothing.
|
||||||
|
func dismissIfLaunchingFromExternalAction() {
|
||||||
|
guard let presentedController = masterFeedViewController.presentedViewController else { return }
|
||||||
|
|
||||||
|
if presentedController.isKind(of: SFSafariViewController.self) {
|
||||||
|
presentedController.dismiss(animated: true, completion: nil)
|
||||||
|
}
|
||||||
|
guard let settings = presentedController.children.first as? SettingsViewController else { return }
|
||||||
|
settings.dismiss(animated: true, completion: nil)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: UISplitViewControllerDelegate
|
// MARK: UISplitViewControllerDelegate
|
||||||
|
@ -11,10 +11,6 @@ import UserNotifications
|
|||||||
import Account
|
import Account
|
||||||
import Zip
|
import Zip
|
||||||
|
|
||||||
public extension Notification.Name {
|
|
||||||
static let DidLaunchFromExternalAction = Notification.Name("DidLaunchFromExternalAction")
|
|
||||||
}
|
|
||||||
|
|
||||||
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||||
|
|
||||||
var window: UIWindow?
|
var window: UIWindow?
|
||||||
@ -111,7 +107,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||||
NotificationCenter.default.post(name: .DidLaunchFromExternalAction, object: nil)
|
self.coordinator.dismissIfLaunchingFromExternalAction()
|
||||||
}
|
}
|
||||||
|
|
||||||
let urlString = context.url.absoluteString
|
let urlString = context.url.absoluteString
|
||||||
|
@ -38,7 +38,6 @@ class SettingsViewController: UITableViewController {
|
|||||||
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange), name: .UserDidDeleteAccount, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange), name: .UserDidDeleteAccount, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange), name: .DisplayNameDidChange, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange), name: .DisplayNameDidChange, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(activeExtensionPointsDidChange), name: .ActiveExtensionPointsDidChange, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(activeExtensionPointsDidChange), name: .ActiveExtensionPointsDidChange, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(didLaunchFromExternalAction), name: .DidLaunchFromExternalAction, object: nil)
|
|
||||||
|
|
||||||
|
|
||||||
tableView.register(UINib(nibName: "SettingsComboTableViewCell", bundle: nil), forCellReuseIdentifier: "SettingsComboTableViewCell")
|
tableView.register(UINib(nibName: "SettingsComboTableViewCell", bundle: nil), forCellReuseIdentifier: "SettingsComboTableViewCell")
|
||||||
@ -390,10 +389,6 @@ class SettingsViewController: UITableViewController {
|
|||||||
tableView.reloadData()
|
tableView.reloadData()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func didLaunchFromExternalAction() {
|
|
||||||
dismiss(animated: true, completion: nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: OPML Document Picker
|
// MARK: OPML Document Picker
|
||||||
|
Loading…
x
Reference in New Issue
Block a user