@@ -12,27 +12,36 @@ import UIKit
1212public final class AddButtonNode : ASButtonNode {
1313 private var onTap : ( ( ) -> Void ) ?
1414 private var identifier : String ?
15+ private let buttonSize = CGSize ( width: . addButtonSize, height: . addButtonSize)
1516
1617 override public init ( ) {
1718 super. init ( )
18- setViewBlock { UIButton ( type : . system ) }
19+ setupNode ( )
1920 }
2021
2122 public init ( identifier: String , _ action: ( ( ) -> Void ) ? ) {
2223 self . identifier = identifier
2324 super. init ( )
2425
25- setViewBlock { UIButton ( type : . system ) }
26+ setupNode ( )
2627 onTap = action
27- frame. size = CGSize ( width: . addButtonSize, height: . addButtonSize)
28+ }
29+
30+ override public var frame : CGRect {
31+ didSet {
32+ guard oldValue. size != frame. size else { return }
33+ updateButtonFrame ( )
34+ }
2835 }
2936
3037 override public func didLoad( ) {
3138 super. didLoad ( )
3239
3340 guard let button = view as? UIButton else { return }
41+ updateButtonFrame ( )
3442 button. accessibilityIdentifier = identifier
3543 button. isAccessibilityElement = true
44+ button. accessibilityLabel = " Add "
3645 button. addTarget ( self , action: #selector( onButtonTap) , for: . touchUpInside)
3746
3847 if #available( iOS 26 . 0 , * ) {
@@ -42,6 +51,23 @@ public final class AddButtonNode: ASButtonNode {
4251 }
4352 }
4453
54+ override public func calculateSizeThatFits( _ constrainedSize: CGSize ) -> CGSize {
55+ buttonSize
56+ }
57+
58+ private func setupNode( ) {
59+ setViewBlock { UIButton ( type: . system) }
60+ style. preferredSize = buttonSize
61+ frame. size = buttonSize
62+ isUserInteractionEnabled = true
63+ }
64+
65+ private func updateButtonFrame( ) {
66+ guard isNodeLoaded else { return }
67+ view. frame = CGRect ( origin: view. frame. origin, size: buttonSize)
68+ view. bounds = CGRect ( origin: . zero, size: buttonSize)
69+ }
70+
4571 @objc private func onButtonTap( ) {
4672 onTap ? ( )
4773 }
0 commit comments