Merge pull request #2277 from keymanapp/ios-dark-mode

[iOS] Basic dark mode implementation
This commit is contained in:
Marc Durdin 2019-11-11 15:35:43 +11:00 committed by GitHub
commit 0fc17a02eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 3 deletions

View file

@ -81,8 +81,6 @@
</array>
<key>UISupportsDocumentBrowser</key>
<false/>
<key>UIUserInterfaceStyle</key>
<string>Light</string>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>

View file

@ -68,7 +68,15 @@ class GetStartedViewController: UIViewController, UITableViewDelegate, UITableVi
footer.addSubview(label)
footer.addSubview(dontShowAgainSwitch)
footer.addSubview(line)
footer.backgroundColor = UIColor(white: 1.0, alpha: 1.0)
if #available(iOS 13.0, *) {
// Allows "dark mode" adjustment
footer.backgroundColor = UIColor.systemBackground
} else {
// Default "light mode" styling.
footer.backgroundColor = UIColor(white: 1.0, alpha: 1.0)
}
tableView.tableHeaderView = header
tableView.tableFooterView = footer
}

View file

@ -143,6 +143,7 @@ class MainViewController: UIViewController, TextViewDelegate, UIActionSheetDeleg
Manager.shared.apiKeyboardRepository.fetch()
Manager.shared.apiLexicalModelRepository.fetch()
// TODO: For dark mode implementation, we'll need to change the color here.
let bgColor = UIColor(red: 1.0, green: 1.0, blue: 207.0 / 255.0, alpha: 1.0)
view?.backgroundColor = bgColor
@ -169,6 +170,20 @@ class MainViewController: UIViewController, TextViewDelegate, UIActionSheetDeleg
// Setup NavigationBar
if let navbar = navigationController?.navigationBar {
if #available(iOS 13.0, *) {
// Dark mode settings must be applied through this new property,
// its class, and others like it.
navbar.standardAppearance.configureWithOpaqueBackground()
// The various options we offer at the top level need significant
// image work to be properly dark-mode ready.
//
// This simply overrides it to have a "light mode" appearance,
// even in dark mode. It's a small bar, so there should be little issue.
navbar.standardAppearance.backgroundColor = UIColor.white
} else {
// Fallback on earlier versions
}
navbarBackground = KMNavigationBarBackgroundView()
navbarBackground.addToNavbar(navbar)
navbarBackground.setOrientation(UIApplication.shared.statusBarOrientation)
@ -183,6 +198,7 @@ class MainViewController: UIViewController, TextViewDelegate, UIActionSheetDeleg
textView.isScrollEnabled = true
textView.isUserInteractionEnabled = true
textView.font = textView.font?.withSize(textSize)
textView.textColor = UIColor.black // Dark mode will use white otherwise
view?.addSubview(textView!)
// Setup Info View