mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
add button request access calendar
This commit is contained in:
parent
a887ee220c
commit
9a19cfbb8f
2 changed files with 65 additions and 4 deletions
|
|
@ -3788,6 +3788,9 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Calendars" : {
|
||||
|
||||
},
|
||||
"Camera" : {
|
||||
"comment" : "A label for the camera privacy indicator.",
|
||||
|
|
@ -12963,6 +12966,9 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Permissions" : {
|
||||
|
||||
},
|
||||
"Pick Color" : {
|
||||
|
||||
|
|
@ -13670,9 +13676,15 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Reminders" : {
|
||||
|
||||
},
|
||||
"Replaces system HUD notifications with Dynamic Island displays." : {
|
||||
|
||||
},
|
||||
"Request Access" : {
|
||||
|
||||
},
|
||||
"Reset" : {
|
||||
|
||||
|
|
|
|||
|
|
@ -788,13 +788,42 @@ struct CalendarSettings: View {
|
|||
.foregroundColor(.red)
|
||||
.multilineTextAlignment(.center)
|
||||
.padding()
|
||||
|
||||
HStack {
|
||||
Button("Request Access") {
|
||||
Task {
|
||||
await calendarManager.checkCalendarAuthorization()
|
||||
}
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
|
||||
Button("Open System Settings") {
|
||||
if let settingsURL = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_Calendars") {
|
||||
NSWorkspace.shared.open(settingsURL)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Permissions status
|
||||
Section {
|
||||
HStack {
|
||||
Text("Calendars")
|
||||
Spacer()
|
||||
Text(statusText(for: calendarManager.calendarAuthorizationStatus))
|
||||
.foregroundColor(color(for: calendarManager.calendarAuthorizationStatus))
|
||||
}
|
||||
HStack {
|
||||
Text("Reminders")
|
||||
Spacer()
|
||||
Text(statusText(for: calendarManager.reminderAuthorizationStatus))
|
||||
.foregroundColor(color(for: calendarManager.reminderAuthorizationStatus))
|
||||
}
|
||||
} header: {
|
||||
Text("Permissions")
|
||||
}
|
||||
|
||||
Defaults.Toggle("Show calendar", key: .showCalendar)
|
||||
|
||||
Section(header: Text("Select Calendars")) {
|
||||
List {
|
||||
ForEach(calendarManager.allCalendars, id: \.id) { calendar in
|
||||
|
|
@ -819,9 +848,29 @@ struct CalendarSettings: View {
|
|||
await calendarManager.checkCalendarAuthorization()
|
||||
}
|
||||
}
|
||||
// Add navigation title if it's missing or adjust as needed
|
||||
.navigationTitle("Calendar")
|
||||
}
|
||||
|
||||
private func statusText(for status: EKAuthorizationStatus) -> String {
|
||||
switch status {
|
||||
case .fullAccess: return "Full Access"
|
||||
case .writeOnly: return "Write Only"
|
||||
case .denied: return "Denied"
|
||||
case .restricted: return "Restricted"
|
||||
case .notDetermined: return "Not Determined"
|
||||
@unknown default: return "Unknown"
|
||||
}
|
||||
}
|
||||
|
||||
private func color(for status: EKAuthorizationStatus) -> Color {
|
||||
switch status {
|
||||
case .fullAccess: return .green
|
||||
case .writeOnly: return .yellow
|
||||
case .denied, .restricted: return .red
|
||||
case .notDetermined: return .secondary
|
||||
@unknown default: return .secondary
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct About: View {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue