Skip to content

Commit 2bf9e8b

Browse files
stephencelisp4checo
authored andcommitted
Update SwiftUI Navigation to support new alert mappings (#1865)
* wip * wip * wip * Bump * Update AlertStateUIKit.swift (cherry picked from commit 63972fa9ea670405011ddc76a09f11e924341fca) # Conflicts: # ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved # Package.resolved
1 parent 9aba1cc commit 2bf9e8b

File tree

6 files changed

+69
-34
lines changed

6 files changed

+69
-34
lines changed

ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved

+24-15
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"kind" : "remoteSourceControl",
2424
"location" : "https://github.com/apple/swift-argument-parser",
2525
"state" : {
26-
"revision" : "9f39744e025c7d377987f30b03770805dcb0bcd1",
27-
"version" : "1.1.4"
26+
"revision" : "4ad606ba5d7673ea60679a61ff867cc1ff8c8e86",
27+
"version" : "1.2.1"
2828
}
2929
},
3030
{
@@ -41,8 +41,8 @@
4141
"kind" : "remoteSourceControl",
4242
"location" : "https://github.com/pointfreeco/swift-case-paths",
4343
"state" : {
44-
"revision" : "15bba50ebf3a2065388c8d12210debe4f6ada202",
45-
"version" : "0.10.0"
44+
"revision" : "c3a42e8d1a76ff557cf565ed6d8b0aee0e6e75af",
45+
"version" : "0.11.0"
4646
}
4747
},
4848
{
@@ -59,34 +59,43 @@
5959
"kind" : "remoteSourceControl",
6060
"location" : "https://github.com/apple/swift-collections",
6161
"state" : {
62-
"revision" : "f504716c27d2e5d4144fa4794b12129301d17729",
63-
"version" : "1.0.3"
62+
"revision" : "937e904258d22af6e447a0b72c0bc67583ef64a2",
63+
"version" : "1.0.4"
6464
}
6565
},
6666
{
6767
"identity" : "swift-custom-dump",
6868
"kind" : "remoteSourceControl",
6969
"location" : "https://github.com/pointfreeco/swift-custom-dump",
7070
"state" : {
71-
"revision" : "819d9d370cd721c9d87671e29d947279292e4541",
72-
"version" : "0.6.0"
71+
"revision" : "ead7d30cc224c3642c150b546f4f1080d1c411a8",
72+
"version" : "0.6.1"
7373
}
7474
},
7575
{
7676
"identity" : "swift-dependencies",
7777
"kind" : "remoteSourceControl",
7878
"location" : "https://github.com/pointfreeco/swift-dependencies",
7979
"state" : {
80-
"revision" : "7a094fcc6a4fcb34fbe625ecd3acd81b881a6dfb",
81-
"version" : "0.1.3"
80+
"revision" : "8282b0c59662eb38946afe30eb403663fc2ecf76",
81+
"version" : "0.1.4"
8282
}
8383
},
8484
{
8585
"identity" : "swift-docc-plugin",
8686
"kind" : "remoteSourceControl",
8787
"location" : "https://github.com/apple/swift-docc-plugin",
8888
"state" : {
89-
"revision" : "3303b164430d9a7055ba484c8ead67a52f7b74f6",
89+
"revision" : "10bc670db657d11bdd561e07de30a9041311b2b1",
90+
"version" : "1.1.0"
91+
}
92+
},
93+
{
94+
"identity" : "swift-docc-symbolkit",
95+
"kind" : "remoteSourceControl",
96+
"location" : "https://github.com/apple/swift-docc-symbolkit",
97+
"state" : {
98+
"revision" : "b45d1f2ed151d057b54504d653e0da5552844e34",
9099
"version" : "1.0.0"
91100
}
92101
},
@@ -95,17 +104,17 @@
95104
"kind" : "remoteSourceControl",
96105
"location" : "https://github.com/pointfreeco/swift-identified-collections",
97106
"state" : {
98-
"revision" : "bfb0d43e75a15b6dfac770bf33479e8393884a36",
99-
"version" : "0.4.1"
107+
"revision" : "fd34c544ad27f3ba6b19142b348005bfa85b6005",
108+
"version" : "0.6.0"
100109
}
101110
},
102111
{
103112
"identity" : "swiftui-navigation",
104113
"kind" : "remoteSourceControl",
105114
"location" : "https://github.com/pointfreeco/swiftui-navigation",
106115
"state" : {
107-
"revision" : "46acf5ecc1cabdb28d7fe03289f6c8b13a023f52",
108-
"version" : "0.4.5"
116+
"revision" : "bf0fb9d53019cbde1a1e0cf290b560a0a0411282",
117+
"version" : "0.6.0"
109118
}
110119
},
111120
{

Package.resolved

+16-7
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"kind" : "remoteSourceControl",
2424
"location" : "https://github.com/apple/swift-argument-parser",
2525
"state" : {
26-
"revision" : "9f39744e025c7d377987f30b03770805dcb0bcd1",
27-
"version" : "1.1.4"
26+
"revision" : "4ad606ba5d7673ea60679a61ff867cc1ff8c8e86",
27+
"version" : "1.2.1"
2828
}
2929
},
3030
{
@@ -77,16 +77,25 @@
7777
"kind" : "remoteSourceControl",
7878
"location" : "https://github.com/pointfreeco/swift-dependencies",
7979
"state" : {
80-
"revision" : "e9e82b5302025092ab8358e794f89a0f0397dd9d",
81-
"version" : "0.1.2"
80+
"revision" : "8282b0c59662eb38946afe30eb403663fc2ecf76",
81+
"version" : "0.1.4"
8282
}
8383
},
8484
{
8585
"identity" : "swift-docc-plugin",
8686
"kind" : "remoteSourceControl",
8787
"location" : "https://github.com/apple/swift-docc-plugin",
8888
"state" : {
89-
"revision" : "3303b164430d9a7055ba484c8ead67a52f7b74f6",
89+
"revision" : "10bc670db657d11bdd561e07de30a9041311b2b1",
90+
"version" : "1.1.0"
91+
}
92+
},
93+
{
94+
"identity" : "swift-docc-symbolkit",
95+
"kind" : "remoteSourceControl",
96+
"location" : "https://github.com/apple/swift-docc-symbolkit",
97+
"state" : {
98+
"revision" : "b45d1f2ed151d057b54504d653e0da5552844e34",
9099
"version" : "1.0.0"
91100
}
92101
},
@@ -104,8 +113,8 @@
104113
"kind" : "remoteSourceControl",
105114
"location" : "https://github.com/pointfreeco/swiftui-navigation",
106115
"state" : {
107-
"revision" : "ddc01cdcddfd30ef7a966049b2e1d251e224ad93",
108-
"version" : "0.5.0"
116+
"revision" : "bf0fb9d53019cbde1a1e0cf290b560a0a0411282",
117+
"version" : "0.6.0"
109118
}
110119
},
111120
{

Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ let package = Package(
2525
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "0.6.0"),
2626
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "0.1.2"),
2727
.package(url: "https://github.com/pointfreeco/swift-identified-collections", from: "0.4.1"),
28-
.package(url: "https://github.com/pointfreeco/swiftui-navigation", from: "0.4.5"),
28+
.package(url: "https://github.com/pointfreeco/swiftui-navigation", from: "0.6.0"),
2929
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "0.5.0"),
3030
],
3131
targets: [

Sources/ComposableArchitecture/SwiftUI/Alert.swift

+10-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ private struct NewAlertModifier<Action>: ViewModifier {
4545
presenting: viewStore.state,
4646
actions: {
4747
ForEach($0.buttons) {
48-
Button($0) { viewStore.send($0) }
48+
Button($0) { action in
49+
if let action = action {
50+
viewStore.send(action)
51+
}
52+
}
4953
}
5054
},
5155
message: { $0.message.map { Text($0) } }
@@ -59,7 +63,11 @@ private struct OldAlertModifier<Action>: ViewModifier {
5963

6064
func body(content: Content) -> some View {
6165
content.alert(item: viewStore.binding(send: dismiss)) { state in
62-
Alert(state) { viewStore.send($0) }
66+
Alert(state) { action in
67+
if let action = action {
68+
viewStore.send(action)
69+
}
70+
}
6371
}
6472
}
6573
}

Sources/ComposableArchitecture/SwiftUI/ConfirmationDialog.swift

+10-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ private struct NewConfirmationDialogModifier<Action>: ViewModifier {
5353
presenting: viewStore.state,
5454
actions: {
5555
ForEach($0.buttons) {
56-
Button($0, action: { viewStore.send($0) })
56+
Button($0) { action in
57+
if let action = action {
58+
viewStore.send(action)
59+
}
60+
}
5761
}
5862
},
5963
message: { $0.message.map { Text($0) } }
@@ -72,7 +76,11 @@ private struct OldConfirmationDialogModifier<Action>: ViewModifier {
7276
func body(content: Content) -> some View {
7377
#if !os(macOS)
7478
return content.actionSheet(item: viewStore.binding(send: dismiss)) {
75-
ActionSheet($0) { viewStore.send($0) }
79+
ActionSheet($0) { action in
80+
if let action = action {
81+
viewStore.send(action)
82+
}
83+
}
7684
}
7785
#else
7886
return EmptyView()

Sources/ComposableArchitecture/UIKit/AlertStateUIKit.swift

+8-7
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
/// - send: A function that wraps an alert action in the view store's action type.
4141
public convenience init<Action>(
4242
state: AlertState<Action>,
43-
send: @escaping (Action) -> Void
43+
send: @escaping (Action?) -> Void
4444
) {
4545
self.init(
4646
title: String(state: state.title),
@@ -58,7 +58,7 @@
5858
/// - state: The state of dialog that can be shown to the user.
5959
/// - send: A function that wraps a dialog action in the view store's action type.
6060
public convenience init<Action>(
61-
state: ConfirmationDialogState<Action>, send: @escaping (Action) -> Void
61+
state: ConfirmationDialogState<Action>, send: @escaping (Action?) -> Void
6262
) {
6363
self.init(
6464
title: String(state: state.title),
@@ -74,7 +74,7 @@
7474
@available(macOS, unavailable)
7575
@available(watchOS, unavailable)
7676
extension UIAlertAction.Style {
77-
init<Action>(_ role: ButtonState<Action>.Role) {
77+
init(_ role: ButtonStateRole) {
7878
switch role {
7979
case .cancel:
8080
self = .cancel
@@ -89,13 +89,14 @@
8989
extension UIAlertAction {
9090
convenience init<Action>(
9191
_ button: ButtonState<Action>,
92-
action: @escaping (Action) -> Void
92+
action handler: @escaping (Action?) -> Void
9393
) {
9494
self.init(
9595
title: String(state: button.label),
96-
style: button.role.map(UIAlertAction.Style.init) ?? .default,
97-
handler: button.action.map { _ in { _ in button.withAction(action) } }
98-
)
96+
style: button.role.map(UIAlertAction.Style.init) ?? .default
97+
) { _ in
98+
button.withAction(handler)
99+
}
99100
}
100101
}
101102
#endif

0 commit comments

Comments
 (0)