Skip to content

Commit

Permalink
added darker theme for oled devices
Browse files Browse the repository at this point in the history
  • Loading branch information
ned committed Jun 4, 2019
1 parent 8afb95d commit a1686f1
Show file tree
Hide file tree
Showing 23 changed files with 74 additions and 69 deletions.
2 changes: 1 addition & 1 deletion appdb/Resources/ILTranslucentView/ILTranslucentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
Expand Down
2 changes: 1 addition & 1 deletion appdb/Resources/SwiftPullToRefresh/IndicatorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion appdb/Resources/• ButtonFactory/ButtonFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}()
Expand Down
6 changes: 3 additions & 3 deletions appdb/Startup/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down
64 changes: 32 additions & 32 deletions appdb/Startup/Colors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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")
}
19 changes: 15 additions & 4 deletions appdb/Startup/Themes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion appdb/Tabs/Downloads/Downloads.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

Expand Down
2 changes: 1 addition & 1 deletion appdb/Tabs/Downloads/Library/Library+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion appdb/Tabs/Featured/Details/Details.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
2 changes: 1 addition & 1 deletion appdb/Tabs/Featured/See All/SeeAll.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion appdb/Tabs/Search/Search.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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, *) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion appdb/Tabs/Settings/News/News.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion appdb/Tabs/Settings/Settings+Sections.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion appdb/Tabs/Settings/Settings+StaticCells.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 5 additions & 14 deletions appdb/Tabs/Settings/Theme Chooser/ThemeChooser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -59,29 +55,24 @@ 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
return cell
}

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()
}
Expand Down
1 change: 1 addition & 0 deletions appdb/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Loading

0 comments on commit a1686f1

Please sign in to comment.