Drop redundant color prefix in Palette fields

This commit is contained in:
Davide De Rosa 2019-04-08 22:44:57 +02:00
parent 01babcfcbc
commit b745e37671
2 changed files with 44 additions and 44 deletions

View File

@ -30,7 +30,7 @@ import Passepartout_Core
extension UITableViewCell {
func applyChecked(_ checked: Bool, _ theme: Theme) {
accessoryType = checked ? .checkmark : .none
tintColor = Theme.current.palette.colorAccessory
tintColor = Theme.current.palette.accessory
}
}
@ -38,52 +38,52 @@ extension DestructiveTableViewCell {
func apply(_ theme: Theme) {
accessoryType = .none
selectionStyle = .default
captionColor = theme.palette.colorDestructive
captionColor = theme.palette.destructive
}
}
extension FieldTableViewCell {
func apply(_ theme: Theme) {
captionColor = theme.palette.colorPrimaryText
captionColor = theme.palette.primaryText
}
}
extension SettingTableViewCell {
func apply(_ theme: Theme) {
leftTextColor = theme.palette.colorPrimaryText
rightTextColor = theme.palette.colorSecondaryText
leftTextColor = theme.palette.primaryText
rightTextColor = theme.palette.secondaryText
}
}
extension ToggleTableViewCell {
func apply(_ theme: Theme) {
captionColor = theme.palette.colorPrimaryText
captionColor = theme.palette.primaryText
}
}
extension SettingTableViewCell {
func applyAction(_ theme: Theme) {
leftTextColor = theme.palette.colorAction
leftTextColor = theme.palette.action
rightTextColor = nil
accessoryType = .none
}
func applyVPN(_ theme: Theme, with vpnStatus: VPNStatus?, error: TunnelKitProvider.ProviderError?) {
leftTextColor = theme.palette.colorPrimaryText
leftTextColor = theme.palette.primaryText
guard let vpnStatus = vpnStatus else {
rightText = L10n.Vpn.disabled
rightTextColor = theme.palette.colorSecondaryText
rightTextColor = theme.palette.secondaryText
return
}
switch vpnStatus {
case .connecting:
rightText = L10n.Vpn.connecting
rightTextColor = theme.palette.colorIndeterminate
rightTextColor = theme.palette.indeterminate
case .connected:
rightText = L10n.Vpn.active
rightTextColor = theme.palette.colorOn
rightTextColor = theme.palette.on
case .disconnecting, .disconnected:
var disconnectionReason: String?
@ -117,11 +117,11 @@ extension SettingTableViewCell {
switch vpnStatus {
case .disconnecting:
rightText = disconnectionReason ?? L10n.Vpn.disconnecting
rightTextColor = theme.palette.colorIndeterminate
rightTextColor = theme.palette.indeterminate
case .disconnected:
rightText = disconnectionReason ?? L10n.Vpn.inactive
rightTextColor = theme.palette.colorOff
rightTextColor = theme.palette.off
default:
break

View File

@ -39,38 +39,38 @@ extension UIColor {
struct Theme {
struct Palette {
var colorPrimaryBackground = UIColor(rgb: 0x515d71, alpha: 1.0)
var primaryBackground = UIColor(rgb: 0x515d71, alpha: 1.0)
var colorAccent1 = UIColor(rgb: 0xd69c68, alpha: 1.0)
var accent1 = UIColor(rgb: 0xd69c68, alpha: 1.0)
var colorPrimaryText: UIColor = .darkText
var primaryText: UIColor = .darkText
var colorPrimaryLightText: UIColor = .white
var primaryLightText: UIColor = .white
var colorSecondaryText: UIColor = .gray
var secondaryText: UIColor = .gray
var colorOn: UIColor {
return colorAccent1
var on: UIColor {
return accent1
}
var colorIndeterminate: UIColor {
return colorSecondaryText
var indeterminate: UIColor {
return secondaryText
}
var colorOff: UIColor {
return colorSecondaryText
var off: UIColor {
return secondaryText
}
// var colorAction = UIColor(red: 214.0 / 255.0, green: 156.0 / 255.0, blue: 104.0 / 255.0, alpha: 1.0)
var colorAction: UIColor {
return colorAccent1
// var action = UIColor(red: 214.0 / 255.0, green: 156.0 / 255.0, blue: 104.0 / 255.0, alpha: 1.0)
var action: UIColor {
return accent1
}
var colorAccessory: UIColor {
return colorAccent1.withAlphaComponent(0.7)
var accessory: UIColor {
return accent1.withAlphaComponent(0.7)
}
var colorDestructive = UIColor(red: 0.8, green: 0.27, blue: 0.2, alpha: 1.0)
var destructive = UIColor(red: 0.8, green: 0.27, blue: 0.2, alpha: 1.0)
}
static let current = Theme()
@ -91,39 +91,39 @@ struct Theme {
extension Theme {
func applyAppearance() {
let bar = UINavigationBar.appearance()
bar.barTintColor = palette.colorPrimaryBackground
bar.tintColor = palette.colorPrimaryLightText
bar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: palette.colorPrimaryLightText]
bar.barTintColor = palette.primaryBackground
bar.tintColor = palette.primaryLightText
bar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: palette.primaryLightText]
bar.largeTitleTextAttributes = bar.titleTextAttributes
let toolbar = UIToolbar.appearance()
toolbar.barTintColor = palette.colorPrimaryBackground
toolbar.tintColor = palette.colorPrimaryLightText
toolbar.barTintColor = palette.primaryBackground
toolbar.tintColor = palette.primaryLightText
let toggle = UISwitch.appearance()
toggle.onTintColor = palette.colorAccessory
toggle.onTintColor = palette.accessory
}
}
extension UIView {
func applyPrimaryBackground(_ theme: Theme) {
backgroundColor = theme.palette.colorPrimaryBackground
backgroundColor = theme.palette.primaryBackground
}
}
extension UILabel {
func apply(_ theme: Theme) {
textColor = theme.palette.colorPrimaryText
textColor = theme.palette.primaryText
}
func applyLight(_ theme: Theme) {
textColor = theme.palette.colorPrimaryLightText
textColor = theme.palette.primaryLightText
}
}
extension UIButton {
func apply(_ theme: Theme) {
tintColor = theme.palette.colorAction
tintColor = theme.palette.action
}
}
@ -140,7 +140,7 @@ extension UITextField {
extension UIActivityIndicatorView {
func applyAccent(_ theme: Theme) {
color = theme.palette.colorAccent1
color = theme.palette.accent1
}
}
@ -148,9 +148,9 @@ extension UIActivityIndicatorView {
extension MFMailComposeViewController {
func apply(_ theme: Theme) {
let bar = navigationBar
bar.barTintColor = theme.palette.colorPrimaryBackground
bar.tintColor = theme.palette.colorPrimaryLightText
bar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: theme.palette.colorPrimaryLightText]
bar.barTintColor = theme.palette.primaryBackground
bar.tintColor = theme.palette.primaryLightText
bar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: theme.palette.primaryLightText]
bar.largeTitleTextAttributes = bar.titleTextAttributes
}
}