11import Foundation
22import UIKit
33
4- open class ViewController : UIViewController {
4+ open class ViewController : UIViewController , DeclarativeProtocol , DeclarativeProtocolInternal , _Toucheable {
55 open override var preferredStatusBarStyle : UIStatusBarStyle { statusBarStyle. rawValue }
66 /// UIKitPlus reimplementation of `preferredStatusBarStyle`
7- open var statusBarStyle : StatusBarStyle { . default }
8-
9- @State public var keyboardHeight : CGFloat = 0
7+ open var statusBarStyle : StatusBarStyle { _statusBarStyle ?? . default }
108
119 public init ( @ViewBuilder block: ViewBuilder . SingleView ) {
1210 super. init ( nibName: nil , bundle: nil )
@@ -35,10 +33,71 @@ open class ViewController: UIViewController {
3533 NotificationCenter . default. removeObserver ( self )
3634 }
3735
38- open func buildUI( ) {
39- view. backgroundColor = . white
36+ // MARK: DeclarativeProtocol
37+
38+ public var declarativeView : View { _view }
39+ public lazy var properties = Properties < View > ( )
40+ lazy var _properties = PropertiesInternal ( )
41+
42+ @State public var height : CGFloat = 0
43+ @State public var width : CGFloat = 0
44+ @State public var top : CGFloat = 0
45+ @State public var leading : CGFloat = 0
46+ @State public var left : CGFloat = 0
47+ @State public var trailing : CGFloat = 0
48+ @State public var right : CGFloat = 0
49+ @State public var bottom : CGFloat = 0
50+ @State public var centerX : CGFloat = 0
51+ @State public var centerY : CGFloat = 0
52+
53+ var __height : State < CGFloat > { _height }
54+ var __width : State < CGFloat > { _width }
55+ var __top : State < CGFloat > { _top }
56+ var __leading : State < CGFloat > { _leading }
57+ var __left : State < CGFloat > { _left }
58+ var __trailing : State < CGFloat > { _trailing }
59+ var __right : State < CGFloat > { _right }
60+ var __bottom : State < CGFloat > { _bottom }
61+ var __centerX : State < CGFloat > { _centerX }
62+ var __centerY : State < CGFloat > { _centerY }
63+
64+ lazy var _view = View ( ) . background ( . white) . edgesToSuperview ( )
65+
66+ open override func loadView( ) {
67+ view = _view
68+ }
69+
70+ // MARK: Toucheable
71+
72+ var _touchesBegan : TouchClosure ?
73+ var _touchesMoved : TouchClosure ?
74+ var _touchesEnded : TouchClosure ?
75+ var _touchesCancelled : TouchClosure ?
76+
77+ override open func touchesBegan( _ touches: Set < UITouch > , with event: UIEvent ? ) {
78+ super. touchesBegan ( touches, with: event)
79+ _touchesBegan ? ( touches, event)
4080 }
4181
82+ open override func touchesMoved( _ touches: Set < UITouch > , with event: UIEvent ? ) {
83+ super. touchesMoved ( touches, with: event)
84+ _touchesMoved ? ( touches, event)
85+ }
86+
87+ override open func touchesEnded( _ touches: Set < UITouch > , with event: UIEvent ? ) {
88+ super. touchesEnded ( touches, with: event)
89+ _touchesEnded ? ( touches, event)
90+ }
91+
92+ open override func touchesCancelled( _ touches: Set < UITouch > , with event: UIEvent ? ) {
93+ super. touchesCancelled ( touches, with: event)
94+ _touchesCancelled ? ( touches, event)
95+ }
96+
97+ // MARK: Lifecycle
98+
99+ open func buildUI( ) { }
100+
42101 public var isAppearedOnce = false
43102
44103 open override func viewDidAppear( _ animated: Bool ) {
@@ -61,6 +120,8 @@ open class ViewController: UIViewController {
61120
62121 open func viewDidAppearFirstTime( _ animated: Bool ) { }
63122
123+ @State public var keyboardHeight : CGFloat = 0
124+
64125 private var isSubscribedToKeyboardNotifications = false
65126
66127 private func subscribeToKeyboardNotifications( ) {
@@ -113,6 +174,14 @@ open class ViewController: UIViewController {
113174 }
114175 return self
115176 }
177+
178+ var _statusBarStyle : StatusBarStyle ?
179+
180+ @discardableResult
181+ public func statusBarStyle( _ value: StatusBarStyle ) -> Self {
182+ _statusBarStyle = value
183+ return self
184+ }
116185}
117186
118187// MARK: Keyboard Notifications
0 commit comments