Skip to content

Commit

Permalink
Merge branch 'tca-release/0.57.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
johnpatrickmorgan committed Aug 1, 2023
2 parents 85ef939 + 2250fd6 commit 5e67b6f
Show file tree
Hide file tree
Showing 35 changed files with 640 additions and 847 deletions.
45 changes: 27 additions & 18 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/pointfreeco/combine-schedulers",
"state": {
"branch": null,
"revision": "882ac01eb7ef9e36d4467eb4b1151e74fcef85ab",
"version": "0.9.1"
"revision": "ec62f32d21584214a4b27c8cee2b2ad70ab2c38a",
"version": "0.11.0"
}
},
{
Expand All @@ -24,17 +24,17 @@
"repositoryURL": "https://github.com/pointfreeco/swift-case-paths",
"state": {
"branch": null,
"revision": "c3a42e8d1a76ff557cf565ed6d8b0aee0e6e75af",
"version": "0.11.0"
"revision": "fc45e7b2cfece9dd80b5a45e6469ffe67fe67984",
"version": "0.14.1"
}
},
{
"package": "swift-clocks",
"repositoryURL": "https://github.com/pointfreeco/swift-clocks",
"state": {
"branch": null,
"revision": "20b25ca0dd88ebfb9111ec937814ddc5a8880172",
"version": "0.2.0"
"revision": "0fbaebfc013715dab44d715a4d350ba37f297e4d",
"version": "0.4.0"
}
},
{
Expand All @@ -49,55 +49,64 @@
{
"package": "swift-composable-architecture",
"repositoryURL": "https://github.com/pointfreeco/swift-composable-architecture",
"state": {
"branch": "release/1.0",
"revision": "b4f15dde13da9f09f3d35177e5ae46ab740a4ed5",
"version": null
}
},
{
"package": "swift-concurrency-extras",
"repositoryURL": "https://github.com/pointfreeco/swift-concurrency-extras",
"state": {
"branch": null,
"revision": "a99024bbd171d85a92bccbcea23e7c66f05dc12b",
"version": "0.50.2"
"revision": "479750bd98fac2e813fffcf2af0728b5b0085795",
"version": "0.1.1"
}
},
{
"package": "swift-custom-dump",
"repositoryURL": "https://github.com/pointfreeco/swift-custom-dump",
"state": {
"branch": null,
"revision": "dd86159e25c749873f144577e5d18309bf57534f",
"version": "0.8.0"
"revision": "4a87bb75be70c983a9548597e8783236feb3401e",
"version": "0.11.1"
}
},
{
"package": "swift-dependencies",
"repositoryURL": "https://github.com/pointfreeco/swift-dependencies",
"state": {
"branch": null,
"revision": "8282b0c59662eb38946afe30eb403663fc2ecf76",
"version": "0.1.4"
"revision": "16fd42ae04c6e7f74a6a86395d04722c641cccee",
"version": "0.6.0"
}
},
{
"package": "swift-identified-collections",
"repositoryURL": "https://github.com/pointfreeco/swift-identified-collections",
"state": {
"branch": null,
"revision": "fd34c544ad27f3ba6b19142b348005bfa85b6005",
"version": "0.6.0"
"revision": "d01446a78fb768adc9a78cbb6df07767c8ccfc29",
"version": "0.8.0"
}
},
{
"package": "swiftui-navigation",
"repositoryURL": "https://github.com/pointfreeco/swiftui-navigation",
"state": {
"branch": null,
"revision": "270a754308f5440be52fc295242eb7031638bd15",
"version": "0.6.1"
"revision": "2aa885e719087ee19df251c08a5980ad3e787f12",
"version": "0.8.0"
}
},
{
"package": "xctest-dynamic-overlay",
"repositoryURL": "https://github.com/pointfreeco/xctest-dynamic-overlay",
"state": {
"branch": null,
"revision": "ace21305e0dd3a9e749aef79fef14be79a3b4669",
"version": "0.8.2"
"revision": "50843cbb8551db836adec2290bb4bc6bac5c1865",
"version": "0.9.0"
}
}
]
Expand Down
14 changes: 9 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,24 @@ let package = Package(
products: [
.library(
name: "TCACoordinators",
targets: ["TCACoordinators"]),
targets: ["TCACoordinators"]
),
],
dependencies: [
.package(url: "https://github.com/johnpatrickmorgan/FlowStacks", from: "0.3.0"),
.package(url: "https://github.com/pointfreeco/swift-composable-architecture", from: "0.45.0"),
.package(url: "https://github.com/pointfreeco/swift-composable-architecture", from: "0.57.0"),
],
targets: [
.target(
name: "TCACoordinators",
dependencies: [
.product(name: "FlowStacks", package: "FlowStacks"),
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
]),
]
),
.testTarget(
name: "TCACoordinatorsTests",
dependencies: ["TCACoordinators"]),
])
dependencies: ["TCACoordinators"]
),
]
)
53 changes: 30 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The library works by translating the array of screens into a hierarchy of nested
First, identify all possible screens that are part of the particular navigation flow you're modelling. The goal will be to combine their reducers into a single reducer - one that can drive the behaviour of any of those screens. Both the state and action types will be the sum of the individual screens' state and action types, and the reducer will combine each individual screens' reducers into one:

```swift
struct Screen: ReducerProtocol {
struct Screen: Reducer {
enum State: Equatable {
case home(Home.State)
case numbersList(NumbersList.State)
Expand All @@ -40,7 +40,7 @@ struct Screen: ReducerProtocol {
case numberDetail(NumberDetail.Action)
}

var body: some ReducerProtocol<State, Action> {
var body: some ReducerOf<Self> {
Scope(state: /State.home, action: /Action.home) {
Home()
}
Expand All @@ -59,7 +59,7 @@ struct Screen: ReducerProtocol {
The coordinator will manage multiple screens in a navigation flow. Its state should include an array of `Route<Screen.State>`s, representing the navigation stack: i.e. appending a new screen state to this array will trigger the corresponding screen to be pushed or presented. `Route` is an enum whose cases capture the screen state and how it should be shown, e.g. `case push(Screen.State)`.

```swift
struct Coordinator: ReducerProtocol {
struct Coordinator: Reducer {
struct State: Equatable, IndexedRouterState {
var routes: [Route<Screen.State>]
}
Expand All @@ -70,7 +70,7 @@ struct Coordinator: ReducerProtocol {
The coordinator's action should include two special cases. The first includes an index to allow screen actions to be dispatched to the correct screen in the routes array. The second allows the routes array to be updated automatically, e.g. when a user taps 'Back':

```swift
struct Coordinator: ReducerProtocol {
struct Coordinator: Reducer {
...
enum Action: IndexedRouterAction {
case routeAction(Int, action: Screen.Action)
Expand All @@ -83,10 +83,10 @@ struct Coordinator: ReducerProtocol {
The coordinator reducer defines any logic for presenting and dismissing screens, and uses `forEachRoute` to further apply the `Screen` reducer to each screen in the `routes` array:

```swift
struct Coordinator: ReducerProtocol {
struct Coordinator: Reducer {
...
var body: some ReducerProtocol<State, Action> {
return Reduce<State, Action> { state, action in
var body: some ReducerOf<Self> {
Reduce<State, Action> { state, action in
switch action {
case .routeAction(_, .home(.startTapped)):
state.routes.presentSheet(.numbersList(.init(numbers: Array(0 ..< 4))), embedInNavigationView: true)
Expand Down Expand Up @@ -131,22 +131,29 @@ struct CoordinatorView: View {

var body: some View {
TCARouter(store) { screen in
SwitchStore(screen) {
CaseLet(
state: /Screen.State.home,
action: Screen.Action.home,
then: HomeView.init
)
CaseLet(
state: /Screen.State.numbersList,
action: Screen.Action.numbersList,
then: NumbersListView.init
)
CaseLet(
state: /Screen.State.numberDetail,
action: Screen.Action.numberDetail,
then: NumberDetailView.init
)
SwitchStore(screen) { screen in
switch screen {
case .home:
CaseLet(
/Screen.State.home,
action: Screen.Action.home,
then: HomeView.init
)

case .numbersList:
CaseLet(
/Screen.State.numbersList,
action: Screen.Action.numbersList,
then: NumbersListView.init
)

case .numberDetail:
CaseLet(
/Screen.State.numberDetail,
action: Screen.Action.numberDetail,
then: NumberDetailView.init
)
}
}
}
}
Expand Down

This file was deleted.

Loading

0 comments on commit 5e67b6f

Please sign in to comment.