Skip to content

Commit

Permalink
Fix Navigation tutorial (#2736)
Browse files Browse the repository at this point in the history
* Add missing case

* `destination` property should be `nil`

* Change `store` property to `Bindable` to show alert

* Fix filename

* Fix indentation diffs
  • Loading branch information
bricklife authored Jan 29, 2024
1 parent 499798a commit da028ac
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ struct ContactsFeature {
state.contacts.remove(id: id)
return .none

case .destination:
return .none

case let .deleteButtonTapped(id: id):
state.destination = .alert(
AlertState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ struct ContactsFeature {
state.contacts.remove(id: id)
return .none

case .destination:
return .none

case let .deleteButtonTapped(id: id):
state.destination = .alert(
AlertState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ struct ContactsFeature {
state.contacts.remove(id: id)
return .none

case .destination:
return .none

case let .deleteButtonTapped(id: id):
state.destination = .alert(
AlertState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final class ContactsFeatureTests: XCTestCase {
} withDependencies: {
$0.uuid = .incrementing
}

await store.send(.addButtonTapped) {
$0.destination = .addContact(
AddContactFeature.State(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final class ContactsFeatureTests: XCTestCase {
} withDependencies: {
$0.uuid = .incrementing
}

await store.send(.addButtonTapped) {
$0.destination = .addContact(
AddContactFeature.State(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final class ContactsFeatureTests: XCTestCase {
} withDependencies: {
$0.uuid = .incrementing
}

await store.send(.addButtonTapped) {
$0.destination = .addContact(
AddContactFeature.State(
Expand All @@ -31,6 +31,8 @@ final class ContactsFeatureTests: XCTestCase {
Contact(id: UUID(0), name: "Blob Jr.")
]
}
await store.receive(\.destination.dismiss)
await store.receive(\.destination.dismiss) {
$0.destination = nil
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ struct ContactsFeature {
state.contacts.remove(id: id)
return .none

case .destination:
return .none

case let .deleteButtonTapped(id: id):
state.destination = .alert(
AlertState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ struct ContactsFeature {
state.contacts.remove(id: id)
return .none

case .destination:
return .none

case let .deleteButtonTapped(id: id):
state.destination = .alert(.deleteConfirmation(id: id))
return .none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
To further assert that when the `saveContact` delegate action was received, you must
annotate `AddContactFeature.Action.Delegate` with the `@CasePathable` macro.

@Code(name: "ContactsFeatureTests.swift", file: 02-03-01-code-0015.swift, previousFile: 02-03-01-code-0015-previous.swift)
@Code(name: "ContactsFeature.swift", file: 02-03-01-code-0015.swift, previousFile: 02-03-01-code-0015-previous.swift)
}

@Step {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ struct ContactsFeature {
state.contacts.remove(id: id)
return .none

case .destination:
return .none

case let .deleteButtonTapped(id: id):
state.destination = .alert(.deleteConfirmation(id: id))
return .none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ struct ContactsFeature {
state.contacts.remove(id: id)
return .none

case .destination:
return .none

case let .deleteButtonTapped(id: id):
state.destination = .alert(.deleteConfirmation(id: id))
return .none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ struct ContactsFeature {
state.contacts.remove(id: id)
return .none

case .destination:
return .none

case let .deleteButtonTapped(id: id):
state.destination = .alert(.deleteConfirmation(id: id))
return .none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ struct ContactsFeature {
state.contacts.remove(id: id)
return .none

case .destination:
return .none

case let .deleteButtonTapped(id: id):
state.destination = .alert(.deleteConfirmation(id: id))
return .none
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SwiftUI

struct ContactDetailView: View {
let store: StoreOf<ContactDetailFeature>
@Bindable var store: StoreOf<ContactDetailFeature>

var body: some View {
Form {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ struct ContactsFeature {
state.contacts.remove(id: id)
return .none

case .destination:
return .none

case let .deleteButtonTapped(id: id):
state.destination = .alert(.deleteConfirmation(id: id))
return .none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ struct ContactsFeature {
state.contacts.remove(id: id)
return .none

case .destination:
return .none

case let .deleteButtonTapped(id: id):
state.destination = .alert(.deleteConfirmation(id: id))
return .none
Expand Down

0 comments on commit da028ac

Please sign in to comment.