Skip to content
Open
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
29 changes: 28 additions & 1 deletion MeetingBar/Preferences/CalendarsTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ struct CalendarSectionsView: View {

var body: some View {
ForEach(sources, id: \.self) { source in
Section(header: Text(source)) {
Section(header: CalendarSourceHeader(source: source, calendars: grouped[source]!)) {
ForEach(grouped[source]!, id: \.id) { cal in
CalendarRow(calendar: cal)
}
Expand All @@ -191,6 +191,33 @@ struct CalendarSectionsView: View {
}
}

struct CalendarSourceHeader: View {
let source: String
let calendars: [MBCalendar]
@EnvironmentObject var appModel: AppModel

var body: some View {
HStack {
Text(source)
Spacer()
Toggle(
source,
isOn: Binding(
get: { calendars.allSatisfy { appModel.state.selectedCalendarIDs.contains($0.id) } },
set: { selected in
for calendar in calendars {
appModel.toggleCalendarSelection(id: calendar.id, selected: selected)
}
}
)
)
.labelsHidden()
.toggleStyle(.switch)
.controlSize(.mini)
}
}
}

struct ProviderPicker: View {
@EnvironmentObject var appModel: AppModel
@State private var picker = EventStoreProvider.macOSEventKit
Expand Down
Loading