Skip to content

Commit

Permalink
Merge branch 'navigation-beta' into prerelease/1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis committed Mar 8, 2023
2 parents f2c6e5f + bfadebf commit 34d47cd
Show file tree
Hide file tree
Showing 17 changed files with 298 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-case-paths",
"state" : {
"revision" : "f623901b4bcc97f59c36704f81583f169b228e51",
"version" : "0.13.0"
"revision" : "870133b7b2387df136ad301ec67b2e864b51dda1",
"version" : "0.14.0"
}
},
{
Expand All @@ -59,17 +59,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-custom-dump",
"state" : {
"revision" : "dd86159e25c749873f144577e5d18309bf57534f",
"version" : "0.8.0"
"revision" : "de8ba65649e7ee317b9daf27dd5eebf34bd4be57",
"version" : "0.9.1"
}
},
{
"identity" : "swift-dependencies",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-dependencies",
"state" : {
"revision" : "8282b0c59662eb38946afe30eb403663fc2ecf76",
"version" : "0.1.4"
"revision" : "6bb1034e8a1bfbf46dfb766b6c09b7b17e1cba10",
"version" : "0.2.0"
}
},
{
Expand Down Expand Up @@ -104,8 +104,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swiftui-navigation",
"state" : {
"revision" : "270a754308f5440be52fc295242eb7031638bd15",
"version" : "0.6.1"
"revision" : "0a0e1b321d70ee6a464ecfe6b0136d9eff77ebfc",
"version" : "0.7.0"
}
},
{
Expand Down
35 changes: 33 additions & 2 deletions Examples/Integration/Integration/PresentationTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ private struct PresentationTestCase: Reducer {
enum AlertAction {
case ok
case showDialog
case showSheet
}
enum DialogAction {
case ok
case showAlert
case showSheet
}
var body: some ReducerOf<Self> {
Scope(state: /State.fullScreenCover, action: /Action.fullScreenCover) {
Expand Down Expand Up @@ -85,14 +87,16 @@ private struct PresentationTestCase: Reducer {
ButtonState(action: .showDialog) {
TextState("Show dialog")
}
ButtonState(action: .showSheet) {
TextState("Show sheet")
}
ButtonState(role: .cancel) {
TextState("Cancel")
}
}
)
return .none
case .destination(.presented(.fullScreenCover(.parentSendDismissActionButtonTapped))),
.destination(.presented(.navigationDestination(.parentSendDismissActionButtonTapped))),
.destination(.presented(.sheet(.parentSendDismissActionButtonTapped))),
.destination(.presented(.popover(.parentSendDismissActionButtonTapped))):
return .send(.destination(.dismiss))
Expand All @@ -104,13 +108,24 @@ private struct PresentationTestCase: Reducer {
}
)
return .none
case .destination(.presented(.dialog(.showAlert))):
case .destination(.presented(.alert(.showSheet))):
state.destination = .sheet(ChildFeature.State())
return .none
case
.destination(.presented(.dialog(.showAlert))),
.destination(.presented(.fullScreenCover(.dismissAndAlert))),
.destination(.presented(.popover(.dismissAndAlert))),
.destination(.presented(.navigationDestination(.dismissAndAlert))),
.destination(.presented(.sheet(.dismissAndAlert))):
state.destination = .alert(
AlertState {
TextState("Hello!")
}
)
return .none
case .destination(.presented(.dialog(.showSheet))):
state.destination = .sheet(ChildFeature.State())
return .none
case .destination(.dismiss):
state.message = "Dismiss action sent"
return .none
Expand All @@ -127,6 +142,9 @@ private struct PresentationTestCase: Reducer {
ButtonState(action: .showAlert) {
TextState("Show alert")
}
ButtonState(action: .showSheet) {
TextState("Show sheet")
}
}
)
return .none
Expand Down Expand Up @@ -157,11 +175,13 @@ private struct ChildFeature: Reducer {
struct State: Equatable, Identifiable {
var id = UUID()
var count = 0
var isDismissed = false
@BindingState var text = ""
}
enum Action: BindableAction, Equatable {
case binding(BindingAction<State>)
case childDismissButtonTapped
case dismissAndAlert
case incrementButtonTapped
case parentSendDismissActionButtonTapped
case resetIdentity
Expand All @@ -176,11 +196,15 @@ private struct ChildFeature: Reducer {
case .binding:
return .none
case .childDismissButtonTapped:
state.isDismissed = true
return .fireAndForget { await self.dismiss() }
case .dismissAndAlert:
return .none
case .incrementButtonTapped:
state.count += 1
return .none
case .parentSendDismissActionButtonTapped:
state.isDismissed = true
return .none
case .resetIdentity:
state.id = UUID()
Expand Down Expand Up @@ -308,6 +332,7 @@ struct PresentationTestCaseView: View {
}

private struct ChildView: View {
@Environment(\.dismiss) var dismiss
let store: StoreOf<ChildFeature>

var body: some View {
Expand All @@ -324,13 +349,19 @@ private struct ChildView: View {
Button("Parent dismiss") {
viewStore.send(.parentSendDismissActionButtonTapped)
}
Button("Dismiss and alert") {
viewStore.send(.dismissAndAlert)
}
Button("Start effect") {
viewStore.send(.startButtonTapped)
}
Button("Reset identity") {
viewStore.send(.resetIdentity)
}
}
.onChange(of: viewStore.isDismissed) { _ in
self.dismiss()
}
}
}
}
Expand Down
54 changes: 45 additions & 9 deletions Examples/Integration/IntegrationUITests/PresentationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ final class PresentationTests: XCTestCase {
}

func testSheet_IdentityChange() async throws {
// TODO: Remove this XCTExpectFailure once the destination identifiable problem is fixed.
XCTExpectFailure()

self.app.buttons["Open sheet"].tap()
XCTAssertEqual(true, self.app.staticTexts["Count: 0"].exists)

Expand Down Expand Up @@ -157,15 +154,19 @@ final class PresentationTests: XCTestCase {
}

func testAlertThenDialog() {
// TODO: Remove this XCTExpectFailure once the destination identifiable problem is fixed.
XCTExpectFailure()

self.app.buttons["Open alert"].tap()
self.app.buttons["Show dialog"].tap()
_ = self.app.staticTexts["Hello!"].waitForExistence(timeout: 1)
XCTAssertEqual(true, self.app.staticTexts["Hello!"].exists)
}

func testAlertThenSheet() {
self.app.buttons["Open alert"].tap()
self.app.buttons["Show sheet"].tap()
_ = self.app.staticTexts["Count: 0"].waitForExistence(timeout: 1)
XCTAssertEqual(true, self.app.staticTexts["Count: 0"].exists)
}

func testDialogActionDoesNotSendExtraDismiss() {
self.app.buttons["Open dialog"].tap()
self.app.buttons["OK"].tap()
Expand All @@ -181,9 +182,6 @@ final class PresentationTests: XCTestCase {
}

func testShowDialogThenAlert() {
// TODO: Remove this XCTExpectFailure once the destination identifiable problem is fixed.
XCTExpectFailure()

self.app.buttons["Open dialog"].tap()
self.app.buttons["Show alert"].tap()
_ = self.app.staticTexts["Hello!"].waitForExistence(timeout: 1)
Expand Down Expand Up @@ -253,4 +251,42 @@ final class PresentationTests: XCTestCase {
self.app.buttons["Parent dismiss"].tap()
XCTAssertEqual(self.app.staticTexts["Action sent while state nil."].exists, false)
}


func testNavigationDestination_ChildDismiss() {
self.app.buttons["Open navigation destination"].tap()
XCTAssertEqual(true, self.app.staticTexts["Count: 0"].exists)

self.app.buttons["Increment"].tap()
XCTAssertEqual(true, self.app.staticTexts["Count: 1"].exists)
self.app.buttons["Increment"].tap()
XCTAssertEqual(true, self.app.staticTexts["Count: 2"].exists)

self.app.buttons["Child dismiss"].tap()
XCTAssertEqual(false, self.app.staticTexts["Count: 2"].exists)
}

func testNavigationDestination_ParentDismiss() {
self.app.buttons["Open navigation destination"].tap()
XCTAssertEqual(true, self.app.staticTexts["Count: 0"].exists)

self.app.buttons["Parent dismiss"].tap()
XCTAssertEqual(false, self.app.staticTexts["Count: 0"].exists)
}

func testNavigationDestination_EffectsCancelOnDismiss() async throws {
self.app.buttons["Open navigation destination"].tap()
XCTAssertEqual(true, self.app.staticTexts["Count: 0"].exists)

self.app.buttons["Start effect"].tap()
XCTAssertEqual(true, self.app.staticTexts["Count: 1"].exists)

self.app.buttons["Parent dismiss"].tap()
XCTAssertEqual(false, self.app.staticTexts["Count: 1"].exists)

self.app.buttons["Open navigation destination"].tap()
XCTAssertEqual(true, self.app.staticTexts["Count: 0"].exists)
try await Task.sleep(for: .seconds(3))
XCTAssertEqual(false, self.app.staticTexts["Count: 999"].exists)
}
}
16 changes: 8 additions & 8 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-case-paths",
"state" : {
"revision" : "f623901b4bcc97f59c36704f81583f169b228e51",
"version" : "0.13.0"
"revision" : "870133b7b2387df136ad301ec67b2e864b51dda1",
"version" : "0.14.0"
}
},
{
Expand All @@ -59,17 +59,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-custom-dump",
"state" : {
"revision" : "dd86159e25c749873f144577e5d18309bf57534f",
"version" : "0.8.0"
"revision" : "de8ba65649e7ee317b9daf27dd5eebf34bd4be57",
"version" : "0.9.1"
}
},
{
"identity" : "swift-dependencies",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-dependencies",
"state" : {
"revision" : "8282b0c59662eb38946afe30eb403663fc2ecf76",
"version" : "0.1.4"
"revision" : "6bb1034e8a1bfbf46dfb766b6c09b7b17e1cba10",
"version" : "0.2.0"
}
},
{
Expand Down Expand Up @@ -104,8 +104,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swiftui-navigation",
"state" : {
"revision" : "270a754308f5440be52fc295242eb7031638bd15",
"version" : "0.6.1"
"revision" : "0a0e1b321d70ee6a464ecfe6b0136d9eff77ebfc",
"version" : "0.7.0"
}
},
{
Expand Down
10 changes: 5 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ let package = Package(
)
],
dependencies: [
.package(url: "https://github.com/apple/swift-collections", from: "1.0.2"),
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
.package(url: "https://github.com/google/swift-benchmark", from: "0.1.0"),
.package(url: "https://github.com/pointfreeco/combine-schedulers", from: "0.8.0"),
.package(url: "https://github.com/pointfreeco/swift-case-paths", from: "0.13.0"),
.package(url: "https://github.com/apple/swift-collections", from: "1.0.2"),
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "0.7.0"),
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "0.1.2"),
.package(url: "https://github.com/pointfreeco/swift-case-paths", from: "0.14.0"),
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "0.9.1"),
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "0.2.0"),
.package(url: "https://github.com/pointfreeco/swift-identified-collections", from: "0.7.0"),
.package(url: "https://github.com/pointfreeco/swiftui-navigation", from: "0.6.0"),
.package(url: "https://github.com/pointfreeco/swiftui-navigation", from: "0.7.0"),
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "0.5.0"),
],
targets: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@

- ``EffectPublisher/unimplemented(_:)``

### Combine integration

- ``EffectPublisher/publisher(_:)``

### SwiftUI integration

- ``EffectPublisher/animation(_:)``
Expand Down
Loading

0 comments on commit 34d47cd

Please sign in to comment.