iPad UI improvements

This commit is contained in:
Ilya Laktyushin
2020-04-03 18:24:54 +04:00
parent 03e68b6415
commit 91f02f42fe
24 changed files with 364 additions and 74 deletions

View File

@@ -29,6 +29,8 @@ public final class TextAlertContentActionNode: HighlightableButtonNode {
private let backgroundNode: ASDisplayNode
private var pointerInteraction: PointerInteraction?
public init(theme: AlertControllerTheme, action: TextAlertAction) {
self.theme = theme
self.action = action
@@ -59,6 +61,22 @@ public final class TextAlertContentActionNode: HighlightableButtonNode {
self.updateTheme(theme)
}
public override func didLoad() {
super.didLoad()
self.addTarget(self, action: #selector(self.pressed), forControlEvents: .touchUpInside)
self.pointerInteraction = PointerInteraction(node: self, style: .hover, willEnter: { [weak self] in
if let strongSelf = self {
strongSelf.backgroundNode.alpha = 0.25
}
}, willExit: { [weak self] in
if let strongSelf = self {
strongSelf.backgroundNode.alpha = 1.0
}
})
}
public var actionEnabled: Bool = true {
didSet {
self.isUserInteractionEnabled = self.actionEnabled
@@ -90,12 +108,6 @@ public final class TextAlertContentActionNode: HighlightableButtonNode {
self.setAttributedTitle(NSAttributedString(string: self.action.title, font: font, textColor: color, paragraphAlignment: .center), for: [])
}
override public func didLoad() {
super.didLoad()
self.addTarget(self, action: #selector(self.pressed), forControlEvents: .touchUpInside)
}
@objc func pressed() {
self.action.action()
}