Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Building Sync-ups Tutorial] fixes in "Navigating to sync-up detail" chapter #3581

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct CardView: View {
.font(.caption)
}
.padding()
.foregroundColor(syncUp.theme.accentColor)
.foregroundStyle(syncUp.theme.accentColor)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct CardView: View {
.font(.caption)
}
.padding()
.foregroundColor(syncUp.theme.accentColor)
.foregroundStyle(syncUp.theme.accentColor)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct CardView: View {
.font(.caption)
}
.padding()
.foregroundColor(syncUp.theme.accentColor)
.foregroundStyle(syncUp.theme.accentColor)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct SyncUpsListView: View {

var body: some View {
List {
ForEach(store.$syncUps) { $syncUp in
ForEach(Array(store.$syncUps)) { $syncUp in
NavigationLink(
state: AppFeature.Path.State.detail(SyncUpDetail.State(syncUp: <#Shared<SyncUp>#>))
) {
Expand Down Expand Up @@ -66,7 +66,7 @@ struct CardView: View {
.font(.caption)
}
.padding()
.foregroundColor(syncUp.theme.accentColor)
.foregroundStyle(syncUp.theme.accentColor)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct CardView: View {
.font(.caption)
}
.padding()
.foregroundColor(syncUp.theme.accentColor)
.foregroundStyle(syncUp.theme.accentColor)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@
@Step {
Pass the shared collection to the `ForEach` to derive a `Shared<SyncUp>` for each element in
the `Shared<IdentifiedArrayOf<SyncUp>>`.

> Note: We need to further encapsulate the shared collection into an `Array` to avoid that the compiler
> complains about `ForEach` requiring conformance to `RandomAccessCollection` for its argument.

@Code(name: "SyncUpsList.swift", file: SyncUpDetailNavigation-03-code-0003.swift)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct AppFeatureTests {
AppFeature()
}

let sharedSyncUp = try #require($syncUps[id: syncUp.id])
let sharedSyncUp = try #require(Shared($syncUps[id: syncUp.id]))

await store.send(\.path.push, (id: 0, .detail(SyncUpDetail.State(syncUp: sharedSyncUp)))) {
$0.path[id: 0] = .detail(SyncUpDetail.State(syncUp: sharedSyncUp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ struct AppFeatureTests {
AppFeature()
}

let sharedSyncUp = try #require($syncUps[id: syncUp.id])
let sharedSyncUp = try #require(Shared($syncUps[id: syncUp.id]))

await store.send(\.path.push, (id: 0, .detail(SyncUpDetail.State(syncUp: sharedSyncUp)))) {
$0.path[id: 0] = .detail(SyncUpDetail.State(syncUp: sharedSyncUp))
}

await store.send(\.path[id:0].detail.deleteButtonTapped) {
$0.path[id: 0]?.detail?.destination = .alert(.deleteSyncUp)
$0.path[id: 0, case: \.detail]?.destination = .alert(.deleteSyncUp)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ struct AppFeatureTests {
AppFeature()
}

let sharedSyncUp = try #require($syncUps[id: syncUp.id])
let sharedSyncUp = try #require(Shared($syncUps[id: syncUp.id]))

await store.send(\.path.push, (id: 0, .detail(SyncUpDetail.State(syncUp: sharedSyncUp)))) {
$0.path[id: 0] = .detail(SyncUpDetail.State(syncUp: sharedSyncUp))
}

await store.send(\.path[id:0].detail.deleteButtonTapped) {
$0.path[id: 0]?.detail?.destination = .alert(.deleteSyncUp)
$0.path[id: 0, case: \.detail]?.destination = .alert(.deleteSyncUp)
}

await store.send(\.path[id:0].detail.destination.alert.confirmButtonTapped) {
$0.path[id: 0, case: \.detail]?.destination = nil
$0.syncUpsList.syncUps = []
$0.syncUpsList.$syncUps.withLock { $0 = [] }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ struct AppFeatureTests {
AppFeature()
}

let sharedSyncUp = try #require($syncUps[id: syncUp.id])
let sharedSyncUp = try #require(Shared($syncUps[id: syncUp.id]))

await store.send(\.path.push, (id: 0, .detail(SyncUpDetail.State(syncUp: sharedSyncUp)))) {
$0.path[id: 0] = .detail(SyncUpDetail.State(syncUp: sharedSyncUp))
}

await store.send(\.path[id:0].detail.deleteButtonTapped) {
$0.path[id: 0]?.detail?.destination = .alert(.deleteSyncUp)
$0.path[id: 0, case: \.detail]?.destination = .alert(.deleteSyncUp)
}

await store.send(\.path[id:0].detail.destination.alert.confirmButtonTapped) {
$0.path[id: 0, case: \.detail]?.destination = nil
$0.syncUpsList.syncUps = []
$0.syncUpsList.$syncUps.withLock { $0 = [] }
}

await store.receive(\.path.popFrom) {
Expand Down