UI: iOS: more dark mode fixes
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
a1ca4f6eb5
commit
d7ce621cb2
|
@ -21,7 +21,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
let window = UIWindow(frame: UIScreen.main.bounds)
|
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
|
self.window = window
|
||||||
|
|
||||||
let mainVC = MainViewController()
|
let mainVC = MainViewController()
|
||||||
|
|
|
@ -41,7 +41,11 @@ class LogViewController: UIViewController {
|
||||||
|
|
||||||
override func loadView() {
|
override func loadView() {
|
||||||
view = UIView()
|
view = UIView()
|
||||||
view.backgroundColor = .white
|
if #available(iOS 13.0, *) {
|
||||||
|
view.backgroundColor = .systemBackground
|
||||||
|
} else {
|
||||||
|
view.backgroundColor = .white
|
||||||
|
}
|
||||||
|
|
||||||
view.addSubview(textView)
|
view.addSubview(textView)
|
||||||
textView.translatesAutoresizingMaskIntoConstraints = false
|
textView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
@ -87,12 +91,18 @@ class LogViewController: UIViewController {
|
||||||
let richText = NSMutableAttributedString()
|
let richText = NSMutableAttributedString()
|
||||||
let bodyFont = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body)
|
let bodyFont = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body)
|
||||||
let captionFont = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.caption1)
|
let captionFont = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.caption1)
|
||||||
let lightGrayColor = UIColor(white: 0.88, alpha: 1.0)
|
|
||||||
|
|
||||||
for logEntry in fetchedLogEntries {
|
for logEntry in fetchedLogEntries {
|
||||||
let bgColor = self.isNextLineHighlighted ? lightGrayColor : UIColor.white
|
var bgColor: UIColor
|
||||||
let timestampText = NSAttributedString(string: logEntry.timestamp + "\n", attributes: [.font: captionFont, .backgroundColor: bgColor, .paragraphStyle: self.paragraphStyle])
|
var fgColor: UIColor
|
||||||
let messageText = NSAttributedString(string: logEntry.message + "\n", attributes: [.font: bodyFont, .backgroundColor: bgColor, .paragraphStyle: self.paragraphStyle])
|
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(timestampText)
|
||||||
richText.append(messageText)
|
richText.append(messageText)
|
||||||
self.isNextLineHighlighted.toggle()
|
self.isNextLineHighlighted.toggle()
|
||||||
|
|
|
@ -11,7 +11,11 @@ class MainViewController: UISplitViewController {
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
let detailVC = UIViewController()
|
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 detailNC = UINavigationController(rootViewController: detailVC)
|
||||||
|
|
||||||
let masterVC = TunnelsListTableViewController()
|
let masterVC = TunnelsListTableViewController()
|
||||||
|
|
|
@ -52,7 +52,11 @@ class TunnelsListTableViewController: UIViewController {
|
||||||
|
|
||||||
override func loadView() {
|
override func loadView() {
|
||||||
view = UIView()
|
view = UIView()
|
||||||
view.backgroundColor = .white
|
if #available(iOS 13.0, *) {
|
||||||
|
view.backgroundColor = .systemBackground
|
||||||
|
} else {
|
||||||
|
view.backgroundColor = .white
|
||||||
|
}
|
||||||
|
|
||||||
tableView.dataSource = self
|
tableView.dataSource = self
|
||||||
tableView.delegate = self
|
tableView.delegate = self
|
||||||
|
@ -395,7 +399,11 @@ extension TunnelsListTableViewController: TunnelsManagerListDelegate {
|
||||||
(splitViewController.viewControllers[0] as? UINavigationController)?.popToRootViewController(animated: false)
|
(splitViewController.viewControllers[0] as? UINavigationController)?.popToRootViewController(animated: false)
|
||||||
} else {
|
} else {
|
||||||
let detailVC = UIViewController()
|
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 detailNC = UINavigationController(rootViewController: detailVC)
|
||||||
splitViewController.showDetailViewController(detailNC, sender: self)
|
splitViewController.showDetailViewController(detailNC, sender: self)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue