UI: iOS: adjust colors for iOS 13
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>
This commit is contained in:
parent
226166bdaf
commit
4c37a4b7a7
|
@ -9,8 +9,8 @@ class ButtonCell: UITableViewCell {
|
||||||
set(value) { button.setTitle(value, for: .normal) }
|
set(value) { button.setTitle(value, for: .normal) }
|
||||||
}
|
}
|
||||||
var hasDestructiveAction: Bool {
|
var hasDestructiveAction: Bool {
|
||||||
get { return button.tintColor == .red }
|
get { return button.tintColor == .systemRed }
|
||||||
set(value) { button.tintColor = value ? .red : buttonStandardTintColor }
|
set(value) { button.tintColor = value ? .systemRed : buttonStandardTintColor }
|
||||||
}
|
}
|
||||||
var onTapped: (() -> Void)?
|
var onTapped: (() -> Void)?
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,11 @@ class KeyValueCell: UITableViewCell {
|
||||||
let keyLabel = UILabel()
|
let keyLabel = UILabel()
|
||||||
keyLabel.font = UIFont.preferredFont(forTextStyle: .body)
|
keyLabel.font = UIFont.preferredFont(forTextStyle: .body)
|
||||||
keyLabel.adjustsFontForContentSizeCategory = true
|
keyLabel.adjustsFontForContentSizeCategory = true
|
||||||
keyLabel.textColor = .black
|
if #available(iOS 13.0, *) {
|
||||||
|
keyLabel.textColor = .label
|
||||||
|
} else {
|
||||||
|
keyLabel.textColor = .black
|
||||||
|
}
|
||||||
keyLabel.textAlignment = .left
|
keyLabel.textAlignment = .left
|
||||||
return keyLabel
|
return keyLabel
|
||||||
}()
|
}()
|
||||||
|
@ -31,7 +35,11 @@ class KeyValueCell: UITableViewCell {
|
||||||
valueTextField.autocapitalizationType = .none
|
valueTextField.autocapitalizationType = .none
|
||||||
valueTextField.autocorrectionType = .no
|
valueTextField.autocorrectionType = .no
|
||||||
valueTextField.spellCheckingType = .no
|
valueTextField.spellCheckingType = .no
|
||||||
valueTextField.textColor = .gray
|
if #available(iOS 13.0, *) {
|
||||||
|
valueTextField.textColor = .secondaryLabel
|
||||||
|
} else {
|
||||||
|
valueTextField.textColor = .gray
|
||||||
|
}
|
||||||
return valueTextField
|
return valueTextField
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -56,10 +64,18 @@ class KeyValueCell: UITableViewCell {
|
||||||
|
|
||||||
var isValueValid = true {
|
var isValueValid = true {
|
||||||
didSet {
|
didSet {
|
||||||
if isValueValid {
|
if #available(iOS 13.0, *) {
|
||||||
keyLabel.textColor = .black
|
if isValueValid {
|
||||||
|
keyLabel.textColor = .label
|
||||||
|
} else {
|
||||||
|
keyLabel.textColor = .systemRed
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
keyLabel.textColor = .red
|
if isValueValid {
|
||||||
|
keyLabel.textColor = .black
|
||||||
|
} else {
|
||||||
|
keyLabel.textColor = .red
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,11 @@ class SwitchCell: UITableViewCell {
|
||||||
get { return switchView.isEnabled }
|
get { return switchView.isEnabled }
|
||||||
set(value) {
|
set(value) {
|
||||||
switchView.isEnabled = 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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,11 @@ class TextCell: UITableViewCell {
|
||||||
override func prepareForReuse() {
|
override func prepareForReuse() {
|
||||||
super.prepareForReuse()
|
super.prepareForReuse()
|
||||||
message = ""
|
message = ""
|
||||||
setTextColor(.black)
|
if #available(iOS 13.0, *) {
|
||||||
|
setTextColor(.label)
|
||||||
|
} else {
|
||||||
|
setTextColor(.black)
|
||||||
|
}
|
||||||
setTextAlignment(.left)
|
setTextAlignment(.left)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,11 @@ class TunnelEditEditableKeyValueCell: TunnelEditKeyValueCell {
|
||||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||||
|
|
||||||
copyableGesture = false
|
copyableGesture = false
|
||||||
valueTextField.textColor = .black
|
if #available(iOS 13.0, *) {
|
||||||
|
valueTextField.textColor = .label
|
||||||
|
} else {
|
||||||
|
valueTextField.textColor = .black
|
||||||
|
}
|
||||||
valueTextField.isEnabled = true
|
valueTextField.isEnabled = true
|
||||||
valueLabelScrollView.isScrollEnabled = false
|
valueLabelScrollView.isScrollEnabled = false
|
||||||
valueTextField.widthAnchor.constraint(equalTo: valueLabelScrollView.widthAnchor).isActive = true
|
valueTextField.widthAnchor.constraint(equalTo: valueLabelScrollView.widthAnchor).isActive = true
|
||||||
|
|
|
@ -29,9 +29,15 @@ class TunnelListCell: UITableViewCell {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
let busyIndicator: UIActivityIndicatorView = {
|
let busyIndicator: UIActivityIndicatorView = {
|
||||||
let busyIndicator = UIActivityIndicatorView(style: .gray)
|
if #available(iOS 13.0, *) {
|
||||||
busyIndicator.hidesWhenStopped = true
|
let busyIndicator = UIActivityIndicatorView(style: .medium)
|
||||||
return busyIndicator
|
busyIndicator.hidesWhenStopped = true
|
||||||
|
return busyIndicator
|
||||||
|
} else {
|
||||||
|
let busyIndicator = UIActivityIndicatorView(style: .gray)
|
||||||
|
busyIndicator.hidesWhenStopped = true
|
||||||
|
return busyIndicator
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
let statusSwitch = UISwitch()
|
let statusSwitch = UISwitch()
|
||||||
|
|
|
@ -15,9 +15,15 @@ class LogViewController: UIViewController {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
let busyIndicator: UIActivityIndicatorView = {
|
let busyIndicator: UIActivityIndicatorView = {
|
||||||
let busyIndicator = UIActivityIndicatorView(style: .gray)
|
if #available(iOS 13.0, *) {
|
||||||
busyIndicator.hidesWhenStopped = true
|
let busyIndicator = UIActivityIndicatorView(style: .medium)
|
||||||
return busyIndicator
|
busyIndicator.hidesWhenStopped = true
|
||||||
|
return busyIndicator
|
||||||
|
} else {
|
||||||
|
let busyIndicator = UIActivityIndicatorView(style: .gray)
|
||||||
|
busyIndicator.hidesWhenStopped = true
|
||||||
|
return busyIndicator
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
let paragraphStyle: NSParagraphStyle = {
|
let paragraphStyle: NSParagraphStyle = {
|
||||||
|
|
|
@ -176,7 +176,11 @@ extension SSIDOptionEditTableViewController {
|
||||||
private func noSSIDsCell(for tableView: UITableView, at indexPath: IndexPath) -> UITableViewCell {
|
private func noSSIDsCell(for tableView: UITableView, at indexPath: IndexPath) -> UITableViewCell {
|
||||||
let cell: TextCell = tableView.dequeueReusableCell(for: indexPath)
|
let cell: TextCell = tableView.dequeueReusableCell(for: indexPath)
|
||||||
cell.message = tr("tunnelOnDemandNoSSIDs")
|
cell.message = tr("tunnelOnDemandNoSSIDs")
|
||||||
cell.setTextColor(.gray)
|
if #available(iOS 13.0, *) {
|
||||||
|
cell.setTextColor(.secondaryLabel)
|
||||||
|
} else {
|
||||||
|
cell.setTextColor(.gray)
|
||||||
|
}
|
||||||
cell.setTextAlignment(.center)
|
cell.setTextAlignment(.center)
|
||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,15 @@ class TunnelsListTableViewController: UIViewController {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
let busyIndicator: UIActivityIndicatorView = {
|
let busyIndicator: UIActivityIndicatorView = {
|
||||||
let busyIndicator = UIActivityIndicatorView(style: .gray)
|
if #available(iOS 13.0, *) {
|
||||||
busyIndicator.hidesWhenStopped = true
|
let busyIndicator = UIActivityIndicatorView(style: .medium)
|
||||||
return busyIndicator
|
busyIndicator.hidesWhenStopped = true
|
||||||
|
return busyIndicator
|
||||||
|
} else {
|
||||||
|
let busyIndicator = UIActivityIndicatorView(style: .gray)
|
||||||
|
busyIndicator.hidesWhenStopped = true
|
||||||
|
return busyIndicator
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var detailDisplayedTunnel: TunnelContainer?
|
var detailDisplayedTunnel: TunnelContainer?
|
||||||
|
|
Loading…
Reference in New Issue