From 5c0738b136040bdd2db93e05d6b6259ed1bf8f51 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Mon, 15 Oct 2018 00:08:39 +0200 Subject: [PATCH 1/2] Apply accent color to accessory checkmarks --- .../Global/OptionViewController.swift | 2 +- Passepartout-iOS/Global/Theme+Cells.swift | 7 +++++++ .../Scenes/EndpointViewController.swift | 16 ++++++++-------- .../Organizer/OrganizerViewController.swift | 2 +- .../Scenes/ProviderPoolViewController.swift | 2 +- .../Scenes/ProviderPresetViewController.swift | 2 +- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Passepartout-iOS/Global/OptionViewController.swift b/Passepartout-iOS/Global/OptionViewController.swift index 56a32f7b..94c64501 100644 --- a/Passepartout-iOS/Global/OptionViewController.swift +++ b/Passepartout-iOS/Global/OptionViewController.swift @@ -64,7 +64,7 @@ class OptionViewController: UIViewController, UITableViewDataSource let opt = options[indexPath.row] let cell = Cells.setting.dequeue(from: tableView, for: indexPath) cell.leftText = descriptionBlock?(opt) ?? delegate?.optionController(self, descriptionFor: opt) - cell.accessoryType = (opt == selectedOption) ? .checkmark : .none + cell.applyChecked(opt == selectedOption, Theme.current) return cell } diff --git a/Passepartout-iOS/Global/Theme+Cells.swift b/Passepartout-iOS/Global/Theme+Cells.swift index dd951a13..3afaa488 100644 --- a/Passepartout-iOS/Global/Theme+Cells.swift +++ b/Passepartout-iOS/Global/Theme+Cells.swift @@ -25,6 +25,13 @@ import UIKit +extension UITableViewCell { + func applyChecked(_ checked: Bool, _ theme: Theme) { + accessoryType = checked ? .checkmark : .none + tintColor = Theme.current.palette.colorAction.withAlphaComponent(0.7) + } +} + extension DestructiveTableViewCell { func apply(_ theme: Theme) { accessoryType = .none diff --git a/Passepartout-iOS/Scenes/EndpointViewController.swift b/Passepartout-iOS/Scenes/EndpointViewController.swift index 31a2f41e..6488aed3 100644 --- a/Passepartout-iOS/Scenes/EndpointViewController.swift +++ b/Passepartout-iOS/Scenes/EndpointViewController.swift @@ -211,9 +211,9 @@ extension EndpointViewController: UITableViewDataSource, UITableViewDelegate { cell.accessoryType = .none cell.isTappable = true if let _ = currentAddress { - cell.accessoryType = .none + cell.applyChecked(false, Theme.current) } else { - cell.accessoryType = .checkmark + cell.applyChecked(true, Theme.current) currentAddressIndexPath = indexPath } return cell @@ -225,10 +225,10 @@ extension EndpointViewController: UITableViewDataSource, UITableViewDelegate { cell.accessoryType = .none cell.isTappable = true if address == currentAddress { - cell.accessoryType = .checkmark + cell.applyChecked(true, Theme.current) currentAddressIndexPath = indexPath } else { - cell.accessoryType = .none + cell.applyChecked(false, Theme.current) } return cell @@ -238,9 +238,9 @@ extension EndpointViewController: UITableViewDataSource, UITableViewDelegate { cell.accessoryType = .none cell.isTappable = true if let _ = currentProtocol { - cell.accessoryType = .none + cell.applyChecked(false, Theme.current) } else { - cell.accessoryType = .checkmark + cell.applyChecked(true, Theme.current) currentProtocolIndexPath = indexPath } return cell @@ -252,10 +252,10 @@ extension EndpointViewController: UITableViewDataSource, UITableViewDelegate { cell.accessoryType = .none cell.isTappable = true if proto == currentProtocol { - cell.accessoryType = .checkmark + cell.applyChecked(true, Theme.current) currentProtocolIndexPath = indexPath } else { - cell.accessoryType = .none + cell.applyChecked(false, Theme.current) } return cell } diff --git a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift index 580a6f6b..70116780 100644 --- a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift @@ -289,7 +289,7 @@ extension OrganizerViewController { let cell = Cells.setting.dequeue(from: tableView, for: indexPath) let rowProfile = profile(at: indexPath) cell.leftText = rowProfile.title - cell.accessoryType = service.isActiveProfile(rowProfile) ? .checkmark : .none + cell.applyChecked(service.isActiveProfile(rowProfile), Theme.current) return cell case .addProvider: diff --git a/Passepartout-iOS/Scenes/ProviderPoolViewController.swift b/Passepartout-iOS/Scenes/ProviderPoolViewController.swift index fb3346a7..81c1f6be 100644 --- a/Passepartout-iOS/Scenes/ProviderPoolViewController.swift +++ b/Passepartout-iOS/Scenes/ProviderPoolViewController.swift @@ -77,7 +77,7 @@ extension ProviderPoolViewController: UITableViewDataSource, UITableViewDelegate let cell = Cells.setting.dequeue(from: tableView, for: indexPath) cell.leftText = pool.name // cell.rightText = pool.country - cell.accessoryType = (pool.id == currentPoolId) ? .checkmark : .none + cell.applyChecked(pool.id == currentPoolId, Theme.current) cell.isTappable = true return cell } diff --git a/Passepartout-iOS/Scenes/ProviderPresetViewController.swift b/Passepartout-iOS/Scenes/ProviderPresetViewController.swift index 4f534590..f50bc8da 100644 --- a/Passepartout-iOS/Scenes/ProviderPresetViewController.swift +++ b/Passepartout-iOS/Scenes/ProviderPresetViewController.swift @@ -108,7 +108,7 @@ extension ProviderPresetViewController: UITableViewDataSource, UITableViewDelega switch rows[indexPath.row] { case .presetDescription: cell.leftText = preset.comment - cell.accessoryType = (preset.id == currentPresetId) ? .checkmark : .none + cell.applyChecked(preset.id == currentPresetId, Theme.current) case .techDetails: cell.applyAction(Theme.current) From ac06d2ccdec8ffe32965700ac0bc21c4352ae8b5 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Mon, 15 Oct 2018 00:12:37 +0200 Subject: [PATCH 2/2] Group accessory color with less alpha --- Passepartout-iOS/Global/Theme+Cells.swift | 2 +- Passepartout-iOS/Global/Theme.swift | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Passepartout-iOS/Global/Theme+Cells.swift b/Passepartout-iOS/Global/Theme+Cells.swift index 3afaa488..b19203cb 100644 --- a/Passepartout-iOS/Global/Theme+Cells.swift +++ b/Passepartout-iOS/Global/Theme+Cells.swift @@ -28,7 +28,7 @@ import UIKit extension UITableViewCell { func applyChecked(_ checked: Bool, _ theme: Theme) { accessoryType = checked ? .checkmark : .none - tintColor = Theme.current.palette.colorAction.withAlphaComponent(0.7) + tintColor = Theme.current.palette.colorAccessory } } diff --git a/Passepartout-iOS/Global/Theme.swift b/Passepartout-iOS/Global/Theme.swift index 05683c03..13fe5af8 100644 --- a/Passepartout-iOS/Global/Theme.swift +++ b/Passepartout-iOS/Global/Theme.swift @@ -64,6 +64,10 @@ struct Theme { 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) } @@ -95,7 +99,7 @@ extension Theme { toolbar.tintColor = palette.colorPrimaryLightText let toggle = UISwitch.appearance() - toggle.onTintColor = palette.colorAction.withAlphaComponent(0.7) + toggle.onTintColor = palette.colorAccessory } }