Skip to content

Commit 7953e49

Browse files
[Building Sync-ups Tutorial] fixes in "Editing and deleting a sync-up" chapter (pointfreeco#3578)
* Replace cornerRadius with clipShape in SyncUpDetailView tutorial code Update view code files to use the newer `.clipShape(.rect(cornerRadius:))` modifier instead of the deprecated `.cornerRadius()` method * Update SyncUpDetailView to use foregroundStyle and destructive button role - Replace deprecated `.foregroundColor()` with `.foregroundStyle()` - Add `.destructive` role to delete button - Remove explicit `.foregroundColor(.red)` styling for the delete button - Replace `.accentColor` with `Color.accentColor` in foregroundStyle modifier for tutorial code files to fix compilation error "type 'ShapeStyle' has no member 'accentColor'" * Update SyncUpDetail tutorial code to use thread-safe state mutation Use `withLock` to safely update the shared `syncUp` state when editing a sync-up in the tutorial code files * Update SyncUpDetail tutorial code for deletion and dismissal Refactor SyncUpDetail reducer to: - Use type-safe `.syncUps` key for shared state - Implement thread-safe state mutation with `withLock` * Update SyncUpDetail tutorial to clarify `.run` effect usage Modify tutorial documentation to: - Simplify explanation of `.run` effect - Remove unnecessary commentary about sending delegate action which are no longer done with the usage of `@Shared` * Remove unnecessary whitespace in SyncUpDetail tutorial code Minor code cleanup by removing an extra blank line in the SyncUpDetail reducer that was causing weird diff in the tutorial * wip --------- Co-authored-by: Stephen Celis <stephen@stephencelis.com>
1 parent d7e42c7 commit 7953e49

File tree

32 files changed

+81
-86
lines changed

32 files changed

+81
-86
lines changed

Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/06-SyncUpDetail/EditingAndDeletingSyncUp-01-code-0005-previous.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct SyncUpDetailView: View {
1616
} label: {
1717
Label("Start Meeting", systemImage: "timer")
1818
.font(.headline)
19-
.foregroundColor(.accentColor)
19+
.foregroundStyle(Color.accentColor)
2020
}
2121
HStack {
2222
Label("Length", systemImage: "clock")
@@ -29,9 +29,9 @@ struct SyncUpDetailView: View {
2929
Spacer()
3030
Text(store.syncUp.theme.name)
3131
.padding(4)
32-
.foregroundColor(store.syncUp.theme.accentColor)
32+
.foregroundStyle(store.syncUp.theme.accentColor)
3333
.background(store.syncUp.theme.mainColor)
34-
.cornerRadius(4)
34+
.clipShape(.rect(cornerRadius: 4))
3535
}
3636
} header: {
3737
Text("Sync-up Info")
@@ -63,10 +63,9 @@ struct SyncUpDetailView: View {
6363
}
6464

6565
Section {
66-
Button("Delete") {
66+
Button("Delete", role: .destructive) {
6767
store.send(.deleteButtonTapped)
6868
}
69-
.foregroundColor(.red)
7069
.frame(maxWidth: .infinity)
7170
}
7271
}

Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/06-SyncUpDetail/EditingAndDeletingSyncUp-01-code-0005.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct SyncUpDetailView: View {
1616
} label: {
1717
Label("Start Meeting", systemImage: "timer")
1818
.font(.headline)
19-
.foregroundColor(.accentColor)
19+
.foregroundStyle(Color.accentColor)
2020
}
2121
HStack {
2222
Label("Length", systemImage: "clock")
@@ -29,9 +29,9 @@ struct SyncUpDetailView: View {
2929
Spacer()
3030
Text(store.syncUp.theme.name)
3131
.padding(4)
32-
.foregroundColor(store.syncUp.theme.accentColor)
32+
.foregroundStyle(store.syncUp.theme.accentColor)
3333
.background(store.syncUp.theme.mainColor)
34-
.cornerRadius(4)
34+
.clipShape(.rect(cornerRadius: 4))
3535
}
3636
} header: {
3737
Text("Sync-up Info")
@@ -63,10 +63,9 @@ struct SyncUpDetailView: View {
6363
}
6464

6565
Section {
66-
Button("Delete") {
66+
Button("Delete", role: .destructive) {
6767
store.send(.deleteButtonTapped)
6868
}
69-
.foregroundColor(.red)
7069
.frame(maxWidth: .infinity)
7170
}
7271
}

Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/06-SyncUpDetail/EditingAndDeletingSyncUp-01-code-0006.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct SyncUpDetailView: View {
1616
} label: {
1717
Label("Start Meeting", systemImage: "timer")
1818
.font(.headline)
19-
.foregroundColor(.accentColor)
19+
.foregroundStyle(Color.accentColor)
2020
}
2121
HStack {
2222
Label("Length", systemImage: "clock")
@@ -29,9 +29,9 @@ struct SyncUpDetailView: View {
2929
Spacer()
3030
Text(store.syncUp.theme.name)
3131
.padding(4)
32-
.foregroundColor(store.syncUp.theme.accentColor)
32+
.foregroundStyle(store.syncUp.theme.accentColor)
3333
.background(store.syncUp.theme.mainColor)
34-
.cornerRadius(4)
34+
.clipShape(.rect(cornerRadius: 4))
3535
}
3636
} header: {
3737
Text("Sync-up Info")
@@ -63,10 +63,9 @@ struct SyncUpDetailView: View {
6363
}
6464

6565
Section {
66-
Button("Delete") {
66+
Button("Delete", role: .destructive) {
6767
store.send(.deleteButtonTapped)
6868
}
69-
.foregroundColor(.red)
7069
.frame(maxWidth: .infinity)
7170
}
7271
}

Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/06-SyncUpDetail/EditingAndDeletingSyncUp-01-code-0007.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct SyncUpDetailView: View {
1616
} label: {
1717
Label("Start Meeting", systemImage: "timer")
1818
.font(.headline)
19-
.foregroundColor(.accentColor)
19+
.foregroundStyle(Color.accentColor)
2020
}
2121
HStack {
2222
Label("Length", systemImage: "clock")
@@ -29,9 +29,9 @@ struct SyncUpDetailView: View {
2929
Spacer()
3030
Text(store.syncUp.theme.name)
3131
.padding(4)
32-
.foregroundColor(store.syncUp.theme.accentColor)
32+
.foregroundStyle(store.syncUp.theme.accentColor)
3333
.background(store.syncUp.theme.mainColor)
34-
.cornerRadius(4)
34+
.clipShape(.rect(cornerRadius: 4))
3535
}
3636
} header: {
3737
Text("Sync-up Info")
@@ -63,10 +63,9 @@ struct SyncUpDetailView: View {
6363
}
6464

6565
Section {
66-
Button("Delete") {
66+
Button("Delete", role: .destructive) {
6767
store.send(.deleteButtonTapped)
6868
}
69-
.foregroundColor(.red)
7069
.frame(maxWidth: .infinity)
7170
}
7271
}

Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/06-SyncUpDetail/EditingAndDeletingSyncUp-01-code-0008.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct SyncUpDetailView: View {
1616
} label: {
1717
Label("Start Meeting", systemImage: "timer")
1818
.font(.headline)
19-
.foregroundColor(.accentColor)
19+
.foregroundStyle(Color.accentColor)
2020
}
2121
HStack {
2222
Label("Length", systemImage: "clock")
@@ -29,9 +29,9 @@ struct SyncUpDetailView: View {
2929
Spacer()
3030
Text(store.syncUp.theme.name)
3131
.padding(4)
32-
.foregroundColor(store.syncUp.theme.accentColor)
32+
.foregroundStyle(store.syncUp.theme.accentColor)
3333
.background(store.syncUp.theme.mainColor)
34-
.cornerRadius(4)
34+
.clipShape(.rect(cornerRadius: 4))
3535
}
3636
} header: {
3737
Text("Sync-up Info")
@@ -63,10 +63,9 @@ struct SyncUpDetailView: View {
6363
}
6464

6565
Section {
66-
Button("Delete") {
66+
Button("Delete", role: .destructive) {
6767
store.send(.deleteButtonTapped)
6868
}
69-
.foregroundColor(.red)
7069
.frame(maxWidth: .infinity)
7170
}
7271
}
@@ -93,6 +92,7 @@ struct SyncUpDetailView: View {
9392
}
9493
}
9594
}
95+
}
9696
}
9797
}
9898

Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/06-SyncUpDetail/EditingAndDeletingSyncUp-01-code-0011.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct SyncUpDetail {
3030
case .doneEditingButtonTapped:
3131
guard let editedSyncUp = state.editSyncUp?.syncUp
3232
else { return .none }
33-
state.syncUp = editedSyncUp
33+
state.$syncUp.withLock { $0 = editedSyncUp }
3434
state.editSyncUp = nil
3535
return .none
3636

Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/06-SyncUpDetail/EditingAndDeletingSyncUp-02-code-0001-previous.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct SyncUpDetail {
3030
case .doneEditingButtonTapped:
3131
guard let editedSyncUp = state.editSyncUp?.syncUp
3232
else { return .none }
33-
state.syncUp = editedSyncUp
33+
state.$syncUp.withLock { $0 = editedSyncUp }
3434
state.editSyncUp = nil
3535
return .none
3636

Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/06-SyncUpDetail/EditingAndDeletingSyncUp-02-code-0001.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct SyncUpDetail {
3434
case .doneEditingButtonTapped:
3535
guard let editedSyncUp = state.editSyncUp?.syncUp
3636
else { return .none }
37-
state.syncUp = editedSyncUp
37+
state.$syncUp.withLock { $0 = editedSyncUp }
3838
state.editSyncUp = nil
3939
return .none
4040

Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/06-SyncUpDetail/EditingAndDeletingSyncUp-02-code-0002.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct SyncUpDetail {
3535
case .doneEditingButtonTapped:
3636
guard let editedSyncUp = state.editSyncUp?.syncUp
3737
else { return .none }
38-
state.syncUp = editedSyncUp
38+
state.$syncUp.withLock { $0 = editedSyncUp }
3939
state.editSyncUp = nil
4040
return .none
4141

Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/06-SyncUpDetail/EditingAndDeletingSyncUp-02-code-0003.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct SyncUpDetail {
3636
case .doneEditingButtonTapped:
3737
guard let editedSyncUp = state.editSyncUp?.syncUp
3838
else { return .none }
39-
state.syncUp = editedSyncUp
39+
state.$syncUp.withLock { $0 = editedSyncUp }
4040
state.editSyncUp = nil
4141
return .none
4242

0 commit comments

Comments
 (0)