Files
2024-06-05 13:14:22 -07:00

117 lines
2.8 KiB
Swift

import ComposableArchitecture
import SwiftUI
@Reducer
struct SyncUpDetail {
// ...
}
struct SyncUpDetailView: View {
@Bindable var store: StoreOf<SyncUpDetail>
var body: some View {
Form {
Section {
NavigationLink {
} label: {
Label("Start Meeting", systemImage: "timer")
.font(.headline)
.foregroundColor(.accentColor)
}
HStack {
Label("Length", systemImage: "clock")
Spacer()
Text(store.syncUp.duration.formatted(.units()))
}
HStack {
Label("Theme", systemImage: "paintpalette")
Spacer()
Text(store.syncUp.theme.name)
.padding(4)
.foregroundColor(store.syncUp.theme.accentColor)
.background(store.syncUp.theme.mainColor)
.cornerRadius(4)
}
} header: {
Text("Sync-up Info")
}
if !store.syncUp.meetings.isEmpty {
Section {
ForEach(store.syncUp.meetings) { meeting in
NavigationLink(
state: AppFeature.Path.State.meeting(meeting, syncUp: store.syncUp)
) {
HStack {
Image(systemName: "calendar")
Text(meeting.date, style: .date)
Text(meeting.date, style: .time)
}
}
}
} header: {
Text("Past meetings")
}
}
Section {
ForEach(store.syncUp.attendees) { attendee in
Label(attendee.name, systemImage: "person")
}
} header: {
Text("Attendees")
}
Section {
Button("Delete") {
store.send(.deleteButtonTapped)
}
.foregroundColor(.red)
.frame(maxWidth: .infinity)
}
}
.navigationTitle(Text(store.syncUp.title))
.toolbar {
Button("Edit") {
store.send(.editButtonTapped)
}
}
.alert($store.scope(state: \.destination?.alert, action: \.destination.alert))
.sheet(
item: $store.scope(state: \.destination?.edit, action: \.destination.edit)
) { editSyncUpStore in
NavigationStack {
SyncUpFormView(store: editSyncUpStore)
.navigationTitle(store.syncUp.title)
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("Cancel") {
store.send(.cancelEditButtonTapped)
}
}
ToolbarItem(placement: .confirmationAction) {
Button("Done") {
store.send(.doneEditingButtonTapped)
}
}
}
}
}
}
}
#Preview {
NavigationStack {
SyncUpDetailView(
store: Store(
initialState: SyncUpDetail.State(
syncUp: Shared(.mock)
)
) {
SyncUpDetail()
}
)
}
}