Skip to content

Commit 53235eb

Browse files
committed
UI: iOS: clean up visuals in SSID editor
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
1 parent b9ff5c2 commit 53235eb

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

Sources/WireGuardApp/Base.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
"tunnelOnDemandSectionTitleAddSSIDs" = "Add SSIDs";
110110
"tunnelOnDemandAddMessageAddConnectedSSID (%@)" = "Add connected: %@";
111111
"tunnelOnDemandAddMessageAddNewSSID" = "Add new";
112+
"tunnelOnDemandSSIDTextFieldPlaceholder" = "SSID";
112113

113114
"tunnelOnDemandKey" = "On demand";
114115
"tunnelOnDemandOptionOff" = "Off";

Sources/WireGuardApp/UI/iOS/View/EditableTextCell.swift

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ class EditableTextCell: UITableViewCell {
99
set(value) { valueTextField.text = value }
1010
}
1111

12+
var placeholder: String? {
13+
get { return valueTextField.placeholder }
14+
set(value) { valueTextField.placeholder = value }
15+
}
16+
1217
let valueTextField: UITextField = {
1318
let valueTextField = UITextField()
1419
valueTextField.textAlignment = .left
@@ -29,12 +34,13 @@ class EditableTextCell: UITableViewCell {
2934
valueTextField.delegate = self
3035
contentView.addSubview(valueTextField)
3136
valueTextField.translatesAutoresizingMaskIntoConstraints = false
32-
let bottomAnchorConstraint = contentView.layoutMarginsGuide.bottomAnchor.constraint(equalToSystemSpacingBelow: valueTextField.bottomAnchor, multiplier: 1)
37+
// Reduce the bottom margin by 0.5pt to maintain the default cell height (44pt)
38+
let bottomAnchorConstraint = contentView.layoutMarginsGuide.bottomAnchor.constraint(equalTo: valueTextField.bottomAnchor, constant: -0.5)
3339
bottomAnchorConstraint.priority = .defaultLow
3440
NSLayoutConstraint.activate([
35-
valueTextField.leadingAnchor.constraint(equalToSystemSpacingAfter: contentView.layoutMarginsGuide.leadingAnchor, multiplier: 1),
36-
contentView.layoutMarginsGuide.trailingAnchor.constraint(equalToSystemSpacingAfter: valueTextField.trailingAnchor, multiplier: 1),
37-
valueTextField.topAnchor.constraint(equalToSystemSpacingBelow: contentView.layoutMarginsGuide.topAnchor, multiplier: 1),
41+
valueTextField.leadingAnchor.constraint(equalTo: contentView.layoutMarginsGuide.leadingAnchor),
42+
contentView.layoutMarginsGuide.trailingAnchor.constraint(equalTo: valueTextField.trailingAnchor),
43+
contentView.layoutMarginsGuide.topAnchor.constraint(equalTo: valueTextField.topAnchor),
3844
bottomAnchorConstraint
3945
])
4046
}
@@ -50,6 +56,7 @@ class EditableTextCell: UITableViewCell {
5056
override func prepareForReuse() {
5157
super.prepareForReuse()
5258
message = ""
59+
placeholder = nil
5360
}
5461
}
5562

Sources/WireGuardApp/UI/iOS/ViewController/SSIDOptionEditTableViewController.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class SSIDOptionEditTableViewController: UITableViewController {
6060
tableView.register(TextCell.self)
6161
tableView.isEditing = true
6262
tableView.allowsSelectionDuringEditing = true
63+
tableView.keyboardDismissMode = .onDrag
6364
}
6465

6566
func loadSections() {
@@ -188,6 +189,7 @@ extension SSIDOptionEditTableViewController {
188189
private func selectedSSIDCell(for tableView: UITableView, at indexPath: IndexPath) -> UITableViewCell {
189190
let cell: EditableTextCell = tableView.dequeueReusableCell(for: indexPath)
190191
cell.message = selectedSSIDs[indexPath.row]
192+
cell.placeholder = tr("tunnelOnDemandSSIDTextFieldPlaceholder")
191193
cell.isEditing = true
192194
cell.onValueBeingEdited = { [weak self, weak cell] text in
193195
guard let self = self, let cell = cell else { return }

0 commit comments

Comments
 (0)