aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-03-09 00:02:03 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2021-03-09 09:10:07 -0700
commit53235eb38f2784e71010765269fcf5fa0c16e80c (patch)
tree67635168dcb7f001420bcb7b42093fb34057ebe3
parentREADME: account for funky xcode paths (diff)
downloadwireguard-apple-53235eb38f2784e71010765269fcf5fa0c16e80c.tar.xz
wireguard-apple-53235eb38f2784e71010765269fcf5fa0c16e80c.zip
UI: iOS: clean up visuals in SSID editor
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--Sources/WireGuardApp/Base.lproj/Localizable.strings1
-rw-r--r--Sources/WireGuardApp/UI/iOS/View/EditableTextCell.swift15
-rw-r--r--Sources/WireGuardApp/UI/iOS/ViewController/SSIDOptionEditTableViewController.swift2
3 files changed, 14 insertions, 4 deletions
diff --git a/Sources/WireGuardApp/Base.lproj/Localizable.strings b/Sources/WireGuardApp/Base.lproj/Localizable.strings
index a2cc455..2c7ad04 100644
--- a/Sources/WireGuardApp/Base.lproj/Localizable.strings
+++ b/Sources/WireGuardApp/Base.lproj/Localizable.strings
@@ -109,6 +109,7 @@
"tunnelOnDemandSectionTitleAddSSIDs" = "Add SSIDs";
"tunnelOnDemandAddMessageAddConnectedSSID (%@)" = "Add connected: %@";
"tunnelOnDemandAddMessageAddNewSSID" = "Add new";
+"tunnelOnDemandSSIDTextFieldPlaceholder" = "SSID";
"tunnelOnDemandKey" = "On demand";
"tunnelOnDemandOptionOff" = "Off";
diff --git a/Sources/WireGuardApp/UI/iOS/View/EditableTextCell.swift b/Sources/WireGuardApp/UI/iOS/View/EditableTextCell.swift
index f7e907e..20c2972 100644
--- a/Sources/WireGuardApp/UI/iOS/View/EditableTextCell.swift
+++ b/Sources/WireGuardApp/UI/iOS/View/EditableTextCell.swift
@@ -9,6 +9,11 @@ class EditableTextCell: UITableViewCell {
set(value) { valueTextField.text = value }
}
+ var placeholder: String? {
+ get { return valueTextField.placeholder }
+ set(value) { valueTextField.placeholder = value }
+ }
+
let valueTextField: UITextField = {
let valueTextField = UITextField()
valueTextField.textAlignment = .left
@@ -29,12 +34,13 @@ class EditableTextCell: UITableViewCell {
valueTextField.delegate = self
contentView.addSubview(valueTextField)
valueTextField.translatesAutoresizingMaskIntoConstraints = false
- let bottomAnchorConstraint = contentView.layoutMarginsGuide.bottomAnchor.constraint(equalToSystemSpacingBelow: valueTextField.bottomAnchor, multiplier: 1)
+ // Reduce the bottom margin by 0.5pt to maintain the default cell height (44pt)
+ let bottomAnchorConstraint = contentView.layoutMarginsGuide.bottomAnchor.constraint(equalTo: valueTextField.bottomAnchor, constant: -0.5)
bottomAnchorConstraint.priority = .defaultLow
NSLayoutConstraint.activate([
- valueTextField.leadingAnchor.constraint(equalToSystemSpacingAfter: contentView.layoutMarginsGuide.leadingAnchor, multiplier: 1),
- contentView.layoutMarginsGuide.trailingAnchor.constraint(equalToSystemSpacingAfter: valueTextField.trailingAnchor, multiplier: 1),
- valueTextField.topAnchor.constraint(equalToSystemSpacingBelow: contentView.layoutMarginsGuide.topAnchor, multiplier: 1),
+ valueTextField.leadingAnchor.constraint(equalTo: contentView.layoutMarginsGuide.leadingAnchor),
+ contentView.layoutMarginsGuide.trailingAnchor.constraint(equalTo: valueTextField.trailingAnchor),
+ contentView.layoutMarginsGuide.topAnchor.constraint(equalTo: valueTextField.topAnchor),
bottomAnchorConstraint
])
}
@@ -50,6 +56,7 @@ class EditableTextCell: UITableViewCell {
override func prepareForReuse() {
super.prepareForReuse()
message = ""
+ placeholder = nil
}
}
diff --git a/Sources/WireGuardApp/UI/iOS/ViewController/SSIDOptionEditTableViewController.swift b/Sources/WireGuardApp/UI/iOS/ViewController/SSIDOptionEditTableViewController.swift
index 527a8fd..7a0cd7b 100644
--- a/Sources/WireGuardApp/UI/iOS/ViewController/SSIDOptionEditTableViewController.swift
+++ b/Sources/WireGuardApp/UI/iOS/ViewController/SSIDOptionEditTableViewController.swift
@@ -60,6 +60,7 @@ class SSIDOptionEditTableViewController: UITableViewController {
tableView.register(TextCell.self)
tableView.isEditing = true
tableView.allowsSelectionDuringEditing = true
+ tableView.keyboardDismissMode = .onDrag
}
func loadSections() {
@@ -188,6 +189,7 @@ extension SSIDOptionEditTableViewController {
private func selectedSSIDCell(for tableView: UITableView, at indexPath: IndexPath) -> UITableViewCell {
let cell: EditableTextCell = tableView.dequeueReusableCell(for: indexPath)
cell.message = selectedSSIDs[indexPath.row]
+ cell.placeholder = tr("tunnelOnDemandSSIDTextFieldPlaceholder")
cell.isEditing = true
cell.onValueBeingEdited = { [weak self, weak cell] text in
guard let self = self, let cell = cell else { return }