@ebarooni/capacitor-calendar 7.2.0 → 8.0.1

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.
Files changed (140) hide show
  1. package/EbarooniCapacitorCalendar.podspec +2 -2
  2. package/Package.swift +4 -4
  3. package/README.md +176 -162
  4. package/android/build.gradle +21 -19
  5. package/android/src/main/java/dev/barooni/capacitor/calendar/implementation/CapacitorCalendar.kt +90 -61
  6. package/android/src/main/java/dev/barooni/capacitor/calendar/models/data/EventRecurrenceRule.kt +135 -0
  7. package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/CreateEventInput.kt +1 -0
  8. package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/CreateEventWithPromptInput.kt +5 -0
  9. package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ModifyEvent.kt +2 -0
  10. package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ModifyEventWithPromptInput.kt +3 -0
  11. package/android/src/main/java/dev/barooni/capacitor/calendar/utils/ImplementationHelper.kt +48 -4
  12. package/dist/docs.json +584 -324
  13. package/dist/esm/definitions.d.ts +5 -5
  14. package/dist/esm/definitions.js.map +1 -1
  15. package/dist/esm/index.d.ts +46 -46
  16. package/dist/esm/index.js +16 -17
  17. package/dist/esm/index.js.map +1 -1
  18. package/dist/esm/schemas/enums/attendee-role.js.map +1 -1
  19. package/dist/esm/schemas/enums/attendee-status.js.map +1 -1
  20. package/dist/esm/schemas/enums/attendee-type.js.map +1 -1
  21. package/dist/esm/schemas/enums/calendar-permission-scope.js.map +1 -1
  22. package/dist/esm/schemas/enums/event-status.js.map +1 -1
  23. package/dist/esm/schemas/interfaces/calendar-event.d.ts +7 -5
  24. package/dist/esm/schemas/interfaces/calendar-event.js.map +1 -1
  25. package/dist/esm/schemas/interfaces/calendar-source.d.ts +1 -1
  26. package/dist/esm/schemas/interfaces/calendar-source.js.map +1 -1
  27. package/dist/esm/schemas/interfaces/calendar.d.ts +2 -2
  28. package/dist/esm/schemas/interfaces/calendar.js.map +1 -1
  29. package/dist/esm/schemas/interfaces/create-event-options.d.ts +63 -46
  30. package/dist/esm/schemas/interfaces/create-event-options.js.map +1 -1
  31. package/dist/esm/schemas/interfaces/create-event-with-prompt-options.d.ts +42 -31
  32. package/dist/esm/schemas/interfaces/create-event-with-prompt-options.js.map +1 -1
  33. package/dist/esm/schemas/interfaces/create-reminder-options.d.ts +10 -1
  34. package/dist/esm/schemas/interfaces/create-reminder-options.js.map +1 -1
  35. package/dist/esm/schemas/interfaces/delete-event-options.d.ts +1 -1
  36. package/dist/esm/schemas/interfaces/delete-event-options.js.map +1 -1
  37. package/dist/esm/schemas/interfaces/delete-event-with-prompt-options.d.ts +1 -1
  38. package/dist/esm/schemas/interfaces/delete-event-with-prompt-options.js.map +1 -1
  39. package/dist/esm/schemas/interfaces/delete-events-by-id-options.d.ts +1 -1
  40. package/dist/esm/schemas/interfaces/delete-events-by-id-options.js.map +1 -1
  41. package/dist/esm/schemas/interfaces/event-recurrence-rule.d.ts +96 -0
  42. package/dist/esm/schemas/interfaces/event-recurrence-rule.js +2 -0
  43. package/dist/esm/schemas/interfaces/event-recurrence-rule.js.map +1 -0
  44. package/dist/esm/schemas/interfaces/modify-event-options.d.ts +61 -44
  45. package/dist/esm/schemas/interfaces/modify-event-options.js.map +1 -1
  46. package/dist/esm/schemas/interfaces/modify-event-with-prompt-options.d.ts +1 -1
  47. package/dist/esm/schemas/interfaces/modify-event-with-prompt-options.js.map +1 -1
  48. package/dist/esm/schemas/interfaces/modify-reminder-options.d.ts +12 -1
  49. package/dist/esm/schemas/interfaces/modify-reminder-options.js.map +1 -1
  50. package/dist/esm/schemas/interfaces/recurrence-rule.d.ts +1 -1
  51. package/dist/esm/schemas/interfaces/recurrence-rule.js.map +1 -1
  52. package/dist/esm/schemas/interfaces/reminder-recurrence-rule.d.ts +1 -1
  53. package/dist/esm/schemas/interfaces/reminder-recurrence-rule.js.map +1 -1
  54. package/dist/esm/schemas/interfaces/reminder.d.ts +1 -1
  55. package/dist/esm/schemas/interfaces/reminder.js.map +1 -1
  56. package/dist/esm/schemas/interfaces/reminders-list.d.ts +2 -2
  57. package/dist/esm/schemas/interfaces/reminders-list.js.map +1 -1
  58. package/dist/esm/schemas/interfaces/select-calendars-with-prompt-options.d.ts +1 -1
  59. package/dist/esm/schemas/interfaces/select-calendars-with-prompt-options.js.map +1 -1
  60. package/dist/esm/schemas/types/event-edit-action.d.ts +1 -1
  61. package/dist/esm/schemas/types/event-edit-action.js.map +1 -1
  62. package/dist/esm/schemas/types/recurrence-frequency.d.ts +4 -0
  63. package/dist/esm/schemas/types/recurrence-frequency.js +2 -0
  64. package/dist/esm/schemas/types/recurrence-frequency.js.map +1 -0
  65. package/dist/esm/sub-definitions/calendar-access.d.ts +4 -4
  66. package/dist/esm/sub-definitions/calendar-access.js.map +1 -1
  67. package/dist/esm/sub-definitions/calendar-operations.d.ts +7 -7
  68. package/dist/esm/sub-definitions/calendar-operations.js.map +1 -1
  69. package/dist/esm/sub-definitions/event-operations.d.ts +10 -10
  70. package/dist/esm/sub-definitions/event-operations.js.map +1 -1
  71. package/dist/esm/sub-definitions/reminders-access.d.ts +1 -1
  72. package/dist/esm/sub-definitions/reminders-access.js.map +1 -1
  73. package/dist/esm/sub-definitions/reminders-operations.d.ts +10 -10
  74. package/dist/esm/sub-definitions/reminders-operations.js.map +1 -1
  75. package/dist/esm/web.d.ts +33 -32
  76. package/dist/esm/web.js +1 -1
  77. package/dist/esm/web.js.map +1 -1
  78. package/dist/plugin.cjs.js +1 -24
  79. package/dist/plugin.cjs.js.map +1 -1
  80. package/dist/plugin.js +1 -24
  81. package/dist/plugin.js.map +1 -1
  82. package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/CapacitorCalendarPlugin.swift +90 -71
  83. package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Implementation/CapacitorCalendar.swift +45 -63
  84. package/ios/Plugin/Info.plist +24 -0
  85. package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/CreateEventInput.swift +25 -21
  86. package/ios/Plugin/Models/Inputs/CreateEventWithPromptInput.swift +171 -0
  87. package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/CreateReminderInput.swift +2 -2
  88. package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/ModifyEventInput.swift +63 -41
  89. package/ios/Plugin/Models/Structs/RecurrenceInput.swift +31 -0
  90. package/package.json +37 -45
  91. package/dist/esm/schemas/enums/recurrence-frequency.d.ts +0 -21
  92. package/dist/esm/schemas/enums/recurrence-frequency.js +0 -23
  93. package/dist/esm/schemas/enums/recurrence-frequency.js.map +0 -1
  94. package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/CreateEventWithPromptInput.swift +0 -89
  95. package/ios/Tests/CapacitorCalendarPluginTests/CapacitorCalendarPluginTests.swift +0 -15
  96. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Enums/CAPPermissionState.swift +0 -0
  97. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Enums/CalendarPermissionScope.swift +0 -0
  98. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Enums/EventEditAction.swift +0 -0
  99. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/CheckPermissionInput.swift +0 -0
  100. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/CreateCalendarInput.swift +0 -0
  101. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteCalendarInput.swift +0 -0
  102. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteEventInput.swift +0 -0
  103. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteEventWithPromptInput.swift +0 -0
  104. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteEventsByIdInput.swift +0 -0
  105. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteReminderInput.swift +0 -0
  106. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteReminderWithPromptInput.swift +0 -0
  107. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteRemindersByIdInput.swift +0 -0
  108. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/GetReminderByIdInput.swift +0 -0
  109. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/GetRemindersFromListsInput.swift +0 -0
  110. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/ListEventsInRangeInput.swift +0 -0
  111. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/ModifyCalendarInput.swift +0 -0
  112. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/ModifyEventWithPromptInput.swift +0 -0
  113. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/ModifyReminderInput.swift +0 -0
  114. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/OpenCalendarInput.swift +0 -0
  115. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/RequestPermissionInput.swift +0 -0
  116. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/SelectCalendarsWithPromptInput.swift +0 -0
  117. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CheckAllPermissionsResult.swift +0 -0
  118. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CheckPermissionResult.swift +0 -0
  119. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CreateCalendarResult.swift +0 -0
  120. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CreateEventResult.swift +0 -0
  121. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CreateEventWithPromptResult.swift +0 -0
  122. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CreateReminderResult.swift +0 -0
  123. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/DeleteEventWithPromptResult.swift +0 -0
  124. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/DeleteEventsByIdResult.swift +0 -0
  125. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/DeleteRemindersByIdResult.swift +0 -0
  126. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/FetchAllCalendarSourcesResult.swift +0 -0
  127. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/GetDefaultCalendarResult.swift +0 -0
  128. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/GetReminderByIdResult.swift +0 -0
  129. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/GetRemindersFromListsResult.swift +0 -0
  130. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/ListCalendarsResult.swift +0 -0
  131. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/ListEventsInRangeResult.swift +0 -0
  132. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/ModifyEventWithPromptResult.swift +0 -0
  133. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/RequestAllPermissionsResult.swift +0 -0
  134. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/RequestPermissionResult.swift +0 -0
  135. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/SelectCalendarsWithPromptResult.swift +0 -0
  136. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Templates/JSResult.swift +0 -0
  137. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/PluginConfig.swift +0 -0
  138. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/PluginError.swift +0 -0
  139. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Utils/ImplementationHelper.swift +0 -0
  140. /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Utils/UIColorFromHexExtension.swift +0 -0
@@ -3,12 +3,12 @@ import Combine
3
3
  import EventKitUI
4
4
  import Capacitor
5
5
 
6
- class CapacitorCalendar: NSObject, EKEventEditViewDelegate, EKCalendarChooserDelegate {
7
- private let plugin: CapacitorCalendarPlugin
6
+ class CapacitorCalendar: NSObject {
7
+ private var createEventWithPromptContinuation: CheckedContinuation<CreateEventWithPromptResult, Error>?
8
8
  private let eventStore = EKEventStore()
9
- private let createEventWithPromptResultEmitter = CurrentValueSubject<CheckedContinuation<CreateEventWithPromptResult, Error>?, Never>(nil)
10
- private let modifyEventWithPromptResultEmitter = CurrentValueSubject<CheckedContinuation<ModifyEventWithPromptResult, Error>?, Never>(nil)
11
- private let selectCalendarsWithPromptResultEmitter = CurrentValueSubject<CheckedContinuation<SelectCalendarsWithPromptResult, Error>?, Never>(nil)
9
+ private var modifyEventWithPromptContinuation: CheckedContinuation<ModifyEventWithPromptResult, Error>?
10
+ private let plugin: CapacitorCalendarPlugin
11
+ private var selectCalendarsWithPromptContinuation: CheckedContinuation<SelectCalendarsWithPromptResult, Error>?
12
12
 
13
13
  init(plugin: CapacitorCalendarPlugin) {
14
14
  self.plugin = plugin
@@ -107,6 +107,8 @@ class CapacitorCalendar: NSObject, EKEventEditViewDelegate, EKCalendarChooserDel
107
107
  event.endDate = input.getEndDate()
108
108
  event.url = input.getUrl()
109
109
  event.notes = input.getDescription()
110
+ event.recurrenceRules = input.getRecurrenceRule()
111
+
110
112
  if let availability = input.getAvailability() {
111
113
  event.availability = availability
112
114
  }
@@ -121,7 +123,7 @@ class CapacitorCalendar: NSObject, EKEventEditViewDelegate, EKCalendarChooserDel
121
123
  eventEditViewController.eventStore = eventStore
122
124
  eventEditViewController.editViewDelegate = self
123
125
  viewController.present(eventEditViewController, animated: true) {
124
- self.createEventWithPromptResultEmitter.send(continuation)
126
+ self.createEventWithPromptContinuation = continuation
125
127
  }
126
128
  }
127
129
  }
@@ -169,7 +171,7 @@ class CapacitorCalendar: NSObject, EKEventEditViewDelegate, EKCalendarChooserDel
169
171
  eventEditViewController.eventStore = eventStore
170
172
  eventEditViewController.editViewDelegate = self
171
173
  viewController.present(eventEditViewController, animated: true) {
172
- self.modifyEventWithPromptResultEmitter.send(continuation)
174
+ self.modifyEventWithPromptContinuation = continuation
173
175
  }
174
176
  }
175
177
  }
@@ -186,6 +188,8 @@ class CapacitorCalendar: NSObject, EKEventEditViewDelegate, EKCalendarChooserDel
186
188
  event.endDate = input.getEndDate()
187
189
  event.url = input.getUrl()
188
190
  event.notes = input.getDescription()
191
+ event.recurrenceRules = input.getRecurrenceRule()
192
+
189
193
  if let availability = input.getAvailability() {
190
194
  event.availability = availability
191
195
  }
@@ -229,6 +233,8 @@ class CapacitorCalendar: NSObject, EKEventEditViewDelegate, EKCalendarChooserDel
229
233
  if let alerts = input.getAlerts() {
230
234
  event.alarms = alerts
231
235
  }
236
+ event.recurrenceRules = input.getRecurrenceRule()
237
+
232
238
  try eventStore.save(event, span: input.getSpan())
233
239
  }
234
240
 
@@ -248,7 +254,7 @@ class CapacitorCalendar: NSObject, EKEventEditViewDelegate, EKCalendarChooserDel
248
254
  calendarChooser.delegate = self
249
255
 
250
256
  viewController.present(UINavigationController(rootViewController: calendarChooser), animated: true) {
251
- self.selectCalendarsWithPromptResultEmitter.send(continuation)
257
+ self.selectCalendarsWithPromptContinuation = continuation
252
258
  }
253
259
  }
254
260
  }
@@ -503,7 +509,7 @@ class CapacitorCalendar: NSObject, EKEventEditViewDelegate, EKCalendarChooserDel
503
509
  guard let viewController = plugin.bridge?.viewController else {
504
510
  throw PluginError.viewControllerMissing
505
511
  }
506
- guard let reminder = eventStore.calendarItem(withIdentifier: input.getId()) as? EKReminder else {
512
+ guard let _ = eventStore.calendarItem(withIdentifier: input.getId()) as? EKReminder else {
507
513
  throw PluginError.reminderNotFound
508
514
  }
509
515
 
@@ -527,70 +533,46 @@ class CapacitorCalendar: NSObject, EKEventEditViewDelegate, EKCalendarChooserDel
527
533
  viewController.present(alert, animated: true)
528
534
  }
529
535
  }
536
+ }
530
537
 
531
- func eventEditViewController(_ controller: EKEventEditViewController, didCompleteWith action: EKEventEditViewAction) {
532
- var createEventWithPromptCancellable: AnyCancellable?
533
- createEventWithPromptCancellable = self.createEventWithPromptResultEmitter.sink { promise in
534
- guard let promise = promise else {
535
- return
536
- }
537
- switch action {
538
- case .saved:
539
- promise.resume(returning: CreateEventWithPromptResult(id: controller.event?.eventIdentifier))
540
- case .canceled, .cancelled, .deleted:
541
- promise.resume(returning: CreateEventWithPromptResult(id: nil))
542
- @unknown default:
543
- promise.resume(throwing: PluginError.processFailed)
544
- }
545
-
546
- controller.dismiss(animated: true) {
547
- createEventWithPromptCancellable?.cancel()
548
- }
538
+ extension CapacitorCalendar: EKCalendarChooserDelegate {
539
+ func calendarChooserDidFinish(_ calendarChooser: EKCalendarChooser) {
540
+ selectCalendarsWithPromptContinuation?.resume(returning: SelectCalendarsWithPromptResult(calendarChooser.selectedCalendars))
541
+ self.plugin.bridge?.viewController?.dismiss(animated: true) {
542
+ self.selectCalendarsWithPromptContinuation = nil
549
543
  }
544
+ }
550
545
 
551
- var modifyEventWithPromptCancellable: AnyCancellable?
552
- modifyEventWithPromptCancellable = self.modifyEventWithPromptResultEmitter.sink { promise in
553
- guard let promise = promise else {
554
- return
555
- }
556
-
557
- do {
558
- promise.resume(returning: try ModifyEventWithPromptResult(action: action))
559
- } catch let error {
560
- promise.resume(throwing: error)
561
- }
562
-
563
- controller.dismiss(animated: true) {
564
- modifyEventWithPromptCancellable?.cancel()
565
- }
546
+ func calendarChooserDidCancel(_ calendarChooser: EKCalendarChooser) {
547
+ selectCalendarsWithPromptContinuation?.resume(returning: SelectCalendarsWithPromptResult(calendarChooser.selectedCalendars))
548
+ self.plugin.bridge?.viewController?.dismiss(animated: true) {
549
+ self.selectCalendarsWithPromptContinuation = nil
566
550
  }
567
551
  }
552
+ }
568
553
 
569
- func calendarChooserDidFinish(_ calendarChooser: EKCalendarChooser) {
570
- var selectCalendarsWithPromptCancellable: AnyCancellable?
571
- selectCalendarsWithPromptCancellable = self.selectCalendarsWithPromptResultEmitter.sink { promise in
572
- guard let promise = promise else {
573
- return
574
- }
554
+ extension CapacitorCalendar: EKEventEditViewDelegate {
555
+ func eventEditViewController(_ controller: EKEventEditViewController, didCompleteWith action: EKEventEditViewAction) {
556
+ let identifier = controller.event?.eventIdentifier
575
557
 
576
- promise.resume(returning: SelectCalendarsWithPromptResult(calendarChooser.selectedCalendars))
577
- self.plugin.bridge?.viewController?.dismiss(animated: true) {
578
- selectCalendarsWithPromptCancellable?.cancel()
579
- }
558
+ switch action {
559
+ case .saved:
560
+ createEventWithPromptContinuation?.resume(returning: CreateEventWithPromptResult(id: identifier))
561
+ case .canceled, .cancelled, .deleted:
562
+ createEventWithPromptContinuation?.resume(returning: CreateEventWithPromptResult(id: identifier))
563
+ @unknown default:
564
+ createEventWithPromptContinuation?.resume(throwing: PluginError.processFailed)
580
565
  }
581
- }
582
566
 
583
- func calendarChooserDidCancel(_ calendarChooser: EKCalendarChooser) {
584
- var selectCalendarsWithPromptCancellable: AnyCancellable?
585
- selectCalendarsWithPromptCancellable = self.selectCalendarsWithPromptResultEmitter.sink { promise in
586
- guard let promise = promise else {
587
- return
588
- }
567
+ do {
568
+ modifyEventWithPromptContinuation?.resume(returning: try ModifyEventWithPromptResult(action: action))
569
+ } catch let error {
570
+ modifyEventWithPromptContinuation?.resume(throwing: error)
571
+ }
589
572
 
590
- promise.resume(returning: SelectCalendarsWithPromptResult(calendarChooser.selectedCalendars))
591
- self.plugin.bridge?.viewController?.dismiss(animated: true) {
592
- selectCalendarsWithPromptCancellable?.cancel()
593
- }
573
+ controller.dismiss(animated: true) {
574
+ self.createEventWithPromptContinuation = nil
575
+ self.modifyEventWithPromptContinuation = nil
594
576
  }
595
577
  }
596
578
  }
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>$(EXECUTABLE_NAME)</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundleName</key>
14
+ <string>$(PRODUCT_NAME)</string>
15
+ <key>CFBundlePackageType</key>
16
+ <string>FMWK</string>
17
+ <key>CFBundleShortVersionString</key>
18
+ <string>1.0</string>
19
+ <key>CFBundleVersion</key>
20
+ <string>$(CURRENT_PROJECT_VERSION)</string>
21
+ <key>NSPrincipalClass</key>
22
+ <string></string>
23
+ </dict>
24
+ </plist>
@@ -7,55 +7,59 @@ struct CreateEventInput {
7
7
  private let commit: Bool
8
8
 
9
9
  init(call: CAPPluginCall) throws {
10
+ self.commit = call.getBool("commit", true)
10
11
  self.input = CreateEventWithPromptInput(call: call)
11
12
  guard let title = call.getString("title") else {
12
13
  throw PluginError.titleMissing
13
14
  }
14
15
  self.title = title
15
- self.commit = call.getBool("commit", true)
16
- }
17
-
18
- func getTitle() -> String {
19
- return title
20
- }
21
-
22
- func getIsAllDay() -> Bool {
23
- return input.getIsAllDay()
24
16
  }
25
17
 
26
18
  func getAlerts() -> [EKAlarm] {
27
19
  return input.getAlerts()
28
20
  }
29
21
 
22
+ func getAvailability() -> EKEventAvailability? {
23
+ return input.getAvailability()
24
+ }
25
+
30
26
  func getCalendar(from eventStore: EKEventStore) -> EKCalendar? {
31
27
  return input.getCalendar(from: eventStore)
32
28
  }
33
29
 
34
- func getLocation() -> String? {
35
- return input.getLocation()
30
+ func getCommit() -> Bool {
31
+ return commit
36
32
  }
37
33
 
38
- func getStartDate() -> Date? {
39
- return input.getStartDate()
34
+ func getDescription() -> String? {
35
+ return input.getDescription()
40
36
  }
41
37
 
42
38
  func getEndDate() -> Date? {
43
39
  return input.getEndDate()
44
40
  }
45
41
 
46
- func getUrl() -> URL? {
47
- return input.getUrl()
42
+ func getIsAllDay() -> Bool {
43
+ return input.getIsAllDay()
48
44
  }
49
45
 
50
- func getDescription() -> String? {
51
- return input.getDescription()
46
+ func getLocation() -> String? {
47
+ return input.getLocation()
52
48
  }
53
49
 
54
- func getAvailability() -> EKEventAvailability? {
55
- return input.getAvailability()
50
+ func getRecurrenceRule() -> [EKRecurrenceRule] {
51
+ return input.getRecurrenceRule()
56
52
  }
57
53
 
58
- func getCommit() -> Bool {
59
- return commit
54
+ func getStartDate() -> Date? {
55
+ return input.getStartDate()
56
+ }
57
+
58
+ func getTitle() -> String {
59
+ return title
60
+ }
61
+
62
+ func getUrl() -> URL? {
63
+ return input.getUrl()
60
64
  }
61
65
  }
@@ -0,0 +1,171 @@
1
+ import Capacitor
2
+ import EventKit
3
+
4
+ struct CreateEventWithPromptInput {
5
+ private var alerts: [Double]
6
+ private var availability: EKEventAvailability?
7
+ private var calendarId: String?
8
+ private var description: String?
9
+ private var endDate: Double?
10
+ private let isAllDay: Bool
11
+ private var location: String?
12
+ private let recurrence: RecurrenceInput?
13
+ private var startDate: Double?
14
+ private let title: String
15
+ private var url: String?
16
+
17
+ init(call: CAPPluginCall) {
18
+ if let alerts = call.getArray("alerts", []) as? [Double] {
19
+ self.alerts = alerts
20
+ } else {
21
+ self.alerts = []
22
+ }
23
+ if let availability = call.getInt("availability") {
24
+ self.availability = EKEventAvailability(rawValue: availability)
25
+ }
26
+ if let calendarId = call.getString("calendarId") {
27
+ self.calendarId = calendarId
28
+ }
29
+ if let description = call.getString("description") {
30
+ self.description = description
31
+ }
32
+ if let endDate = call.getDouble("endDate") as Double? {
33
+ self.endDate = endDate
34
+ }
35
+ self.isAllDay = call.getBool("isAllDay", false)
36
+ if let location = call.getString("location") {
37
+ self.location = location
38
+ }
39
+ self.recurrence = CreateEventWithPromptInput.getRecurrence(from: call)
40
+ if let startDate = call.getDouble("startDate") as Double? {
41
+ self.startDate = startDate
42
+ }
43
+ self.title = call.getString("title", "")
44
+ if let url = call.getString("url") {
45
+ self.url = url
46
+ }
47
+ }
48
+
49
+ func getAlerts() -> [EKAlarm] {
50
+ return alerts.map { EKAlarm(relativeOffset: $0 * 60) }
51
+ }
52
+
53
+ func getAvailability() -> EKEventAvailability? {
54
+ return availability
55
+ }
56
+
57
+ func getCalendar(from eventStore: EKEventStore) -> EKCalendar? {
58
+ return ImplementationHelper.getCalendarFromId(eventStore: eventStore, calendarId: calendarId, fallback: true)
59
+ }
60
+
61
+ func getDescription() -> String? {
62
+ return description
63
+ }
64
+
65
+ func getEndDate() -> Date? {
66
+ guard let endDate = endDate else { return nil }
67
+ return ImplementationHelper.dateFromTimestamp(endDate)
68
+ }
69
+
70
+ func getIsAllDay() -> Bool {
71
+ return isAllDay
72
+ }
73
+
74
+ func getLocation() -> String? {
75
+ return location
76
+ }
77
+
78
+ func getRecurrenceRule() -> [EKRecurrenceRule] {
79
+ guard let recurrence = recurrence else {
80
+ return []
81
+ }
82
+
83
+ let rule = EKRecurrenceRule(
84
+ recurrenceWith: recurrence.frequency.toEKFrequency(),
85
+ interval: recurrence.interval,
86
+ daysOfTheWeek: recurrence.byWeekDay,
87
+ daysOfTheMonth: recurrence.byMonthDay,
88
+ monthsOfTheYear: recurrence.byMonth,
89
+ weeksOfTheYear: recurrence.weeksOfTheYear,
90
+ daysOfTheYear: recurrence.daysOfTheYear,
91
+ setPositions: nil,
92
+ end: recurrence.end
93
+ )
94
+
95
+ return [rule]
96
+ }
97
+
98
+ func getStartDate() -> Date? {
99
+ guard let startDate = startDate else { return nil }
100
+ return ImplementationHelper.dateFromTimestamp(startDate)
101
+ }
102
+
103
+ func getTitle() -> String {
104
+ return title
105
+ }
106
+
107
+ func getUrl() -> URL? {
108
+ guard let url = url else { return nil }
109
+ return URL(string: url)
110
+ }
111
+
112
+ static func getRecurrence(from call: CAPPluginCall) -> RecurrenceInput? {
113
+ if let recurrenceObject = call.getObject("recurrence") {
114
+ if let frequencyString = recurrenceObject["frequency"] as? String, let frequency = RecurrenceInput.Frequency(rawValue: frequencyString) {
115
+ let interval = recurrenceObject["interval"] as? Int ?? 1
116
+ let count = recurrenceObject["count"] as? Int
117
+
118
+ var endDate: Date?
119
+ if let endMs = recurrenceObject["end"] as? Double {
120
+ endDate = ImplementationHelper.dateFromTimestamp(endMs)
121
+ }
122
+
123
+ var end: EKRecurrenceEnd?
124
+ if let count = count {
125
+ end = EKRecurrenceEnd(occurrenceCount: count)
126
+ } else if let endDate = endDate {
127
+ end = EKRecurrenceEnd(end: endDate)
128
+ } else {
129
+ end = nil
130
+ }
131
+
132
+ var byWeekDay: [EKRecurrenceDayOfWeek]?
133
+ if let days = recurrenceObject["byWeekDay"] as? [Int] {
134
+ byWeekDay = days.compactMap { day in
135
+ switch day {
136
+ case 1: return EKRecurrenceDayOfWeek(.monday)
137
+ case 2: return EKRecurrenceDayOfWeek(.tuesday)
138
+ case 3: return EKRecurrenceDayOfWeek(.wednesday)
139
+ case 4: return EKRecurrenceDayOfWeek(.thursday)
140
+ case 5: return EKRecurrenceDayOfWeek(.friday)
141
+ case 6: return EKRecurrenceDayOfWeek(.saturday)
142
+ case 7: return EKRecurrenceDayOfWeek(.sunday)
143
+ default: return nil
144
+ }
145
+ }
146
+ }
147
+
148
+ let byMonthDay = (recurrenceObject["byMonthDay"] as? [Int])?.map { NSNumber(value: $0) }
149
+ let byMonth = (recurrenceObject["byMonth"] as? [Int])?.map { NSNumber(value: $0) }
150
+ let weeksOfTheYear = (recurrenceObject["weeksOfTheYear"] as? [Int])?.map { NSNumber(value: $0) }
151
+ let daysOfTheYear = (recurrenceObject["daysOfTheYear"] as? [Int])?.map { NSNumber(value: $0) }
152
+
153
+ return RecurrenceInput(
154
+ frequency: frequency,
155
+ interval: max(1, interval),
156
+ count: count,
157
+ end: end,
158
+ byWeekDay: byWeekDay,
159
+ byMonthDay: byMonthDay,
160
+ byMonth: byMonth,
161
+ weeksOfTheYear: weeksOfTheYear,
162
+ daysOfTheYear: daysOfTheYear
163
+ )
164
+ } else {
165
+ return nil
166
+ }
167
+ } else {
168
+ return nil
169
+ }
170
+ }
171
+ }
@@ -32,10 +32,10 @@ struct CreateReminderInput {
32
32
  self.url = call.getString("url")
33
33
  self.location = call.getString("location")
34
34
  if let recurrence = call.getObject("recurrence") {
35
- guard let frequency = recurrence["frequency"] as? Int else {
35
+ guard let frequency = recurrence["frequency"] as? String else {
36
36
  throw PluginError.missingFrequency
37
37
  }
38
- self.frequency = EKRecurrenceFrequency(rawValue: frequency)
38
+ self.frequency = RecurrenceInput.Frequency(rawValue: frequency)?.toEKFrequency()
39
39
  guard let interval = recurrence["interval"] as? Int else {
40
40
  throw PluginError.missingInterval
41
41
  }
@@ -2,59 +2,73 @@ import Capacitor
2
2
  import EventKit
3
3
 
4
4
  struct ModifyEventInput {
5
- private let id: String
6
- private var title: String?
5
+ private var alerts: [Double]?
6
+ private var availability: EKEventAvailability?
7
7
  private var calendarId: String?
8
- private var location: String?
9
- private var startDate: Double?
8
+ private var description: String?
10
9
  private var endDate: Double?
10
+ private let id: String
11
11
  private var isAllDay: Bool?
12
- private var alerts: [Double]?
13
- private var url: String?
14
- private var description: String?
15
- private var availability: EKEventAvailability?
12
+ private var location: String?
13
+ private let recurrence: RecurrenceInput?
16
14
  private var span: EKSpan
15
+ private var startDate: Double?
16
+ private var title: String?
17
+ private var url: String?
17
18
 
18
19
  init(call: CAPPluginCall) throws {
19
- guard let id = call.getString("id") else {
20
- throw PluginError.idMissing
20
+ if let alerts = call.getArray("alerts") as? [Double] {
21
+ self.alerts = alerts
21
22
  }
22
- self.id = id
23
- if let title = call.getString("title") {
24
- self.title = title
23
+ if let availability = call.getInt("availability") {
24
+ self.availability = EKEventAvailability(rawValue: availability)
25
25
  }
26
26
  if let calendarId = call.getString("calendarId") {
27
27
  self.calendarId = calendarId
28
28
  }
29
- if let location = call.getString("location") {
30
- self.location = location
31
- }
32
- if let startDate = call.getDouble("startDate") as Double? {
33
- self.startDate = startDate
29
+ if let description = call.getString("description") {
30
+ self.description = description
34
31
  }
35
32
  if let endDate = call.getDouble("endDate") as Double? {
36
33
  self.endDate = endDate
37
34
  }
35
+ guard let id = call.getString("id") else {
36
+ throw PluginError.idMissing
37
+ }
38
+ self.id = id
38
39
  if let isAllDay = call.getBool("isAllDay") as Bool? {
39
40
  self.isAllDay = isAllDay
40
41
  }
41
- if let alerts = call.getArray("alerts") as? [Double] {
42
- self.alerts = alerts
43
- }
44
- if let url = call.getString("url") {
45
- self.url = url
46
- }
47
- if let description = call.getString("description") {
48
- self.description = description
49
- }
50
- if let availability = call.getInt("availability") {
51
- self.availability = EKEventAvailability(rawValue: availability)
42
+ if let location = call.getString("location") {
43
+ self.location = location
52
44
  }
45
+ self.recurrence = CreateEventWithPromptInput.getRecurrence(from: call)
53
46
  if let spanInt = call.getInt("span"), let span = EKSpan(rawValue: spanInt) {
54
47
  self.span = span
55
48
  } else {
56
49
  self.span = .thisEvent
57
50
  }
51
+ if let startDate = call.getDouble("startDate") as Double? {
52
+ self.startDate = startDate
53
+ }
54
+ if let title = call.getString("title") {
55
+ self.title = title
56
+ }
57
+ if let url = call.getString("url") {
58
+ self.url = url
59
+ }
60
+ }
61
+
62
+ func getAlerts() -> [EKAlarm]? {
63
+ if let alerts = self.alerts {
64
+ return alerts.map { EKAlarm(relativeOffset: $0 * 60) }
65
+ } else {
66
+ return nil
67
+ }
68
+ }
69
+
70
+ func getIsAllDay() -> Bool? {
71
+ return isAllDay
58
72
  }
59
73
 
60
74
  func getEvent(from eventStore: EKEventStore) throws -> EKEvent {
@@ -76,6 +90,26 @@ struct ModifyEventInput {
76
90
  return location
77
91
  }
78
92
 
93
+ func getRecurrenceRule() -> [EKRecurrenceRule] {
94
+ guard let recurrence = recurrence else {
95
+ return []
96
+ }
97
+
98
+ let rule = EKRecurrenceRule(
99
+ recurrenceWith: recurrence.frequency.toEKFrequency(),
100
+ interval: recurrence.interval,
101
+ daysOfTheWeek: recurrence.byWeekDay,
102
+ daysOfTheMonth: recurrence.byMonthDay,
103
+ monthsOfTheYear: recurrence.byMonth,
104
+ weeksOfTheYear: recurrence.weeksOfTheYear,
105
+ daysOfTheYear: recurrence.daysOfTheYear,
106
+ setPositions: nil,
107
+ end: recurrence.end
108
+ )
109
+
110
+ return [rule]
111
+ }
112
+
79
113
  func getStartDate() -> Date? {
80
114
  guard let startDate = startDate else { return nil }
81
115
  return ImplementationHelper.dateFromTimestamp(startDate)
@@ -86,18 +120,6 @@ struct ModifyEventInput {
86
120
  return ImplementationHelper.dateFromTimestamp(endDate)
87
121
  }
88
122
 
89
- func getIsAllDay() -> Bool? {
90
- return isAllDay
91
- }
92
-
93
- func getAlerts() -> [EKAlarm]? {
94
- if let alerts = self.alerts {
95
- return alerts.map { EKAlarm(relativeOffset: $0 * 60) }
96
- } else {
97
- return nil
98
- }
99
- }
100
-
101
123
  func getUrl() -> URL? {
102
124
  guard let url = url else { return nil }
103
125
  return URL(string: url)
@@ -0,0 +1,31 @@
1
+ import EventKit
2
+
3
+ struct RecurrenceInput {
4
+ enum Frequency: String {
5
+ case daily
6
+ case weekly
7
+ case monthly
8
+ case yearly
9
+
10
+ func toEKFrequency() -> EKRecurrenceFrequency {
11
+ switch self {
12
+ case .daily: return .daily
13
+ case .weekly: return .weekly
14
+ case .monthly: return .monthly
15
+ case .yearly: return .yearly
16
+ }
17
+ }
18
+ }
19
+
20
+ let frequency: Frequency
21
+ let interval: Int
22
+ let count: Int?
23
+ let end: EKRecurrenceEnd?
24
+
25
+ let byWeekDay: [EKRecurrenceDayOfWeek]?
26
+ let byMonthDay: [NSNumber]?
27
+ let byMonth: [NSNumber]?
28
+
29
+ let weeksOfTheYear: [NSNumber]?
30
+ let daysOfTheYear: [NSNumber]?
31
+ }