aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/iOS/Settings
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuard/UI/iOS/Settings/SettingsButtonCell.swift47
-rw-r--r--WireGuard/WireGuard/UI/iOS/Settings/SettingsKeyValueCell.swift29
-rw-r--r--WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift (renamed from WireGuard/WireGuard/UI/iOS/Settings/SettingsTableViewController.swift)13
3 files changed, 7 insertions, 82 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/Settings/SettingsButtonCell.swift b/WireGuard/WireGuard/UI/iOS/Settings/SettingsButtonCell.swift
deleted file mode 100644
index d795ab4..0000000
--- a/WireGuard/WireGuard/UI/iOS/Settings/SettingsButtonCell.swift
+++ /dev/null
@@ -1,47 +0,0 @@
-// SPDX-License-Identifier: MIT
-// Copyright © 2018 WireGuard LLC. All Rights Reserved.
-
-import UIKit
-
-class SettingsButtonCell: UITableViewCell {
- var buttonText: String {
- get { return button.title(for: .normal) ?? "" }
- set(value) { button.setTitle(value, for: .normal) }
- }
- var onTapped: (() -> Void)?
-
- let button: UIButton = {
- let button = UIButton(type: .system)
- button.titleLabel?.font = UIFont.preferredFont(forTextStyle: .body)
- button.titleLabel?.adjustsFontForContentSizeCategory = true
- return button
- }()
-
- override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
- super.init(style: style, reuseIdentifier: reuseIdentifier)
-
- contentView.addSubview(button)
- button.translatesAutoresizingMaskIntoConstraints = false
- NSLayoutConstraint.activate([
- button.topAnchor.constraint(equalTo: contentView.layoutMarginsGuide.topAnchor),
- contentView.layoutMarginsGuide.bottomAnchor.constraint(equalTo: button.bottomAnchor),
- button.centerXAnchor.constraint(equalTo: contentView.centerXAnchor)
- ])
-
- button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
- }
-
- @objc func buttonTapped() {
- onTapped?()
- }
-
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
-
- override func prepareForReuse() {
- super.prepareForReuse()
- buttonText = ""
- onTapped = nil
- }
-}
diff --git a/WireGuard/WireGuard/UI/iOS/Settings/SettingsKeyValueCell.swift b/WireGuard/WireGuard/UI/iOS/Settings/SettingsKeyValueCell.swift
deleted file mode 100644
index 532f1d1..0000000
--- a/WireGuard/WireGuard/UI/iOS/Settings/SettingsKeyValueCell.swift
+++ /dev/null
@@ -1,29 +0,0 @@
-// SPDX-License-Identifier: MIT
-// Copyright © 2018 WireGuard LLC. All Rights Reserved.
-
-import UIKit
-
-class SettingsKeyValueCell: UITableViewCell {
- var key: String {
- get { return textLabel?.text ?? "" }
- set(value) { textLabel?.text = value }
- }
- var value: String {
- get { return detailTextLabel?.text ?? "" }
- set(value) { detailTextLabel?.text = value }
- }
-
- override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
- super.init(style: .value1, reuseIdentifier: SettingsKeyValueCell.reuseIdentifier)
- }
-
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
-
- override func prepareForReuse() {
- super.prepareForReuse()
- key = ""
- value = ""
- }
-}
diff --git a/WireGuard/WireGuard/UI/iOS/Settings/SettingsTableViewController.swift b/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift
index 5e8aee6..b583c5b 100644
--- a/WireGuard/WireGuard/UI/iOS/Settings/SettingsTableViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift
@@ -40,15 +40,15 @@ class SettingsTableViewController: UITableViewController {
tableView.rowHeight = UITableView.automaticDimension
tableView.allowsSelection = false
- tableView.register(SettingsKeyValueCell.self)
- tableView.register(SettingsButtonCell.self)
+ tableView.register(KeyValueCell.self)
+ tableView.register(ButtonCell.self)
tableView.tableFooterView = UIImageView(image: UIImage(named: "wireguard.pdf"))
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
- guard let logo = self.tableView.tableFooterView else { return }
+ guard let logo = tableView.tableFooterView else { return }
let bottomPadding = max(tableView.layoutMargins.bottom, 10)
let fullHeight = max(tableView.contentSize.height, tableView.bounds.size.height - tableView.layoutMargins.top - bottomPadding)
@@ -167,7 +167,8 @@ extension SettingsTableViewController {
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let field = settingsFieldsBySection[indexPath.section][indexPath.row]
if field == .iosAppVersion || field == .goBackendVersion {
- let cell: SettingsKeyValueCell = tableView.dequeueReusableCell(for: indexPath)
+ let cell: KeyValueCell = tableView.dequeueReusableCell(for: indexPath)
+ cell.copyableGesture = false
cell.key = field.rawValue
if field == .iosAppVersion {
var appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown version"
@@ -180,7 +181,7 @@ extension SettingsTableViewController {
}
return cell
} else if field == .exportZipArchive {
- let cell: SettingsButtonCell = tableView.dequeueReusableCell(for: indexPath)
+ let cell: ButtonCell = tableView.dequeueReusableCell(for: indexPath)
cell.buttonText = field.rawValue
cell.onTapped = { [weak self] in
self?.exportConfigurationsAsZipFile(sourceView: cell.button)
@@ -188,7 +189,7 @@ extension SettingsTableViewController {
return cell
} else {
assert(field == .exportLogFile)
- let cell: SettingsButtonCell = tableView.dequeueReusableCell(for: indexPath)
+ let cell: ButtonCell = tableView.dequeueReusableCell(for: indexPath)
cell.buttonText = field.rawValue
cell.onTapped = { [weak self] in
self?.exportLogForLastActivatedTunnel(sourceView: cell.button)