Merge branch 'uniform-accent-color'

This commit is contained in:
Davide De Rosa 2018-10-15 00:13:27 +02:00
commit e4488d90e1
7 changed files with 24 additions and 13 deletions

View File

@ -64,7 +64,7 @@ class OptionViewController<T: Hashable>: UIViewController, UITableViewDataSource
let opt = options[indexPath.row] let opt = options[indexPath.row]
let cell = Cells.setting.dequeue(from: tableView, for: indexPath) let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = descriptionBlock?(opt) ?? delegate?.optionController(self, descriptionFor: opt) cell.leftText = descriptionBlock?(opt) ?? delegate?.optionController(self, descriptionFor: opt)
cell.accessoryType = (opt == selectedOption) ? .checkmark : .none cell.applyChecked(opt == selectedOption, Theme.current)
return cell return cell
} }

View File

@ -25,6 +25,13 @@
import UIKit import UIKit
extension UITableViewCell {
func applyChecked(_ checked: Bool, _ theme: Theme) {
accessoryType = checked ? .checkmark : .none
tintColor = Theme.current.palette.colorAccessory
}
}
extension DestructiveTableViewCell { extension DestructiveTableViewCell {
func apply(_ theme: Theme) { func apply(_ theme: Theme) {
accessoryType = .none accessoryType = .none

View File

@ -64,6 +64,10 @@ struct Theme {
return colorAccent1 return colorAccent1
} }
var colorAccessory: UIColor {
return colorAccent1.withAlphaComponent(0.7)
}
var colorDestructive = UIColor(red: 0.8, green: 0.27, blue: 0.2, alpha: 1.0) var colorDestructive = UIColor(red: 0.8, green: 0.27, blue: 0.2, alpha: 1.0)
} }
@ -95,7 +99,7 @@ extension Theme {
toolbar.tintColor = palette.colorPrimaryLightText toolbar.tintColor = palette.colorPrimaryLightText
let toggle = UISwitch.appearance() let toggle = UISwitch.appearance()
toggle.onTintColor = palette.colorAction.withAlphaComponent(0.7) toggle.onTintColor = palette.colorAccessory
} }
} }

View File

@ -211,9 +211,9 @@ extension EndpointViewController: UITableViewDataSource, UITableViewDelegate {
cell.accessoryType = .none cell.accessoryType = .none
cell.isTappable = true cell.isTappable = true
if let _ = currentAddress { if let _ = currentAddress {
cell.accessoryType = .none cell.applyChecked(false, Theme.current)
} else { } else {
cell.accessoryType = .checkmark cell.applyChecked(true, Theme.current)
currentAddressIndexPath = indexPath currentAddressIndexPath = indexPath
} }
return cell return cell
@ -225,10 +225,10 @@ extension EndpointViewController: UITableViewDataSource, UITableViewDelegate {
cell.accessoryType = .none cell.accessoryType = .none
cell.isTappable = true cell.isTappable = true
if address == currentAddress { if address == currentAddress {
cell.accessoryType = .checkmark cell.applyChecked(true, Theme.current)
currentAddressIndexPath = indexPath currentAddressIndexPath = indexPath
} else { } else {
cell.accessoryType = .none cell.applyChecked(false, Theme.current)
} }
return cell return cell
@ -238,9 +238,9 @@ extension EndpointViewController: UITableViewDataSource, UITableViewDelegate {
cell.accessoryType = .none cell.accessoryType = .none
cell.isTappable = true cell.isTappable = true
if let _ = currentProtocol { if let _ = currentProtocol {
cell.accessoryType = .none cell.applyChecked(false, Theme.current)
} else { } else {
cell.accessoryType = .checkmark cell.applyChecked(true, Theme.current)
currentProtocolIndexPath = indexPath currentProtocolIndexPath = indexPath
} }
return cell return cell
@ -252,10 +252,10 @@ extension EndpointViewController: UITableViewDataSource, UITableViewDelegate {
cell.accessoryType = .none cell.accessoryType = .none
cell.isTappable = true cell.isTappable = true
if proto == currentProtocol { if proto == currentProtocol {
cell.accessoryType = .checkmark cell.applyChecked(true, Theme.current)
currentProtocolIndexPath = indexPath currentProtocolIndexPath = indexPath
} else { } else {
cell.accessoryType = .none cell.applyChecked(false, Theme.current)
} }
return cell return cell
} }

View File

@ -289,7 +289,7 @@ extension OrganizerViewController {
let cell = Cells.setting.dequeue(from: tableView, for: indexPath) let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
let rowProfile = profile(at: indexPath) let rowProfile = profile(at: indexPath)
cell.leftText = rowProfile.title cell.leftText = rowProfile.title
cell.accessoryType = service.isActiveProfile(rowProfile) ? .checkmark : .none cell.applyChecked(service.isActiveProfile(rowProfile), Theme.current)
return cell return cell
case .addProvider: case .addProvider:

View File

@ -77,7 +77,7 @@ extension ProviderPoolViewController: UITableViewDataSource, UITableViewDelegate
let cell = Cells.setting.dequeue(from: tableView, for: indexPath) let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = pool.name cell.leftText = pool.name
// cell.rightText = pool.country // cell.rightText = pool.country
cell.accessoryType = (pool.id == currentPoolId) ? .checkmark : .none cell.applyChecked(pool.id == currentPoolId, Theme.current)
cell.isTappable = true cell.isTappable = true
return cell return cell
} }

View File

@ -108,7 +108,7 @@ extension ProviderPresetViewController: UITableViewDataSource, UITableViewDelega
switch rows[indexPath.row] { switch rows[indexPath.row] {
case .presetDescription: case .presetDescription:
cell.leftText = preset.comment cell.leftText = preset.comment
cell.accessoryType = (preset.id == currentPresetId) ? .checkmark : .none cell.applyChecked(preset.id == currentPresetId, Theme.current)
case .techDetails: case .techDetails:
cell.applyAction(Theme.current) cell.applyAction(Theme.current)