@@ -101,6 +101,67 @@ struct AlertAndConfirmationDialog {
101101 }
102102}
103103
104+ import UIKit
105+ final class AlertAndConfirmationDialogViewController : UIViewController {
106+ @UIBindable var store : StoreOf < AlertAndConfirmationDialog >
107+
108+ init ( store: StoreOf < AlertAndConfirmationDialog > ) {
109+ self . store = store
110+ super. init ( nibName: nil , bundle: nil )
111+ }
112+
113+ required init ? ( coder: NSCoder ) {
114+ fatalError ( " init(coder:) has not been implemented " )
115+ }
116+
117+ override func viewDidLoad( ) {
118+ super. viewDidLoad ( )
119+
120+ let countLabel = UILabel ( )
121+
122+ let alertButton = UIButton ( type: . system, primaryAction: UIAction { [ weak self] _ in
123+ self ? . store. send ( . alertButtonTapped)
124+ } )
125+ alertButton. setTitle ( " Alert " , for: . normal)
126+
127+ let confirmationDialogButton = UIButton ( type: . system, primaryAction: UIAction { [ weak self] _ in
128+ self ? . store. send ( . confirmationDialogButtonTapped)
129+ } )
130+ confirmationDialogButton. setTitle ( " Confirmation Dialog " , for: . normal)
131+
132+ let stack = UIStackView ( arrangedSubviews: [
133+ countLabel,
134+ alertButton,
135+ confirmationDialogButton,
136+ ] )
137+ stack. axis = . vertical
138+ stack. translatesAutoresizingMaskIntoConstraints = false
139+
140+ view. addSubview ( stack)
141+
142+ NSLayoutConstraint . activate ( [
143+ stack. topAnchor. constraint ( equalTo: view. topAnchor) ,
144+ stack. bottomAnchor. constraint ( equalTo: view. bottomAnchor) ,
145+ stack. leadingAnchor. constraint ( equalTo: view. leadingAnchor) ,
146+ stack. trailingAnchor. constraint ( equalTo: view. trailingAnchor) ,
147+ ] )
148+
149+ observe { [ weak self] in
150+ guard let self else { return }
151+ countLabel. text = " Count: \( store. count) "
152+ }
153+
154+ present ( item: $store. scope ( state: \. alert, action: \. alert) ) { store in
155+ UIAlertController ( store: store)
156+ }
157+ present (
158+ item: $store. scope ( state: \. confirmationDialog, action: \. confirmationDialog)
159+ ) { store in
160+ UIAlertController ( store: store)
161+ }
162+ }
163+ }
164+
104165struct AlertAndConfirmationDialogView : View {
105166 @Bindable var store : StoreOf < AlertAndConfirmationDialog >
106167
0 commit comments