mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Update fantastical open cmds
This commit is contained in:
parent
d9742dbacd
commit
ab7d2619d7
4 changed files with 94 additions and 19 deletions
|
|
@ -256,6 +256,18 @@ enum CalendarSelectionState: Codable, Defaults.Serializable {
|
|||
case selected(Set<String>)
|
||||
}
|
||||
|
||||
enum FantasticalViewStyle: String, CaseIterable, Codable, Defaults.Serializable {
|
||||
case mini = "mini"
|
||||
case calendar = "calendar"
|
||||
|
||||
var displayName: String {
|
||||
switch self {
|
||||
case .mini: return "Mini View"
|
||||
case .calendar: return "Full Calendar"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum ClipboardDisplayMode: String, CaseIterable, Codable, Defaults.Serializable {
|
||||
case popover = "popover" // Traditional popover attached to button
|
||||
case panel = "panel" // Floating panel near notch
|
||||
|
|
@ -854,6 +866,10 @@ extension Defaults.Keys {
|
|||
static let lockScreenShowCalendarStartTimeAfterBegins = Key<Bool>("lockScreenShowCalendarStartTimeAfterBegins", default: true)
|
||||
static let lockScreenWeatherWidgetRowOrder = Key<String>("lockScreenWeatherWidgetRowOrder", default: "weather_calendar_focus")
|
||||
|
||||
// MARK: Third-party Calendar Integration
|
||||
static let useFantasticalCalendar = Key<Bool>("useFantasticalCalendar", default: false)
|
||||
static let fantasticalDefaultView = Key<FantasticalViewStyle>("fantasticalDefaultView", default: .mini)
|
||||
|
||||
// MARK: Battery
|
||||
static let showPowerStatusNotifications = Key<Bool>("showPowerStatusNotifications", default: true)
|
||||
static let showBatteryIndicator = Key<Bool>("showBatteryIndicator", default: BatteryActivityManager.shared.hasBattery())
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
*/
|
||||
|
||||
import Foundation
|
||||
import Defaults
|
||||
|
||||
struct EventModel: Equatable, Identifiable {
|
||||
let id: String
|
||||
|
|
@ -97,7 +98,15 @@ extension EventModel {
|
|||
var isMeeting: Bool { !participants.isEmpty }
|
||||
|
||||
func calendarAppURL() -> URL? {
|
||||
|
||||
// Check if Fantastical is enabled
|
||||
if Defaults[.useFantasticalCalendar] {
|
||||
return fantasticalURL()
|
||||
}
|
||||
return appleCalendarURL()
|
||||
}
|
||||
|
||||
/// Returns URL to open event in Apple Calendar
|
||||
private func appleCalendarURL() -> URL? {
|
||||
guard let id = id.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) else {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -123,6 +132,34 @@ extension EventModel {
|
|||
}
|
||||
return URL(string: "ical://ekevent\(date)/\(id)?method=show&options=more")
|
||||
}
|
||||
|
||||
/// Returns URL to open date in Fantastical
|
||||
private func fantasticalURL() -> URL? {
|
||||
// Reminders still use Apple's Reminders app
|
||||
guard !type.isReminder else {
|
||||
return URL(string: "x-apple-reminderkit://remcdreminder/\(id)")
|
||||
}
|
||||
|
||||
let viewStyle = Defaults[.fantasticalDefaultView]
|
||||
let dateFormatter = DateFormatter()
|
||||
dateFormatter.dateFormat = "yyyy-MM-dd"
|
||||
let dateString = dateFormatter.string(from: start)
|
||||
|
||||
// x-fantastical3://show/mini/yyyy-MM-dd or x-fantastical3://show/calendar/yyyy-MM-dd
|
||||
return URL(string: "x-fantastical3://show/\(viewStyle.rawValue)/\(dateString)")
|
||||
}
|
||||
|
||||
/// Returns URL to open Fantastical at current date (for general calendar access)
|
||||
static func fantasticalShowURL(for date: Date? = nil) -> URL? {
|
||||
let viewStyle = Defaults[.fantasticalDefaultView]
|
||||
if let date = date {
|
||||
let dateFormatter = DateFormatter()
|
||||
dateFormatter.dateFormat = "yyyy-MM-dd"
|
||||
let dateString = dateFormatter.string(from: date)
|
||||
return URL(string: "x-fantastical3://show/\(viewStyle.rawValue)/\(dateString)")
|
||||
}
|
||||
return URL(string: "x-fantastical3://show/\(viewStyle.rawValue)")
|
||||
}
|
||||
}
|
||||
|
||||
struct Participant: Hashable {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue