summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2022-03-25 12:16:48 +0100
committerAndrej Mihajlov <and@mullvad.net>2022-03-25 16:32:27 +0100
commit0f73f660f107d50eccd1f5af738254137fbdca2c (patch)
treeb6a038380f423b62104b697d2a110423ad48b4c4
parentf231a9f7c4d1c830f90c43868105d5f0852e63f4 (diff)
downloadmullvadvpn-0f73f660f107d50eccd1f5af738254137fbdca2c.tar.xz
mullvadvpn-0f73f660f107d50eccd1f5af738254137fbdca2c.zip
Settings: add external link disclosure
-rw-r--r--ios/MullvadVPN/SettingsCell.swift49
-rw-r--r--ios/MullvadVPN/SettingsDataSource.swift12
2 files changed, 40 insertions, 21 deletions
diff --git a/ios/MullvadVPN/SettingsCell.swift b/ios/MullvadVPN/SettingsCell.swift
index 02d704f50b..2bb7a8a43f 100644
--- a/ios/MullvadVPN/SettingsCell.swift
+++ b/ios/MullvadVPN/SettingsCell.swift
@@ -8,18 +8,47 @@
import UIKit
+enum SettingsDisclosureType {
+ case none
+ case chevron
+ case externalLink
+
+ var image: UIImage? {
+ switch self {
+ case .none:
+ return nil
+ case .chevron:
+ return UIImage(named: "IconChevron")
+ case .externalLink:
+ return UIImage(named: "IconExtlink")
+ }
+ }
+}
+
class SettingsCell: UITableViewCell {
let titleLabel = UILabel()
let detailTitleLabel = UILabel()
+ let disclosureImageView = UIImageView(image: nil)
- lazy var customDisclosureIndicator: UIImageView = {
- let disclosureImage = UIImage(named: "IconChevron")?
- .backport_withTintColor(UIColor.Cell.disclosureIndicatorColor, renderingMode: .alwaysOriginal)
+ var disclosureType: SettingsDisclosureType = .none {
+ didSet {
+ accessoryType = .none
- return UIImageView(image: disclosureImage)
- }()
+ let image = disclosureType.image?.backport_withTintColor(
+ UIColor.Cell.disclosureIndicatorColor,
+ renderingMode: .alwaysOriginal
+ )
+ if let image = image {
+ disclosureImageView.image = image
+ disclosureImageView.sizeToFit()
+ accessoryView = disclosureImageView
+ } else {
+ accessoryView = nil
+ }
+ }
+ }
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
@@ -94,16 +123,6 @@ class SettingsCell: UITableViewCell {
contentView.layoutMargins = UIMetrics.settingsCellLayoutMargins
}
- func setCustomDisclosureIndicator() {
- accessoryType = .none
- accessoryView = customDisclosureIndicator
- }
-
- func unsetCustomDisclosureIndicator() {
- accessoryView = nil
- accessoryType = .none
- }
-
/// On iOS 12, standard edit and reorder controls do not respect layout margins.
/// This method does layout adjustments to fix that.
private func layoutSubviews_iOS12() {
diff --git a/ios/MullvadVPN/SettingsDataSource.swift b/ios/MullvadVPN/SettingsDataSource.swift
index 231bd70b56..7ceb891e44 100644
--- a/ios/MullvadVPN/SettingsDataSource.swift
+++ b/ios/MullvadVPN/SettingsDataSource.swift
@@ -115,7 +115,7 @@ class SettingsDataSource: NSObject, AccountObserver, UITableViewDataSource, UITa
cell.titleLabel.text = NSLocalizedString("ACCOUNT_CELL_LABEL", tableName: "Settings", value: "Account", comment: "")
cell.accountExpiryDate = Account.shared.expiry
cell.accessibilityIdentifier = "AccountCell"
- cell.setCustomDisclosureIndicator()
+ cell.disclosureType = .chevron
return cell
@@ -124,7 +124,7 @@ class SettingsDataSource: NSObject, AccountObserver, UITableViewDataSource, UITa
cell.titleLabel.text = NSLocalizedString("PREFERENCES_CELL_LABEL", tableName: "Settings", value: "Preferences", comment: "")
cell.detailTitleLabel.text = nil
cell.accessibilityIdentifier = nil
- cell.setCustomDisclosureIndicator()
+ cell.disclosureType = .chevron
return cell
@@ -133,7 +133,7 @@ class SettingsDataSource: NSObject, AccountObserver, UITableViewDataSource, UITa
cell.titleLabel.text = NSLocalizedString("WIREGUARD_KEY_CELL_LABEL", tableName: "Settings", value: "WireGuard key", comment: "")
cell.detailTitleLabel.text = nil
cell.accessibilityIdentifier = "WireGuardKeyCell"
- cell.setCustomDisclosureIndicator()
+ cell.disclosureType = .chevron
return cell
@@ -142,7 +142,7 @@ class SettingsDataSource: NSObject, AccountObserver, UITableViewDataSource, UITa
cell.titleLabel.text = NSLocalizedString("APP_VERSION_CELL_LABEL", tableName: "Settings", value: "App version", comment: "")
cell.detailTitleLabel.text = Bundle.main.productVersion
cell.accessibilityIdentifier = nil
- cell.unsetCustomDisclosureIndicator()
+ cell.disclosureType = .none
return cell
@@ -151,7 +151,7 @@ class SettingsDataSource: NSObject, AccountObserver, UITableViewDataSource, UITa
cell.titleLabel.text = NSLocalizedString("REPORT_PROBLEM_CELL_LABEL", tableName: "Settings", value: "Report a problem", comment: "")
cell.detailTitleLabel.text = nil
cell.accessibilityIdentifier = nil
- cell.setCustomDisclosureIndicator()
+ cell.disclosureType = .chevron
return cell
@@ -160,7 +160,7 @@ class SettingsDataSource: NSObject, AccountObserver, UITableViewDataSource, UITa
cell.titleLabel.text = NSLocalizedString("FAQ_AND_GUIDES_CELL_LABEL", tableName: "Settings", value: "FAQ & Guides", comment: "")
cell.detailTitleLabel.text = nil
cell.accessibilityIdentifier = nil
- cell.unsetCustomDisclosureIndicator()
+ cell.disclosureType = .externalLink
return cell