UI: not all subclasses of CopyableLabelTableViewCell have a detailTextLabel, so generalize
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
ecb6035d36
commit
fff1a70ab9
|
@ -6,6 +6,10 @@ import UIKit
|
|||
class CopyableLabelTableViewCell: UITableViewCell {
|
||||
var copyableGesture = true
|
||||
|
||||
var textToCopy: String? {
|
||||
fatalError("textToCopy must be implemented by subclass")
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
@ -41,7 +45,7 @@ class CopyableLabelTableViewCell: UITableViewCell {
|
|||
}
|
||||
|
||||
override func copy(_ sender: Any?) {
|
||||
UIPasteboard.general.string = self.detailTextLabel?.text
|
||||
UIPasteboard.general.string = textToCopy
|
||||
}
|
||||
|
||||
override func prepareForReuse() {
|
||||
|
|
|
@ -311,6 +311,10 @@ class TunnelDetailTableViewKeyValueCell: CopyableLabelTableViewCell {
|
|||
set(value) { detailTextLabel?.text = value }
|
||||
}
|
||||
|
||||
override var textToCopy: String? {
|
||||
return self.detailTextLabel?.text
|
||||
}
|
||||
|
||||
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
|
||||
super.init(style: .value1, reuseIdentifier: TunnelDetailTableViewKeyValueCell.id)
|
||||
}
|
||||
|
|
|
@ -441,6 +441,10 @@ class TunnelEditTableViewKeyValueCell: CopyableLabelTableViewCell {
|
|||
valueTextField.spellCheckingType = .no
|
||||
}
|
||||
|
||||
override var textToCopy: String? {
|
||||
return self.valueTextField.text
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue