mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Merge remote-tracking branch 'origin/main' into pr-361
# Conflicts: # DynamicIsland/components/Settings/SettingsView.swift
This commit is contained in:
commit
73d076636f
14 changed files with 6786 additions and 929 deletions
|
|
@ -382,6 +382,36 @@ class CalendarManager: ObservableObject {
|
|||
lastEventsFetchDate = Date()
|
||||
}
|
||||
|
||||
func setCalendarsSelected(_ calendars: [CalendarModel], isSelected: Bool) async {
|
||||
var selectionState = Defaults[.calendarSelectionState]
|
||||
let ids = Set(calendars.map { $0.id })
|
||||
|
||||
switch selectionState {
|
||||
case .all:
|
||||
if !isSelected {
|
||||
let identifiers = Set(allCalendars.map { $0.id }).subtracting(ids)
|
||||
selectionState = .selected(identifiers)
|
||||
}
|
||||
case .selected(var identifiers):
|
||||
if isSelected {
|
||||
identifiers.formUnion(ids)
|
||||
} else {
|
||||
identifiers.subtract(ids)
|
||||
}
|
||||
|
||||
if identifiers.isEmpty || identifiers.count == allCalendars.count {
|
||||
selectionState = .all
|
||||
} else {
|
||||
selectionState = .selected(identifiers)
|
||||
}
|
||||
}
|
||||
|
||||
Defaults[.calendarSelectionState] = selectionState
|
||||
updateSelectedCalendars()
|
||||
await updateEvents(force: true)
|
||||
await updateLockScreenEvents(force: true)
|
||||
}
|
||||
|
||||
func setReminderCompleted(reminderID: String, completed: Bool) async {
|
||||
await calendarService.setReminderCompleted(reminderID: reminderID, completed: completed)
|
||||
await updateEvents(force: true)
|
||||
|
|
|
|||
|
|
@ -302,6 +302,7 @@ final class LockScreenWidgetPreviewManager: ObservableObject {
|
|||
private func applyCalendarPreviewEvents() {
|
||||
let now = Date()
|
||||
let reminderCalendar = CalendarModel(
|
||||
accountName: "Preview",
|
||||
id: "preview.reminders",
|
||||
title: "Reminders",
|
||||
color: .systemBlue,
|
||||
|
|
@ -327,6 +328,7 @@ final class LockScreenWidgetPreviewManager: ObservableObject {
|
|||
)
|
||||
|
||||
let eventCalendar = CalendarModel(
|
||||
accountName: "Preview",
|
||||
id: "preview.calendar",
|
||||
title: "Calendar",
|
||||
color: .systemOrange,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue