Show shortcut add on viewDidAppear

This commit is contained in:
Davide De Rosa 2019-03-27 22:36:23 +01:00
parent 37cb568142
commit 77658e5cc6
1 changed files with 16 additions and 10 deletions

View File

@ -66,6 +66,8 @@ private struct ShortcutWrapper: Comparable {
class ShortcutsViewController: UITableViewController, INUIAddVoiceShortcutViewControllerDelegate, INUIEditVoiceShortcutViewControllerDelegate, ShortcutsIntentDelegate, TableModelHost { class ShortcutsViewController: UITableViewController, INUIAddVoiceShortcutViewControllerDelegate, INUIEditVoiceShortcutViewControllerDelegate, ShortcutsIntentDelegate, TableModelHost {
private var wrappers: [ShortcutWrapper]? private var wrappers: [ShortcutWrapper]?
private var pendingShortcut: INShortcut?
private var editedIndexPath: IndexPath? private var editedIndexPath: IndexPath?
// MARK: TableModel // MARK: TableModel
@ -102,6 +104,18 @@ class ShortcutsViewController: UITableViewController, INUIAddVoiceShortcutViewCo
} }
} }
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
guard let shortcut = pendingShortcut else {
return
}
pendingShortcut = nil
let vc = INUIAddVoiceShortcutViewController(shortcut: shortcut)
vc.delegate = self
present(vc, animated: true, completion: nil)
}
// MARK: Actions // MARK: Actions
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
@ -201,16 +215,8 @@ class ShortcutsViewController: UITableViewController, INUIAddVoiceShortcutViewCo
// MARK: ShortcutsIntentDelegate // MARK: ShortcutsIntentDelegate
func shortcutsDidSelectIntent(intent: INIntent) { func shortcutsDidSelectIntent(intent: INIntent) {
guard let shortcut = INShortcut(intent: intent) else { pendingShortcut = INShortcut(intent: intent)
return navigationController?.popToViewController(self, animated: true)
}
navigationController?.popToRootViewController(animated: true)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
let vc = INUIAddVoiceShortcutViewController(shortcut: shortcut)
vc.delegate = self
self.present(vc, animated: true, completion: nil)
}
} }
// MARK: INUIAddVoiceShortcutViewControllerDelegate // MARK: INUIAddVoiceShortcutViewControllerDelegate