From a935e4c8fa3d7165fcc121d78b7e455265a09fdb Mon Sep 17 00:00:00 2001 From: jahorton Date: Mon, 4 Nov 2019 15:09:08 +0700 Subject: [PATCH] feat(ios): main text view - dark theme support --- .../Keyman/Keyman.xcodeproj/project.pbxproj | 4 ++ .../Keyman/Keyman/MainViewController.swift | 9 +++-- .../Keyman/Keyman/MainViewController_.xib | 9 ++--- .../Themes+Colors.xcassets/Contents.json | 6 +++ .../InputBackground.colorset/Contents.json | 38 +++++++++++++++++++ 5 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 ios/keyman/Keyman/Keyman/Themes+Colors.xcassets/Contents.json create mode 100644 ios/keyman/Keyman/Keyman/Themes+Colors.xcassets/InputBackground.colorset/Contents.json diff --git a/ios/keyman/Keyman/Keyman.xcodeproj/project.pbxproj b/ios/keyman/Keyman/Keyman.xcodeproj/project.pbxproj index 8e81b66515..d8ba19390b 100644 --- a/ios/keyman/Keyman/Keyman.xcodeproj/project.pbxproj +++ b/ios/keyman/Keyman/Keyman.xcodeproj/project.pbxproj @@ -134,6 +134,7 @@ CE2B1E4C21B6112B007D092E /* DeviceKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE2B1E4B21B6112B007D092E /* DeviceKit.framework */; }; CE6138011FB99538009D0EF2 /* KeymanEngine.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = CE6137FF1FB99538009D0EF2 /* KeymanEngine.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; CE6138021FB999C8009D0EF2 /* KeymanEngine.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE6138031FB999C8009D0EF2 /* KeymanEngine.framework */; }; + CE79CDB52370111200010C06 /* Themes+Colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CE79CDB42370111200010C06 /* Themes+Colors.xcassets */; }; CE7C1AE2236925D800100C2C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CE7C1AE1236925D800100C2C /* LaunchScreen.storyboard */; }; /* End PBXBuildFile section */ @@ -297,6 +298,7 @@ CE2B1E4B21B6112B007D092E /* DeviceKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DeviceKit.framework; path = ../../Carthage/Build/iOS/DeviceKit.framework; sourceTree = ""; }; CE6137FF1FB99538009D0EF2 /* KeymanEngine.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = KeymanEngine.framework; sourceTree = BUILT_PRODUCTS_DIR; }; CE6138031FB999C8009D0EF2 /* KeymanEngine.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = KeymanEngine.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + CE79CDB42370111200010C06 /* Themes+Colors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Themes+Colors.xcassets"; sourceTree = ""; }; CE7C1AE1236925D800100C2C /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; /* End PBXFileReference section */ @@ -511,6 +513,7 @@ 162E2C9420926C8600F40769 /* Classes */, 9845A7BE1A439A9200544E2E /* GetStartedViewController */, 98C893F119F0811A000B9AC8 /* Images.xcassets */, + CE79CDB42370111200010C06 /* Themes+Colors.xcassets */, 9845A7C21A439A9200544E2E /* InfoViewController */, 984FA1E21974B06C0037EE5D /* Keyman.entitlements */, 9845A7B71A4398B200544E2E /* DropDownList */, @@ -825,6 +828,7 @@ 9845A8D91A439F1000544E2E /* UIButtonBarStop@2x.png in Resources */, 9845A8D31A439F1000544E2E /* 786-browser@2x.png in Resources */, 981AFACF19EF44DE006706BF /* textsize_selected@2x.png in Resources */, + CE79CDB52370111200010C06 /* Themes+Colors.xcassets in Resources */, CE1F5ECE23331DA400141F3E /* OfflineHelp.bundle in Resources */, 981AFAD319EF44DE006706BF /* navbar-Landscape-568h@2x.png in Resources */, 9845A8CC1A439F1000544E2E /* 715-globe-toolbar.png in Resources */, diff --git a/ios/keyman/Keyman/Keyman/MainViewController.swift b/ios/keyman/Keyman/Keyman/MainViewController.swift index 47572ab10d..ba10a24975 100644 --- a/ios/keyman/Keyman/Keyman/MainViewController.swift +++ b/ios/keyman/Keyman/Keyman/MainViewController.swift @@ -143,8 +143,12 @@ 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) + // Implement a default color... + var bgColor = UIColor(red: 1.0, green: 1.0, blue: 207.0 / 255.0, alpha: 1.0) + // And if the iOS version is current enough, override it from the palette. + if #available(iOS 11.0, *) { + bgColor = UIColor(named: "InputBackground")! + } view?.backgroundColor = bgColor // Check for configuration profiles/fonts to install @@ -198,7 +202,6 @@ 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 diff --git a/ios/keyman/Keyman/Keyman/MainViewController_.xib b/ios/keyman/Keyman/Keyman/MainViewController_.xib index 47f2f55ca6..9e4bb17858 100644 --- a/ios/keyman/Keyman/Keyman/MainViewController_.xib +++ b/ios/keyman/Keyman/Keyman/MainViewController_.xib @@ -1,11 +1,9 @@ - - - - + + - + @@ -46,6 +44,7 @@ + diff --git a/ios/keyman/Keyman/Keyman/Themes+Colors.xcassets/Contents.json b/ios/keyman/Keyman/Keyman/Themes+Colors.xcassets/Contents.json new file mode 100644 index 0000000000..da4a164c91 --- /dev/null +++ b/ios/keyman/Keyman/Keyman/Themes+Colors.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ios/keyman/Keyman/Keyman/Themes+Colors.xcassets/InputBackground.colorset/Contents.json b/ios/keyman/Keyman/Keyman/Themes+Colors.xcassets/InputBackground.colorset/Contents.json new file mode 100644 index 0000000000..ddff24f08e --- /dev/null +++ b/ios/keyman/Keyman/Keyman/Themes+Colors.xcassets/InputBackground.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "1.000", + "alpha" : "1.000", + "blue" : "0.812", + "green" : "1.000" + } + } + }, + { + "idiom" : "universal", + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0.000", + "alpha" : "1.000", + "blue" : "0.188", + "green" : "0.000" + } + } + } + ] +} \ No newline at end of file