aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-10-25 10:59:16 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-10-25 10:59:16 +0200
commitd7ce621cb2d1c4a91844ac1111e7c041c58dec8e (patch)
treefc83b3d576107edfbda44bc9ac4f54861d99c004
parentwireguard-go-bridge: work around Go 1.13.3 regression (diff)
downloadwireguard-apple-d7ce621cb2d1c4a91844ac1111e7c041c58dec8e.tar.xz
wireguard-apple-d7ce621cb2d1c4a91844ac1111e7c041c58dec8e.zip
UI: iOS: more dark mode fixes
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--WireGuard/WireGuard/UI/iOS/AppDelegate.swift6
-rw-r--r--WireGuard/WireGuard/UI/iOS/ViewController/LogViewController.swift22
-rw-r--r--WireGuard/WireGuard/UI/iOS/ViewController/MainViewController.swift6
-rw-r--r--WireGuard/WireGuard/UI/iOS/ViewController/TunnelsListTableViewController.swift12
4 files changed, 36 insertions, 10 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/AppDelegate.swift b/WireGuard/WireGuard/UI/iOS/AppDelegate.swift
index 41a136e..418557e 100644
--- a/WireGuard/WireGuard/UI/iOS/AppDelegate.swift
+++ b/WireGuard/WireGuard/UI/iOS/AppDelegate.swift
@@ -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()
diff --git a/WireGuard/WireGuard/UI/iOS/ViewController/LogViewController.swift b/WireGuard/WireGuard/UI/iOS/ViewController/LogViewController.swift
index 25c16b0..f31af01 100644
--- a/WireGuard/WireGuard/UI/iOS/ViewController/LogViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/ViewController/LogViewController.swift
@@ -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()
diff --git a/WireGuard/WireGuard/UI/iOS/ViewController/MainViewController.swift b/WireGuard/WireGuard/UI/iOS/ViewController/MainViewController.swift
index b37a4d4..514e037 100644
--- a/WireGuard/WireGuard/UI/iOS/ViewController/MainViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/ViewController/MainViewController.swift
@@ -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()
diff --git a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelsListTableViewController.swift
index 58d98c9..e805db5 100644
--- a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelsListTableViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelsListTableViewController.swift
@@ -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)
}