|
28 | 28 | public convenience init<Action>( |
29 | 29 | store: Store<AlertState<Action>, Action> |
30 | 30 | ) { |
31 | | - let state = store.currentState |
32 | | - self.init( |
33 | | - title: String(state: state.title), |
34 | | - message: state.message.map { String(state: $0) }, |
35 | | - preferredStyle: .alert |
36 | | - ) |
37 | | - for button in state.buttons { |
38 | | - addAction(UIAlertAction(button, action: { _ = $0.map(store.send) })) |
39 | | - } |
40 | | - if state.buttons.isEmpty { |
41 | | - addAction(UIAlertAction(title: "OK", style: .cancel)) |
42 | | - } |
| 31 | + self.init(state: store.currentState) { _ = $0.map(store.send) } |
43 | 32 | } |
44 | 33 |
|
45 | 34 | /// Creates a `UIAlertController` from a ``Store`` focused on confirmation dialog state. |
|
63 | 52 | public convenience init<Action>( |
64 | 53 | store: Store<ConfirmationDialogState<Action>, Action> |
65 | 54 | ) { |
66 | | - let state = store.currentState |
67 | | - self.init( |
68 | | - title: String(state: state.title), |
69 | | - message: state.message.map { String(state: $0) }, |
70 | | - preferredStyle: .actionSheet |
71 | | - ) |
72 | | - for button in state.buttons { |
73 | | - addAction(UIAlertAction(button, action: { _ = $0.map(store.send) })) |
74 | | - } |
75 | | - if state.buttons.isEmpty { |
76 | | - addAction(UIAlertAction(title: "OK", style: .cancel)) |
77 | | - } |
| 55 | + self.init(state: store.currentState) { _ = $0.map(store.send) } |
78 | 56 | } |
79 | | - |
80 | 57 | } |
81 | 58 | #endif |
0 commit comments