]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
UI: iOS: adjust colors for iOS 13
authorDiab Neiroukh <officiallazerl0rd@gmail.com>
Mon, 14 Oct 2019 21:43:56 +0000 (22:43 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Mon, 14 Oct 2019 22:01:17 +0000 (00:01 +0200)
To be compatible with Dark Mode, we need to change some of our
color references to be "dynamic".

Signed-off-by: Diab Neiroukh <officiallazerl0rd@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
WireGuard/WireGuard/UI/iOS/View/ButtonCell.swift
WireGuard/WireGuard/UI/iOS/View/KeyValueCell.swift
WireGuard/WireGuard/UI/iOS/View/SwitchCell.swift
WireGuard/WireGuard/UI/iOS/View/TextCell.swift
WireGuard/WireGuard/UI/iOS/View/TunnelEditKeyValueCell.swift
WireGuard/WireGuard/UI/iOS/View/TunnelListCell.swift
WireGuard/WireGuard/UI/iOS/ViewController/LogViewController.swift
WireGuard/WireGuard/UI/iOS/ViewController/SSIDOptionEditTableViewController.swift
WireGuard/WireGuard/UI/iOS/ViewController/TunnelsListTableViewController.swift

index 62333152714b693c9a4f965b90a680dab3344d24..90601c5d0dc774fb7caa59349268ac5b7b9e41f0 100644 (file)
@@ -9,8 +9,8 @@ class ButtonCell: UITableViewCell {
         set(value) { button.setTitle(value, for: .normal) }
     }
     var hasDestructiveAction: Bool {
-        get { return button.tintColor == .red }
-        set(value) { button.tintColor = value ? .red : buttonStandardTintColor }
+        get { return button.tintColor == .systemRed }
+        set(value) { button.tintColor = value ? .systemRed : buttonStandardTintColor }
     }
     var onTapped: (() -> Void)?
 
index df86752f8ab4c925c0045a29bf9d3dd796c021a9..9b1d13b9e9ab0e508374f9311e5529db4401f41b 100644 (file)
@@ -9,7 +9,11 @@ class KeyValueCell: UITableViewCell {
         let keyLabel = UILabel()
         keyLabel.font = UIFont.preferredFont(forTextStyle: .body)
         keyLabel.adjustsFontForContentSizeCategory = true
-        keyLabel.textColor = .black
+        if #available(iOS 13.0, *) {
+            keyLabel.textColor = .label
+        } else {
+            keyLabel.textColor = .black
+        }
         keyLabel.textAlignment = .left
         return keyLabel
     }()
@@ -31,7 +35,11 @@ class KeyValueCell: UITableViewCell {
         valueTextField.autocapitalizationType = .none
         valueTextField.autocorrectionType = .no
         valueTextField.spellCheckingType = .no
-        valueTextField.textColor = .gray
+        if #available(iOS 13.0, *) {
+            valueTextField.textColor = .secondaryLabel
+        } else {
+            valueTextField.textColor = .gray
+        }
         return valueTextField
     }()
 
@@ -56,10 +64,18 @@ class KeyValueCell: UITableViewCell {
 
     var isValueValid = true {
         didSet {
-            if isValueValid {
-                keyLabel.textColor = .black
+            if #available(iOS 13.0, *) {
+                if isValueValid {
+                    keyLabel.textColor = .label
+                } else {
+                    keyLabel.textColor = .systemRed
+                }
             } else {
-                keyLabel.textColor = .red
+                if isValueValid {
+                    keyLabel.textColor = .black
+                } else {
+                    keyLabel.textColor = .red
+                }
             }
         }
     }
index 616959300ff2c093657c7e3f22cc4578e652874d..0d6e4dea35d36b829fbe9b5a686a9dde33d08e40 100644 (file)
@@ -16,7 +16,11 @@ class SwitchCell: UITableViewCell {
         get { return switchView.isEnabled }
         set(value) {
             switchView.isEnabled = value
-            textLabel?.textColor = value ? .black : .gray
+            if #available(iOS 13.0, *) {
+                textLabel?.textColor = value ? .label : .secondaryLabel
+            } else {
+                textLabel?.textColor = value ? .black : .gray
+            }
         }
     }
 
index ba9b37f855ca02f62ff9fef763c07708ef63d167..7df9444f02091e1c9fea15180eece74d33df9407 100644 (file)
@@ -28,7 +28,11 @@ class TextCell: UITableViewCell {
     override func prepareForReuse() {
         super.prepareForReuse()
         message = ""
-        setTextColor(.black)
+        if #available(iOS 13.0, *) {
+            setTextColor(.label)
+        } else {
+            setTextColor(.black)
+        }
         setTextAlignment(.left)
     }
 }
index 7c69a4740434706030765d6b2696d1893aeb2b96..c139566bcab69e14c7bacb9db8e93c8d994d7781 100644 (file)
@@ -30,7 +30,11 @@ class TunnelEditEditableKeyValueCell: TunnelEditKeyValueCell {
         super.init(style: style, reuseIdentifier: reuseIdentifier)
 
         copyableGesture = false
-        valueTextField.textColor = .black
+        if #available(iOS 13.0, *) {
+            valueTextField.textColor = .label
+        } else {
+            valueTextField.textColor = .black
+        }
         valueTextField.isEnabled = true
         valueLabelScrollView.isScrollEnabled = false
         valueTextField.widthAnchor.constraint(equalTo: valueLabelScrollView.widthAnchor).isActive = true
index 914acc259a9601fbe4249d71fb91e4ea8c9e7086..b2e0ba9feba3d021abcd39c49cbee3129bb741e8 100644 (file)
@@ -29,9 +29,15 @@ class TunnelListCell: UITableViewCell {
     }()
 
     let busyIndicator: UIActivityIndicatorView = {
-        let busyIndicator = UIActivityIndicatorView(style: .gray)
-        busyIndicator.hidesWhenStopped = true
-        return busyIndicator
+        if #available(iOS 13.0, *) {
+            let busyIndicator = UIActivityIndicatorView(style: .medium)
+            busyIndicator.hidesWhenStopped = true
+            return busyIndicator
+        } else {
+            let busyIndicator = UIActivityIndicatorView(style: .gray)
+            busyIndicator.hidesWhenStopped = true
+            return busyIndicator
+        }
     }()
 
     let statusSwitch = UISwitch()
index 4e4412d672ec5e054b38e733616f619a925cda3e..25c16b0768817845d100946a603fea1605ca2c1e 100644 (file)
@@ -15,9 +15,15 @@ class LogViewController: UIViewController {
     }()
 
     let busyIndicator: UIActivityIndicatorView = {
-        let busyIndicator = UIActivityIndicatorView(style: .gray)
-        busyIndicator.hidesWhenStopped = true
-        return busyIndicator
+        if #available(iOS 13.0, *) {
+            let busyIndicator = UIActivityIndicatorView(style: .medium)
+            busyIndicator.hidesWhenStopped = true
+            return busyIndicator
+        } else {
+            let busyIndicator = UIActivityIndicatorView(style: .gray)
+            busyIndicator.hidesWhenStopped = true
+            return busyIndicator
+        }
     }()
 
     let paragraphStyle: NSParagraphStyle = {
index 8740f06d7c1599dbdbd05d1eebd7b8f1c208aaa8..a9822583437281f59acee3b318aa98c3d4b1155f 100644 (file)
@@ -176,7 +176,11 @@ extension SSIDOptionEditTableViewController {
     private func noSSIDsCell(for tableView: UITableView, at indexPath: IndexPath) -> UITableViewCell {
         let cell: TextCell = tableView.dequeueReusableCell(for: indexPath)
         cell.message = tr("tunnelOnDemandNoSSIDs")
-        cell.setTextColor(.gray)
+        if #available(iOS 13.0, *) {
+            cell.setTextColor(.secondaryLabel)
+        } else {
+            cell.setTextColor(.gray)
+        }
         cell.setTextAlignment(.center)
         return cell
     }
index 372a8e397a5e83a4d01a5c4e3f22366f9f4119cd..d58b2680e54869e1aff9acecd8a51e5fcaefad48 100644 (file)
@@ -32,9 +32,15 @@ class TunnelsListTableViewController: UIViewController {
     }()
 
     let busyIndicator: UIActivityIndicatorView = {
-        let busyIndicator = UIActivityIndicatorView(style: .gray)
-        busyIndicator.hidesWhenStopped = true
-        return busyIndicator
+        if #available(iOS 13.0, *) {
+            let busyIndicator = UIActivityIndicatorView(style: .medium)
+            busyIndicator.hidesWhenStopped = true
+            return busyIndicator
+        } else {
+            let busyIndicator = UIActivityIndicatorView(style: .gray)
+            busyIndicator.hidesWhenStopped = true
+            return busyIndicator
+        }
     }()
 
     var detailDisplayedTunnel: TunnelContainer?