]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
UI: iOS: more dark mode fixes
authorJason A. Donenfeld <Jason@zx2c4.com>
Fri, 25 Oct 2019 08:59:16 +0000 (10:59 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 25 Oct 2019 08:59:16 +0000 (10:59 +0200)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
WireGuard/WireGuard/UI/iOS/AppDelegate.swift
WireGuard/WireGuard/UI/iOS/ViewController/LogViewController.swift
WireGuard/WireGuard/UI/iOS/ViewController/MainViewController.swift
WireGuard/WireGuard/UI/iOS/ViewController/TunnelsListTableViewController.swift

index 41a136ec6e4aeff284f886db6be0b149dd3967cf..418557ec679314a79f2a44375b89b0af2852fdf6 100644 (file)
@@ -21,7 +21,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
         }
 
         let window = UIWindow(frame: UIScreen.main.bounds)
-        window.backgroundColor = .white
+        if #available(iOS 13.0, *) {
+            window.backgroundColor = .systemBackground
+        } else {
+            window.backgroundColor = .white
+        }
         self.window = window
 
         let mainVC = MainViewController()
index 25c16b0768817845d100946a603fea1605ca2c1e..f31af0149ce4057cc34cd55ad5287b37167ce6ac 100644 (file)
@@ -41,7 +41,11 @@ class LogViewController: UIViewController {
 
     override func loadView() {
         view = UIView()
-        view.backgroundColor = .white
+        if #available(iOS 13.0, *) {
+            view.backgroundColor = .systemBackground
+        } else {
+            view.backgroundColor = .white
+        }
 
         view.addSubview(textView)
         textView.translatesAutoresizingMaskIntoConstraints = false
@@ -87,12 +91,18 @@ class LogViewController: UIViewController {
             let richText = NSMutableAttributedString()
             let bodyFont = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body)
             let captionFont = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.caption1)
-            let lightGrayColor = UIColor(white: 0.88, alpha: 1.0)
-
             for logEntry in fetchedLogEntries {
-                let bgColor = self.isNextLineHighlighted ? lightGrayColor : UIColor.white
-                let timestampText = NSAttributedString(string: logEntry.timestamp + "\n", attributes: [.font: captionFont, .backgroundColor: bgColor, .paragraphStyle: self.paragraphStyle])
-                let messageText = NSAttributedString(string: logEntry.message + "\n", attributes: [.font: bodyFont, .backgroundColor: bgColor, .paragraphStyle: self.paragraphStyle])
+                var bgColor: UIColor
+                var fgColor: UIColor
+                if #available(iOS 13.0, *) {
+                    bgColor = self.isNextLineHighlighted ? .systemGray3 : .systemBackground
+                    fgColor = .label
+                } else {
+                    bgColor = self.isNextLineHighlighted ? UIColor(white: 0.88, alpha: 1.0) : UIColor.white
+                    fgColor = .black
+                }
+                let timestampText = NSAttributedString(string: logEntry.timestamp + "\n", attributes: [.font: captionFont, .backgroundColor: bgColor, .foregroundColor: fgColor, .paragraphStyle: self.paragraphStyle])
+                let messageText = NSAttributedString(string: logEntry.message + "\n", attributes: [.font: bodyFont, .backgroundColor: bgColor, .foregroundColor: fgColor, .paragraphStyle: self.paragraphStyle])
                 richText.append(timestampText)
                 richText.append(messageText)
                 self.isNextLineHighlighted.toggle()
index b37a4d456b7bbd67326b456d37a25d9a77d5b91c..514e03742b9f32bb2cea39952a961b74384da15a 100644 (file)
@@ -11,7 +11,11 @@ class MainViewController: UISplitViewController {
 
     init() {
         let detailVC = UIViewController()
-        detailVC.view.backgroundColor = .white
+        if #available(iOS 13.0, *) {
+            detailVC.view.backgroundColor = .systemBackground
+        } else {
+            detailVC.view.backgroundColor = .white
+        }
         let detailNC = UINavigationController(rootViewController: detailVC)
 
         let masterVC = TunnelsListTableViewController()
index 58d98c9b3ff38aa3e800ac49f05341dce0224348..e805db5128697111cf6298bbb46deda10f13dbb0 100644 (file)
@@ -52,7 +52,11 @@ class TunnelsListTableViewController: UIViewController {
 
     override func loadView() {
         view = UIView()
-        view.backgroundColor = .white
+        if #available(iOS 13.0, *) {
+            view.backgroundColor = .systemBackground
+        } else {
+            view.backgroundColor = .white
+        }
 
         tableView.dataSource = self
         tableView.delegate = self
@@ -395,7 +399,11 @@ extension TunnelsListTableViewController: TunnelsManagerListDelegate {
                 (splitViewController.viewControllers[0] as? UINavigationController)?.popToRootViewController(animated: false)
             } else {
                 let detailVC = UIViewController()
-                detailVC.view.backgroundColor = .white
+                if #available(iOS 13.0, *) {
+                    detailVC.view.backgroundColor = .systemBackground
+                } else {
+                    detailVC.view.backgroundColor = .white
+                }
                 let detailNC = UINavigationController(rootViewController: detailVC)
                 splitViewController.showDetailViewController(detailNC, sender: self)
             }