diff --git a/WireGuard/WireGuard/UI/iOS/CopyableLabelTableViewCell.swift b/WireGuard/WireGuard/UI/iOS/CopyableLabelTableViewCell.swift index 779fe8f..ffe8d6f 100644 --- a/WireGuard/WireGuard/UI/iOS/CopyableLabelTableViewCell.swift +++ b/WireGuard/WireGuard/UI/iOS/CopyableLabelTableViewCell.swift @@ -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() { diff --git a/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift index fe413c9..72df738 100644 --- a/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift @@ -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) } diff --git a/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift index e0b11e4..a536499 100644 --- a/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift @@ -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") }