Skip to content

Commit 3b49fde

Browse files
committed
Merge branch 'navigation-beta' into prerelease/1.0
2 parents 53cf633 + 7b9759d commit 3b49fde

33 files changed

+889
-421
lines changed

ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/Integration/Integration.xcodeproj/project.pbxproj

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
CAF5802329A564590042FB62 /* TestCases.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CAF57FFC29A564210042FB62 /* TestCases.framework */; };
2222
CAF5802529A5651D0042FB62 /* PresentationTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAF5802429A5651D0042FB62 /* PresentationTestCase.swift */; };
2323
CAF5802729A567BB0042FB62 /* PresentationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAF5802629A567BB0042FB62 /* PresentationTests.swift */; };
24+
CAF8595829BF8882008721D4 /* SwiftUINavigation in Frameworks */ = {isa = PBXBuildFile; productRef = CAF8595729BF8882008721D4 /* SwiftUINavigation */; };
2425
E9919D3E296E28C800C8716B /* EscapedWithViewStoreTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9919D3D296E28C800C8716B /* EscapedWithViewStoreTestCase.swift */; };
2526
E9919D40296E3EF400C8716B /* EscapedWithViewStoreTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9919D3F296E3EF400C8716B /* EscapedWithViewStoreTests.swift */; };
2627
E9919D42296E47A400C8716B /* BindingsAnimationsTestBench.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9919D41296E47A400C8716B /* BindingsAnimationsTestBench.swift */; };
@@ -91,6 +92,7 @@
9192
files = (
9293
CAF5801C29A564440042FB62 /* TestCases.framework in Frameworks */,
9394
CA595278296DF67E00B5B695 /* ComposableArchitecture in Frameworks */,
95+
CAF8595829BF8882008721D4 /* SwiftUINavigation in Frameworks */,
9496
);
9597
runOnlyForDeploymentPostprocessing = 0;
9698
};
@@ -214,6 +216,7 @@
214216
name = Integration;
215217
packageProductDependencies = (
216218
CA595277296DF67E00B5B695 /* ComposableArchitecture */,
219+
CAF8595729BF8882008721D4 /* SwiftUINavigation */,
217220
);
218221
productName = Integration;
219222
productReference = CAA1CAF1296DEE78000665B1 /* Integration.app */;
@@ -287,6 +290,9 @@
287290
Base,
288291
);
289292
mainGroup = CAA1CAE8296DEE78000665B1;
293+
packageReferences = (
294+
CAF8595629BF8882008721D4 /* XCRemoteSwiftPackageReference "swiftui-navigation" */,
295+
);
290296
productRefGroup = CAA1CAF2296DEE78000665B1 /* Products */;
291297
projectDirPath = "";
292298
projectRoot = "";
@@ -685,6 +691,17 @@
685691
};
686692
/* End XCConfigurationList section */
687693

694+
/* Begin XCRemoteSwiftPackageReference section */
695+
CAF8595629BF8882008721D4 /* XCRemoteSwiftPackageReference "swiftui-navigation" */ = {
696+
isa = XCRemoteSwiftPackageReference;
697+
repositoryURL = "https://github.com/pointfreeco/swiftui-navigation.git";
698+
requirement = {
699+
kind = upToNextMajorVersion;
700+
minimumVersion = 0.5.0;
701+
};
702+
};
703+
/* End XCRemoteSwiftPackageReference section */
704+
688705
/* Begin XCSwiftPackageProductDependency section */
689706
CA595277296DF67E00B5B695 /* ComposableArchitecture */ = {
690707
isa = XCSwiftPackageProductDependency;
@@ -694,6 +711,11 @@
694711
isa = XCSwiftPackageProductDependency;
695712
productName = ComposableArchitecture;
696713
};
714+
CAF8595729BF8882008721D4 /* SwiftUINavigation */ = {
715+
isa = XCSwiftPackageProductDependency;
716+
package = CAF8595629BF8882008721D4 /* XCRemoteSwiftPackageReference "swiftui-navigation" */;
717+
productName = SwiftUINavigation;
718+
};
697719
/* End XCSwiftPackageProductDependency section */
698720
};
699721
rootObject = CAA1CAE9296DEE78000665B1 /* Project object */;

Examples/Integration/Integration/PresentationTestCase.swift

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@preconcurrency import ComposableArchitecture
22
import SwiftUI
3+
import SwiftUINavigation
34

45
private struct PresentationTestCase: Reducer {
56
struct State: Equatable {
@@ -8,6 +9,7 @@ private struct PresentationTestCase: Reducer {
89
}
910
enum Action: Equatable, Sendable {
1011
case alertButtonTapped
12+
case customAlertButtonTapped
1113
case destination(PresentationAction<Destination.Action>)
1214
case dialogButtonTapped
1315
case fullScreenCoverButtonTapped
@@ -20,6 +22,7 @@ private struct PresentationTestCase: Reducer {
2022
struct Destination: Reducer {
2123
enum State: Equatable {
2224
case alert(AlertState<AlertAction>)
25+
case customAlert
2326
case dialog(ConfirmationDialogState<DialogAction>)
2427
case fullScreenCover(ChildFeature.State)
2528
case navigationDestination(ChildFeature.State)
@@ -29,6 +32,7 @@ private struct PresentationTestCase: Reducer {
2932
}
3033
enum Action: Equatable {
3134
case alert(AlertAction)
35+
case customAlert(AlertAction)
3236
case dialog(DialogAction)
3337
case fullScreenCover(ChildFeature.Action)
3438
case navigationDestination(ChildFeature.Action)
@@ -96,6 +100,9 @@ private struct PresentationTestCase: Reducer {
96100
}
97101
)
98102
return .none
103+
case .customAlertButtonTapped:
104+
state.destination = .customAlert
105+
return .none
99106
case .destination(.presented(.fullScreenCover(.parentSendDismissActionButtonTapped))),
100107
.destination(.presented(.sheet(.parentSendDismissActionButtonTapped))),
101108
.destination(.presented(.popover(.parentSendDismissActionButtonTapped))):
@@ -225,23 +232,26 @@ private struct ChildFeature: Reducer {
225232

226233
struct PresentationTestCaseView: View {
227234
private let store: StoreOf<PresentationTestCase>
228-
@StateObject private var viewStore: ViewStore<String, PresentationTestCase.Action>
235+
@StateObject private var viewStore: ViewStore<PresentationTestCase.State, PresentationTestCase.Action>
236+
@State var alertMessage = ""
229237

230238
init() {
231239
let store = Store(
232240
initialState: PresentationTestCase.State(),
233-
reducer: PresentationTestCase()._printChanges()
241+
reducer: PresentationTestCase()
242+
._printChanges()
234243
)
235244
self.store = store
236245
self._viewStore = StateObject(
237-
wrappedValue: ViewStore(store, observe: { $0.message })
246+
wrappedValue: ViewStore(store, observe: { $0 })
238247
)
239248
}
240249

241250
var body: some View {
242251
Form {
243252
Section {
244-
Text(self.viewStore.state)
253+
Text(self.viewStore.message)
254+
Text(self.alertMessage)
245255
}
246256

247257
Button("Open alert") {
@@ -254,6 +264,21 @@ struct PresentationTestCaseView: View {
254264
action: PresentationTestCase.Destination.Action.alert
255265
)
256266

267+
Button("Open custom alert") {
268+
self.viewStore.send(.customAlertButtonTapped)
269+
}
270+
.alert(
271+
"Custom alert!",
272+
isPresented: viewStore
273+
.binding(get: \.destination, send: PresentationTestCase.Action.destination(.dismiss))
274+
.case(/PresentationTestCase.Destination.State.customAlert)
275+
.isPresent()
276+
) {
277+
TextField("Message", text: self.$alertMessage)
278+
Button("Submit") {}
279+
Button("Cancel", role: .cancel) {}
280+
}
281+
257282
Button("Open dialog") {
258283
self.viewStore.send(.dialogButtonTapped)
259284
}
@@ -370,10 +395,14 @@ private struct NavigationLinkDemoFeature: ReducerProtocol {
370395
struct State: Equatable {
371396
var message = ""
372397
@PresentationState var child: ChildFeature.State?
398+
@PresentationState var identifiedChild: ChildFeature.State?
373399
}
374400
enum Action: Equatable {
375401
case child(PresentationAction<ChildFeature.Action>)
402+
case identifiedChild(PresentationAction<ChildFeature.Action>)
403+
case identifiedNavigationLinkButtonTapped
376404
case navigationLinkButtonTapped
405+
case nonDeadbeefIdentifiedNavigationLinkButtonTapped
377406
}
378407
var body: some ReducerProtocolOf<Self> {
379408
Reduce<State, Action> { state, action in
@@ -390,16 +419,30 @@ private struct NavigationLinkDemoFeature: ReducerProtocol {
390419
case .child(.presented(.parentSendDismissActionButtonTapped)):
391420
state.child = nil
392421
return .none
393-
case .child:
422+
case .identifiedChild(.presented(.parentSendDismissActionButtonTapped)):
423+
state.child = nil
424+
return .none
425+
case .child, .identifiedChild:
426+
return .none
427+
case .identifiedNavigationLinkButtonTapped:
428+
state.identifiedChild = ChildFeature.State(
429+
id: UUID(uuidString: "deadbeef-dead-beef-dead-beefdeadbeef")!
430+
)
394431
return .none
395432
case .navigationLinkButtonTapped:
396433
state.child = ChildFeature.State()
397434
return .none
435+
case .nonDeadbeefIdentifiedNavigationLinkButtonTapped:
436+
state.identifiedChild = ChildFeature.State()
437+
return .none
398438
}
399439
}
400440
.ifLet(\.$child, action: /Action.child) {
401441
ChildFeature()
402442
}
443+
.ifLet(\.$identifiedChild, action: /Action.identifiedChild) {
444+
ChildFeature()
445+
}
403446
}
404447
}
405448

@@ -411,16 +454,34 @@ private struct NavigationLinkDemoView: View {
411454
Form {
412455
WithViewStore(self.store, observe: \.message) { viewStore in
413456
Text(viewStore.state)
414-
457+
415458
NavigationLinkStore(
416-
store: self.store.scope(state: \.$child, action: NavigationLinkDemoFeature.Action.child)
459+
self.store.scope(state: \.$child, action: NavigationLinkDemoFeature.Action.child)
417460
) {
418461
viewStore.send(.navigationLinkButtonTapped)
419462
} destination: { store in
420463
ChildView(store: store)
421464
} label: {
422465
Text("Open navigation link")
423466
}
467+
468+
NavigationLinkStore(
469+
self.store.scope(
470+
state: \.$identifiedChild,
471+
action: NavigationLinkDemoFeature.Action.identifiedChild
472+
),
473+
id: UUID(uuidString: "deadbeef-dead-beef-dead-beefdeadbeef")!
474+
) {
475+
viewStore.send(.identifiedNavigationLinkButtonTapped)
476+
} destination: { store in
477+
ChildView(store: store)
478+
} label: {
479+
Text("Open identified navigation link")
480+
}
481+
482+
Button("Open non-deadbeef identified navigation link") {
483+
viewStore.send(.nonDeadbeefIdentifiedNavigationLinkButtonTapped)
484+
}
424485
}
425486
}
426487
}

0 commit comments

Comments
 (0)