Document Controls: adds dark mode button
This commit is contained in:
@@ -41,6 +41,14 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat
|
||||
|
||||
private var commandKeyHeld: Bool = false
|
||||
|
||||
private var darkModeEnabled: Bool {
|
||||
get { tab.bridge.darkModeEnabled }
|
||||
set {
|
||||
tab.bridge.darkModeEnabled = newValue
|
||||
toolbarController.darkModeEnabled = newValue
|
||||
}
|
||||
}
|
||||
|
||||
override var preferredStatusBarStyle: UIStatusBarStyle { .lightContent }
|
||||
|
||||
init() {
|
||||
@@ -124,8 +132,7 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat
|
||||
|
||||
// Dark mode button
|
||||
toolbarController.darkModeButton.addAction(UIAction(handler: { [unowned self] _ in
|
||||
self.tab.bridge.darkModeEnabled = !self.tab.bridge.darkModeEnabled
|
||||
self.toolbarController.darkModeEnabled = self.tab.bridge.darkModeEnabled
|
||||
self.darkModeEnabled = !self.darkModeEnabled
|
||||
}), for: .touchUpInside)
|
||||
|
||||
// Tabs button
|
||||
@@ -192,7 +199,7 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat
|
||||
|
||||
// Font size adjust
|
||||
toolbarController.urlBar.documentButton.addAction(UIAction(handler: { [unowned self] _ in
|
||||
let documentControls = DocumentControlViewController()
|
||||
let documentControls = DocumentControlViewController(darkModeEnabled: tab.bridge.darkModeEnabled)
|
||||
documentControls.modalPresentationStyle = .popover
|
||||
documentControls.popoverPresentationController?.permittedArrowDirections = [ .down, .up ]
|
||||
documentControls.popoverPresentationController?.sourceView = toolbarController.urlBar.documentButton
|
||||
@@ -257,6 +264,12 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat
|
||||
}
|
||||
}, for: .touchUpInside)
|
||||
|
||||
// Dark mode
|
||||
documentControls.darkModeView.addAction(UIAction { [unowned self] _ in
|
||||
self.darkModeEnabled = !self.darkModeEnabled
|
||||
documentControls.dismiss(animated: true, completion: nil)
|
||||
}, for: .touchUpInside)
|
||||
|
||||
present(documentControls, animated: true, completion: nil)
|
||||
}), for: .touchUpInside)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user