diff options
author | Jeroen Leenarts <jeroen.leenarts@gmail.com> | 2018-09-25 20:59:15 +0200 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2018-10-28 23:20:18 +0530 |
commit | f57953767b519b84dfcac23f1093305530fb6509 (patch) | |
tree | a9dc201f9b13c166e35b46b3c3453fb2510fd1a4 /WireGuard/WireGuard/UI/iOS/QRScanViewController.swift | |
parent | QR code: Minor refactoring (diff) | |
download | wireguard-apple-f57953767b519b84dfcac23f1093305530fb6509.tar.xz wireguard-apple-f57953767b519b84dfcac23f1093305530fb6509.zip |
QR code: Ask for title when scanning a QR code
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | WireGuard/WireGuard/UI/iOS/QRScanViewController.swift | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift b/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift index 5ae8d08..a959445 100644 --- a/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift @@ -101,8 +101,20 @@ class QRScanViewController: UIViewController { scanDidEncounterError(title: "Invalid Code", message: "The scanned code is not a valid WireGuard config file.") return } - delegate?.scannedQRCode(tunnelConfiguration: tunnelConfiguration, qrScanViewController: self) - dismiss(animated: true, completion: nil) + + let alert = UIAlertController(title: NSLocalizedString("Enter a title for new tunnel", comment: ""), message: nil, preferredStyle: .alert) + alert.addTextField(configurationHandler: nil) + alert.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .cancel, handler: nil)) + alert.addAction(UIAlertAction(title: NSLocalizedString("Save", comment: ""), style: .default, handler: { [weak self] _ in + let title = alert.textFields?[0].text ?? "" + if (title.isEmpty) { return } + tunnelConfiguration.interface.name = title + if let s = self { + s.delegate?.scannedQRCode(tunnelConfiguration: tunnelConfiguration, qrScanViewController: s) + s.dismiss(animated: true, completion: nil) + } + })) + present(alert, animated: true) } func scanDidEncounterError(title: String, message: String) { |