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> </barButtonItem>
</navigationItem> </navigationItem>
<connections> <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> </connections>
</tableViewController> </tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="s4j-l7-Hi8" userLabel="First Responder" sceneMemberID="firstResponder"/> <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 detailTitleDisplayMode: UINavigationItem.LargeTitleDisplayMode
var modalPresentationStyle: UIModalPresentationStyle
private init() { private init() {
palette = Palette() palette = Palette()
masterTitleDisplayMode = .never masterTitleDisplayMode = .never
detailTitleDisplayMode = .never detailTitleDisplayMode = .never
modalPresentationStyle = .formSheet
} }
} }
@ -150,6 +153,8 @@ extension UIActivityIndicatorView {
// XXX: status bar is broken // XXX: status bar is broken
extension MFMailComposeViewController { extension MFMailComposeViewController {
func apply(_ theme: Theme) { func apply(_ theme: Theme) {
modalPresentationStyle = theme.modalPresentationStyle
let bar = navigationBar let bar = navigationBar
bar.barTintColor = theme.palette.primaryBackground bar.barTintColor = theme.palette.primaryBackground
bar.tintColor = theme.palette.primaryLightText 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 // MARK: Actions
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
@ -148,6 +136,20 @@ class ShortcutsViewController: UITableViewController, INUIAddVoiceShortcutViewCo
tableView.reloadData() 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() { @IBAction private func close() {
dismiss(animated: true, completion: nil) dismiss(animated: true, completion: nil)
} }
@ -203,6 +205,7 @@ class ShortcutsViewController: UITableViewController, INUIAddVoiceShortcutViewCo
break break
} }
let vc = INUIEditVoiceShortcutViewController(voiceShortcut: wrapper.original) let vc = INUIEditVoiceShortcutViewController(voiceShortcut: wrapper.original)
vc.modalPresentationStyle = Theme.current.modalPresentationStyle
vc.delegate = self vc.delegate = self
editedIndexPath = indexPath editedIndexPath = indexPath
present(vc, animated: true, completion: nil) present(vc, animated: true, completion: nil)
@ -216,7 +219,9 @@ class ShortcutsViewController: UITableViewController, INUIAddVoiceShortcutViewCo
func shortcutsDidSelectIntent(intent: INIntent) { func shortcutsDidSelectIntent(intent: INIntent) {
pendingShortcut = INShortcut(intent: intent) pendingShortcut = INShortcut(intent: intent)
dismiss(animated: true, completion: nil) dismiss(animated: true) {
self.finishAddingPendingShortcut()
}
} }
// MARK: INUIAddVoiceShortcutViewControllerDelegate // MARK: INUIAddVoiceShortcutViewControllerDelegate