Skip to content

Commit 2a9f48e

Browse files
authored
Use swift-navigation helpers for presenting alerts and action sheets (#3623)
1 parent 4712118 commit 2a9f48e

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

Sources/ComposableArchitecture/UIKit/AlertStateUIKit.swift

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,7 @@
2828
public convenience init<Action>(
2929
store: Store<AlertState<Action>, Action>
3030
) {
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) }
4332
}
4433

4534
/// Creates a `UIAlertController` from a ``Store`` focused on confirmation dialog state.
@@ -63,19 +52,7 @@
6352
public convenience init<Action>(
6453
store: Store<ConfirmationDialogState<Action>, Action>
6554
) {
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) }
7856
}
79-
8057
}
8158
#endif

0 commit comments

Comments
 (0)