summaryrefslogtreecommitdiffhomepage
path: root/ios
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2019-12-05 16:45:36 +0100
committerAndrej Mihajlov <and@mullvad.net>2019-12-06 10:34:03 +0100
commitf0e08152b60cae8a4c65c9c4e1361d0c52791d43 (patch)
tree7f0ce4a934217f44bd5264a37c021ea31fbbf583 /ios
parenta7837d5099f2677e67bc7991ecd9d54d202c6c18 (diff)
downloadmullvadvpn-f0e08152b60cae8a4c65c9c4e1361d0c52791d43.tar.xz
mullvadvpn-f0e08152b60cae8a4c65c9c4e1361d0c52791d43.zip
Adjust settings cell margins and fix disclosure tint color
Diffstat (limited to 'ios')
-rw-r--r--ios/MullvadVPN/SettingsAccountCell.swift7
-rw-r--r--ios/MullvadVPN/SettingsCell.swift27
2 files changed, 26 insertions, 8 deletions
diff --git a/ios/MullvadVPN/SettingsAccountCell.swift b/ios/MullvadVPN/SettingsAccountCell.swift
index f938b26df2..cc959c7c46 100644
--- a/ios/MullvadVPN/SettingsAccountCell.swift
+++ b/ios/MullvadVPN/SettingsAccountCell.swift
@@ -19,13 +19,6 @@ class SettingsAccountCell: SettingsCell {
}
}
- override func awakeFromNib() {
- super.awakeFromNib()
-
- // Remove the right margin since the accessory view adds it automatically
- contentView.layoutMargins.right = 0
- }
-
private func didUpdateAccountExpiry() {
if let accountExpiryDate = accountExpiryDate {
let accountExpiry = AccountExpiry(date: accountExpiryDate)
diff --git a/ios/MullvadVPN/SettingsCell.swift b/ios/MullvadVPN/SettingsCell.swift
index 4d09e52651..754cba03e9 100644
--- a/ios/MullvadVPN/SettingsCell.swift
+++ b/ios/MullvadVPN/SettingsCell.swift
@@ -7,10 +7,12 @@
//
import UIKit
+import Combine
class SettingsCell: BasicTableViewCell {
- private let preferredMargins = UIEdgeInsets(top: 14, left: 24, bottom: 14, right: 12)
+ private let preferredMargins = UIEdgeInsets(top: 16, left: 24, bottom: 16, right: 12)
+ private var appDidBecomeActiveSubscriber: AnyCancellable?
override func awakeFromNib() {
super.awakeFromNib()
@@ -19,6 +21,29 @@ class SettingsCell: BasicTableViewCell {
selectedBackgroundView?.backgroundColor = UIColor.Cell.selectedAltBackgroundColor
contentView.layoutMargins = preferredMargins
+
+ enableDisclosureViewTintColorFix()
}
+ /// `UITableViewCell` resets the disclosure view image when the app goes in background
+ /// This fix ensures that the image is tinted when the app becomes active again.
+ private func enableDisclosureViewTintColorFix() {
+ appDidBecomeActiveSubscriber = NotificationCenter.default
+ .publisher(for: UIApplication.didBecomeActiveNotification, object: nil)
+ .sink { [weak self] (_) in
+ self?.updateDisclosureViewTintColor()
+ }
+
+ updateDisclosureViewTintColor()
+ }
+
+ /// For some reason the `tintColor` is not applied to standard accessory views.
+ /// Fix this by looking for the accessory button and changing the image rendering mode
+ private func updateDisclosureViewTintColor() {
+ for case let button as UIButton in subviews {
+ if let image = button.backgroundImage(for: .normal)?.withRenderingMode(.alwaysTemplate) {
+ button.setBackgroundImage(image, for: .normal)
+ }
+ }
+ }
}