diff options
author | Roopesh Chander <roop@roopc.net> | 2018-11-01 23:45:29 +0530 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2018-11-01 23:45:48 +0530 |
commit | 46e9eddecc17465945f32d6a8bfccff5f7ce0dc0 (patch) | |
tree | a2df4a75adb70f46c8f522e9bf4d2019ae61473f /WireGuard | |
parent | Tunnels list: Swipe left to delete (diff) | |
download | wireguard-apple-46e9eddecc17465945f32d6a8bfccff5f7ce0dc0.tar.xz wireguard-apple-46e9eddecc17465945f32d6a8bfccff5f7ce0dc0.zip |
Tunnel edit: Highlight erroring field keys in red
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard')
-rw-r--r-- | WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift index fac2b37..c9f159d 100644 --- a/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift @@ -72,6 +72,7 @@ class TunnelEditTableViewController: UITableViewController { case .error(let errorMessage): let erroringConfiguration = (tunnelViewModel.interfaceData.validatedConfiguration == nil) ? "Interface" : "Peer" ErrorPresenter.showErrorAlert(title: "Invalid \(erroringConfiguration)", message: errorMessage, from: self) + self.tableView.reloadData() // Highlight erroring fields case .saved(let tunnelConfiguration): if let tunnel = tunnel { // We're modifying an existing tunnel @@ -201,6 +202,8 @@ extension TunnelEditTableViewController { } else if (field == .addresses || field == .dns) { cell.keyboardType = .numbersAndPunctuation } + // Show erroring fields + cell.isValueValid = (!interfaceData.fieldsWithError.contains(field)) // Bind values to view model cell.value = interfaceData[field] if (field == .dns) { // While editing DNS, you might directly set exclude private IPs @@ -282,6 +285,8 @@ extension TunnelEditTableViewController { } else if (field == .allowedIPs) { cell.keyboardType = .numbersAndPunctuation } + // Show erroring fields + cell.isValueValid = (!peerData.fieldsWithError.contains(field)) // Bind values to view model cell.value = peerData[field] if (field != .allowedIPs) { @@ -383,8 +388,8 @@ class TunnelEditTableViewKeyValueCell: CopyableLabelTableViewCell { } } var isValueValid: Bool = true { - didSet(value) { - if (value) { + didSet { + if (isValueValid) { keyLabel.textColor = isValueEditable ? UIColor.black : UIColor.gray } else { keyLabel.textColor = UIColor.red |