diff options
author | Roopesh Chander <roop@roopc.net> | 2018-11-02 13:24:10 +0530 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2018-11-02 13:24:10 +0530 |
commit | 90af773fef10f50683eb49c382f00133aedb7387 (patch) | |
tree | ea0edde3234b815f5d50a54522131d9a8e6bc6fd /WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift | |
parent | Table edit: Show/hide 'Exclude Private IPs' instead of enable/disable (diff) | |
download | wireguard-apple-90af773fef10f50683eb49c382f00133aedb7387.tar.xz wireguard-apple-90af773fef10f50683eb49c382f00133aedb7387.zip |
Handle cell reuse in showing delete buttons in red
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r-- | WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift index c7794e3..17615ab 100644 --- a/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift @@ -240,7 +240,7 @@ extension TunnelEditTableViewController { if (field == .deletePeer) { let cell = tableView.dequeueReusableCell(withIdentifier: TunnelEditTableViewButtonCell.id, for: indexPath) as! TunnelEditTableViewButtonCell cell.buttonText = field.rawValue - cell.button.tintColor = UIColor.red + cell.hasDestructiveAction = true cell.onTapped = { [weak self, weak peerData] in guard let peerData = peerData else { return } guard let s = self else { return } @@ -512,12 +512,18 @@ class TunnelEditTableViewButtonCell: UITableViewCell { get { return button.title(for: .normal) ?? "" } set(value) { button.setTitle(value, for: .normal) } } + var hasDestructiveAction: Bool { + get { return button.tintColor == UIColor.red } + set(value) { button.tintColor = value ? UIColor.red : buttonStandardTintColor } + } var onTapped: (() -> Void)? = nil let button: UIButton + var buttonStandardTintColor: UIColor override init(style: UITableViewCellStyle, reuseIdentifier: String?) { button = UIButton(type: .system) + buttonStandardTintColor = button.tintColor super.init(style: style, reuseIdentifier: reuseIdentifier) contentView.addSubview(button) button.translatesAutoresizingMaskIntoConstraints = false @@ -540,6 +546,7 @@ class TunnelEditTableViewButtonCell: UITableViewCell { super.prepareForReuse() buttonText = "" onTapped = nil + hasDestructiveAction = false } } |