Commit cb85b540 by Daniel Dahan

renamed the Reminders subspec to Events and updated the Reminders API based on…

renamed the Reminders subspec to Events and updated the Reminders API based on the latest rework concepts
parent 510173b2
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'Material' s.name = 'Material'
s.version = '2.6.3' s.version = '2.6.3'
s.license = 'BSD-3-Clause' s.license = 'BSD-3-Clause'
s.summary = 'An animation and graphics framework for Material Design in Swift.' s.summary = 'An animation and graphics framework for Material Design in Swift.'
s.homepage = 'http://materialswift.com' s.homepage = 'http://materialswift.com'
s.social_media_url = 'https://www.facebook.com/cosmicmindcom' s.social_media_url = 'https://www.facebook.com/cosmicmindcom'
s.authors = { 'CosmicMind, Inc.' => 'support@cosmicmind.com' } s.authors = { 'CosmicMind, Inc.' => 'support@cosmicmind.com' }
s.source = { :git => 'https://github.com/CosmicMind/Material.git', :tag => s.version } s.source = { :git => 'https://github.com/CosmicMind/Material.git', :tag => s.version }
s.default_subspec = 'Core' s.default_subspec = 'Core'
s.platform = :ios, '8.0' s.platform = :ios, '8.0'
s.subspec 'Core' do |s| s.subspec 'Core' do |s|
s.ios.deployment_target = '8.0' s.ios.deployment_target = '8.0'
s.ios.source_files = 'Sources/iOS/*.swift' s.ios.source_files = 'Sources/iOS/*.swift'
s.requires_arc = true s.requires_arc = true
s.resource_bundles = { s.resource_bundles = {
'com.cosmicmind.material.icons' => ['Sources/**/*.xcassets'], 'com.cosmicmind.material.icons' => ['Sources/**/*.xcassets'],
'com.cosmicmind.material.fonts' => ['Sources/**/*.ttf'] 'com.cosmicmind.material.fonts' => ['Sources/**/*.ttf']
} }
end end
s.subspec 'Capture' do |capture| s.subspec 'Capture' do |capture|
capture.source_files = 'Sources/iOS/Capture/*.swift' capture.source_files = 'Sources/iOS/Capture/*.swift'
capture.dependency 'Material/Core' capture.dependency 'Material/Core'
end end
s.subspec 'Photos' do |photos| s.subspec 'Photos' do |photos|
photos.source_files = 'Sources/iOS/Photos/*.swift' photos.source_files = 'Sources/iOS/Photos/*.swift'
photos.dependency 'Material/Core' photos.dependency 'Material/Core'
end end
s.subspec 'Reminders' do |reminders|
reminders.source_files = 'Sources/iOS/Reminders/*.swift'
reminders.dependency 'Material/Core'
end
s.subspec 'Events' do |events|
events.source_files = 'Sources/iOS/Events/*.swift'
events.dependency 'Material/Core'
end
end end
...@@ -34,16 +34,14 @@ ...@@ -34,16 +34,14 @@
961E6BDF1DDA2A95004E6C93 /* Application.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961E6BDE1DDA2A95004E6C93 /* Application.swift */; }; 961E6BDF1DDA2A95004E6C93 /* Application.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961E6BDE1DDA2A95004E6C93 /* Application.swift */; };
961E6BE21DDA2AF3004E6C93 /* Screen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961E6BE11DDA2AF3004E6C93 /* Screen.swift */; }; 961E6BE21DDA2AF3004E6C93 /* Screen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961E6BE11DDA2AF3004E6C93 /* Screen.swift */; };
96328B7A1E020A41009A4C90 /* CollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96328B791E020A41009A4C90 /* CollectionViewController.swift */; }; 96328B7A1E020A41009A4C90 /* CollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96328B791E020A41009A4C90 /* CollectionViewController.swift */; };
96328B911E05B6B5009A4C90 /* Reminders.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96328B901E05B6B5009A4C90 /* Reminders.swift */; };
96328B931E05B6E5009A4C90 /* RemindersController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96328B921E05B6E5009A4C90 /* RemindersController.swift */; };
96328B971E05C0BB009A4C90 /* TableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96328B961E05C0BB009A4C90 /* TableView.swift */; }; 96328B971E05C0BB009A4C90 /* TableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96328B961E05C0BB009A4C90 /* TableView.swift */; };
96328B991E05C0CE009A4C90 /* TableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96328B981E05C0CE009A4C90 /* TableViewController.swift */; }; 96328B991E05C0CE009A4C90 /* TableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96328B981E05C0CE009A4C90 /* TableViewController.swift */; };
96328B9B1E05C24E009A4C90 /* CollectionViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96328B791E020A41009A4C90 /* CollectionViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96328B9B1E05C24E009A4C90 /* CollectionViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96328B791E020A41009A4C90 /* CollectionViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96328B9C1E05C24E009A4C90 /* Reminders.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96328B901E05B6B5009A4C90 /* Reminders.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96328B9D1E05C24E009A4C90 /* RemindersController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96328B921E05B6E5009A4C90 /* RemindersController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96328B9E1E05C24E009A4C90 /* TableView.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96328B961E05C0BB009A4C90 /* TableView.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96328B9E1E05C24E009A4C90 /* TableView.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96328B961E05C0BB009A4C90 /* TableView.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96328B9F1E05C24E009A4C90 /* TableViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96328B981E05C0CE009A4C90 /* TableViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96328B9F1E05C24E009A4C90 /* TableViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96328B981E05C0CE009A4C90 /* TableViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96334EF61C8B84660083986B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96334EF51C8B84660083986B /* Assets.xcassets */; }; 96334EF61C8B84660083986B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96334EF51C8B84660083986B /* Assets.xcassets */; };
9639526C1EC3882F004BA9DE /* Reminders.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9639526A1EC3882F004BA9DE /* Reminders.swift */; };
9639526D1EC3882F004BA9DE /* RemindersController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9639526B1EC3882F004BA9DE /* RemindersController.swift */; };
965E80CC1DD4C50600D61E4B /* Bar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7981CB40DC500C806FE /* Bar.swift */; }; 965E80CC1DD4C50600D61E4B /* Bar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7981CB40DC500C806FE /* Bar.swift */; };
965E80CD1DD4C50600D61E4B /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7701CB40DC500C806FE /* Button.swift */; }; 965E80CD1DD4C50600D61E4B /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7701CB40DC500C806FE /* Button.swift */; };
965E80CE1DD4C50600D61E4B /* FABButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB75F1CB40DC500C806FE /* FABButton.swift */; }; 965E80CE1DD4C50600D61E4B /* FABButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB75F1CB40DC500C806FE /* FABButton.swift */; };
...@@ -204,12 +202,12 @@ ...@@ -204,12 +202,12 @@
9628645E1D540AF300690B69 /* DynamicFontType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DynamicFontType.swift; sourceTree = "<group>"; }; 9628645E1D540AF300690B69 /* DynamicFontType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DynamicFontType.swift; sourceTree = "<group>"; };
9631A7C01D95E3AC00CFB109 /* PresenterCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PresenterCard.swift; sourceTree = "<group>"; }; 9631A7C01D95E3AC00CFB109 /* PresenterCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PresenterCard.swift; sourceTree = "<group>"; };
96328B791E020A41009A4C90 /* CollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionViewController.swift; sourceTree = "<group>"; }; 96328B791E020A41009A4C90 /* CollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionViewController.swift; sourceTree = "<group>"; };
96328B901E05B6B5009A4C90 /* Reminders.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Reminders.swift; path = Reminders/Reminders.swift; sourceTree = "<group>"; };
96328B921E05B6E5009A4C90 /* RemindersController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RemindersController.swift; path = Reminders/RemindersController.swift; sourceTree = "<group>"; };
96328B961E05C0BB009A4C90 /* TableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableView.swift; sourceTree = "<group>"; }; 96328B961E05C0BB009A4C90 /* TableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableView.swift; sourceTree = "<group>"; };
96328B981E05C0CE009A4C90 /* TableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableViewController.swift; sourceTree = "<group>"; }; 96328B981E05C0CE009A4C90 /* TableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableViewController.swift; sourceTree = "<group>"; };
96334EF51C8B84660083986B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 96334EF51C8B84660083986B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
963832361B88DFD80015F710 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Material.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 963832361B88DFD80015F710 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Material.framework; sourceTree = BUILT_PRODUCTS_DIR; };
9639526A1EC3882F004BA9DE /* Reminders.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Reminders.swift; sourceTree = "<group>"; };
9639526B1EC3882F004BA9DE /* RemindersController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemindersController.swift; sourceTree = "<group>"; };
963FBEFC1D669510008F8512 /* Snackbar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Snackbar.swift; sourceTree = "<group>"; }; 963FBEFC1D669510008F8512 /* Snackbar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Snackbar.swift; sourceTree = "<group>"; };
965532281E47E388005C2792 /* SpringAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpringAnimation.swift; sourceTree = "<group>"; }; 965532281E47E388005C2792 /* SpringAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpringAnimation.swift; sourceTree = "<group>"; };
9658F2161CD6FA4700B902C1 /* IconButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IconButton.swift; sourceTree = "<group>"; }; 9658F2161CD6FA4700B902C1 /* IconButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IconButton.swift; sourceTree = "<group>"; };
...@@ -372,15 +370,6 @@ ...@@ -372,15 +370,6 @@
name = BottomTabBar; name = BottomTabBar;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
96328B8F1E05B69A009A4C90 /* Reminders */ = {
isa = PBXGroup;
children = (
96328B901E05B6B5009A4C90 /* Reminders.swift */,
96328B921E05B6E5009A4C90 /* RemindersController.swift */,
);
name = Reminders;
sourceTree = "<group>";
};
96328B9A1E05C135009A4C90 /* Data */ = { 96328B9A1E05C135009A4C90 /* Data */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -405,6 +394,15 @@ ...@@ -405,6 +394,15 @@
name = Products; name = Products;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
963952691EC3882F004BA9DE /* Events */ = {
isa = PBXGroup;
children = (
9639526A1EC3882F004BA9DE /* Reminders.swift */,
9639526B1EC3882F004BA9DE /* RemindersController.swift */,
);
path = Events;
sourceTree = "<group>";
};
963FBEFB1D6694E8008F8512 /* Snackbar */ = { 963FBEFB1D6694E8008F8512 /* Snackbar */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -510,6 +508,7 @@ ...@@ -510,6 +508,7 @@
96328B9A1E05C135009A4C90 /* Data */, 96328B9A1E05C135009A4C90 /* Data */,
96BCB80B1CB410CC00C806FE /* Device */, 96BCB80B1CB410CC00C806FE /* Device */,
96230AB61D6A51FD00AF47DC /* Divider */, 96230AB61D6A51FD00AF47DC /* Divider */,
963952691EC3882F004BA9DE /* Events */,
96BCB80A1CB410A100C806FE /* Extension */, 96BCB80A1CB410A100C806FE /* Extension */,
963FBF021D6696D0008F8512 /* FABMenu */, 963FBF021D6696D0008F8512 /* FABMenu */,
96BCB8071CB4101C00C806FE /* Font */, 96BCB8071CB4101C00C806FE /* Font */,
...@@ -522,7 +521,6 @@ ...@@ -522,7 +521,6 @@
96BCB8011CB40F1700C806FE /* Navigation */, 96BCB8011CB40F1700C806FE /* Navigation */,
961E6BEF1DDA4B04004E6C93 /* NavigationDrawer */, 961E6BEF1DDA4B04004E6C93 /* NavigationDrawer */,
96717B151DBE6B1800DA84DB /* Photos */, 96717B151DBE6B1800DA84DB /* Photos */,
96328B8F1E05B69A009A4C90 /* Reminders */,
9626CA951DAB5370003E2611 /* Root */, 9626CA951DAB5370003E2611 /* Root */,
961E6BE01DDA2ADD004E6C93 /* Screen */, 961E6BE01DDA2ADD004E6C93 /* Screen */,
963FBF031D6696EF008F8512 /* SearchBar */, 963FBF031D6696EF008F8512 /* SearchBar */,
...@@ -819,8 +817,6 @@ ...@@ -819,8 +817,6 @@
9617B0901DFCA8CF00410F8F /* Toolbar.swift in Headers */, 9617B0901DFCA8CF00410F8F /* Toolbar.swift in Headers */,
9617B0911DFCA8CF00410F8F /* ToolbarController.swift in Headers */, 9617B0911DFCA8CF00410F8F /* ToolbarController.swift in Headers */,
96328B9B1E05C24E009A4C90 /* CollectionViewController.swift in Headers */, 96328B9B1E05C24E009A4C90 /* CollectionViewController.swift in Headers */,
96328B9C1E05C24E009A4C90 /* Reminders.swift in Headers */,
96328B9D1E05C24E009A4C90 /* RemindersController.swift in Headers */,
96328B9E1E05C24E009A4C90 /* TableView.swift in Headers */, 96328B9E1E05C24E009A4C90 /* TableView.swift in Headers */,
96328B9F1E05C24E009A4C90 /* TableViewController.swift in Headers */, 96328B9F1E05C24E009A4C90 /* TableViewController.swift in Headers */,
961409B01E43D15C00E7BA99 /* CollectionViewCard.swift in Headers */, 961409B01E43D15C00E7BA99 /* CollectionViewCard.swift in Headers */,
...@@ -936,14 +932,14 @@ ...@@ -936,14 +932,14 @@
965E81161DD4D5C800D61E4B /* DisplayStyle.swift in Sources */, 965E81161DD4D5C800D61E4B /* DisplayStyle.swift in Sources */,
965E81171DD4D5C800D61E4B /* RootController.swift in Sources */, 965E81171DD4D5C800D61E4B /* RootController.swift in Sources */,
965E81181DD4D5C800D61E4B /* Snackbar.swift in Sources */, 965E81181DD4D5C800D61E4B /* Snackbar.swift in Sources */,
96328B911E05B6B5009A4C90 /* Reminders.swift in Sources */,
965E81191DD4D5C800D61E4B /* SnackbarController.swift in Sources */, 965E81191DD4D5C800D61E4B /* SnackbarController.swift in Sources */,
965E811A1DD4D5C800D61E4B /* StatusBarController.swift in Sources */, 965E811A1DD4D5C800D61E4B /* StatusBarController.swift in Sources */,
965E811B1DD4D5C800D61E4B /* Switch.swift in Sources */, 965E811B1DD4D5C800D61E4B /* Switch.swift in Sources */,
96328B931E05B6E5009A4C90 /* RemindersController.swift in Sources */, 9639526C1EC3882F004BA9DE /* Reminders.swift in Sources */,
965E811C1DD4D5C800D61E4B /* TabBar.swift in Sources */, 965E811C1DD4D5C800D61E4B /* TabBar.swift in Sources */,
965E811D1DD4D5C800D61E4B /* TableViewCell.swift in Sources */, 965E811D1DD4D5C800D61E4B /* TableViewCell.swift in Sources */,
965E811E1DD4D5C800D61E4B /* TextField.swift in Sources */, 965E811E1DD4D5C800D61E4B /* TextField.swift in Sources */,
9639526D1EC3882F004BA9DE /* RemindersController.swift in Sources */,
965E811F1DD4D5C800D61E4B /* ErrorTextField.swift in Sources */, 965E811F1DD4D5C800D61E4B /* ErrorTextField.swift in Sources */,
965E81211DD4D5C800D61E4B /* TextStorage.swift in Sources */, 965E81211DD4D5C800D61E4B /* TextStorage.swift in Sources */,
965E81221DD4D5C800D61E4B /* TextView.swift in Sources */, 965E81221DD4D5C800D61E4B /* TextView.swift in Sources */,
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
import EventKit import EventKit
@objc(RemindersAuthorizationStatus) @objc(RemindersAuthorizationStatus)
...@@ -110,32 +109,84 @@ open class Reminders: NSObject { ...@@ -110,32 +109,84 @@ open class Reminders: NSObject {
open weak var delegate: RemindersDelegate? open weak var delegate: RemindersDelegate?
open func requestAuthorization(_ completion: ((RemindersAuthorizationStatus) -> Void)? = nil) { open func requestAuthorization(_ completion: ((RemindersAuthorizationStatus) -> Void)? = nil) {
eventStore.requestAccess(to: .reminder) { [weak self, completion = completion] (permission, _) in eventStore.requestAccess(to: .reminder) { [weak self, completion = completion] (isAuthorized, _) in
DispatchQueue.main.async { [weak self, completion = completion] in DispatchQueue.main.async { [weak self, completion = completion] in
guard let s = self else { guard let s = self else {
return return
} }
if permission {
s.delegate?.reminders?(reminders: s, status: .authorized) guard isAuthorized else {
s.delegate?.reminders?(authorized: s) completion?(.denied)
completion?(.authorized)
} else {
s.delegate?.reminders?(reminders: s, status: .denied) s.delegate?.reminders?(reminders: s, status: .denied)
s.delegate?.reminders?(denied: s) s.delegate?.reminders?(denied: s)
completion?(.denied) return
} }
completion?(.authorized)
s.delegate?.reminders?(reminders: s, status: .authorized)
s.delegate?.reminders?(authorized: s)
} }
} }
} }
} }
// List CRUD operations
extension Reminders { extension Reminders {
/**
Creates a predicate for the reminders Array of calendars.
- Parameter in calendars: An optional Array of EKCalendars.
*/
open func predicateForReminders(in calendars: [EKCalendar]) -> NSPredicate {
return eventStore.predicateForReminders(in: calendars)
}
/** /**
A method for creating new Reminder lists A method for retrieving reminder calendars in alphabetical order.
- Parameter list title: the name of the list - Parameter completion: A completion call back
- Parameter completion: optional completion call back */
open func calendars(completion: @escaping ([EKCalendar]) -> Void) {
DispatchQueue.global(qos: .default).async { [weak self, completion = completion] in
guard let s = self else {
return
}
let calendar = s.eventStore.calendars(for: .reminder).sorted(by: { (a, b) -> Bool in
return a.title < b.title
})
DispatchQueue.main.async { [calendar = calendar, completion = completion] in
completion(calendar)
}
}
}
/**
A method for retrieving events with a predicate in date sorted order.
- Parameter predicate: A NSPredicate.
- Parameter completion: A completion call back.
*/
open func reminders(matching predicate: NSPredicate, completion: @escaping ([EKReminder]) -> Void) {
eventStore.fetchReminders(matching: predicate, completion: { [completion = completion] (reminders) in
DispatchQueue.main.async { [completion = completion] in
completion(reminders ?? [])
}
})
}
/**
Fetch all the reminders in a given Array of calendar.
- Parameter in calendars: An Array of EKCalendars.
- Parameter completion: A completion call back.
*/
open func reminders(in calendars: [EKCalendar], completion: @escaping ([EKReminder]) -> Void) {
reminders(matching: predicateForReminders(in: calendars), completion: completion)
}
}
extension Reminders {
/**
A method for creating new Reminder calendar.
- Parameter list title: the name of the list.
- Parameter completion: An optional completion call back.
*/ */
open func create(list title: String, completion: ((Bool, Error?) -> Void)? = nil) { open func create(list title: String, completion: ((Bool, Error?) -> Void)? = nil) {
DispatchQueue.global(qos: .default).async { [weak self, completion = completion] in DispatchQueue.global(qos: .default).async { [weak self, completion = completion] in
...@@ -173,9 +224,9 @@ extension Reminders { ...@@ -173,9 +224,9 @@ extension Reminders {
} }
/** /**
A method for deleting existing Reminder lists A method for deleting existing Reminder lists,
- Parameter list identifier: the name of the list - Parameter list identifier: the name of the list.
- Parameter completion: optional completion call back - Parameter completion: An optional completion call back.
*/ */
open func delete(list identifier: String, completion: ((Bool, Error?) -> Void)? = nil) { open func delete(list identifier: String, completion: ((Bool, Error?) -> Void)? = nil) {
DispatchQueue.global(qos: .default).async { [weak self, completion = completion] in DispatchQueue.global(qos: .default).async { [weak self, completion = completion] in
...@@ -207,99 +258,83 @@ extension Reminders { ...@@ -207,99 +258,83 @@ extension Reminders {
} }
} }
} }
/**
A method for retrieving reminder lists
- Parameter completion: completion call back
*/
public func fetchLists(completion: ([EKCalendar]) -> Void) {
completion(eventStore.calendars(for: .reminder))
}
} }
// Reminder list CRUD operations extension Reminders {
extension Reminders { // // FIX ME: Should we use the calendar identifier here instead of the title for finding the right cal?
// /**
/** // A method for adding a new reminder to an optionally existing list.
A method for retrieving reminders from an optionally existing list. // if the list does not exist it will be added to the default reminders list.
if the list does not exist the reminders will be retrieved from the default reminders list // - Parameter completion: optional A completion call back
- Parameter list: An optional EKCalendar. // */
- Parameter completion: completion call back // open func create(title: String, dateComponents: DateComponents, in calendar: EKCalendar? = nil, completion: ((Error?) -> Void)? = nil) {
*/ // var reminderCal = [EKCalendar]()
open func fetchReminders(list: EKCalendar, completion: @escaping ([EKReminder]) -> Void) { //
var lists = [EKCalendar]() // if calendar != nil {
lists.append(list) // calendars(completion: { (calendars) in
// for v in calendars {
eventStore.fetchReminders(matching: eventStore.predicateForReminders(in: lists), completion: { [completion = completion] (reminders) in // if v.title == calendar!.title {
DispatchQueue.main.async { [completion = completion] in // reminderCal.append(calendar)
completion(reminders ?? []) // }
} // }
}) // })
} // }
//
// FIX ME: Should we use the calendar identifier here instead of the title for finding the right cal? // let reminder = EKReminder(eventStore: eventStore)
/** // reminder.title = title
A method for adding a new reminder to an optionally existing list. // reminder.dueDateComponents = dateComponents
if the list does not exist it will be added to the default reminders list. // reminder.calendar = reminderCal.last!
- Parameter completion: optional completion call back //
*/ // var created: Bool = false
open func create(title: String, dateComponents: DateComponents, in list: EKCalendar? = nil, completion: ((Error?) -> Void)? = nil) { // var error: Error?
var reminderCal = [EKCalendar]() //
if list != nil { // do {
fetchLists(completion: { (calendars) in // try eventStore.save(reminder, commit: true)
for calendar in calendars { // created = true
if calendar.title == list!.title { // } catch let e {
reminderCal.append(calendar) // error = e
} // }
} //
}) // DispatchQueue.main.async { [weak self] in
} // guard let s = self else {
let reminder = EKReminder(eventStore: eventStore) // return
reminder.title = title // }
reminder.dueDateComponents = dateComponents //
reminder.calendar = reminderCal.last! // s.delegate?.reminders?(reminders: s, created: created)
var created: Bool = false //
var error: Error? // if let c = completion {
do { // c(error)
try eventStore.save(reminder, commit: true) // }
created = true // }
} catch let e { // }
error = e //
} // // FIX ME: Should we use the calendar identifier here instead of the title for finding the right cal?
DispatchQueue.main.async { [weak self] in // /**
guard let s = self else { // A method for adding a new reminder to an optionally existing list.
return // if the list does not exist it will be added to the default reminders list.
} // - Parameter completion: An optional completion call back.
s.delegate?.reminders?(reminders: s, created: created) // */
if let c = completion { // open func delete(reminder: EKReminder, completion: ((Error?) -> Void)? = nil) {
c(error) // var deleted: Bool = false
} // var error: Error?
} //
} // do {
// try eventStore.remove(reminder, commit: true)
// FIX ME: Should we use the calendar identifier here instead of the title for finding the right cal? // deleted = true
/** // } catch let e {
A method for adding a new reminder to an optionally existing list. // error = e
if the list does not exist it will be added to the default reminders list. // }
- Parameter completion: optional completion call back //
*/ // DispatchQueue.main.async { [weak self] in
open func delete(reminder: EKReminder, completion: ((Error?) -> Void)? = nil) { // guard let s = self else {
var deleted: Bool = false // return
var error: Error? // }
do { //
try eventStore.remove(reminder, commit: true) // s.delegate?.reminders?(reminders: s, deleted: deleted)
deleted = true //
} catch let e { // if let c = completion {
error = e // c(error)
} // }
DispatchQueue.main.async { [weak self] in // }
guard let s = self else { // }
return
}
s.delegate?.reminders?(reminders: s, deleted: deleted)
if let c = completion {
c(error)
}
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment