Use form sheet presentation in more vcs

- Shortcuts
- Mail composers

BEWARE: viewDidAppear is NOT called, move code to dismiss callback.
This commit is contained in:
Davide De Rosa 2019-04-09 10:34:19 +02:00
parent f630087ba8
commit fca1aee73e
3 changed files with 24 additions and 14 deletions

View File

@ -198,7 +198,7 @@
</barButtonItem>
</navigationItem>
<connections>
<segue destination="6Cw-6b-1Xa" kind="presentation" identifier="ShortcutAddSegueIdentifier" id="Mnc-d9-blv"/>
<segue destination="6Cw-6b-1Xa" kind="presentation" identifier="ShortcutAddSegueIdentifier" modalPresentationStyle="formSheet" id="Mnc-d9-blv"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="s4j-l7-Hi8" userLabel="First Responder" sceneMemberID="firstResponder"/>

View File

@ -81,10 +81,13 @@ struct Theme {
var detailTitleDisplayMode: UINavigationItem.LargeTitleDisplayMode
var modalPresentationStyle: UIModalPresentationStyle
private init() {
palette = Palette()
masterTitleDisplayMode = .never
detailTitleDisplayMode = .never
modalPresentationStyle = .formSheet
}
}
@ -150,6 +153,8 @@ extension UIActivityIndicatorView {
// XXX: status bar is broken
extension MFMailComposeViewController {
func apply(_ theme: Theme) {
modalPresentationStyle = theme.modalPresentationStyle
let bar = navigationBar
bar.barTintColor = theme.palette.primaryBackground
bar.tintColor = theme.palette.primaryLightText

View File

@ -104,18 +104,6 @@ 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
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
@ -147,6 +135,20 @@ class ShortcutsViewController: UITableViewController, INUIAddVoiceShortcutViewCo
reloadModel()
tableView.reloadData()
}
private func finishAddingPendingShortcut() {
guard let shortcut = pendingShortcut else {
return
}
if let ip = tableView.indexPathForSelectedRow {
tableView.deselectRow(at: ip, animated: true)
}
pendingShortcut = nil
let vc = INUIAddVoiceShortcutViewController(shortcut: shortcut)
vc.modalPresentationStyle = Theme.current.modalPresentationStyle
vc.delegate = self
present(vc, animated: true, completion: nil)
}
@IBAction private func close() {
dismiss(animated: true, completion: nil)
@ -203,6 +205,7 @@ class ShortcutsViewController: UITableViewController, INUIAddVoiceShortcutViewCo
break
}
let vc = INUIEditVoiceShortcutViewController(voiceShortcut: wrapper.original)
vc.modalPresentationStyle = Theme.current.modalPresentationStyle
vc.delegate = self
editedIndexPath = indexPath
present(vc, animated: true, completion: nil)
@ -216,7 +219,9 @@ class ShortcutsViewController: UITableViewController, INUIAddVoiceShortcutViewCo
func shortcutsDidSelectIntent(intent: INIntent) {
pendingShortcut = INShortcut(intent: intent)
dismiss(animated: true, completion: nil)
dismiss(animated: true) {
self.finishAddingPendingShortcut()
}
}
// MARK: INUIAddVoiceShortcutViewControllerDelegate