Some fixes for macOS

This commit is contained in:
James Magahern
2020-08-14 17:40:01 -07:00
parent 1d3d04ffdf
commit 669da89ff3
5 changed files with 55 additions and 27 deletions

View File

@@ -18,18 +18,16 @@ class ScriptPolicyControl: UIControl
didSet { setNeedsLayout() }
}
private class PolicyButton: UIButton {
override func imageRect(forContentRect contentRect: CGRect) -> CGRect {
contentRect.insetBy(dx: 8.0, dy: 8.0)
}
}
private let allowButton = PolicyButton(frame: .zero)
private let denyButton = PolicyButton(frame: .zero)
private let allowButton = ReliefButton()
private let denyButton = ReliefButton()
private let segmentContainer = SegmentedReliefButton(children: [])
convenience init() {
self.init(frame: .zero)
segmentContainer.children = [ allowButton, denyButton ]
addSubview(segmentContainer)
allowButton.addAction(UIAction(handler: { [unowned self] _ in
self.policyStatus = .allowed
self.sendActions(for: .valueChanged)
@@ -52,8 +50,7 @@ class ScriptPolicyControl: UIControl
override func layoutSubviews() {
super.layoutSubviews()
allowButton.frame = CGRect(origin: .zero, size: CGSize(width: bounds.width / 2, height: bounds.height))
denyButton.frame = CGRect(origin: CGPoint(x: allowButton.frame.maxX, y: 0), size: allowButton.frame.size)
segmentContainer.frame = bounds
if policyStatus == .allowed {
allowButton.tintColor = .blue