-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixes for TestingSyncUpForm * Typo, heirarchy -> hierarchy * Typo: recursive -> recursively * Typo: comes -> combines * Further fixes for TestingSyncUpForm * Typo: is -> to be * Typo: add -> we added * Typo: 3 -> 2 * Adding a note to avoid confusion * Add more detail to step * Remove stray whitespace causing a diff to incorrectly display * Removed step documentation for unused code * Typo: apart -> a part * Fix App.Path Equatable conformance * App -> AppReducer to avoid conflict with SwiftUI.App * Fix code file link * Typo: reducer -> reducers * Add missing mock * AppReducer -> AppFeature * Standardize tutorial on `@Shared(.syncUps)` * Fix mainactor placement * Fix transcript param not compiling * Add durationPerAttendee to be usable * Add a minimal dismiss override to fit with the docs * Fix commenting out of Tagged discussion * Fix commenting out of TestingSyncUpDetail discussion * Undo a whitespace change * Partial revert of TestingSyncUpForm-02-code-0004.swift * Undo unintentionally committed code * Revert "Add missing mock" This reverts commit 9672ecb. * Revert "Fixes for TestingSyncUpForm" This reverts commit 5bece14. * wip --------- Co-authored-by: Stephen Celis <stephen@stephencelis.com>
- Loading branch information
1 parent
7461262
commit 8631b5f
Showing
31 changed files
with
150 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 53 additions & 9 deletions
62
....docc/Tutorials/BuildingSyncUps/05-PersistingSyncUps/PersistingSyncUps-01-code-0004.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,62 @@ | ||
import ComposableArchitecture | ||
import SwiftUI | ||
|
||
@main | ||
struct SyncUpsApp: App { | ||
@MainActor | ||
static let store = Store(initialState: SyncUpsList.State()) { | ||
SyncUpsList() | ||
@Reducer | ||
struct SyncUpsList { | ||
@ObservableState | ||
struct State: Equatable { | ||
@Presents var addSyncUp: SyncUpForm.State? | ||
@Shared(.syncUps) var syncUps | ||
} | ||
enum Action { | ||
case addSyncUpButtonTapped | ||
case addSyncUp(PresentationAction<SyncUpForm.Action>) | ||
case confirmAddButtonTapped | ||
case discardButtonTapped | ||
case onDelete(IndexSet) | ||
case syncUpTapped(id: SyncUp.ID) | ||
} | ||
var body: some ReducerOf<Self> { | ||
Reduce { state, action in | ||
switch action { | ||
case .addSyncUpButtonTapped: | ||
state.addSyncUp = SyncUpForm.State(syncUp: SyncUp(id: SyncUp.ID())) | ||
return .none | ||
|
||
case .addSyncUp: | ||
return .none | ||
|
||
case .confirmAddButtonTapped: | ||
guard let newSyncUp = state.addSyncUp?.syncUp | ||
else { return .none } | ||
state.addSyncUp = nil | ||
state.syncUps.append(newSyncUp) | ||
return .none | ||
|
||
case .discardButtonTapped: | ||
state.addSyncUp = nil | ||
return .none | ||
|
||
case let .onDelete(indexSet): | ||
state.syncUps.remove(atOffsets: indexSet) | ||
return .none | ||
|
||
var body: some Scene { | ||
WindowGroup { | ||
NavigationStack { | ||
SyncUpsListView(store: Self.store) | ||
case .syncUpTapped: | ||
return .none | ||
} | ||
} | ||
.ifLet(\.$addSyncUp, action: \.addSyncUp) { | ||
SyncUpForm() | ||
} | ||
} | ||
} | ||
|
||
extension PersistenceReaderKey | ||
where Self == PersistenceKeyDefault<FileStorageKey<IdentifiedArrayOf<SyncUp>>> { | ||
static var syncUps: Self { | ||
PersistenceKeyDefault( | ||
.fileStorage(.documentsDirectory.appending(component: "sync-ups.json")), | ||
[] | ||
) | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ import ComposableArchitecture | |
import SwiftUI | ||
|
||
@Reducer | ||
struct App { | ||
struct AppFeature { | ||
// ... | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import ComposableArchitecture | |
import SwiftUI | ||
|
||
@Reducer | ||
struct App { | ||
struct AppFeature { | ||
// ... | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.