diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-11-03 19:35:25 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-11-03 19:35:25 +0100 |
commit | 955de09c9e0e318642089fe63c4c1d44517e3ff8 (patch) | |
tree | 82e99b4f67464fa5c464eff9a7d6db5a40b8d669 /WireGuard/WireGuard/UI/iOS | |
parent | Settings: limit size of logo (diff) | |
download | wireguard-apple-955de09c9e0e318642089fe63c4c1d44517e3ff8.tar.xz wireguard-apple-955de09c9e0e318642089fe63c4c1d44517e3ff8.zip |
Global: run through swiftlint
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'WireGuard/WireGuard/UI/iOS')
6 files changed, 34 insertions, 35 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/AppDelegate.swift b/WireGuard/WireGuard/UI/iOS/AppDelegate.swift index 57b6191..d7d1652 100644 --- a/WireGuard/WireGuard/UI/iOS/AppDelegate.swift +++ b/WireGuard/WireGuard/UI/iOS/AppDelegate.swift @@ -26,7 +26,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { return true } - func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool { + func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool { defer { do { try FileManager.default.removeItem(at: url) diff --git a/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift b/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift index 929b6b0..ea9ece4 100644 --- a/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift @@ -6,7 +6,7 @@ import CoreData import UIKit protocol QRScanViewControllerDelegate: class { - func addScannedQRCode(tunnelConfiguration: TunnelConfiguration, qrScanViewController: QRScanViewController, completionHandler: (() ->Void)?) + func addScannedQRCode(tunnelConfiguration: TunnelConfiguration, qrScanViewController: QRScanViewController, completionHandler: (() -> Void)?) } class QRScanViewController: UIViewController { diff --git a/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift b/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift index acca64d..ca8f45b 100644 --- a/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift @@ -12,13 +12,13 @@ class SettingsTableViewController: UITableViewController { case exportZipArchive = "Export zip archive" } - let settingsFieldsBySection : [[SettingsFields]] = [ + let settingsFieldsBySection: [[SettingsFields]] = [ [.exportZipArchive], [.iosAppVersion, .goBackendVersion] ] let tunnelsManager: TunnelsManager? - var wireguardCaptionedImage: (view: UIView, size: CGSize)? = nil + var wireguardCaptionedImage: (view: UIView, size: CGSize)? init(tunnelsManager: TunnelsManager?) { self.tunnelsManager = tunnelsManager @@ -97,7 +97,7 @@ class SettingsTableViewController: UITableViewController { // popoverPresentationController shall be non-nil on the iPad activityVC.popoverPresentationController?.sourceView = sourceView present(activityVC, animated: true) - + } catch (let error) { showErrorAlert(title: "Unable to export", message: "There was an error exporting the tunnel configuration archive: \(String(describing: error))") } @@ -201,7 +201,7 @@ class TunnelSettingsTableViewButtonCell: UITableViewCell { get { return button.title(for: .normal) ?? "" } set(value) { button.setTitle(value, for: .normal) } } - var onTapped: (() -> Void)? = nil + var onTapped: (() -> Void)? let button: UIButton diff --git a/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift index 2174602..3165553 100644 --- a/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift @@ -62,7 +62,7 @@ class TunnelDetailTableViewController: UITableViewController { func showConfirmationAlert(message: String, buttonTitle: String, from sourceView: UIView, onConfirmed: @escaping (() -> Void)) { - let destroyAction = UIAlertAction(title: buttonTitle, style: .destructive) { (action) in + let destroyAction = UIAlertAction(title: buttonTitle, style: .destructive) { (_) in onConfirmed() } let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) @@ -221,11 +221,11 @@ class TunnelDetailTableViewStatusCell: UITableViewCell { get { return statusSwitch.isUserInteractionEnabled } set(value) { statusSwitch.isUserInteractionEnabled = value } } - var onSwitchToggled: ((Bool) -> Void)? = nil + var onSwitchToggled: ((Bool) -> Void)? private var isOnSwitchToggledHandlerEnabled: Bool = true let statusSwitch: UISwitch - private var statusObservervationToken: AnyObject? = nil + private var statusObservervationToken: AnyObject? override init(style: UITableViewCellStyle, reuseIdentifier: String?) { statusSwitch = UISwitch() @@ -382,7 +382,7 @@ class TunnelDetailTableViewButtonCell: UITableViewCell { get { return button.tintColor == UIColor.red } set(value) { button.tintColor = value ? UIColor.red : buttonStandardTintColor } } - var onTapped: (() -> Void)? = nil + var onTapped: (() -> Void)? let button: UIButton var buttonStandardTintColor: UIColor diff --git a/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift index 2c217a1..37613c2 100644 --- a/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift @@ -12,7 +12,7 @@ protocol TunnelEditTableViewControllerDelegate: class { class TunnelEditTableViewController: UITableViewController { - weak var delegate: TunnelEditTableViewControllerDelegate? = nil + weak var delegate: TunnelEditTableViewControllerDelegate? let interfaceFieldsBySection: [[TunnelViewModel.InterfaceField]] = [ [.name], @@ -388,7 +388,7 @@ extension TunnelEditTableViewController { func showConfirmationAlert(message: String, buttonTitle: String, from sourceView: UIView, onConfirmed: @escaping (() -> Void)) { - let destroyAction = UIAlertAction(title: buttonTitle, style: .destructive) { (action) in + let destroyAction = UIAlertAction(title: buttonTitle, style: .destructive) { (_) in onConfirmed() } let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) @@ -440,8 +440,8 @@ class TunnelEditTableViewKeyValueCell: CopyableLabelTableViewCell { set(value) { valueTextField.keyboardType = value } } - var onValueChanged: ((String) -> Void)? = nil - var onValueBeingEdited: ((String) -> Void)? = nil + var onValueChanged: ((String) -> Void)? + var onValueBeingEdited: ((String) -> Void)? let keyLabel: UILabel let valueTextField: UITextField @@ -534,7 +534,7 @@ class TunnelEditTableViewButtonCell: UITableViewCell { get { return button.tintColor == UIColor.red } set(value) { button.tintColor = value ? UIColor.red : buttonStandardTintColor } } - var onTapped: (() -> Void)? = nil + var onTapped: (() -> Void)? let button: UIButton var buttonStandardTintColor: UIColor @@ -586,7 +586,7 @@ class TunnelEditTableViewSwitchCell: UITableViewCell { } } - var onSwitchToggled: ((Bool) -> Void)? = nil + var onSwitchToggled: ((Bool) -> Void)? let switchView: UISwitch diff --git a/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift index 15da060..48515e9 100644 --- a/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift @@ -6,12 +6,12 @@ import MobileCoreServices class TunnelsListTableViewController: UIViewController { - var tunnelsManager: TunnelsManager? = nil - var onTunnelsManagerReady: ((TunnelsManager) -> Void)? = nil + var tunnelsManager: TunnelsManager? + var onTunnelsManagerReady: ((TunnelsManager) -> Void)? - var busyIndicator: UIActivityIndicatorView? = nil - var centeredAddButton: BorderedTextButton? = nil - var tableView: UITableView? = nil + var busyIndicator: UIActivityIndicatorView? + var centeredAddButton: BorderedTextButton? + var tableView: UITableView? override func viewDidLoad() { super.viewDidLoad() @@ -88,17 +88,17 @@ class TunnelsListTableViewController: UIViewController { @objc func addButtonTapped(sender: AnyObject) { if (self.tunnelsManager == nil) { return } // Do nothing until we've loaded the tunnels let alert = UIAlertController(title: "", message: "Add a new WireGuard tunnel", preferredStyle: .actionSheet) - let importFileAction = UIAlertAction(title: "Create from file or archive", style: .default) { [weak self] (action) in + let importFileAction = UIAlertAction(title: "Create from file or archive", style: .default) { [weak self] (_) in self?.presentViewControllerForFileImport() } alert.addAction(importFileAction) - let scanQRCodeAction = UIAlertAction(title: "Create from QR code", style: .default) { [weak self] (action) in + let scanQRCodeAction = UIAlertAction(title: "Create from QR code", style: .default) { [weak self] (_) in self?.presentViewControllerForScanningQRCode() } alert.addAction(scanQRCodeAction) - let createFromScratchAction = UIAlertAction(title: "Create from scratch", style: .default) { [weak self] (action) in + let createFromScratchAction = UIAlertAction(title: "Create from scratch", style: .default) { [weak self] (_) in if let s = self, let tunnelsManager = s.tunnelsManager { s.presentViewControllerForTunnelCreation(tunnelsManager: tunnelsManager, tunnelConfiguration: nil) } @@ -181,7 +181,7 @@ class TunnelsListTableViewController: UIViewController { let fileBaseName = url.deletingPathExtension().lastPathComponent.trimmingCharacters(in: .whitespacesAndNewlines) if let fileContents = try? String(contentsOf: url), let tunnelConfiguration = try? WgQuickConfigFileParser.parse(fileContents, name: fileBaseName) { - tunnelsManager?.add(tunnelConfiguration: tunnelConfiguration) { (tunnel, error) in + tunnelsManager?.add(tunnelConfiguration: tunnelConfiguration) { (_, error) in if let error = error { ErrorPresenter.showErrorAlert(error: error, from: self) } @@ -203,7 +203,7 @@ class TunnelsListTableViewController: UIViewController { showErrorAlert(title: "Unable to read zip archive", message: "Unexpected error: \(String(describing: error))") return } - + for (i, unarchivedFile) in unarchivedFiles.enumerated().reversed() { let fileBaseName = URL(string: unarchivedFile.fileName)?.deletingPathExtension().lastPathComponent if let trimmedName = fileBaseName?.trimmingCharacters(in: .whitespacesAndNewlines), !trimmedName.isEmpty { @@ -218,7 +218,7 @@ class TunnelsListTableViewController: UIViewController { } guard let tunnelsManager = tunnelsManager else { return } unarchivedFiles.sort { $0.fileName < $1.fileName } - var lastFileName : String? + var lastFileName: String? var configs: [TunnelConfiguration] = [] for file in unarchivedFiles { if file.fileName == lastFileName { @@ -258,8 +258,8 @@ extension TunnelsListTableViewController: UIDocumentPickerDelegate { extension TunnelsListTableViewController: QRScanViewControllerDelegate { func addScannedQRCode(tunnelConfiguration: TunnelConfiguration, qrScanViewController: QRScanViewController, - completionHandler: (() ->Void)?) { - tunnelsManager?.add(tunnelConfiguration: tunnelConfiguration) { (tunnel, error) in + completionHandler: (() -> Void)?) { + tunnelsManager?.add(tunnelConfiguration: tunnelConfiguration) { (_, error) in if let error = error { ErrorPresenter.showErrorAlert(error: error, from: qrScanViewController, onDismissal: completionHandler) } else { @@ -354,7 +354,7 @@ extension TunnelsListTableViewController: TunnelsManagerDelegate { func tunnelMoved(at oldIndex: Int, to newIndex: Int) { tableView?.moveRow(at: IndexPath(row: oldIndex, section: 0), to: IndexPath(row: newIndex, section: 0)) } - + func tunnelRemoved(at index: Int) { tableView?.deleteRows(at: [IndexPath(row: index, section: 0)], with: .automatic) centeredAddButton?.isHidden = (tunnelsManager?.numberOfTunnels() ?? 0 > 0) @@ -377,14 +377,14 @@ class TunnelsListTableViewCell: UITableViewCell { } } } - var onSwitchToggled: ((Bool) -> Void)? = nil + var onSwitchToggled: ((Bool) -> Void)? let nameLabel: UILabel let busyIndicator: UIActivityIndicatorView let statusSwitch: UISwitch - private var statusObservervationToken: AnyObject? = nil - private var nameObservervationToken: AnyObject? = nil + private var statusObservervationToken: AnyObject? + private var nameObservervationToken: AnyObject? override init(style: UITableViewCellStyle, reuseIdentifier: String?) { nameLabel = UILabel() @@ -466,7 +466,7 @@ class BorderedTextButton: UIView { set(value) { button.setTitle(value, for: .normal) } } - var onTapped: (() -> Void)? = nil + var onTapped: (() -> Void)? init() { button = UIButton(type: .system) @@ -491,4 +491,3 @@ class BorderedTextButton: UIView { fatalError("init(coder:) has not been implemented") } } - |