Tunnel edit: TunnelEditTableViewKeyValueCell need not support a read-only mode now
This commit is contained in:
parent
845305d8c8
commit
0f61703c34
|
@ -212,10 +212,6 @@ extension TunnelEditTableViewController {
|
||||||
case .publicKey: break
|
case .publicKey: break
|
||||||
case .generateKeyPair: break
|
case .generateKeyPair: break
|
||||||
}
|
}
|
||||||
// Set editable
|
|
||||||
if (field == .publicKey) {
|
|
||||||
cell.isValueEditable = false
|
|
||||||
}
|
|
||||||
// Set keyboardType
|
// Set keyboardType
|
||||||
if (field == .mtu || field == .listenPort) {
|
if (field == .mtu || field == .listenPort) {
|
||||||
cell.keyboardType = .numberPad
|
cell.keyboardType = .numberPad
|
||||||
|
@ -409,7 +405,7 @@ extension TunnelEditTableViewController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TunnelEditTableViewKeyValueCell: CopyableLabelTableViewCell {
|
class TunnelEditTableViewKeyValueCell: UITableViewCell {
|
||||||
static let id: String = "TunnelEditTableViewKeyValueCell"
|
static let id: String = "TunnelEditTableViewKeyValueCell"
|
||||||
var key: String {
|
var key: String {
|
||||||
get { return keyLabel.text ?? "" }
|
get { return keyLabel.text ?? "" }
|
||||||
|
@ -423,19 +419,10 @@ class TunnelEditTableViewKeyValueCell: CopyableLabelTableViewCell {
|
||||||
get { return valueTextField.placeholder ?? "" }
|
get { return valueTextField.placeholder ?? "" }
|
||||||
set(value) { valueTextField.placeholder = value }
|
set(value) { valueTextField.placeholder = value }
|
||||||
}
|
}
|
||||||
var isValueEditable: Bool {
|
|
||||||
get { return valueTextField.isEnabled }
|
|
||||||
set(value) {
|
|
||||||
super.copyableGesture = !value
|
|
||||||
valueTextField.isEnabled = value
|
|
||||||
keyLabel.textColor = value ? UIColor.black : UIColor.gray
|
|
||||||
valueTextField.textColor = value ? UIColor.black : UIColor.gray
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var isValueValid: Bool = true {
|
var isValueValid: Bool = true {
|
||||||
didSet {
|
didSet {
|
||||||
if (isValueValid) {
|
if (isValueValid) {
|
||||||
keyLabel.textColor = isValueEditable ? UIColor.black : UIColor.gray
|
keyLabel.textColor = UIColor.black
|
||||||
} else {
|
} else {
|
||||||
keyLabel.textColor = UIColor.red
|
keyLabel.textColor = UIColor.red
|
||||||
}
|
}
|
||||||
|
@ -458,7 +445,6 @@ class TunnelEditTableViewKeyValueCell: CopyableLabelTableViewCell {
|
||||||
keyLabel = UILabel()
|
keyLabel = UILabel()
|
||||||
valueTextField = UITextField()
|
valueTextField = UITextField()
|
||||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||||
isValueEditable = true
|
|
||||||
contentView.addSubview(keyLabel)
|
contentView.addSubview(keyLabel)
|
||||||
keyLabel.translatesAutoresizingMaskIntoConstraints = false
|
keyLabel.translatesAutoresizingMaskIntoConstraints = false
|
||||||
keyLabel.textAlignment = .right
|
keyLabel.textAlignment = .right
|
||||||
|
@ -489,10 +475,6 @@ class TunnelEditTableViewKeyValueCell: CopyableLabelTableViewCell {
|
||||||
valueTextField.spellCheckingType = .no
|
valueTextField.spellCheckingType = .no
|
||||||
}
|
}
|
||||||
|
|
||||||
override var textToCopy: String? {
|
|
||||||
return self.valueTextField.text
|
|
||||||
}
|
|
||||||
|
|
||||||
required init?(coder aDecoder: NSCoder) {
|
required init?(coder aDecoder: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
@ -502,7 +484,6 @@ class TunnelEditTableViewKeyValueCell: CopyableLabelTableViewCell {
|
||||||
key = ""
|
key = ""
|
||||||
value = ""
|
value = ""
|
||||||
placeholderText = ""
|
placeholderText = ""
|
||||||
isValueEditable = true
|
|
||||||
isValueValid = true
|
isValueValid = true
|
||||||
keyboardType = .default
|
keyboardType = .default
|
||||||
onValueChanged = nil
|
onValueChanged = nil
|
||||||
|
|
Loading…
Reference in New Issue