From bacd510345945b0d9b59858b8b4a5dfc2d2c492b Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Tue, 19 Nov 2019 23:20:22 +0100 Subject: [PATCH] Create modal presentation theme --- Passepartout-iOS/AppDelegate.swift | 2 +- Passepartout-iOS/Global/Theme.swift | 6 ++++++ .../Scenes/Shortcuts/ShortcutsViewController.swift | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Passepartout-iOS/AppDelegate.swift b/Passepartout-iOS/AppDelegate.swift index 2cfd786f..9419c868 100644 --- a/Passepartout-iOS/AppDelegate.swift +++ b/Passepartout-iOS/AppDelegate.swift @@ -142,7 +142,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele wizard.parsingResult = parsingResult wizard.removesConfigurationOnCancel = true - wizardNav.modalPresentationStyle = .formSheet + wizardNav.applyModalPresentation(.current) target.present(wizardNav, animated: true, completion: nil) } } diff --git a/Passepartout-iOS/Global/Theme.swift b/Passepartout-iOS/Global/Theme.swift index 546028ba..46db848a 100644 --- a/Passepartout-iOS/Global/Theme.swift +++ b/Passepartout-iOS/Global/Theme.swift @@ -110,6 +110,12 @@ extension Theme { } } +extension UIViewController { + func applyModalPresentation(_ theme: Theme) { + modalPresentationStyle = theme.modalPresentationStyle + } +} + extension UIView { func applyPrimaryBackground(_ theme: Theme) { backgroundColor = theme.palette.primaryBackground diff --git a/Passepartout-iOS/Scenes/Shortcuts/ShortcutsViewController.swift b/Passepartout-iOS/Scenes/Shortcuts/ShortcutsViewController.swift index 7bd98717..52accb15 100644 --- a/Passepartout-iOS/Scenes/Shortcuts/ShortcutsViewController.swift +++ b/Passepartout-iOS/Scenes/Shortcuts/ShortcutsViewController.swift @@ -146,7 +146,7 @@ class ShortcutsViewController: UITableViewController, INUIAddVoiceShortcutViewCo } pendingShortcut = nil let vc = INUIAddVoiceShortcutViewController(shortcut: shortcut) - vc.modalPresentationStyle = Theme.current.modalPresentationStyle + vc.applyModalPresentation(.current) vc.delegate = self present(vc, animated: true, completion: nil) } @@ -206,7 +206,7 @@ class ShortcutsViewController: UITableViewController, INUIAddVoiceShortcutViewCo break } let vc = INUIEditVoiceShortcutViewController(voiceShortcut: wrapper.original) - vc.modalPresentationStyle = Theme.current.modalPresentationStyle + vc.applyModalPresentation(.current) vc.delegate = self editedIndexPath = indexPath present(vc, animated: true, completion: nil)