Drop redundant color prefix in Palette fields
This commit is contained in:
parent
01babcfcbc
commit
b745e37671
|
@ -30,7 +30,7 @@ import Passepartout_Core
|
||||||
extension UITableViewCell {
|
extension UITableViewCell {
|
||||||
func applyChecked(_ checked: Bool, _ theme: Theme) {
|
func applyChecked(_ checked: Bool, _ theme: Theme) {
|
||||||
accessoryType = checked ? .checkmark : .none
|
accessoryType = checked ? .checkmark : .none
|
||||||
tintColor = Theme.current.palette.colorAccessory
|
tintColor = Theme.current.palette.accessory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,52 +38,52 @@ extension DestructiveTableViewCell {
|
||||||
func apply(_ theme: Theme) {
|
func apply(_ theme: Theme) {
|
||||||
accessoryType = .none
|
accessoryType = .none
|
||||||
selectionStyle = .default
|
selectionStyle = .default
|
||||||
captionColor = theme.palette.colorDestructive
|
captionColor = theme.palette.destructive
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension FieldTableViewCell {
|
extension FieldTableViewCell {
|
||||||
func apply(_ theme: Theme) {
|
func apply(_ theme: Theme) {
|
||||||
captionColor = theme.palette.colorPrimaryText
|
captionColor = theme.palette.primaryText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension SettingTableViewCell {
|
extension SettingTableViewCell {
|
||||||
func apply(_ theme: Theme) {
|
func apply(_ theme: Theme) {
|
||||||
leftTextColor = theme.palette.colorPrimaryText
|
leftTextColor = theme.palette.primaryText
|
||||||
rightTextColor = theme.palette.colorSecondaryText
|
rightTextColor = theme.palette.secondaryText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ToggleTableViewCell {
|
extension ToggleTableViewCell {
|
||||||
func apply(_ theme: Theme) {
|
func apply(_ theme: Theme) {
|
||||||
captionColor = theme.palette.colorPrimaryText
|
captionColor = theme.palette.primaryText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension SettingTableViewCell {
|
extension SettingTableViewCell {
|
||||||
func applyAction(_ theme: Theme) {
|
func applyAction(_ theme: Theme) {
|
||||||
leftTextColor = theme.palette.colorAction
|
leftTextColor = theme.palette.action
|
||||||
rightTextColor = nil
|
rightTextColor = nil
|
||||||
accessoryType = .none
|
accessoryType = .none
|
||||||
}
|
}
|
||||||
|
|
||||||
func applyVPN(_ theme: Theme, with vpnStatus: VPNStatus?, error: TunnelKitProvider.ProviderError?) {
|
func applyVPN(_ theme: Theme, with vpnStatus: VPNStatus?, error: TunnelKitProvider.ProviderError?) {
|
||||||
leftTextColor = theme.palette.colorPrimaryText
|
leftTextColor = theme.palette.primaryText
|
||||||
guard let vpnStatus = vpnStatus else {
|
guard let vpnStatus = vpnStatus else {
|
||||||
rightText = L10n.Vpn.disabled
|
rightText = L10n.Vpn.disabled
|
||||||
rightTextColor = theme.palette.colorSecondaryText
|
rightTextColor = theme.palette.secondaryText
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
switch vpnStatus {
|
switch vpnStatus {
|
||||||
case .connecting:
|
case .connecting:
|
||||||
rightText = L10n.Vpn.connecting
|
rightText = L10n.Vpn.connecting
|
||||||
rightTextColor = theme.palette.colorIndeterminate
|
rightTextColor = theme.palette.indeterminate
|
||||||
|
|
||||||
case .connected:
|
case .connected:
|
||||||
rightText = L10n.Vpn.active
|
rightText = L10n.Vpn.active
|
||||||
rightTextColor = theme.palette.colorOn
|
rightTextColor = theme.palette.on
|
||||||
|
|
||||||
case .disconnecting, .disconnected:
|
case .disconnecting, .disconnected:
|
||||||
var disconnectionReason: String?
|
var disconnectionReason: String?
|
||||||
|
@ -117,11 +117,11 @@ extension SettingTableViewCell {
|
||||||
switch vpnStatus {
|
switch vpnStatus {
|
||||||
case .disconnecting:
|
case .disconnecting:
|
||||||
rightText = disconnectionReason ?? L10n.Vpn.disconnecting
|
rightText = disconnectionReason ?? L10n.Vpn.disconnecting
|
||||||
rightTextColor = theme.palette.colorIndeterminate
|
rightTextColor = theme.palette.indeterminate
|
||||||
|
|
||||||
case .disconnected:
|
case .disconnected:
|
||||||
rightText = disconnectionReason ?? L10n.Vpn.inactive
|
rightText = disconnectionReason ?? L10n.Vpn.inactive
|
||||||
rightTextColor = theme.palette.colorOff
|
rightTextColor = theme.palette.off
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
|
|
|
@ -39,38 +39,38 @@ extension UIColor {
|
||||||
|
|
||||||
struct Theme {
|
struct Theme {
|
||||||
struct Palette {
|
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 {
|
var on: UIColor {
|
||||||
return colorAccent1
|
return accent1
|
||||||
}
|
}
|
||||||
|
|
||||||
var colorIndeterminate: UIColor {
|
var indeterminate: UIColor {
|
||||||
return colorSecondaryText
|
return secondaryText
|
||||||
}
|
}
|
||||||
|
|
||||||
var colorOff: UIColor {
|
var off: UIColor {
|
||||||
return colorSecondaryText
|
return secondaryText
|
||||||
}
|
}
|
||||||
|
|
||||||
// var colorAction = UIColor(red: 214.0 / 255.0, green: 156.0 / 255.0, blue: 104.0 / 255.0, alpha: 1.0)
|
// var action = UIColor(red: 214.0 / 255.0, green: 156.0 / 255.0, blue: 104.0 / 255.0, alpha: 1.0)
|
||||||
var colorAction: UIColor {
|
var action: UIColor {
|
||||||
return colorAccent1
|
return accent1
|
||||||
}
|
}
|
||||||
|
|
||||||
var colorAccessory: UIColor {
|
var accessory: UIColor {
|
||||||
return colorAccent1.withAlphaComponent(0.7)
|
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()
|
static let current = Theme()
|
||||||
|
@ -91,39 +91,39 @@ struct Theme {
|
||||||
extension Theme {
|
extension Theme {
|
||||||
func applyAppearance() {
|
func applyAppearance() {
|
||||||
let bar = UINavigationBar.appearance()
|
let bar = UINavigationBar.appearance()
|
||||||
bar.barTintColor = palette.colorPrimaryBackground
|
bar.barTintColor = palette.primaryBackground
|
||||||
bar.tintColor = palette.colorPrimaryLightText
|
bar.tintColor = palette.primaryLightText
|
||||||
bar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: palette.colorPrimaryLightText]
|
bar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: palette.primaryLightText]
|
||||||
bar.largeTitleTextAttributes = bar.titleTextAttributes
|
bar.largeTitleTextAttributes = bar.titleTextAttributes
|
||||||
|
|
||||||
let toolbar = UIToolbar.appearance()
|
let toolbar = UIToolbar.appearance()
|
||||||
toolbar.barTintColor = palette.colorPrimaryBackground
|
toolbar.barTintColor = palette.primaryBackground
|
||||||
toolbar.tintColor = palette.colorPrimaryLightText
|
toolbar.tintColor = palette.primaryLightText
|
||||||
|
|
||||||
let toggle = UISwitch.appearance()
|
let toggle = UISwitch.appearance()
|
||||||
toggle.onTintColor = palette.colorAccessory
|
toggle.onTintColor = palette.accessory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension UIView {
|
extension UIView {
|
||||||
func applyPrimaryBackground(_ theme: Theme) {
|
func applyPrimaryBackground(_ theme: Theme) {
|
||||||
backgroundColor = theme.palette.colorPrimaryBackground
|
backgroundColor = theme.palette.primaryBackground
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension UILabel {
|
extension UILabel {
|
||||||
func apply(_ theme: Theme) {
|
func apply(_ theme: Theme) {
|
||||||
textColor = theme.palette.colorPrimaryText
|
textColor = theme.palette.primaryText
|
||||||
}
|
}
|
||||||
|
|
||||||
func applyLight(_ theme: Theme) {
|
func applyLight(_ theme: Theme) {
|
||||||
textColor = theme.palette.colorPrimaryLightText
|
textColor = theme.palette.primaryLightText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension UIButton {
|
extension UIButton {
|
||||||
func apply(_ theme: Theme) {
|
func apply(_ theme: Theme) {
|
||||||
tintColor = theme.palette.colorAction
|
tintColor = theme.palette.action
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ extension UITextField {
|
||||||
|
|
||||||
extension UIActivityIndicatorView {
|
extension UIActivityIndicatorView {
|
||||||
func applyAccent(_ theme: Theme) {
|
func applyAccent(_ theme: Theme) {
|
||||||
color = theme.palette.colorAccent1
|
color = theme.palette.accent1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,9 +148,9 @@ extension UIActivityIndicatorView {
|
||||||
extension MFMailComposeViewController {
|
extension MFMailComposeViewController {
|
||||||
func apply(_ theme: Theme) {
|
func apply(_ theme: Theme) {
|
||||||
let bar = navigationBar
|
let bar = navigationBar
|
||||||
bar.barTintColor = theme.palette.colorPrimaryBackground
|
bar.barTintColor = theme.palette.primaryBackground
|
||||||
bar.tintColor = theme.palette.colorPrimaryLightText
|
bar.tintColor = theme.palette.primaryLightText
|
||||||
bar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: theme.palette.colorPrimaryLightText]
|
bar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: theme.palette.primaryLightText]
|
||||||
bar.largeTitleTextAttributes = bar.titleTextAttributes
|
bar.largeTitleTextAttributes = bar.titleTextAttributes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue