diff --git a/Passepartout-iOS/Scenes/Organizer/ShortcutsAddViewController.swift b/Passepartout-iOS/Scenes/Organizer/ShortcutsAddViewController.swift index 0863df67..58879c08 100644 --- a/Passepartout-iOS/Scenes/Organizer/ShortcutsAddViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/ShortcutsAddViewController.swift @@ -29,9 +29,9 @@ import Passepartout_Core @available(iOS 12, *) protocol ShortcutsAddViewControllerDelegate: class { - func shortcutAddController(_ controller: ShortcutsAddViewController, voiceShortcut: INVoiceShortcut) + func shortcutAddController(_ controller: UIViewController?, voiceShortcut: INVoiceShortcut) - func shortcutAddControllerDidCancel(_ controller: ShortcutsAddViewController) + func shortcutAddControllerDidCancel(_ controller: UIViewController?) } @available(iOS 12, *) @@ -157,6 +157,12 @@ class ShortcutsAddViewController: UITableViewController, INUIAddVoiceShortcutVie } // MARK: Actions + + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + if let vc = segue.destination as? ShortcutsConnectToViewController { + vc.delegate = delegate + } + } private func addConnect() { guard TransientStore.shared.service.hasProfiles() else { diff --git a/Passepartout-iOS/Scenes/Organizer/ShortcutsConnectToViewController.swift b/Passepartout-iOS/Scenes/Organizer/ShortcutsConnectToViewController.swift index 195d851b..055f0b97 100644 --- a/Passepartout-iOS/Scenes/Organizer/ShortcutsConnectToViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/ShortcutsConnectToViewController.swift @@ -38,6 +38,8 @@ class ShortcutsConnectToViewController: UITableViewController, ProviderPoolViewC private var selectedProfile: ConnectionProfile? + weak var delegate: ShortcutsAddViewControllerDelegate? + // MARK: TableModelHost let model: TableModel = { @@ -187,11 +189,14 @@ class ShortcutsConnectToViewController: UITableViewController, ProviderPoolViewC // MARK: INUIAddVoiceShortcutViewControllerDelegate func addVoiceShortcutViewController(_ controller: INUIAddVoiceShortcutViewController, didFinishWith voiceShortcut: INVoiceShortcut?, error: Error?) { - navigationController?.popViewController(animated: true) - dismiss(animated: true, completion: nil) + guard let voiceShortcut = voiceShortcut else { + delegate?.shortcutAddControllerDidCancel(nil) + return + } + delegate?.shortcutAddController(nil, voiceShortcut: voiceShortcut) } func addVoiceShortcutViewControllerDidCancel(_ controller: INUIAddVoiceShortcutViewController) { - dismiss(animated: true, completion: nil) + delegate?.shortcutAddControllerDidCancel(nil) } } diff --git a/Passepartout-iOS/Scenes/Organizer/ShortcutsEditViewController.swift b/Passepartout-iOS/Scenes/Organizer/ShortcutsEditViewController.swift index 4e03c944..dbd8d60b 100644 --- a/Passepartout-iOS/Scenes/Organizer/ShortcutsEditViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/ShortcutsEditViewController.swift @@ -195,7 +195,7 @@ class ShortcutsEditViewController: UITableViewController, INUIEditVoiceShortcutV // MARK: ShortcutsAddViewControllerDelegate - func shortcutAddController(_ controller: ShortcutsAddViewController, voiceShortcut: INVoiceShortcut) { + func shortcutAddController(_ controller: UIViewController?, voiceShortcut: INVoiceShortcut) { wrappers?.append(ShortcutWrapper.from(voiceShortcut)) wrappers?.sort() reloadModel() @@ -205,7 +205,7 @@ class ShortcutsEditViewController: UITableViewController, INUIEditVoiceShortcutV dismiss(animated: true, completion: nil) } - func shortcutAddControllerDidCancel(_ controller: ShortcutsAddViewController) { + func shortcutAddControllerDidCancel(_ controller: UIViewController?) { dismiss(animated: true, completion: nil) }