diff options
Diffstat (limited to 'WireGuard/WireGuard/UI/iOS/View/TunnelEditKeyValueCell.swift')
-rw-r--r-- | WireGuard/WireGuard/UI/iOS/View/TunnelEditKeyValueCell.swift | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/View/TunnelEditKeyValueCell.swift b/WireGuard/WireGuard/UI/iOS/View/TunnelEditKeyValueCell.swift new file mode 100644 index 0000000..3e18670 --- /dev/null +++ b/WireGuard/WireGuard/UI/iOS/View/TunnelEditKeyValueCell.swift @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: MIT +// Copyright © 2018 WireGuard LLC. All Rights Reserved. + +import UIKit + +class TunnelEditKeyValueCell: KeyValueCell { + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + + keyLabel.textAlignment = .right + valueTextField.textAlignment = .left + + 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, + // so set a CR priority > the 0.4-constraint's priority. + widthRatioConstraint.priority = .defaultHigh + 1 + widthRatioConstraint.isActive = true + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + +} + +class TunnelEditEditableKeyValueCell: TunnelEditKeyValueCell { + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + + valueTextField.textColor = .black + valueTextField.isEnabled = true + valueLabelScrollView.isScrollEnabled = false + valueTextField.widthAnchor.constraint(equalTo: valueLabelScrollView.widthAnchor).isActive = true + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + +} |