Skip to content

Instantly share code, notes, and snippets.

@mbrandonw
Created January 24, 2024 18:31
Show Gist options
  • Save mbrandonw/285d15609ae36243b975a37479ae9b44 to your computer and use it in GitHub Desktop.
Save mbrandonw/285d15609ae36243b975a37479ae9b44 to your computer and use it in GitHub Desktop.
struct SyncUpDetailView: View {
- @Bindable var model: SyncUpDetailModel
+ @Bindable var store: StoreOf<SyncUpDetail>
var body: some View {
Form {
Section {
Button {
- model.startMeetingButtonTapped()
+ store.send(.startMeetingButtonTapped)
} label: {
Label("Start Meeting", systemImage: "timer")
.font(.headline)
.foregroundColor(.accentColor)
}
HStack {
Label("Length", systemImage: "clock")
Spacer()
- Text(model.syncUp.duration.formatted(.units()))
+ Text(store.syncUp.duration.formatted(.units()))
}
HStack {
Label("Theme", systemImage: "paintpalette")
Spacer()
- Text(model.syncUp.theme.name)
+ Text(store.syncUp.theme.name)
.padding(4)
- .foregroundColor(model.syncUp.theme.accentColor)
- .background(model.syncUp.theme.mainColor)
+ .foregroundColor(store.syncUp.theme.accentColor)
+ .background(store.syncUp.theme.mainColor)
.cornerRadius(4)
}
} header: {
Text("Sync-up Info")
}
- if !model.syncUp.meetings.isEmpty {
+ if !store.syncUp.meetings.isEmpty {
Section {
- ForEach(model.syncUp.meetings) { meeting in
+ ForEach(store.syncUp.meetings) { meeting in
- NavigationLink(value: AppModel.Destination.meeting(meeting, syncUp: model.syncUp))) {
+ NavigationLink(state: AppFeature.Path.State.meeting(meeting, syncUp: store.syncUp)) {
HStack {
Image(systemName: "calendar")
Text(meeting.date, style: .date)
Text(meeting.date, style: .time)
}
}
}
.onDelete { indices in
- model.deleteMeetings(atOffsets: indices)
+ store.send(.deleteMeetings(atOffsets: indices))
}
} header: {
Text("Past meetings")
}
}
Section {
- ForEach(model.syncUp.attendees) { attendee in
+ ForEach(store.syncUp.attendees) { attendee in
Label(attendee.name, systemImage: "person")
}
} header: {
Text("Attendees")
}
Section {
Button("Delete") {
- model.deleteButtonTapped()
+ store.send(.deleteButtonTapped)
}
.foregroundColor(.red)
.frame(maxWidth: .infinity)
}
}
.toolbar {
Button("Edit") {
- model.editButtonTapped()
+ store.send(.editButtonTapped)
}
}
- .navigationTitle(model.syncUp.title)
+ .navigationTitle(store.syncUp.title)
- .alert($model.destination.alert) { action in
- await model.alertButtonTapped(action)
- }
+ .alert($store.scope(state: \.destination?.alert, action: \.destination.alert))
- .sheet(item: $model.destination.edit) { editModel in
+ .sheet(item: $store.scope(state: \.destination?.edit, action: \.destination.edit)) { store in
NavigationStack {
- SyncUpFormView(model: editModel)
+ SyncUpFormView(store: store)
- .navigationTitle(model.syncUp.title)
+ .navigationTitle(self.store.syncUp.title)
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("Cancel") {
- model.cancelEditButtonTapped()
+ self.store.send(.cancelEditButtonTapped)
}
}
ToolbarItem(placement: .confirmationAction) {
Button("Done") {
- model.doneEditingButtonTapped()
+ self.store.send(.doneEditingButtonTapped)
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment