@ebarooni/capacitor-calendar 8.1.0 → 8.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -23
- package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendarPlugin.kt +10 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/PluginError.kt +4 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/implementation/CapacitorCalendar.kt +29 -6
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/data/EventDeleteInfo.kt +8 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/enums/EventSpan.kt +13 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/DeleteEventInput.kt +4 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/DeleteEventWithPromptInput.kt +4 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/DeleteEventsByIdInput.kt +2 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/utils/ImplementationHelper.kt +272 -4
- package/dist/docs.json +414 -45
- package/dist/esm/index.d.ts +4 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/schemas/enums/event-span.d.ts +4 -0
- package/dist/esm/schemas/enums/event-span.js +4 -0
- package/dist/esm/schemas/enums/event-span.js.map +1 -1
- package/dist/esm/schemas/interfaces/create-reminders-list-options.d.ts +0 -1
- package/dist/esm/schemas/interfaces/create-reminders-list-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/create-reminders-list-result.d.ts +0 -1
- package/dist/esm/schemas/interfaces/create-reminders-list-result.js.map +1 -1
- package/dist/esm/schemas/interfaces/delete-event-options.d.ts +28 -3
- package/dist/esm/schemas/interfaces/delete-event-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/delete-event-with-prompt-options.d.ts +38 -13
- package/dist/esm/schemas/interfaces/delete-event-with-prompt-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/delete-events-by-id-options.d.ts +15 -3
- package/dist/esm/schemas/interfaces/delete-events-by-id-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/delete-reminders-list-options.d.ts +23 -0
- package/dist/esm/schemas/interfaces/delete-reminders-list-options.js +2 -0
- package/dist/esm/schemas/interfaces/delete-reminders-list-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/update-reminders-list-options.d.ts +40 -0
- package/dist/esm/schemas/interfaces/update-reminders-list-options.js +2 -0
- package/dist/esm/schemas/interfaces/update-reminders-list-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/update-reminders-list-result.d.ts +12 -0
- package/dist/esm/schemas/interfaces/update-reminders-list-result.js +2 -0
- package/dist/esm/schemas/interfaces/update-reminders-list-result.js.map +1 -0
- package/dist/esm/sub-definitions/calendar-operations.d.ts +1 -1
- package/dist/esm/sub-definitions/calendar-operations.js.map +1 -1
- package/dist/esm/sub-definitions/reminders-operations.d.ts +17 -0
- package/dist/esm/sub-definitions/reminders-operations.js.map +1 -1
- package/dist/esm/web.d.ts +5 -0
- package/dist/esm/web.js +6 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +10 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +10 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorCalendarPlugin.swift +30 -0
- package/ios/Plugin/Implementation/CapacitorCalendar.swift +42 -3
- package/ios/Plugin/Models/Enums/EventSpan.swift +8 -0
- package/ios/Plugin/Models/Inputs/DeleteEventInput.swift +9 -4
- package/ios/Plugin/Models/Inputs/DeleteEventWithPromptInput.swift +9 -4
- package/ios/Plugin/Models/Inputs/DeleteEventsByIdInput.swift +9 -4
- package/ios/Plugin/Models/Inputs/DeleteRemindersListInput.swift +22 -0
- package/ios/Plugin/Models/Inputs/UpdateRemindersListInput.swift +55 -0
- package/ios/Plugin/Models/Results/UpdateRemindersListResult.swift +15 -0
- package/ios/Plugin/PluginConfig.swift +3 -1
- package/ios/Plugin/PluginError.swift +3 -0
- package/ios/Plugin/Utils/ImplementationHelper.swift +7 -2
- package/package.json +1 -1
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import Capacitor
|
|
2
|
-
import EventKit
|
|
3
2
|
|
|
4
3
|
struct DeleteEventWithPromptInput {
|
|
4
|
+
private let commit: Bool
|
|
5
5
|
private let id: String
|
|
6
|
-
private let span:
|
|
6
|
+
private let span: EventSpan
|
|
7
7
|
private let title: String
|
|
8
8
|
private let message: String
|
|
9
9
|
private let confirmButtonText: String
|
|
10
10
|
private let cancelButtonText: String
|
|
11
11
|
|
|
12
12
|
init(call: CAPPluginCall) throws {
|
|
13
|
+
self.commit = call.getBool("commit", true)
|
|
13
14
|
guard let id = call.getString("id") else {
|
|
14
15
|
throw PluginError.idMissing
|
|
15
16
|
}
|
|
16
17
|
self.id = id
|
|
17
|
-
if let spanInt = call.getInt("span"), let span =
|
|
18
|
+
if let spanInt = call.getInt("span"), let span = EventSpan(rawValue: spanInt) {
|
|
18
19
|
self.span = span
|
|
19
20
|
} else {
|
|
20
21
|
self.span = .thisEvent
|
|
@@ -31,11 +32,15 @@ struct DeleteEventWithPromptInput {
|
|
|
31
32
|
self.cancelButtonText = call.getString("cancelButtonText", "Cancel")
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
func getCommit() -> Bool {
|
|
36
|
+
return commit
|
|
37
|
+
}
|
|
38
|
+
|
|
34
39
|
func getId() -> String {
|
|
35
40
|
return id
|
|
36
41
|
}
|
|
37
42
|
|
|
38
|
-
func getSpan() ->
|
|
43
|
+
func getSpan() -> EventSpan {
|
|
39
44
|
return span
|
|
40
45
|
}
|
|
41
46
|
|
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
import Capacitor
|
|
2
|
-
import EventKit
|
|
3
2
|
|
|
4
3
|
struct DeleteEventsByIdInput {
|
|
4
|
+
private let commit: Bool
|
|
5
5
|
private let ids: [String]
|
|
6
|
-
private let span:
|
|
6
|
+
private let span: EventSpan
|
|
7
7
|
|
|
8
8
|
init(call: CAPPluginCall) throws {
|
|
9
|
+
self.commit = call.getBool("commit", true)
|
|
9
10
|
guard let ids = call.getArray("ids") as? [String] else {
|
|
10
11
|
throw PluginError.idMissing
|
|
11
12
|
}
|
|
12
13
|
self.ids = ids
|
|
13
|
-
if let spanInt = call.getInt("span"), let span =
|
|
14
|
+
if let spanInt = call.getInt("span"), let span = EventSpan(rawValue: spanInt) {
|
|
14
15
|
self.span = span
|
|
15
16
|
} else {
|
|
16
17
|
self.span = .thisEvent
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
func getCommit() -> Bool {
|
|
22
|
+
return commit
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
func getIds() -> [String] {
|
|
21
26
|
return ids
|
|
22
27
|
}
|
|
23
28
|
|
|
24
|
-
func getSpan() ->
|
|
29
|
+
func getSpan() -> EventSpan {
|
|
25
30
|
return span
|
|
26
31
|
}
|
|
27
32
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Capacitor
|
|
2
|
+
|
|
3
|
+
struct DeleteRemindersListInput {
|
|
4
|
+
private let commit: Bool
|
|
5
|
+
private let id: String
|
|
6
|
+
|
|
7
|
+
init(call: CAPPluginCall) throws {
|
|
8
|
+
self.commit = call.getBool("commit", true)
|
|
9
|
+
guard let id = call.getString("id") else {
|
|
10
|
+
throw PluginError.idMissing
|
|
11
|
+
}
|
|
12
|
+
self.id = id
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
func getCommit() -> Bool {
|
|
16
|
+
return commit
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
func getId() -> String {
|
|
20
|
+
return id
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import Capacitor
|
|
2
|
+
|
|
3
|
+
struct UpdateRemindersListInput {
|
|
4
|
+
private let color: CGColor?
|
|
5
|
+
private let commit: Bool
|
|
6
|
+
private let id: String
|
|
7
|
+
private let title: String?
|
|
8
|
+
|
|
9
|
+
init(call: CAPPluginCall) throws {
|
|
10
|
+
guard let id = call.getString("id") else {
|
|
11
|
+
throw PluginError.idMissing
|
|
12
|
+
}
|
|
13
|
+
self.id = id
|
|
14
|
+
self.title = call.getString("title")
|
|
15
|
+
self.color = UpdateRemindersListInput.getListColorFromCall(call)
|
|
16
|
+
self.commit = call.getBool("commit", true)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
func getColor() -> CGColor? {
|
|
20
|
+
return color
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
func getCommit() -> Bool {
|
|
24
|
+
return commit
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
func getId() -> String {
|
|
28
|
+
return id
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
func getTitle() -> String? {
|
|
32
|
+
return title
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private static func getListColorFromCall(_ call: CAPPluginCall) -> CGColor? {
|
|
36
|
+
guard let colorName = call.getString("color") else {
|
|
37
|
+
return nil
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
switch colorName.lowercased() {
|
|
41
|
+
case "blue": return UIColor.systemBlue.cgColor
|
|
42
|
+
case "brown": return UIColor.systemBrown.cgColor
|
|
43
|
+
case "gray": return UIColor.systemGray.cgColor
|
|
44
|
+
case "green": return UIColor.systemGreen.cgColor
|
|
45
|
+
case "indigo": return UIColor.systemIndigo.cgColor
|
|
46
|
+
case "orange": return UIColor.systemOrange.cgColor
|
|
47
|
+
case "pink": return UIColor.systemPink.cgColor
|
|
48
|
+
case "purple": return UIColor.systemPurple.cgColor
|
|
49
|
+
case "red": return UIColor.systemRed.cgColor
|
|
50
|
+
case "teal": return UIColor.systemTeal.cgColor
|
|
51
|
+
case "yellow": return UIColor.systemYellow.cgColor
|
|
52
|
+
default: return nil
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -17,6 +17,7 @@ struct PluginConfig {
|
|
|
17
17
|
CAPPluginMethod(name: "deleteEventWithPrompt", returnType: CAPPluginReturnPromise),
|
|
18
18
|
CAPPluginMethod(name: "deleteEventsById", returnType: CAPPluginReturnPromise),
|
|
19
19
|
CAPPluginMethod(name: "deleteReminder", returnType: CAPPluginReturnPromise),
|
|
20
|
+
CAPPluginMethod(name: "deleteRemindersList", returnType: CAPPluginReturnPromise),
|
|
20
21
|
CAPPluginMethod(name: "deleteReminderWithPrompt", returnType: CAPPluginReturnPromise),
|
|
21
22
|
CAPPluginMethod(name: "deleteRemindersById", returnType: CAPPluginReturnPromise),
|
|
22
23
|
CAPPluginMethod(name: "fetchAllCalendarSources", returnType: CAPPluginReturnPromise),
|
|
@@ -40,6 +41,7 @@ struct PluginConfig {
|
|
|
40
41
|
CAPPluginMethod(name: "requestPermission", returnType: CAPPluginReturnPromise),
|
|
41
42
|
CAPPluginMethod(name: "requestReadOnlyCalendarAccess", returnType: CAPPluginReturnPromise),
|
|
42
43
|
CAPPluginMethod(name: "requestWriteOnlyCalendarAccess", returnType: CAPPluginReturnPromise),
|
|
43
|
-
CAPPluginMethod(name: "selectCalendarsWithPrompt", returnType: CAPPluginReturnPromise)
|
|
44
|
+
CAPPluginMethod(name: "selectCalendarsWithPrompt", returnType: CAPPluginReturnPromise),
|
|
45
|
+
CAPPluginMethod(name: "updateRemindersList", returnType: CAPPluginReturnPromise)
|
|
44
46
|
]
|
|
45
47
|
}
|
|
@@ -21,6 +21,7 @@ enum PluginError: LocalizedError {
|
|
|
21
21
|
case invalidColor
|
|
22
22
|
case calendarNotFound
|
|
23
23
|
case listNotFound
|
|
24
|
+
case listNotModifiable
|
|
24
25
|
case missingFrequency
|
|
25
26
|
case missingInterval
|
|
26
27
|
case fromDateMissing
|
|
@@ -58,6 +59,8 @@ enum PluginError: LocalizedError {
|
|
|
58
59
|
return NSLocalizedString("Calendar not found.", comment: "Calendar not found error")
|
|
59
60
|
case .listNotFound:
|
|
60
61
|
return NSLocalizedString("List not found.", comment: "List not found error")
|
|
62
|
+
case .listNotModifiable:
|
|
63
|
+
return NSLocalizedString("List is not modifiable.", comment: "List not modifiable error")
|
|
61
64
|
case .invalidUrl:
|
|
62
65
|
return NSLocalizedString("Invalid URL.", comment: "Invalid URL error")
|
|
63
66
|
case .unableToOpenUrl:
|
|
@@ -133,11 +133,16 @@ struct ImplementationHelper {
|
|
|
133
133
|
try eventStore.remove(reminder, commit: true)
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
static func deleteEvent(_ id: String, _ span:
|
|
136
|
+
static func deleteEvent(commit: Bool, _ id: String, _ span: EventSpan, _ eventStore: EKEventStore) throws {
|
|
137
137
|
guard let event = eventStore.event(withIdentifier: id) else {
|
|
138
138
|
throw PluginError.eventNotFound
|
|
139
139
|
}
|
|
140
|
-
|
|
140
|
+
switch span {
|
|
141
|
+
case .thisEvent:
|
|
142
|
+
try eventStore.remove(event, span: .thisEvent, commit: commit)
|
|
143
|
+
case .thisAndFutureEvents:
|
|
144
|
+
try eventStore.remove(event, span: .futureEvents, commit: commit)
|
|
145
|
+
}
|
|
141
146
|
}
|
|
142
147
|
|
|
143
148
|
static func calendarsSetToJSArray(_ calendars: Set<EKCalendar>) -> [JSObject] {
|
package/package.json
CHANGED