aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-11-06 16:48:53 +0530
committerRoopesh Chander <roop@roopc.net>2018-11-06 16:49:09 +0530
commit1a43ad6e39bb52ef4c501e73c58988cdd3bf43d1 (patch)
tree6fd9270e6c18ef7016a9c9aec721ae4349bcba51 /WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift
parentTunnel view model: Peers in a configuation may not share the same public key (diff)
downloadwireguard-apple-1a43ad6e39bb52ef4c501e73c58988cdd3bf43d1.tar.xz
wireguard-apple-1a43ad6e39bb52ef4c501e73c58988cdd3bf43d1.zip
Tunnel detail: Refactor out the label scrolling into a separate UI class
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift40
1 files changed, 9 insertions, 31 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift
index 64aaa7b..9120f38 100644
--- a/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift
@@ -296,7 +296,7 @@ class TunnelDetailTableViewKeyValueCell: CopyableLabelTableViewCell {
set(value) { keyLabel.text = value }
}
var value: String {
- get { return valueLabel.text ?? "" }
+ get { return valueLabel.text }
set(value) { valueLabel.text = value }
}
@@ -305,39 +305,17 @@ class TunnelDetailTableViewKeyValueCell: CopyableLabelTableViewCell {
}
let keyLabel: UILabel
- let valueLabel: UILabel
- let valueScroller: UIScrollView
+ let valueLabel: ScrollableLabel
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
keyLabel = UILabel()
- valueLabel = UILabel()
- valueScroller = UIScrollView()
+ valueLabel = ScrollableLabel()
keyLabel.textColor = UIColor.black
valueLabel.textColor = UIColor.gray
- valueScroller.isDirectionalLockEnabled = true
- valueScroller.showsHorizontalScrollIndicator = false
- valueScroller.showsVerticalScrollIndicator = false
super.init(style: style, reuseIdentifier: reuseIdentifier)
- valueScroller.addSubview(valueLabel)
- valueLabel.translatesAutoresizingMaskIntoConstraints = false
- valueLabel.textAlignment = .right
- NSLayoutConstraint.activate([
- valueLabel.leftAnchor.constraint(equalTo: valueScroller.contentLayoutGuide.leftAnchor),
- valueLabel.topAnchor.constraint(equalTo: valueScroller.contentLayoutGuide.topAnchor),
- valueLabel.bottomAnchor.constraint(equalTo: valueScroller.contentLayoutGuide.bottomAnchor),
- valueLabel.rightAnchor.constraint(equalTo: valueScroller.contentLayoutGuide.rightAnchor),
- valueLabel.heightAnchor.constraint(equalTo: valueScroller.heightAnchor),
- ])
-
- // Value label should expand to fit the scrollView, so that the right-alignment works
- let expandToFitValueLabelConstraint = NSLayoutConstraint(item: valueLabel, attribute: .width, relatedBy: .equal,
- toItem: valueScroller, attribute: .width, multiplier: 1, constant: 0)
- expandToFitValueLabelConstraint.priority = .defaultLow + 1
- expandToFitValueLabelConstraint.isActive = true
-
contentView.addSubview(keyLabel)
keyLabel.translatesAutoresizingMaskIntoConstraints = false
keyLabel.textAlignment = .left
@@ -346,19 +324,19 @@ class TunnelDetailTableViewKeyValueCell: CopyableLabelTableViewCell {
keyLabel.centerYAnchor.constraint(equalTo: contentView.centerYAnchor)
])
- contentView.addSubview(valueScroller)
- valueScroller.translatesAutoresizingMaskIntoConstraints = false
+ contentView.addSubview(valueLabel)
+ valueLabel.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
- valueScroller.rightAnchor.constraint(equalTo: contentView.layoutMarginsGuide.rightAnchor),
- valueScroller.centerYAnchor.constraint(equalTo: contentView.centerYAnchor),
- valueScroller.leftAnchor.constraint(equalTo: keyLabel.rightAnchor, constant: 8)
+ valueLabel.rightAnchor.constraint(equalTo: contentView.layoutMarginsGuide.rightAnchor),
+ valueLabel.centerYAnchor.constraint(equalTo: contentView.centerYAnchor),
+ valueLabel.leftAnchor.constraint(equalTo: keyLabel.rightAnchor, constant: 8)
])
// Key label should never appear truncated
keyLabel.setContentCompressionResistancePriority(.defaultHigh + 1, for: .horizontal)
// Key label should hug it's content; value label should not.
keyLabel.setContentHuggingPriority(.defaultHigh, for: .horizontal)
- valueScroller.setContentHuggingPriority(.defaultLow, for: .horizontal)
+ valueLabel.setContentHuggingPriority(.defaultLow, for: .horizontal)
}
required init?(coder aDecoder: NSCoder) {