Skip to content

[Building Sync-ups Tutorial] fixes in "Editing and deleting a sync-up" chapter #3578

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

Merged
Show file tree
Hide file tree
Changes from all 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 @@ -16,7 +16,7 @@ struct SyncUpDetailView: View {
} label: {
Label("Start Meeting", systemImage: "timer")
.font(.headline)
.foregroundColor(.accentColor)
.foregroundStyle(Color.accentColor)
}
HStack {
Label("Length", systemImage: "clock")
Expand All @@ -29,9 +29,9 @@ struct SyncUpDetailView: View {
Spacer()
Text(store.syncUp.theme.name)
.padding(4)
.foregroundColor(store.syncUp.theme.accentColor)
.foregroundStyle(store.syncUp.theme.accentColor)
.background(store.syncUp.theme.mainColor)
.cornerRadius(4)
.clipShape(.rect(cornerRadius: 4))
}
} header: {
Text("Sync-up Info")
Expand Down Expand Up @@ -63,10 +63,9 @@ struct SyncUpDetailView: View {
}

Section {
Button("Delete") {
Button("Delete", role: .destructive) {
store.send(.deleteButtonTapped)
}
.foregroundColor(.red)
.frame(maxWidth: .infinity)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct SyncUpDetailView: View {
} label: {
Label("Start Meeting", systemImage: "timer")
.font(.headline)
.foregroundColor(.accentColor)
.foregroundStyle(Color.accentColor)
}
HStack {
Label("Length", systemImage: "clock")
Expand All @@ -29,9 +29,9 @@ struct SyncUpDetailView: View {
Spacer()
Text(store.syncUp.theme.name)
.padding(4)
.foregroundColor(store.syncUp.theme.accentColor)
.foregroundStyle(store.syncUp.theme.accentColor)
.background(store.syncUp.theme.mainColor)
.cornerRadius(4)
.clipShape(.rect(cornerRadius: 4))
}
} header: {
Text("Sync-up Info")
Expand Down Expand Up @@ -63,10 +63,9 @@ struct SyncUpDetailView: View {
}

Section {
Button("Delete") {
Button("Delete", role: .destructive) {
store.send(.deleteButtonTapped)
}
.foregroundColor(.red)
.frame(maxWidth: .infinity)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct SyncUpDetailView: View {
} label: {
Label("Start Meeting", systemImage: "timer")
.font(.headline)
.foregroundColor(.accentColor)
.foregroundStyle(Color.accentColor)
}
HStack {
Label("Length", systemImage: "clock")
Expand All @@ -29,9 +29,9 @@ struct SyncUpDetailView: View {
Spacer()
Text(store.syncUp.theme.name)
.padding(4)
.foregroundColor(store.syncUp.theme.accentColor)
.foregroundStyle(store.syncUp.theme.accentColor)
.background(store.syncUp.theme.mainColor)
.cornerRadius(4)
.clipShape(.rect(cornerRadius: 4))
}
} header: {
Text("Sync-up Info")
Expand Down Expand Up @@ -63,10 +63,9 @@ struct SyncUpDetailView: View {
}

Section {
Button("Delete") {
Button("Delete", role: .destructive) {
store.send(.deleteButtonTapped)
}
.foregroundColor(.red)
.frame(maxWidth: .infinity)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct SyncUpDetailView: View {
} label: {
Label("Start Meeting", systemImage: "timer")
.font(.headline)
.foregroundColor(.accentColor)
.foregroundStyle(Color.accentColor)
}
HStack {
Label("Length", systemImage: "clock")
Expand All @@ -29,9 +29,9 @@ struct SyncUpDetailView: View {
Spacer()
Text(store.syncUp.theme.name)
.padding(4)
.foregroundColor(store.syncUp.theme.accentColor)
.foregroundStyle(store.syncUp.theme.accentColor)
.background(store.syncUp.theme.mainColor)
.cornerRadius(4)
.clipShape(.rect(cornerRadius: 4))
}
} header: {
Text("Sync-up Info")
Expand Down Expand Up @@ -63,10 +63,9 @@ struct SyncUpDetailView: View {
}

Section {
Button("Delete") {
Button("Delete", role: .destructive) {
store.send(.deleteButtonTapped)
}
.foregroundColor(.red)
.frame(maxWidth: .infinity)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct SyncUpDetailView: View {
} label: {
Label("Start Meeting", systemImage: "timer")
.font(.headline)
.foregroundColor(.accentColor)
.foregroundStyle(Color.accentColor)
}
HStack {
Label("Length", systemImage: "clock")
Expand All @@ -29,9 +29,9 @@ struct SyncUpDetailView: View {
Spacer()
Text(store.syncUp.theme.name)
.padding(4)
.foregroundColor(store.syncUp.theme.accentColor)
.foregroundStyle(store.syncUp.theme.accentColor)
.background(store.syncUp.theme.mainColor)
.cornerRadius(4)
.clipShape(.rect(cornerRadius: 4))
}
} header: {
Text("Sync-up Info")
Expand Down Expand Up @@ -63,10 +63,9 @@ struct SyncUpDetailView: View {
}

Section {
Button("Delete") {
Button("Delete", role: .destructive) {
store.send(.deleteButtonTapped)
}
.foregroundColor(.red)
.frame(maxWidth: .infinity)
}
}
Expand All @@ -93,6 +92,7 @@ struct SyncUpDetailView: View {
}
}
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct SyncUpDetail {
case .doneEditingButtonTapped:
guard let editedSyncUp = state.editSyncUp?.syncUp
else { return .none }
state.syncUp = editedSyncUp
state.$syncUp.withLock { $0 = editedSyncUp }
state.editSyncUp = nil
return .none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct SyncUpDetail {
case .doneEditingButtonTapped:
guard let editedSyncUp = state.editSyncUp?.syncUp
else { return .none }
state.syncUp = editedSyncUp
state.$syncUp.withLock { $0 = editedSyncUp }
state.editSyncUp = nil
return .none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct SyncUpDetail {
case .doneEditingButtonTapped:
guard let editedSyncUp = state.editSyncUp?.syncUp
else { return .none }
state.syncUp = editedSyncUp
state.$syncUp.withLock { $0 = editedSyncUp }
state.editSyncUp = nil
return .none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct SyncUpDetail {
case .doneEditingButtonTapped:
guard let editedSyncUp = state.editSyncUp?.syncUp
else { return .none }
state.syncUp = editedSyncUp
state.$syncUp.withLock { $0 = editedSyncUp }
state.editSyncUp = nil
return .none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct SyncUpDetail {
case .doneEditingButtonTapped:
guard let editedSyncUp = state.editSyncUp?.syncUp
else { return .none }
state.syncUp = editedSyncUp
state.$syncUp.withLock { $0 = editedSyncUp }
state.editSyncUp = nil
return .none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct SyncUpDetail {
case .doneEditingButtonTapped:
guard let editedSyncUp = state.editSyncUp?.syncUp
else { return .none }
state.syncUp = editedSyncUp
state.$syncUp.withLock { $0 = editedSyncUp }
state.editSyncUp = nil
return .none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct SyncUpDetail {
case .doneEditingButtonTapped:
guard let editedSyncUp = state.editSyncUp?.syncUp
else { return .none }
state.syncUp = editedSyncUp
state.$syncUp.withLock { $0 = editedSyncUp }
state.editSyncUp = nil
return .none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct SyncUpDetail {
case .doneEditingButtonTapped:
guard let editedSyncUp = state.editSyncUp?.syncUp
else { return .none }
state.syncUp = editedSyncUp
state.$syncUp.withLock { $0 = editedSyncUp }
state.editSyncUp = nil
return .none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct SyncUpDetail {
case .doneEditingButtonTapped:
guard let editedSyncUp = state.editSyncUp?.syncUp
else { return .none }
state.syncUp = editedSyncUp
state.$syncUp.withLock { $0 = editedSyncUp }
state.editSyncUp = nil
return .none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct SyncUpDetail {
case .doneEditingButtonTapped:
guard let editedSyncUp = state.editSyncUp?.syncUp
else { return .none }
state.syncUp = editedSyncUp
state.$syncUp.withLock { $0 = editedSyncUp }
state.editSyncUp = nil
return .none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct SyncUpDetail {
case .doneEditingButtonTapped:
guard let editedSyncUp = state.editSyncUp?.syncUp
else { return .none }
state.syncUp = editedSyncUp
state.$syncUp.withLock { $0 = editedSyncUp }
state.editSyncUp = nil
return .none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct SyncUpDetail {
case .doneEditingButtonTapped:
guard let editedSyncUp = state.editSyncUp?.syncUp
else { return .none }
state.syncUp = editedSyncUp
state.$syncUp.withLock { $0 = editedSyncUp }
state.editSyncUp = nil
return .none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ struct SyncUpDetail {
Reduce { state, action in
switch action {
case .alert(.presented(.confirmButtonTapped)):
@Shared(.fileStorage(.syncUps)) var syncUps: IdentifiedArrayOf<SyncUp> = []
syncUps.remove(id: state.syncUp.id)
@Shared(.syncUps) var syncUps
$syncUps.withLock { _ = $0.remove(id: state.syncUp.id) }
return .none

case .alert(.dismiss):
Expand All @@ -45,7 +45,7 @@ struct SyncUpDetail {
case .doneEditingButtonTapped:
guard let editedSyncUp = state.editSyncUp?.syncUp
else { return .none }
state.syncUp = editedSyncUp
state.$syncUp.withLock { $0 = editedSyncUp }
state.editSyncUp = nil
return .none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ struct SyncUpDetail {
Reduce { state, action in
switch action {
case .alert(.presented(.confirmButtonTapped)):
@Shared(.fileStorage(.syncUps)) var syncUps: IdentifiedArrayOf<SyncUp> = []
syncUps.remove(id: state.syncUp.id)
@Shared(.syncUps) var syncUps
$syncUps.withLock { _ = $0.remove(id: state.syncUp.id) }
return .none

case .alert(.dismiss):
Expand All @@ -47,7 +47,7 @@ struct SyncUpDetail {
case .doneEditingButtonTapped:
guard let editedSyncUp = state.editSyncUp?.syncUp
else { return .none }
state.syncUp = editedSyncUp
state.$syncUp.withLock { $0 = editedSyncUp }
state.editSyncUp = nil
return .none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ struct SyncUpDetail {
Reduce { state, action in
switch action {
case .alert(.presented(.confirmButtonTapped)):
@Shared(.fileStorage(.syncUps)) var syncUps: IdentifiedArrayOf<SyncUp> = []
syncUps.remove(id: state.syncUp.id)
@Shared(.syncUps) var syncUps
$syncUps.withLock { _ = $0.remove(id: state.syncUp.id) }
return .run { _ in await dismiss() }

case .alert(.dismiss):
Expand All @@ -47,7 +47,7 @@ struct SyncUpDetail {
case .doneEditingButtonTapped:
guard let editedSyncUp = state.editSyncUp?.syncUp
else { return .none }
state.syncUp = editedSyncUp
state.$syncUp.withLock { $0 = editedSyncUp }
state.editSyncUp = nil
return .none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ struct SyncUpDetail {
Reduce { state, action in
switch action {
case .alert(.presented(.confirmButtonTapped)):
@Shared(.fileStorage(.syncUps)) var syncUps: IdentifiedArrayOf<SyncUp> = []
syncUps.remove(id: state.syncUp.id)
@Shared(.syncUps) var syncUps
$syncUps.withLock { _ = $0.remove(id: state.syncUp.id) }
return .run { _ in await dismiss() }

case .alert(.dismiss):
Expand All @@ -60,7 +60,7 @@ struct SyncUpDetail {
case .doneEditingButtonTapped:
guard let editedSyncUp = state.editSyncUp?.syncUp
else { return .none }
state.syncUp = editedSyncUp
state.$syncUp.withLock { $0 = editedSyncUp }
state.editSyncUp = nil
return .none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ struct SyncUpDetail {
Reduce { state, action in
switch action {
case .alert(.presented(.confirmButtonTapped)):
@Shared(.fileStorage(.syncUps)) var syncUps: IdentifiedArrayOf<SyncUp> = []
syncUps.remove(id: state.syncUp.id)
@Shared(.syncUps) var syncUps
$syncUps.withLock { _ = $0.remove(id: state.syncUp.id) }
return .run { _ in await dismiss() }

case .alert(.dismiss):
Expand All @@ -61,7 +61,7 @@ struct SyncUpDetail {
case .doneEditingButtonTapped:
guard let editedSyncUp = state.editSyncUp?.syncUp
else { return .none }
state.syncUp = editedSyncUp
state.$syncUp.withLock { $0 = editedSyncUp }
state.editSyncUp = nil
return .none

Expand Down
Loading