Pointer effects
This commit is contained in:
@@ -70,6 +70,11 @@ class ReliefButton: UIButton
|
|||||||
addSubview(backgroundView)
|
addSubview(backgroundView)
|
||||||
|
|
||||||
traitCollectionDidChange(nil)
|
traitCollectionDidChange(nil)
|
||||||
|
|
||||||
|
pointerStyleProvider = { (button, pointerEffect, pointerShape) -> UIPointerStyle? in
|
||||||
|
let preview = UITargetedPreview(view: button)
|
||||||
|
return UIPointerStyle(effect: .lift(preview), shape: pointerShape)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ class SegmentedReliefButton: ReliefButton
|
|||||||
didSet { children.forEach { addSubview($0) }; setNeedsLayout() }
|
didSet { children.forEach { addSubview($0) }; setNeedsLayout() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override var isPointerInteractionEnabled: Bool {
|
||||||
|
set { children.forEach { $0.isPointerInteractionEnabled = newValue } }
|
||||||
|
get { children.first?.isPointerInteractionEnabled ?? false }
|
||||||
|
}
|
||||||
|
|
||||||
private let backgroundsContainerView = UIView(frame: .zero)
|
private let backgroundsContainerView = UIView(frame: .zero)
|
||||||
private var childrenHighlighObservations: [NSKeyValueObservation] = []
|
private var childrenHighlighObservations: [NSKeyValueObservation] = []
|
||||||
|
|
||||||
@@ -30,7 +35,8 @@ class SegmentedReliefButton: ReliefButton
|
|||||||
}
|
}
|
||||||
|
|
||||||
override var isHighlighted: Bool {
|
override var isHighlighted: Bool {
|
||||||
didSet {}
|
// Does not highlight. Only children do.
|
||||||
|
set {} get { false }
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ class TabView: UIControl
|
|||||||
|
|
||||||
addSubview(closeButton)
|
addSubview(closeButton)
|
||||||
closeButton.setImage(UIImage(systemName: "xmark.square.fill"), for: .normal)
|
closeButton.setImage(UIImage(systemName: "xmark.square.fill"), for: .normal)
|
||||||
|
closeButton.isPointerInteractionEnabled = true
|
||||||
closeButton.imageView?.contentMode = .center
|
closeButton.imageView?.contentMode = .center
|
||||||
closeButton.tintColor = .label
|
closeButton.tintColor = .label
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ class ToolbarButtonContainerView: UIView
|
|||||||
public var numberOfButtonViews: Int { buttonViews.count }
|
public var numberOfButtonViews: Int { buttonViews.count }
|
||||||
|
|
||||||
func addButtonView(_ button: UIView) {
|
func addButtonView(_ button: UIView) {
|
||||||
|
if let asButton = button as? UIButton {
|
||||||
|
asButton.isPointerInteractionEnabled = true
|
||||||
|
}
|
||||||
|
|
||||||
buttonViews.append(button)
|
buttonViews.append(button)
|
||||||
addSubview(button)
|
addSubview(button)
|
||||||
setNeedsLayout()
|
setNeedsLayout()
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ class URLBar: ReliefButton
|
|||||||
didSet { updateProgressIndicator() }
|
didSet { updateProgressIndicator() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override var isPointerInteractionEnabled: Bool {
|
||||||
|
get { false } set {}
|
||||||
|
}
|
||||||
|
|
||||||
private let fadeMaskView = UIImageView(frame: .zero)
|
private let fadeMaskView = UIImageView(frame: .zero)
|
||||||
|
|
||||||
private let progressIndicatorView = ProgressIndicatorView()
|
private let progressIndicatorView = ProgressIndicatorView()
|
||||||
@@ -84,6 +88,7 @@ class URLBar: ReliefButton
|
|||||||
|
|
||||||
refreshButton.tintColor = .secondaryLabel
|
refreshButton.tintColor = .secondaryLabel
|
||||||
refreshButton.setImage(refreshImage, for: .normal)
|
refreshButton.setImage(refreshImage, for: .normal)
|
||||||
|
refreshButton.isPointerInteractionEnabled = true
|
||||||
addSubview(refreshButton)
|
addSubview(refreshButton)
|
||||||
|
|
||||||
errorButton.backgroundColor = .systemRed
|
errorButton.backgroundColor = .systemRed
|
||||||
@@ -92,10 +97,12 @@ class URLBar: ReliefButton
|
|||||||
errorButton.titleLabel?.font = UIFont.boldSystemFont(ofSize: 11.0)
|
errorButton.titleLabel?.font = UIFont.boldSystemFont(ofSize: 11.0)
|
||||||
errorButton.setTitleColor(.white, for: .normal)
|
errorButton.setTitleColor(.white, for: .normal)
|
||||||
errorButton.setTitle("ERR", for: .normal)
|
errorButton.setTitle("ERR", for: .normal)
|
||||||
|
errorButton.isPointerInteractionEnabled = true
|
||||||
addSubview(errorButton)
|
addSubview(errorButton)
|
||||||
|
|
||||||
documentButton.tintColor = .secondaryLabel
|
documentButton.tintColor = .secondaryLabel
|
||||||
documentButton.setImage(documentImage, for: .normal)
|
documentButton.setImage(documentImage, for: .normal)
|
||||||
|
documentButton.isPointerInteractionEnabled = true
|
||||||
addSubview(documentButton)
|
addSubview(documentButton)
|
||||||
|
|
||||||
documentSeparatorView.backgroundColor = .secondarySystemFill
|
documentSeparatorView.backgroundColor = .secondarySystemFill
|
||||||
@@ -155,6 +162,10 @@ class URLBar: ReliefButton
|
|||||||
self.setNeedsLayout()
|
self.setNeedsLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func setBackgroundInverted(_ inverted: Bool) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
|
||||||
override var intrinsicContentSize: CGSize {
|
override var intrinsicContentSize: CGSize {
|
||||||
let preferredHeight = CGFloat(34)
|
let preferredHeight = CGFloat(34)
|
||||||
return CGSize(width: 1000.0, height: preferredHeight)
|
return CGSize(width: 1000.0, height: preferredHeight)
|
||||||
|
|||||||
Reference in New Issue
Block a user