Merge branch 'refactor-theme'

This commit is contained in:
Davide De Rosa 2019-11-19 23:20:57 +01:00
commit c33e087f0c
15 changed files with 9 additions and 85 deletions

View File

@ -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)
}
}

View File

@ -26,16 +26,6 @@
import UIKit
import Convenience
extension UIViewController {
func applyMasterTitle(_ theme: Theme) {
navigationItem.largeTitleDisplayMode = theme.masterTitleDisplayMode
}
func applyDetailTitle(_ theme: Theme) {
navigationItem.largeTitleDisplayMode = theme.detailTitleDisplayMode
}
}
extension StrongTableModel {
func headerHeight(for section: Int) -> CGFloat {
guard let title = header(forSection: section) else {

View File

@ -82,16 +82,10 @@ struct Theme {
var palette: Palette
var masterTitleDisplayMode: UINavigationItem.LargeTitleDisplayMode
var detailTitleDisplayMode: UINavigationItem.LargeTitleDisplayMode
var modalPresentationStyle: UIModalPresentationStyle
private init() {
palette = Palette()
masterTitleDisplayMode = .never
detailTitleDisplayMode = .never
modalPresentationStyle = .formSheet
}
}
@ -116,6 +110,12 @@ extension Theme {
}
}
extension UIViewController {
func applyModalPresentation(_ theme: Theme) {
modalPresentationStyle = theme.modalPresentationStyle
}
}
extension UIView {
func applyPrimaryBackground(_ theme: Theme) {
backgroundColor = theme.palette.primaryBackground

View File

@ -53,12 +53,6 @@ class AboutViewController: UITableViewController, StrongTableHost {
// MARK: UIViewController
override func awakeFromNib() {
super.awakeFromNib()
applyDetailTitle(.current)
}
override func viewDidLoad() {
super.viewDidLoad()

View File

@ -37,12 +37,6 @@ class LabelViewController: UIViewController {
var license: AppConstants.License?
override func awakeFromNib() {
super.awakeFromNib()
applyDetailTitle(.current)
}
override func viewDidLoad() {
super.viewDidLoad()

View File

@ -134,12 +134,6 @@ class AccountViewController: UIViewController, StrongTableHost {
// MARK: UIViewController
override func awakeFromNib() {
super.awakeFromNib()
applyDetailTitle(.current)
}
override func viewDidLoad() {
super.viewDidLoad()

View File

@ -90,12 +90,6 @@ class ConfigurationViewController: UIViewController, StrongTableHost {
// MARK: UIViewController
override func awakeFromNib() {
super.awakeFromNib()
applyDetailTitle(.current)
}
override func viewDidLoad() {
super.viewDidLoad()

View File

@ -38,12 +38,6 @@ class DebugLogViewController: UIViewController {
NotificationCenter.default.removeObserver(self)
}
override func awakeFromNib() {
super.awakeFromNib()
applyDetailTitle(.current)
}
// MARK: UIViewController
override func viewDidLoad() {

View File

@ -91,12 +91,6 @@ class EndpointViewController: UIViewController, StrongTableHost {
// MARK: UIViewController
override func awakeFromNib() {
super.awakeFromNib()
applyDetailTitle(.current)
}
override func viewDidLoad() {
super.viewDidLoad()

View File

@ -104,12 +104,6 @@ class OrganizerViewController: UITableViewController, StrongTableHost {
NotificationCenter.default.removeObserver(self)
}
override func awakeFromNib() {
super.awakeFromNib()
applyMasterTitle(.current)
}
override func viewDidLoad() {
super.viewDidLoad()

View File

@ -64,12 +64,6 @@ class ProviderPoolViewController: UIViewController {
// MARK: UIViewController
override func awakeFromNib() {
super.awakeFromNib()
applyDetailTitle(.current)
}
override func viewDidLoad() {
super.viewDidLoad()

View File

@ -45,12 +45,6 @@ class ProviderPresetViewController: UIViewController {
// MARK: UIViewController
override func awakeFromNib() {
super.awakeFromNib()
applyDetailTitle(.current)
}
override func viewDidLoad() {
super.viewDidLoad()

View File

@ -113,12 +113,6 @@ class ServerNetworkViewController: UITableViewController, StrongTableHost {
// MARK: UIViewController
override func awakeFromNib() {
super.awakeFromNib()
applyDetailTitle(.current)
}
override func viewDidLoad() {
super.viewDidLoad()

View File

@ -87,12 +87,6 @@ class ServiceViewController: UIViewController, StrongTableHost {
}
}
override func awakeFromNib() {
super.awakeFromNib()
applyDetailTitle(.current)
}
override func viewDidLoad() {
super.viewDidLoad()

View File

@ -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)