From a1686f17f8397bc32779ab915eefca93eaac5fe1 Mon Sep 17 00:00:00 2001 From: ned Date: Tue, 4 Jun 2019 15:36:36 +0200 Subject: [PATCH] added darker theme for oled devices --- .../ILTranslucentView/ILTranslucentView.swift | 2 +- .../SwiftPullToRefresh/IndicatorView.swift | 2 +- .../ButtonFactory.swift" | 2 +- .../LoadingCollectionView.swift" | 2 +- .../LoadingTableView.swift" | 2 +- appdb/Startup/AppDelegate.swift | 6 +- appdb/Startup/Colors.swift | 64 +++++++++---------- appdb/Startup/Themes.swift | 19 ++++-- appdb/Tabs/Downloads/Downloads.swift | 2 +- .../Downloads/Library/Library+Extension.swift | 2 +- .../Download/Details+VersionHeader.swift | 2 +- appdb/Tabs/Featured/Details/Details.swift | 2 +- appdb/Tabs/Featured/See All/SeeAll.swift | 2 +- appdb/Tabs/Search/Search.swift | 2 +- .../Bulletins/EnterEmailBulletinPage.swift | 2 +- .../Bulletins/EnterLinkCodeBulletinPage.swift | 2 +- appdb/Tabs/Settings/News/News.swift | 2 +- appdb/Tabs/Settings/Settings+Sections.swift | 2 +- .../Tabs/Settings/Settings+StaticCells.swift | 2 +- .../Settings/Theme Chooser/ThemeChooser.swift | 19 ++---- appdb/en.lproj/Localizable.strings | 1 + appdb/es.lproj/Localizable.strings | 1 + appdb/it.lproj/Localizable.strings | 1 + 23 files changed, 74 insertions(+), 69 deletions(-) diff --git a/appdb/Resources/ILTranslucentView/ILTranslucentView.swift b/appdb/Resources/ILTranslucentView/ILTranslucentView.swift index 5a3a6033..49074b8e 100644 --- a/appdb/Resources/ILTranslucentView/ILTranslucentView.swift +++ b/appdb/Resources/ILTranslucentView/ILTranslucentView.swift @@ -119,7 +119,7 @@ extension ILTranslucentView { let _toolbarBG = UIToolbar(frame: rect) _toolbarBG.autoresizingMask = [.flexibleWidth, .flexibleHeight] - _toolbarBG.theme_barStyle = [.default, .black] /* Support dark mode */ + _toolbarBG.theme_barStyle = [.default, .black, .black] /* Support dark mode */ self.toolbarBG = _toolbarBG self.toolbarContainerClipView!.addSubview(self.toolbarBG!) diff --git a/appdb/Resources/SwiftPullToRefresh/IndicatorView.swift b/appdb/Resources/SwiftPullToRefresh/IndicatorView.swift index 9ebb95b6..c7579ad0 100755 --- a/appdb/Resources/SwiftPullToRefresh/IndicatorView.swift +++ b/appdb/Resources/SwiftPullToRefresh/IndicatorView.swift @@ -36,7 +36,7 @@ class IndicatorView: RefreshView { self.isHeader = isHeader super.init(style: isHeader ? .header : .footer, height: height, action: action) - indicator.theme_activityIndicatorViewStyle = [.gray, .white] + indicator.theme_activityIndicatorViewStyle = [.gray, .white, .white] layer.addSublayer(arrowLayer) addSubview(indicator) diff --git "a/appdb/Resources/\342\200\242 ButtonFactory/ButtonFactory.swift" "b/appdb/Resources/\342\200\242 ButtonFactory/ButtonFactory.swift" index abf0b88b..0ef82df4 100644 --- "a/appdb/Resources/\342\200\242 ButtonFactory/ButtonFactory.swift" +++ "b/appdb/Resources/\342\200\242 ButtonFactory/ButtonFactory.swift" @@ -42,7 +42,7 @@ enum ButtonFactory { let button = BouncyButtonWithColoredBorder() button.setTitle(text, for: .normal) - button.theme_setImage(["bolt_dark", "bolt_light"], forState: .normal) + button.theme_setImage(["bolt_dark", "bolt_light", "bolt_light"], forState: .normal) button.setImage(button.imageView!.image!.withRenderingMode(.alwaysTemplate), for: .normal) button.imageView?.theme_tintColor = color button.theme_setTitleColor(color, forState: .normal) diff --git "a/appdb/Resources/\342\200\242 LoadingTableView/LoadingCollectionView.swift" "b/appdb/Resources/\342\200\242 LoadingTableView/LoadingCollectionView.swift" index 656bedc0..341fa87a 100644 --- "a/appdb/Resources/\342\200\242 LoadingTableView/LoadingCollectionView.swift" +++ "b/appdb/Resources/\342\200\242 LoadingTableView/LoadingCollectionView.swift" @@ -20,7 +20,7 @@ class LoadingCollectionView: UICollectionViewController { lazy var activityIndicator: UIActivityIndicatorView = { let activityIndicator = UIActivityIndicatorView() - activityIndicator.theme_activityIndicatorViewStyle = [.gray, .white] + activityIndicator.theme_activityIndicatorViewStyle = [.gray, .white, .white] activityIndicator.hidesWhenStopped = true return activityIndicator }() diff --git "a/appdb/Resources/\342\200\242 LoadingTableView/LoadingTableView.swift" "b/appdb/Resources/\342\200\242 LoadingTableView/LoadingTableView.swift" index ddbc358f..39216df4 100644 --- "a/appdb/Resources/\342\200\242 LoadingTableView/LoadingTableView.swift" +++ "b/appdb/Resources/\342\200\242 LoadingTableView/LoadingTableView.swift" @@ -42,7 +42,7 @@ class LoadingTableView: UITableViewController { lazy var activityIndicator: UIActivityIndicatorView = { let activityIndicator = UIActivityIndicatorView() - activityIndicator.theme_activityIndicatorViewStyle = [.gray, .white] + activityIndicator.theme_activityIndicatorViewStyle = [.gray, .white, .white] activityIndicator.hidesWhenStopped = true return activityIndicator }() diff --git a/appdb/Startup/AppDelegate.swift b/appdb/Startup/AppDelegate.swift index 74aa31c6..75d8fbe4 100644 --- a/appdb/Startup/AppDelegate.swift +++ b/appdb/Startup/AppDelegate.swift @@ -35,7 +35,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UITabBarControllerDelegat self.window?.theme_tintColor = Color.mainTint // Theme Status Bar - UIApplication.shared.theme_setStatusBarStyle([.default, .lightContent], animated: true) + UIApplication.shared.theme_setStatusBarStyle([.default, .lightContent, .lightContent], animated: true) // Theme navigation bar let navigationBar = UINavigationBar.appearance() @@ -45,13 +45,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UITabBarControllerDelegat AttributedStringKey.font: UIFont.boldSystemFont(ofSize: 16.5) ] } - navigationBar.theme_barStyle = [.default, .black] + navigationBar.theme_barStyle = [.default, .black, .black] navigationBar.theme_tintColor = Color.mainTint navigationBar.theme_titleTextAttributes = ThemeDictionaryPicker.pickerWithAttributes(titleAttributes) // Theme Tab Bar let tabBar = UITabBar.appearance() - tabBar.theme_barStyle = [.default, .black] + tabBar.theme_barStyle = [.default, .black, .black] // Theme UISwitch UISwitch.appearance().theme_onTintColor = Color.mainTint diff --git a/appdb/Startup/Colors.swift b/appdb/Startup/Colors.swift index 3a2fffc5..4e6361c3 100644 --- a/appdb/Startup/Colors.swift +++ b/appdb/Startup/Colors.swift @@ -9,7 +9,7 @@ import UIKit import SwiftTheme -/* First is light theme, second is Dark theme hex. */ +/* First is light theme, second is Dark theme hex, third is darker theme (oled). */ enum Color { @@ -18,99 +18,99 @@ enum Color { ///////////////// /* Blue main tint, may not be final */ - static let mainTint: ThemeColorPicker = ["#446CB3", "#6FACFA"] + static let mainTint: ThemeColorPicker = ["#446CB3", "#6FACFA", "#6FACFA"] /* Slightly darker main tint for 'Authorize' cell background */ - static let slightlyDarkerMainTint: ThemeColorPicker = ["#446CB3", "#3A6EB0"] + static let slightlyDarkerMainTint: ThemeColorPicker = ["#446CB3", "#3A6EB0", "#3A6EB0"] /* Darker main tint for pressed 'Authorize' cell state */ - static let darkMainTint: ThemeColorPicker = ["#486A92", "#2C5285"] + static let darkMainTint: ThemeColorPicker = ["#486A92", "#2C5285", "#2C5285"] /* Category, author, seeAll button */ - static let darkGray: ThemeColorPicker = ["#6F7179", "#9c9c9c"] + static let darkGray: ThemeColorPicker = ["#6F7179", "#9c9c9c", "#9c9c9c"] /* Background color, used for tableView and fill spaces */ - static let tableViewBackgroundColor: ThemeColorPicker = ["#EFEFF4", "#121212"] + static let tableViewBackgroundColor: ThemeColorPicker = ["#EFEFF4", "#121212", "#000000"] /* TableView separator color */ - static let borderColor: ThemeColorPicker = ["#C7C7CC", "#373737"] + static let borderColor: ThemeColorPicker = ["#C7C7CC", "#373737", "#373737"] /* Error message, copyright text */ - static let copyrightText: ThemeColorPicker = ["#555555", "#7E7E7E"] + static let copyrightText: ThemeColorPicker = ["#555555", "#7E7E7E", "#7E7E7E"] /* Slightly different than background, used for tableView cells */ - static let veryVeryLightGray: ThemeColorPicker = ["#FDFDFD", "#1E1E1E"] + static let veryVeryLightGray: ThemeColorPicker = ["#FDFDFD", "#1E1E1E", "#000000"] /* Black for light theme, white for dark theme */ - static let title: ThemeColorPicker = ["#121212", "#F8F8F8"] + static let title: ThemeColorPicker = ["#121212", "#F8F8F8", "#F8F8F8"] /* White for light theme, black for dark theme */ - static let invertedTitle: ThemeColorPicker = ["#F8F8F8", "#121212"] + static let invertedTitle: ThemeColorPicker = ["#F8F8F8", "#121212", "#121212"] /* Cell selection overlay color */ - static let cellSelectionColor: ThemeColorPicker = ["#D8D8D8", "#383838"] + static let cellSelectionColor: ThemeColorPicker = ["#D8D8D8", "#383838", "#383838"] /* Matches translucent barStyle color */ - static let popoverArrowColor: ThemeColorPicker = ["#F6F6F7", "#161616"] + static let popoverArrowColor: ThemeColorPicker = ["#F6F6F7", "#161616", "#161616"] /* Details+Information parameter color */ - static let informationParameter: ThemeColorPicker = ["#9A9898", "#C5C3C5"] + static let informationParameter: ThemeColorPicker = ["#9A9898", "#C5C3C5", "#C5C3C5"] /* A light gray used for error message in Downloads */ - static let lightErrorMessage: ThemeColorPicker = ["#9A9898", "#3D3D3D"] + static let lightErrorMessage: ThemeColorPicker = ["#9A9898", "#3D3D3D", "#363636"] /* Green for INSTALL button and verified crackers */ - static let softGreen: ThemeColorPicker = ["#00B600", "#00B600"] + static let softGreen: ThemeColorPicker = ["#00B600", "#00B600", "#00B600"] /* Red for non verified crackers button and 'Deauthorize' cell */ - static let softRed: ThemeColorPicker = ["#D32F2F", "#D32F2F"] + static let softRed: ThemeColorPicker = ["#D32F2F", "#D32F2F", "#D32F2F"] /* Dark red for pressed 'Deauthorize' cell state */ - static let darkRed: ThemeColorPicker = ["#A32F2F", "#6A2121"] + static let darkRed: ThemeColorPicker = ["#A32F2F", "#6A2121", "#6A2121"] /* Gray for timestamp in device status cell */ - static let timestampGray: ThemeColorPicker = ["#AAAAAA", "#AAAAAA"] + static let timestampGray: ThemeColorPicker = ["#AAAAAA", "#AAAAAA", "#AAAAAA"] /* Background for bulletins */ - static let easyBulletinBackground: ThemeColorPicker = ["#EDEFEF", "#242424"] + static let easyBulletinBackground: ThemeColorPicker = ["#EDEFEF", "#242424", "#242424"] /* Hardcoded Apple's UIButton selected color */ - static let buttonBorderColor: ThemeColorPicker = ["#D0D0D4", "#272727"] + static let buttonBorderColor: ThemeColorPicker = ["#D0D0D4", "#272727", "#272727"] /* Almost full white, used for authorize cell text color */ - static let dirtyWhite: ThemeColorPicker = ["#F8F8F8", "#F8F8F8"] + static let dirtyWhite: ThemeColorPicker = ["#F8F8F8", "#F8F8F8", "#F8F8F8"] /* Search suggestions, color for text */ - static let searchSuggestionsTextColor: ThemeColorPicker = ["#777777", "#828282"] + static let searchSuggestionsTextColor: ThemeColorPicker = ["#777777", "#828282", "#828282"] /* Search suggestions, color for search icon */ - static let searchSuggestionsIconColor: ThemeColorPicker = ["#c6c6c6", "#7c7c7c"] + static let searchSuggestionsIconColor: ThemeColorPicker = ["#c6c6c6", "#7c7c7c", "#7c7c7c"] /* "...more" text color in ElasticLabel */ - static let moreTextColor = ["#4E7DD0", "#649EE6"] + static let moreTextColor = ["#4E7DD0", "#649EE6", "#649EE6"] /* Text color used in navigation bar title */ - static let navigationBarTextColor = ["#121212", "#F8F8F8"] + static let navigationBarTextColor = ["#121212", "#F8F8F8", "#F8F8F8"] ///////////////// // CG COLORS // ///////////////// /* CG version of mainTint */ - static let mainTintCgColor = ThemeCGColorPicker(colors: "#446CB3", "#6FACFA") + static let mainTintCgColor = ThemeCGColorPicker(colors: "#446CB3", "#6FACFA", "#6FACFA") /* CG version of copyrightText */ - static let copyrightTextCgColor = ThemeCGColorPicker(colors: "#555555", "#7E7E7E") + static let copyrightTextCgColor = ThemeCGColorPicker(colors: "#555555", "#7E7E7E", "#7E7E7E") /* Icon layer borderColor */ - static let borderCgColor = ThemeCGColorPicker(colors: "#C7C7CC", "#1E1E1E") + static let borderCgColor = ThemeCGColorPicker(colors: "#C7C7CC", "#1E1E1E", "#1E1E1E") /* CG version of tableViewBackgroundColor */ - static let tableViewCGBackgroundColor = ThemeCGColorPicker(colors: "#EFEFF4", "#121212") + static let tableViewCGBackgroundColor = ThemeCGColorPicker(colors: "#EFEFF4", "#121212", "#121212") /* Hardcoded Apple's UIButton selected color */ - static let buttonBorderCgColor = ThemeCGColorPicker(colors: "#D0D0D4", "#272727") + static let buttonBorderCgColor = ThemeCGColorPicker(colors: "#D0D0D4", "#272727", "#272727") /* Arrow Layer Stroke Color */ - static let arrowLayerStrokeCGColor = ThemeCGColorPicker(colors: "#000000CC", "#FFFFFFCC") + static let arrowLayerStrokeCGColor = ThemeCGColorPicker(colors: "#000000CC", "#FFFFFFCC", "#FFFFFFCC") } diff --git a/appdb/Startup/Themes.swift b/appdb/Startup/Themes.swift index 885785db..5f5298e2 100644 --- a/appdb/Startup/Themes.swift +++ b/appdb/Startup/Themes.swift @@ -8,21 +8,32 @@ import SwiftTheme -enum Themes: Int { +enum Themes: Int, CaseIterable { case light = 0 case dark = 1 + case darker = 2 + + var toString: String { + switch self { + case .light: return "Light".localized() + case .dark: return "Dark".localized() + case .darker: return "Darker".localized() // todo + } + } static var current: Themes { return Themes(rawValue: ThemeManager.currentThemeIndex)! } // MARK: - Switch Theme static func switchTo(theme: Themes) { - ThemeManager.setTheme(index: theme.rawValue) - saveCurrentTheme() + if theme != current { + ThemeManager.setTheme(index: theme.rawValue) + saveCurrentTheme() + } } - static var isNight: Bool { return current == .dark } + static var isNight: Bool { return current != .light } // MARK: - Save & Restore diff --git a/appdb/Tabs/Downloads/Downloads.swift b/appdb/Tabs/Downloads/Downloads.swift index eb653d12..07b22002 100644 --- a/appdb/Tabs/Downloads/Downloads.swift +++ b/appdb/Tabs/Downloads/Downloads.swift @@ -199,7 +199,7 @@ extension Downloads { textField.addTarget(self, action: #selector(self.urlTextChanged), for: .editingChanged) textField.placeholder = "https://example.com/file.ipa".localized() textField.keyboardType = .URL - textField.theme_keyboardAppearance = [.light, .dark] + textField.theme_keyboardAppearance = [.light, .dark, .dark] textField.clearButtonMode = .whileEditing }) diff --git a/appdb/Tabs/Downloads/Library/Library+Extension.swift b/appdb/Tabs/Downloads/Library/Library+Extension.swift index 3d8fe52a..cc5d6b94 100644 --- a/appdb/Tabs/Downloads/Library/Library+Extension.swift +++ b/appdb/Tabs/Downloads/Library/Library+Extension.swift @@ -160,7 +160,7 @@ extension Library { textField.addTarget(self, action: #selector(self.renameTextChanged), for: .editingChanged) textField.placeholder = String(file.filename.dropLast(4)) textField.text = String(file.filename.dropLast(4)) - textField.theme_keyboardAppearance = [.light, .dark] + textField.theme_keyboardAppearance = [.light, .dark, .dark] textField.clearButtonMode = .whileEditing }) diff --git a/appdb/Tabs/Featured/Details/Cells/Download/Details+VersionHeader.swift b/appdb/Tabs/Featured/Details/Cells/Download/Details+VersionHeader.swift index 42150ce9..5f7178ef 100644 --- a/appdb/Tabs/Featured/Details/Cells/Download/Details+VersionHeader.swift +++ b/appdb/Tabs/Featured/Details/Cells/Download/Details+VersionHeader.swift @@ -14,7 +14,7 @@ class DetailsVersionHeader: TableViewHeader { var version: UILabel! static var height: CGFloat { return 25 } - private let backgroundGray: ThemeColorPicker = ["#E3E3E3", "#3E3E3E"] + private let backgroundGray: ThemeColorPicker = ["#E3E3E3", "#3E3E3E", "#313131"] convenience init(_ versionNumber: String, isLatest: Bool) { self.init(frame: .zero) diff --git a/appdb/Tabs/Featured/Details/Details.swift b/appdb/Tabs/Featured/Details/Details.swift index d3fdbe21..72c3bc71 100644 --- a/appdb/Tabs/Featured/Details/Details.swift +++ b/appdb/Tabs/Featured/Details/Details.swift @@ -324,7 +324,7 @@ class Details: LoadingTableView { alert.addTextField(configurationHandler: { textField in textField.placeholder = "Enter a reason for your report".localized() - textField.theme_keyboardAppearance = [.light, .dark] + textField.theme_keyboardAppearance = [.light, .dark, .dark] textField.addTarget(self, action: #selector(self.reportTextfieldTextChanged), for: .editingChanged) textField.clearButtonMode = .whileEditing }) diff --git a/appdb/Tabs/Featured/See All/SeeAll.swift b/appdb/Tabs/Featured/See All/SeeAll.swift index 0b042f51..923e891a 100644 --- a/appdb/Tabs/Featured/See All/SeeAll.swift +++ b/appdb/Tabs/Featured/See All/SeeAll.swift @@ -90,7 +90,7 @@ class SeeAll: LoadingTableView { default: break } searchController.searchBar.textField?.theme_textColor = Color.title - searchController.searchBar.textField?.theme_keyboardAppearance = [.light, .dark] + searchController.searchBar.textField?.theme_keyboardAppearance = [.light, .dark, .dark] definesPresentationContext = true if #available(iOS 11.0, *) { navigationItem.searchController = searchController diff --git a/appdb/Tabs/Search/Search.swift b/appdb/Tabs/Search/Search.swift index 15f68405..1a128bf9 100644 --- a/appdb/Tabs/Search/Search.swift +++ b/appdb/Tabs/Search/Search.swift @@ -102,7 +102,7 @@ class Search: LoadingCollectionView, UISearchBarDelegate { searchController.searchBar.placeholder = "Search iOS Apps".localized() searchController.searchBar.textField?.theme_textColor = Color.title searchController.searchBar.textField?.enablesReturnKeyAutomatically = false - searchController.searchBar.textField?.theme_keyboardAppearance = [.light, .dark] + searchController.searchBar.textField?.theme_keyboardAppearance = [.light, .dark, .dark] definesPresentationContext = true if #available(iOS 11.0, *) { diff --git a/appdb/Tabs/Settings/Device Link/Bulletins/EnterEmailBulletinPage.swift b/appdb/Tabs/Settings/Device Link/Bulletins/EnterEmailBulletinPage.swift index 5d30401f..8c0c9abb 100644 --- a/appdb/Tabs/Settings/Device Link/Bulletins/EnterEmailBulletinPage.swift +++ b/appdb/Tabs/Settings/Device Link/Bulletins/EnterEmailBulletinPage.swift @@ -20,7 +20,7 @@ class EnterEmailBulletinPage: BLTNPageItem { textField.theme_backgroundColor = Color.invertedTitle textField.theme_textColor = Color.title textField.attributedPlaceholder = NSAttributedString(string: textField.placeholder!, attributes: [.foregroundColor: UIColor(rgba: "#AAAAAA")]) - textField.theme_keyboardAppearance = [.light, .dark] + textField.theme_keyboardAppearance = [.light, .dark, .dark] descriptionLabel?.theme_textColor = Color.title return [textField] } diff --git a/appdb/Tabs/Settings/Device Link/Bulletins/EnterLinkCodeBulletinPage.swift b/appdb/Tabs/Settings/Device Link/Bulletins/EnterLinkCodeBulletinPage.swift index 2a08199e..b35818e1 100644 --- a/appdb/Tabs/Settings/Device Link/Bulletins/EnterLinkCodeBulletinPage.swift +++ b/appdb/Tabs/Settings/Device Link/Bulletins/EnterLinkCodeBulletinPage.swift @@ -40,7 +40,7 @@ class EnterLinkCodeBulletinPage: BLTNPageItem { textField.theme_backgroundColor = Color.invertedTitle textField.theme_textColor = Color.title textField.attributedPlaceholder = NSAttributedString(string: textField.placeholder!, attributes: [.foregroundColor: UIColor(rgba: "#AAAAAA")]) - textField.theme_keyboardAppearance = [.light, .dark] + textField.theme_keyboardAppearance = [.light, .dark, .dark] descriptionLabel?.theme_textColor = Color.title diff --git a/appdb/Tabs/Settings/News/News.swift b/appdb/Tabs/Settings/News/News.swift index 447cf3ab..b48428c0 100644 --- a/appdb/Tabs/Settings/News/News.swift +++ b/appdb/Tabs/Settings/News/News.swift @@ -69,7 +69,7 @@ class News: LoadingTableView { } searchController.searchBar.placeholder = "Search News".localized() searchController.searchBar.textField?.theme_textColor = Color.title - searchController.searchBar.textField?.theme_keyboardAppearance = [.light, .dark] + searchController.searchBar.textField?.theme_keyboardAppearance = [.light, .dark, .dark] definesPresentationContext = true if #available(iOS 11.0, *) { // Fixes weird crash on peek diff --git a/appdb/Tabs/Settings/Settings+Sections.swift b/appdb/Tabs/Settings/Settings+Sections.swift index dd440e9d..2dea7a8b 100644 --- a/appdb/Tabs/Settings/Settings+Sections.swift +++ b/appdb/Tabs/Settings/Settings+Sections.swift @@ -30,7 +30,7 @@ extension Settings { return [ Section(header: .title("User Interface".localized()), rows: [ Row(text: "Choose Theme".localized(), - detailText: Themes.isNight ? "Dark".localized() : "Light".localized(), selection: { [unowned self] _ in + detailText: Themes.current.toString, selection: { [unowned self] _ in self.pushThemeChooser() }, accessory: .disclosureIndicator, cellClass: SimpleStaticCell.self), Row(text: "Choose Language".localized(), diff --git a/appdb/Tabs/Settings/Settings+StaticCells.swift b/appdb/Tabs/Settings/Settings+StaticCells.swift index 728c1b4d..00200c41 100644 --- a/appdb/Tabs/Settings/Settings+StaticCells.swift +++ b/appdb/Tabs/Settings/Settings+StaticCells.swift @@ -269,7 +269,7 @@ final class StaticTextFieldCell: SimpleStaticCell, UITextFieldDelegate { textField.backgroundColor = .clear textField.textAlignment = .right textField.theme_textColor = Color.title - textField.theme_keyboardAppearance = [.light, .dark] + textField.theme_keyboardAppearance = [.light, .dark, .dark] textField.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged) contentView.addSubview(textField) diff --git a/appdb/Tabs/Settings/Theme Chooser/ThemeChooser.swift b/appdb/Tabs/Settings/Theme Chooser/ThemeChooser.swift index 8e9b4eeb..8c8b00ef 100644 --- a/appdb/Tabs/Settings/Theme Chooser/ThemeChooser.swift +++ b/appdb/Tabs/Settings/Theme Chooser/ThemeChooser.swift @@ -16,10 +16,6 @@ class ThemeChooser: UITableViewController { weak var changedThemeDelegate: ChangedTheme? - private var lightTheme: Bool { - return !Themes.isNight - } - private var bgColorView: UIView = { let bgColorView = UIView() bgColorView.theme_backgroundColor = Color.cellSelectionColor @@ -59,18 +55,15 @@ class ThemeChooser: UITableViewController { } override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 2 + return Themes.allCases.count } override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) - cell.textLabel?.text = indexPath.row == 0 ? "Light".localized() : "Dark".localized() + cell.textLabel?.text = Themes(rawValue: indexPath.row)?.toString cell.textLabel?.makeDynamicFont() cell.textLabel?.theme_textColor = Color.title - switch indexPath.row { - case 0: cell.accessoryType = lightTheme ? .checkmark : .none - default: cell.accessoryType = !lightTheme ? .checkmark : .none - } + cell.accessoryType = Themes.current == Themes(rawValue: indexPath.row) ? .checkmark : .none cell.contentView.theme_backgroundColor = Color.veryVeryLightGray cell.theme_backgroundColor = Color.veryVeryLightGray cell.selectedBackgroundView = bgColorView @@ -78,10 +71,8 @@ class ThemeChooser: UITableViewController { } override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - switch indexPath.row { - case 0: if Themes.isNight { Themes.switchTo(theme: .light) } - default: if !Themes.isNight { Themes.switchTo(theme: .dark) } - } + guard let theme = Themes(rawValue: indexPath.row) else { return } + Themes.switchTo(theme: theme) changedThemeDelegate?.changedTheme() tableView.reloadData() } diff --git a/appdb/en.lproj/Localizable.strings b/appdb/en.lproj/Localizable.strings index e66a73e5..198551dc 100644 --- a/appdb/en.lproj/Localizable.strings +++ b/appdb/en.lproj/Localizable.strings @@ -213,6 +213,7 @@ "Choose Language" = "Choose Language"; "Language set, please restart the app to apply changes" = "Language set, please restart the app to apply changes"; "Dark" = "Dark"; +"Darker" = "Darker"; "Light" = "Light"; "Support" = "Support"; "Visit appdb forum" = "Visit appdb forums"; diff --git a/appdb/es.lproj/Localizable.strings b/appdb/es.lproj/Localizable.strings index 0b559393..5cabfb1e 100644 --- a/appdb/es.lproj/Localizable.strings +++ b/appdb/es.lproj/Localizable.strings @@ -213,6 +213,7 @@ "Choose Language" = "Seleccionar idioma"; "Language set, please restart the app to apply changes" = "Idioma elegido, por favor relanza esta app para aplicar el idioma"; "Dark" = "Oscuro"; +"Darker" = "Negro Oscuro"; "Light" = "Claro"; "Support" = "Soporte"; "Visit appdb forum" = "Visit appdb forums"; diff --git a/appdb/it.lproj/Localizable.strings b/appdb/it.lproj/Localizable.strings index 00310678..91dc75fa 100644 --- a/appdb/it.lproj/Localizable.strings +++ b/appdb/it.lproj/Localizable.strings @@ -213,6 +213,7 @@ "Choose Language" = "Scegli lingua"; "Language set, please restart the app to apply changes" = "Lingua impostata, chiudi e riapri l'app per applicare i cambiamenti"; "Dark" = "Tema scuro"; +"Darker" = "Tema piĆ¹ scuro"; "Light" = "Tema chiaro"; "Support" = "Supporto"; "Visit appdb forum" = "Visita il forum di appdb";