@ebarooni/capacitor-calendar 6.5.0 → 6.6.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 +53 -5
- package/android/build.gradle +2 -2
- package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendar.kt +178 -119
- package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendarPlugin.kt +73 -0
- package/assets/images/text-logo.png +0 -0
- package/dist/docs.json +453 -60
- package/dist/esm/definitions.d.ts +164 -34
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +18 -14
- package/dist/esm/index.js +12 -9
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/schemas/enums/calendar-source-type.d.ts +38 -0
- package/dist/esm/schemas/enums/calendar-source-type.js +40 -0
- package/dist/esm/schemas/enums/calendar-source-type.js.map +1 -0
- package/dist/esm/schemas/enums/calendar-type.d.ts +28 -0
- package/dist/esm/schemas/enums/calendar-type.js +30 -0
- package/dist/esm/schemas/enums/calendar-type.js.map +1 -0
- package/dist/esm/schemas/enums/event-span.d.ts +16 -0
- package/dist/esm/schemas/enums/event-span.js +18 -0
- package/dist/esm/schemas/enums/event-span.js.map +1 -0
- package/dist/esm/schemas/interfaces/calendar-event.d.ts +14 -3
- package/dist/esm/schemas/interfaces/calendar-event.js.map +1 -1
- package/dist/esm/schemas/interfaces/calendar-source.d.ts +15 -0
- package/dist/esm/schemas/interfaces/calendar-source.js +2 -0
- package/dist/esm/schemas/interfaces/calendar-source.js.map +1 -0
- package/dist/esm/schemas/interfaces/calendar.d.ts +43 -2
- package/dist/esm/schemas/interfaces/calendar.js.map +1 -1
- package/dist/esm/web.d.ts +49 -9
- package/dist/esm/web.js +13 -2
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +101 -2
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +101 -2
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorCalendar.swift +210 -17
- package/ios/Plugin/CapacitorCalendarPlugin.m +4 -0
- package/ios/Plugin/CapacitorCalendarPlugin.swift +111 -1
- package/ios/Plugin/CapacitorReminders.swift +62 -8
- package/ios/Plugin/EventCreationParameters.swift +1 -1
- package/package.json +28 -18
|
@@ -161,6 +161,55 @@ public class CapacitorCalendarPlugin: CAPPlugin {
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
+
@objc public func modifyEventWithPrompt(_ call: CAPPluginCall) {
|
|
165
|
+
guard let id = call.getString("id") else {
|
|
166
|
+
call.reject("[CapacitorCalendar.\(#function)] Missing event id")
|
|
167
|
+
return
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
Task {
|
|
171
|
+
do {
|
|
172
|
+
let result: [String]
|
|
173
|
+
|
|
174
|
+
if let update = call.getObject("update") {
|
|
175
|
+
|
|
176
|
+
let title = update["title"] as? String
|
|
177
|
+
let calendarId = update["calendarId"] as? String
|
|
178
|
+
let location = update["location"] as? String
|
|
179
|
+
let startDate = update["startDate"] as? Double
|
|
180
|
+
let endDate = update["endDate"] as? Double
|
|
181
|
+
let isAllDay = update["isAllDay"] as? Bool
|
|
182
|
+
let notes = update["notes"] as? String
|
|
183
|
+
let url = update["url"] as? String
|
|
184
|
+
let alertOffsetInMinutesSingle = update["alertOffsetInMinutes"] as? Double
|
|
185
|
+
let alertOffsetInMinutesMultiple = update["alertOffsetInMinutes"] as? [Double]
|
|
186
|
+
|
|
187
|
+
var eventParameters = EventCreationParameters(
|
|
188
|
+
title: title,
|
|
189
|
+
calendarId: calendarId,
|
|
190
|
+
location: location,
|
|
191
|
+
startDate: startDate,
|
|
192
|
+
endDate: endDate,
|
|
193
|
+
isAllDay: isAllDay,
|
|
194
|
+
alertOffsetInMinutesSingle: alertOffsetInMinutesSingle,
|
|
195
|
+
alertOffsetInMinutesMultiple: alertOffsetInMinutesMultiple,
|
|
196
|
+
notes: notes,
|
|
197
|
+
url: url
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
result = try await calendar.modifyEventWithPrompt(id: id, update: eventParameters)
|
|
201
|
+
} else {
|
|
202
|
+
result = try await calendar.modifyEventWithPrompt(id: id)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
call.resolve(["result": result])
|
|
206
|
+
} catch {
|
|
207
|
+
call.reject("[CapacitorCalendar.\(#function)] Unable to modify event")
|
|
208
|
+
return
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
164
213
|
@objc public func selectCalendarsWithPrompt(_ call: CAPPluginCall) {
|
|
165
214
|
guard let selectionStyle = call.getInt("selectionStyle") else {
|
|
166
215
|
call.reject("[CapacitorCalendar.\(#function)] Selection style was not provided")
|
|
@@ -234,6 +283,48 @@ public class CapacitorCalendarPlugin: CAPPlugin {
|
|
|
234
283
|
}
|
|
235
284
|
}
|
|
236
285
|
|
|
286
|
+
@objc public func modifyEvent(_ call: CAPPluginCall) {
|
|
287
|
+
guard let eventId = call.getString("id") else {
|
|
288
|
+
call.reject("[CapacitorCalendar.\(#function)] An id for the event was not provided")
|
|
289
|
+
return
|
|
290
|
+
}
|
|
291
|
+
guard let update = call.getObject("update") else {
|
|
292
|
+
call.reject("[CapacitorCalendar.\(#function)] An update for the event was not provided")
|
|
293
|
+
return
|
|
294
|
+
}
|
|
295
|
+
let span = call.getInt("span", 0)
|
|
296
|
+
let title = update["title"] as? String
|
|
297
|
+
let calendarId = update["calendarId"] as? String
|
|
298
|
+
let location = update["location"] as? String
|
|
299
|
+
let startDate = update["startDate"] as? Double
|
|
300
|
+
let endDate = update["endDate"] as? Double
|
|
301
|
+
let isAllDay = update["isAllDay"] as? Bool
|
|
302
|
+
let notes = update["notes"] as? String
|
|
303
|
+
let url = update["url"] as? String
|
|
304
|
+
let alertOffsetInMinutesSingle = update["alertOffsetInMinutes"] as? Double
|
|
305
|
+
let alertOffsetInMinutesMultiple = update["alertOffsetInMinutes"] as? [Double]
|
|
306
|
+
|
|
307
|
+
do {
|
|
308
|
+
var eventParameters = EventCreationParameters(
|
|
309
|
+
title: title,
|
|
310
|
+
calendarId: calendarId,
|
|
311
|
+
location: location,
|
|
312
|
+
startDate: startDate,
|
|
313
|
+
endDate: endDate,
|
|
314
|
+
isAllDay: isAllDay,
|
|
315
|
+
alertOffsetInMinutesSingle: alertOffsetInMinutesSingle,
|
|
316
|
+
alertOffsetInMinutesMultiple: alertOffsetInMinutesMultiple,
|
|
317
|
+
notes: notes,
|
|
318
|
+
url: url
|
|
319
|
+
)
|
|
320
|
+
let result: Void = try calendar.modifyEvent(id: eventId, span: EKSpan(rawValue: span) ?? .thisEvent, update: eventParameters)
|
|
321
|
+
call.resolve(["result": result])
|
|
322
|
+
} catch {
|
|
323
|
+
call.reject("[CapacitorCalendar.\(#function)] Unable to modify event")
|
|
324
|
+
return
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
237
328
|
@objc public func getDefaultRemindersList(_ call: CAPPluginCall) {
|
|
238
329
|
do {
|
|
239
330
|
try call.resolve(["result": reminders.getDefaultRemindersList() ?? NSNull()])
|
|
@@ -377,9 +468,10 @@ public class CapacitorCalendarPlugin: CAPPlugin {
|
|
|
377
468
|
return
|
|
378
469
|
}
|
|
379
470
|
let color = call.getString("color")
|
|
471
|
+
let sourceId = call.getString("sourceId")
|
|
380
472
|
|
|
381
473
|
do {
|
|
382
|
-
let id = try calendar.createCalendar(title: title, color: color)
|
|
474
|
+
let id = try calendar.createCalendar(title: title, color: color, sourceId: sourceId)
|
|
383
475
|
call.resolve(["result": id])
|
|
384
476
|
} catch {
|
|
385
477
|
call.reject("[CapacitorCalendar.\(#function)] Could not create calendar")
|
|
@@ -477,4 +569,22 @@ public class CapacitorCalendarPlugin: CAPPlugin {
|
|
|
477
569
|
}
|
|
478
570
|
}
|
|
479
571
|
}
|
|
572
|
+
|
|
573
|
+
@objc public func fetchAllCalendarSources(_ call: CAPPluginCall) {
|
|
574
|
+
do {
|
|
575
|
+
call.resolve(["result": try calendar.fetchAllCalendarSources()])
|
|
576
|
+
} catch {
|
|
577
|
+
call.reject("[CapacitorCalendar.\(#function)] Unable to fetch calendar sources")
|
|
578
|
+
return
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
@objc public func fetchAllRemindersSources(_ call: CAPPluginCall) {
|
|
583
|
+
do {
|
|
584
|
+
call.resolve(["result": try reminders.fetchAllRemindersSources()])
|
|
585
|
+
} catch {
|
|
586
|
+
call.reject("[CapacitorCalendar.\(#function)] Unable to fetch calendar sources")
|
|
587
|
+
return
|
|
588
|
+
}
|
|
589
|
+
}
|
|
480
590
|
}
|
|
@@ -24,13 +24,26 @@ public class CapacitorReminders: NSObject {
|
|
|
24
24
|
self.eventStore = eventStore
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
public func getDefaultRemindersList() throws -> [String:
|
|
27
|
+
public func getDefaultRemindersList() throws -> [String: Any]? {
|
|
28
28
|
let defaultRemindersList = eventStore.defaultCalendarForNewReminders()
|
|
29
29
|
if let defaultRemindersList = defaultRemindersList {
|
|
30
|
-
|
|
30
|
+
var calendarDict: [String: Any] = [
|
|
31
31
|
"id": defaultRemindersList.calendarIdentifier,
|
|
32
|
-
"title": defaultRemindersList.title
|
|
32
|
+
"title": defaultRemindersList.title,
|
|
33
|
+
"color": hexStringFromColor(color: defaultRemindersList.cgColor),
|
|
34
|
+
"isImmutable": defaultRemindersList.isImmutable,
|
|
35
|
+
"allowsContentModifications": defaultRemindersList.allowsContentModifications,
|
|
36
|
+
"type": defaultRemindersList.type.rawValue,
|
|
37
|
+
"isSubscribed": defaultRemindersList.isSubscribed
|
|
33
38
|
]
|
|
39
|
+
if let calendarSource = defaultRemindersList.source {
|
|
40
|
+
calendarDict["source"] = [
|
|
41
|
+
"type": calendarSource.sourceType.rawValue,
|
|
42
|
+
"id": calendarSource.sourceIdentifier,
|
|
43
|
+
"title": calendarSource.title
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
return calendarDict
|
|
34
47
|
} else {
|
|
35
48
|
return nil
|
|
36
49
|
}
|
|
@@ -63,7 +76,7 @@ public class CapacitorReminders: NSObject {
|
|
|
63
76
|
}
|
|
64
77
|
}
|
|
65
78
|
|
|
66
|
-
public func getRemindersLists() -> [[String:
|
|
79
|
+
public func getRemindersLists() -> [[String: Any]] {
|
|
67
80
|
return convertEKCalendarsToDictionaries(calendars: Set(eventStore.calendars(for: .reminder)))
|
|
68
81
|
}
|
|
69
82
|
|
|
@@ -229,14 +242,41 @@ public class CapacitorReminders: NSObject {
|
|
|
229
242
|
}
|
|
230
243
|
}
|
|
231
244
|
|
|
232
|
-
|
|
233
|
-
var result: [[String:
|
|
245
|
+
public func fetchAllRemindersSources() throws -> [[String: Any]] {
|
|
246
|
+
var result: [[String: Any]] = []
|
|
247
|
+
|
|
248
|
+
for source in eventStore.sources {
|
|
249
|
+
let sourceDict: [String: Any] = [
|
|
250
|
+
"id": source.sourceIdentifier,
|
|
251
|
+
"title": source.title,
|
|
252
|
+
"type": source.sourceType.rawValue
|
|
253
|
+
]
|
|
254
|
+
result.append(sourceDict)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return result
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
private func convertEKCalendarsToDictionaries(calendars: Set<EKCalendar>) -> [[String: Any]] {
|
|
261
|
+
var result: [[String: Any]] = []
|
|
234
262
|
|
|
235
263
|
for calendar in calendars {
|
|
236
|
-
|
|
264
|
+
var calendarDict: [String: Any] = [
|
|
237
265
|
"id": calendar.calendarIdentifier,
|
|
238
|
-
"title": calendar.title
|
|
266
|
+
"title": calendar.title,
|
|
267
|
+
"color": hexStringFromColor(color: calendar.cgColor),
|
|
268
|
+
"isImmutable": calendar.isImmutable,
|
|
269
|
+
"allowsContentModifications": calendar.allowsContentModifications,
|
|
270
|
+
"type": calendar.type.rawValue,
|
|
271
|
+
"isSubscribed": calendar.isSubscribed
|
|
239
272
|
]
|
|
273
|
+
if let calendarSource = calendar.source {
|
|
274
|
+
calendarDict["source"] = [
|
|
275
|
+
"type": calendarSource.sourceType.rawValue,
|
|
276
|
+
"id": calendarSource.sourceIdentifier,
|
|
277
|
+
"title": calendarSource.title
|
|
278
|
+
]
|
|
279
|
+
}
|
|
240
280
|
result.append(calendarDict)
|
|
241
281
|
}
|
|
242
282
|
|
|
@@ -355,4 +395,18 @@ public class CapacitorReminders: NSObject {
|
|
|
355
395
|
return obj
|
|
356
396
|
}
|
|
357
397
|
}
|
|
398
|
+
|
|
399
|
+
private func hexStringFromColor(color: CGColor) -> String {
|
|
400
|
+
guard let components = color.components, components.count >= 3 else {
|
|
401
|
+
return "#000000"
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
let red = Float(components[0])
|
|
405
|
+
let green = Float(components[1])
|
|
406
|
+
let blue = Float(components[2])
|
|
407
|
+
return String(format: "#%02lX%02lX%02lX",
|
|
408
|
+
lroundf(red * 255),
|
|
409
|
+
lroundf(green * 255),
|
|
410
|
+
lroundf(blue * 255))
|
|
411
|
+
}
|
|
358
412
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ebarooni/capacitor-calendar",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.0",
|
|
4
4
|
"description": "The Capacitor Calendar Plugin enables full calendar functionality on iOS and Android, with added reminder support for iOS devices.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"android/build.gradle",
|
|
12
12
|
"dist/",
|
|
13
13
|
"ios/Plugin/",
|
|
14
|
-
"EbarooniCapacitorCalendar.podspec"
|
|
14
|
+
"EbarooniCapacitorCalendar.podspec",
|
|
15
|
+
"LICENSE.txt",
|
|
16
|
+
"assets/images/text-logo.png"
|
|
15
17
|
],
|
|
16
18
|
"author": "Ehsan Barooni",
|
|
17
19
|
"license": "MIT",
|
|
@@ -42,47 +44,54 @@
|
|
|
42
44
|
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
|
|
43
45
|
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
44
46
|
"verify:web": "npm run build",
|
|
47
|
+
"prettier:check": "npx prettier . --check",
|
|
48
|
+
"prettier:fix": "npx prettier . --write",
|
|
45
49
|
"swiftlint": "node-swiftlint",
|
|
46
50
|
"ktlint": "ktlint 'android/src/main/java/**'",
|
|
47
|
-
"lint:ts": "npx eslint
|
|
48
|
-
"lint:html": "npx eslint . --ext .html",
|
|
51
|
+
"lint:ts-html": "npx eslint",
|
|
49
52
|
"lint:css": "npx stylelint \"**/*.(css|scss)\"",
|
|
50
53
|
"lint:swift": "npm run swiftlint -- lint",
|
|
51
54
|
"lint:kt": "npm run ktlint",
|
|
52
|
-
"lint": "npm run lint:ts
|
|
53
|
-
"fmt:ts": "npx eslint
|
|
54
|
-
"fmt:html": "npx eslint . --ext .html --fix",
|
|
55
|
+
"lint": "npm run lint:ts-html && npm run lint:css && npm run lint:swift && npm run lint:kt",
|
|
56
|
+
"fmt:ts-html": "npx eslint --fix",
|
|
55
57
|
"fmt:css": "npx stylelint \"**/*.(css|scss)\" --fix",
|
|
56
58
|
"fmt:swift": "npm run swiftlint -- --fix --format",
|
|
57
59
|
"fmt:md": "npx prettier --write \"**/*.md\"",
|
|
58
60
|
"fmt:kt": "npm run ktlint -- -F",
|
|
59
|
-
"fmt": "npm run fmt:ts
|
|
61
|
+
"fmt": "npm run fmt:ts-html && npm run fmt:css && npm run fmt:swift && npm run fmt:md && npm run fmt:kt",
|
|
60
62
|
"docgen:api": "docgen --api CapacitorCalendarPlugin --output-readme documentation.md --output-json dist/docs.json",
|
|
61
63
|
"docgen:readme": "docgen --api CapacitorCalendarPlugin --output-readme README.md",
|
|
62
64
|
"clean": "rm -rf ./dist",
|
|
63
65
|
"build": "npm run clean && npm run docgen:api && npm run docgen:readme && tsc && rollup -c rollup.config.mjs",
|
|
64
|
-
"prepublishOnly": "npm run build"
|
|
66
|
+
"prepublishOnly": "npm run build",
|
|
67
|
+
"serve": "cd example && npx ng serve"
|
|
65
68
|
},
|
|
66
69
|
"devDependencies": {
|
|
67
|
-
"@angular-eslint/eslint-plugin": "^17.3.0",
|
|
68
|
-
"@angular-eslint/eslint-plugin-template": "^17.3.0",
|
|
69
|
-
"@angular-eslint/template-parser": "^17.3.0",
|
|
70
70
|
"@angular/cli": "^17.1.2",
|
|
71
71
|
"@capacitor/android": "^6.0.0",
|
|
72
72
|
"@capacitor/cli": "^6.0.0",
|
|
73
73
|
"@capacitor/core": "^6.0.0",
|
|
74
74
|
"@capacitor/docgen": "^0.0.18",
|
|
75
75
|
"@capacitor/ios": "^6.0.0",
|
|
76
|
-
"@
|
|
77
|
-
"@
|
|
78
|
-
"
|
|
76
|
+
"@ebarooni/eslint-config": "^1.0.0",
|
|
77
|
+
"@ebarooni/prettier-config": "^1.1.0",
|
|
78
|
+
"@ebarooni/stylelint-config": "^1.1.0",
|
|
79
|
+
"@ebarooni/swiftlint-config": "^1.1.0",
|
|
80
|
+
"@eslint/js": "^9.4.0",
|
|
81
|
+
"@types/eslint__js": "^8.42.3",
|
|
82
|
+
"angular-eslint": "^18.0.1",
|
|
83
|
+
"eslint": "^9.4.0",
|
|
79
84
|
"eslint-config-prettier": "^9.1.0",
|
|
80
85
|
"eslint-plugin-prettier": "^5.1.3",
|
|
81
|
-
"
|
|
86
|
+
"postcss": "^8.4.38",
|
|
87
|
+
"prettier": "^3.3.2",
|
|
82
88
|
"rollup": "^4.17.0",
|
|
89
|
+
"stylelint": "^16.6.1",
|
|
90
|
+
"stylelint-config-standard-scss": "^13.1.0",
|
|
83
91
|
"stylelint-prettier": "^5.0.0",
|
|
84
|
-
"swiftlint": "^1.0.
|
|
85
|
-
"typescript": "~5.4.2"
|
|
92
|
+
"swiftlint": "^1.0.2",
|
|
93
|
+
"typescript": "~5.4.2",
|
|
94
|
+
"typescript-eslint": "^8.0.0-alpha.20"
|
|
86
95
|
},
|
|
87
96
|
"peerDependencies": {
|
|
88
97
|
"@capacitor/core": "^6.0.0"
|
|
@@ -95,6 +104,7 @@
|
|
|
95
104
|
"src": "android"
|
|
96
105
|
}
|
|
97
106
|
},
|
|
107
|
+
"prettier": "@ebarooni/prettier-config",
|
|
98
108
|
"publishConfig": {
|
|
99
109
|
"access": "public"
|
|
100
110
|
}
|