UI: iOS: clean up visuals in SSID editor
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
b9ff5c2e94
commit
53235eb38f
|
@ -109,6 +109,7 @@
|
||||||
"tunnelOnDemandSectionTitleAddSSIDs" = "Add SSIDs";
|
"tunnelOnDemandSectionTitleAddSSIDs" = "Add SSIDs";
|
||||||
"tunnelOnDemandAddMessageAddConnectedSSID (%@)" = "Add connected: %@";
|
"tunnelOnDemandAddMessageAddConnectedSSID (%@)" = "Add connected: %@";
|
||||||
"tunnelOnDemandAddMessageAddNewSSID" = "Add new";
|
"tunnelOnDemandAddMessageAddNewSSID" = "Add new";
|
||||||
|
"tunnelOnDemandSSIDTextFieldPlaceholder" = "SSID";
|
||||||
|
|
||||||
"tunnelOnDemandKey" = "On demand";
|
"tunnelOnDemandKey" = "On demand";
|
||||||
"tunnelOnDemandOptionOff" = "Off";
|
"tunnelOnDemandOptionOff" = "Off";
|
||||||
|
|
|
@ -9,6 +9,11 @@ class EditableTextCell: UITableViewCell {
|
||||||
set(value) { valueTextField.text = value }
|
set(value) { valueTextField.text = value }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var placeholder: String? {
|
||||||
|
get { return valueTextField.placeholder }
|
||||||
|
set(value) { valueTextField.placeholder = value }
|
||||||
|
}
|
||||||
|
|
||||||
let valueTextField: UITextField = {
|
let valueTextField: UITextField = {
|
||||||
let valueTextField = UITextField()
|
let valueTextField = UITextField()
|
||||||
valueTextField.textAlignment = .left
|
valueTextField.textAlignment = .left
|
||||||
|
@ -29,12 +34,13 @@ class EditableTextCell: UITableViewCell {
|
||||||
valueTextField.delegate = self
|
valueTextField.delegate = self
|
||||||
contentView.addSubview(valueTextField)
|
contentView.addSubview(valueTextField)
|
||||||
valueTextField.translatesAutoresizingMaskIntoConstraints = false
|
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
|
bottomAnchorConstraint.priority = .defaultLow
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
valueTextField.leadingAnchor.constraint(equalToSystemSpacingAfter: contentView.layoutMarginsGuide.leadingAnchor, multiplier: 1),
|
valueTextField.leadingAnchor.constraint(equalTo: contentView.layoutMarginsGuide.leadingAnchor),
|
||||||
contentView.layoutMarginsGuide.trailingAnchor.constraint(equalToSystemSpacingAfter: valueTextField.trailingAnchor, multiplier: 1),
|
contentView.layoutMarginsGuide.trailingAnchor.constraint(equalTo: valueTextField.trailingAnchor),
|
||||||
valueTextField.topAnchor.constraint(equalToSystemSpacingBelow: contentView.layoutMarginsGuide.topAnchor, multiplier: 1),
|
contentView.layoutMarginsGuide.topAnchor.constraint(equalTo: valueTextField.topAnchor),
|
||||||
bottomAnchorConstraint
|
bottomAnchorConstraint
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
@ -50,6 +56,7 @@ class EditableTextCell: UITableViewCell {
|
||||||
override func prepareForReuse() {
|
override func prepareForReuse() {
|
||||||
super.prepareForReuse()
|
super.prepareForReuse()
|
||||||
message = ""
|
message = ""
|
||||||
|
placeholder = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ class SSIDOptionEditTableViewController: UITableViewController {
|
||||||
tableView.register(TextCell.self)
|
tableView.register(TextCell.self)
|
||||||
tableView.isEditing = true
|
tableView.isEditing = true
|
||||||
tableView.allowsSelectionDuringEditing = true
|
tableView.allowsSelectionDuringEditing = true
|
||||||
|
tableView.keyboardDismissMode = .onDrag
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadSections() {
|
func loadSections() {
|
||||||
|
@ -188,6 +189,7 @@ extension SSIDOptionEditTableViewController {
|
||||||
private func selectedSSIDCell(for tableView: UITableView, at indexPath: IndexPath) -> UITableViewCell {
|
private func selectedSSIDCell(for tableView: UITableView, at indexPath: IndexPath) -> UITableViewCell {
|
||||||
let cell: EditableTextCell = tableView.dequeueReusableCell(for: indexPath)
|
let cell: EditableTextCell = tableView.dequeueReusableCell(for: indexPath)
|
||||||
cell.message = selectedSSIDs[indexPath.row]
|
cell.message = selectedSSIDs[indexPath.row]
|
||||||
|
cell.placeholder = tr("tunnelOnDemandSSIDTextFieldPlaceholder")
|
||||||
cell.isEditing = true
|
cell.isEditing = true
|
||||||
cell.onValueBeingEdited = { [weak self, weak cell] text in
|
cell.onValueBeingEdited = { [weak self, weak cell] text in
|
||||||
guard let self = self, let cell = cell else { return }
|
guard let self = self, let cell = cell else { return }
|
||||||
|
|
Loading…
Reference in New Issue