2018-12-15 02:02:37 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2019-01-02 00:56:33 +00:00
|
|
|
// Copyright © 2018-2019 WireGuard LLC. All Rights Reserved.
|
2018-12-15 02:02:37 +00:00
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
class TunnelEditKeyValueCell: KeyValueCell {
|
2018-12-21 22:34:56 +00:00
|
|
|
|
2018-12-15 02:02:37 +00:00
|
|
|
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
|
|
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
2018-12-21 22:34:56 +00:00
|
|
|
|
2018-12-15 02:02:37 +00:00
|
|
|
keyLabel.textAlignment = .right
|
|
|
|
valueTextField.textAlignment = .left
|
2018-12-21 22:34:56 +00:00
|
|
|
|
2018-12-15 02:02:37 +00:00
|
|
|
let widthRatioConstraint = NSLayoutConstraint(item: keyLabel, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 0.4, constant: 0)
|
|
|
|
// In case the key doesn't fit into 0.4 * width,
|
2018-12-19 10:53:14 +00:00
|
|
|
// set a CR priority > the 0.4-constraint's priority.
|
2018-12-15 02:02:37 +00:00
|
|
|
widthRatioConstraint.priority = .defaultHigh + 1
|
|
|
|
widthRatioConstraint.isActive = true
|
|
|
|
}
|
2018-12-21 22:34:56 +00:00
|
|
|
|
2018-12-15 02:02:37 +00:00
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
|
|
fatalError("init(coder:) has not been implemented")
|
|
|
|
}
|
2018-12-21 22:34:56 +00:00
|
|
|
|
2018-12-15 02:02:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class TunnelEditEditableKeyValueCell: TunnelEditKeyValueCell {
|
2018-12-21 22:34:56 +00:00
|
|
|
|
2018-12-15 02:02:37 +00:00
|
|
|
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
|
|
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
2018-12-21 22:34:56 +00:00
|
|
|
|
2018-12-15 03:48:48 +00:00
|
|
|
copyableGesture = false
|
2019-10-14 21:43:56 +00:00
|
|
|
if #available(iOS 13.0, *) {
|
|
|
|
valueTextField.textColor = .label
|
|
|
|
} else {
|
|
|
|
valueTextField.textColor = .black
|
|
|
|
}
|
2018-12-15 02:02:37 +00:00
|
|
|
valueTextField.isEnabled = true
|
|
|
|
valueLabelScrollView.isScrollEnabled = false
|
|
|
|
valueTextField.widthAnchor.constraint(equalTo: valueLabelScrollView.widthAnchor).isActive = true
|
|
|
|
}
|
2018-12-21 22:34:56 +00:00
|
|
|
|
2018-12-15 02:02:37 +00:00
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
|
|
fatalError("init(coder:) has not been implemented")
|
|
|
|
}
|
2018-12-21 22:34:56 +00:00
|
|
|
|
2018-12-22 00:31:59 +00:00
|
|
|
override func prepareForReuse() {
|
|
|
|
super.prepareForReuse()
|
|
|
|
copyableGesture = false
|
|
|
|
}
|
|
|
|
|
2018-12-15 02:02:37 +00:00
|
|
|
}
|