From 05d4f845f286766c9858596487326b7c43d40a6b Mon Sep 17 00:00:00 2001 From: jahorton Date: Wed, 30 Oct 2019 16:01:50 +0700 Subject: [PATCH 1/2] fix(ios): Basic dark-mode; perma-light main navbar --- ios/keyman/Keyman/Keyman-Info.plist | 2 -- .../GetStartedViewController.swift | 10 +++++++- .../Keyman/Keyman/MainViewController.swift | 24 ++++++++++++++++++- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/ios/keyman/Keyman/Keyman-Info.plist b/ios/keyman/Keyman/Keyman-Info.plist index 9b8e9c9b59..2263aad0d4 100644 --- a/ios/keyman/Keyman/Keyman-Info.plist +++ b/ios/keyman/Keyman/Keyman-Info.plist @@ -81,8 +81,6 @@ UISupportsDocumentBrowser - UIUserInterfaceStyle - Light UTExportedTypeDeclarations diff --git a/ios/keyman/Keyman/Keyman/GetStartedViewController/GetStartedViewController.swift b/ios/keyman/Keyman/Keyman/GetStartedViewController/GetStartedViewController.swift index 0053d428d8..b4c6a4b362 100644 --- a/ios/keyman/Keyman/Keyman/GetStartedViewController/GetStartedViewController.swift +++ b/ios/keyman/Keyman/Keyman/GetStartedViewController/GetStartedViewController.swift @@ -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 } diff --git a/ios/keyman/Keyman/Keyman/MainViewController.swift b/ios/keyman/Keyman/Keyman/MainViewController.swift index a0218c92f7..cca7b36673 100644 --- a/ios/keyman/Keyman/Keyman/MainViewController.swift +++ b/ios/keyman/Keyman/Keyman/MainViewController.swift @@ -143,7 +143,14 @@ class MainViewController: UIViewController, TextViewDelegate, UIActionSheetDeleg Manager.shared.apiKeyboardRepository.fetch() Manager.shared.apiLexicalModelRepository.fetch() - let bgColor = UIColor(red: 1.0, green: 1.0, blue: 207.0 / 255.0, alpha: 1.0) + var bgColor: UIColor +// // Select an appropriate background color for the theme. +// if #available(iOS 13.0, *) { +// bgColor = UIColor.secondarySystemBackground +// } else { +// // Fallback on earlier versions + bgColor = UIColor(red: 1.0, green: 1.0, blue: 207.0 / 255.0, alpha: 1.0) + //} view?.backgroundColor = bgColor // Check for configuration profiles/fonts to install @@ -169,6 +176,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 +204,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 From 18450a4463519679e0da0a3c40ba9df31485d107 Mon Sep 17 00:00:00 2001 From: jahorton Date: Mon, 4 Nov 2019 09:50:26 +0700 Subject: [PATCH 2/2] change(ios): PR artifact cleanup for #2277 --- ios/keyman/Keyman/Keyman/MainViewController.swift | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ios/keyman/Keyman/Keyman/MainViewController.swift b/ios/keyman/Keyman/Keyman/MainViewController.swift index cca7b36673..47572ab10d 100644 --- a/ios/keyman/Keyman/Keyman/MainViewController.swift +++ b/ios/keyman/Keyman/Keyman/MainViewController.swift @@ -143,14 +143,8 @@ class MainViewController: UIViewController, TextViewDelegate, UIActionSheetDeleg Manager.shared.apiKeyboardRepository.fetch() Manager.shared.apiLexicalModelRepository.fetch() - var bgColor: UIColor -// // Select an appropriate background color for the theme. -// if #available(iOS 13.0, *) { -// bgColor = UIColor.secondarySystemBackground -// } else { -// // Fallback on earlier versions - bgColor = UIColor(red: 1.0, green: 1.0, blue: 207.0 / 255.0, alpha: 1.0) - //} + // 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 // Check for configuration profiles/fonts to install