From 13765d2d6a9a20dd6cef670cc0e5b8f7d2ff0160 Mon Sep 17 00:00:00 2001 From: Daniel Sogl Date: Fri, 16 Mar 2018 14:42:22 +0100 Subject: [PATCH] feat(calendar): add getCreateCalendarOptions function --- src/@ionic-native/plugins/calendar/index.ts | 119 +++++++++++++++----- 1 file changed, 91 insertions(+), 28 deletions(-) diff --git a/src/@ionic-native/plugins/calendar/index.ts b/src/@ionic-native/plugins/calendar/index.ts index 329df366..5854ce0e 100644 --- a/src/@ionic-native/plugins/calendar/index.ts +++ b/src/@ionic-native/plugins/calendar/index.ts @@ -1,8 +1,7 @@ import { Injectable } from '@angular/core'; -import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; +import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core'; export interface CalendarOptions { - /** * Id */ @@ -47,7 +46,14 @@ export interface CalendarOptions { * URL */ url?: string; +} +export interface NameOrOptions { + /** Calendar name */ + calendarName?: string; + + /** Calendar color as a HEX string */ + calendarColor?: string; } /** @@ -72,6 +78,7 @@ export interface CalendarOptions { * ``` * @interfaces * CalendarOptions + * NameOrOptions */ @Plugin({ pluginName: 'Calendar', @@ -82,7 +89,6 @@ export interface CalendarOptions { }) @Injectable() export class Calendar extends IonicNativePlugin { - /** * This function checks if we have permission to read/write from/to the calendar. * The promise will resolve with `true` when: @@ -95,51 +101,65 @@ export class Calendar extends IonicNativePlugin { * @returns {Promise} */ @Cordova() - hasReadWritePermission(): Promise { return; } + hasReadWritePermission(): Promise { + return; + } /** * Check if we have read permission * @returns {Promise} */ @Cordova() - hasReadPermission(): Promise { return; } + hasReadPermission(): Promise { + return; + } /** * Check if we have write permission * @returns {Promise} */ @Cordova() - hasWritePermission(): Promise { return; } + hasWritePermission(): Promise { + return; + } /** * Request write permission * @returns {Promise} */ @Cordova() - requestWritePermission(): Promise { return; } + requestWritePermission(): Promise { + return; + } /** * Request read permission * @returns {Promise} */ @Cordova() - requestReadPermission(): Promise { return; } + requestReadPermission(): Promise { + return; + } /** * Requests read/write permissions * @returns {Promise} */ @Cordova() - requestReadWritePermission(): Promise { return; } + requestReadWritePermission(): Promise { + return; + } /** * Create a calendar. (iOS only) * - * @param {string | Object} nameOrOptions either a string name or a options object. If string, provide the calendar name. IF an object, provide a calendar name as a string and a calendar color in hex format as a string + * @param {string | CalendarOptions} nameOrOptions either a string name or a options object. If string, provide the calendar name. IF an object, provide a calendar name as a string and a calendar color in hex format as a string * @returns {Promise} Returns a Promise */ @Cordova() - createCalendar(nameOrOptions: string | any): Promise { return; } + createCalendar(nameOrOptions: string | CalendarOptions): Promise { + return; + } /** * Delete a calendar. (iOS only) @@ -147,7 +167,9 @@ export class Calendar extends IonicNativePlugin { * @returns {Promise} Returns a Promise */ @Cordova() - deleteCalendar(name: string): Promise { return; } + deleteCalendar(name: string): Promise { + return; + } /** * Returns the default calendar options. @@ -157,7 +179,21 @@ export class Calendar extends IonicNativePlugin { @Cordova({ sync: true }) - getCalendarOptions(): CalendarOptions { return; } + getCalendarOptions(): CalendarOptions { + return; + } + + /** + * Returns options for a custom calender with sepcific colord + * + * @return {NameOrOptions} Returns an object with the default options + */ + @Cordova({ + sync: true + }) + getCreateCalendarOptions(): NameOrOptions { + return; + } /** * Silently create an event. @@ -175,7 +211,9 @@ export class Calendar extends IonicNativePlugin { notes?: string, startDate?: Date, endDate?: Date - ): Promise { return; } + ): Promise { + return; + } /** * Silently create an event with additional options. @@ -196,7 +234,9 @@ export class Calendar extends IonicNativePlugin { startDate?: Date, endDate?: Date, options?: CalendarOptions - ): Promise { return; } + ): Promise { + return; + } /** * Interactively create an event. @@ -215,7 +255,9 @@ export class Calendar extends IonicNativePlugin { notes?: string, startDate?: Date, endDate?: Date - ): Promise { return; } + ): Promise { + return; + } /** * Interactively create an event with additional options. @@ -236,7 +278,9 @@ export class Calendar extends IonicNativePlugin { startDate?: Date, endDate?: Date, options?: CalendarOptions - ): Promise { return; } + ): Promise { + return; + } /** * Find an event. @@ -255,7 +299,9 @@ export class Calendar extends IonicNativePlugin { notes?: string, startDate?: Date, endDate?: Date - ): Promise { return; } + ): Promise { + return; + } /** * Find an event with additional options. @@ -275,7 +321,9 @@ export class Calendar extends IonicNativePlugin { startDate?: Date, endDate?: Date, options?: CalendarOptions - ): Promise { return; } + ): Promise { + return; + } /** * Find a list of events within the specified date range. (Android only) @@ -287,14 +335,18 @@ export class Calendar extends IonicNativePlugin { @Cordova({ platforms: ['Android'] }) - listEventsInRange(startDate: Date, endDate: Date): Promise { return; } + listEventsInRange(startDate: Date, endDate: Date): Promise { + return; + } /** * Get a list of all calendars. * @returns {Promise} A Promise that resolves with the list of calendars, or rejects with an error. */ @Cordova() - listCalendars(): Promise { return; } + listCalendars(): Promise { + return; + } /** * Get a list of all future events in the specified calendar. (iOS only) @@ -303,7 +355,9 @@ export class Calendar extends IonicNativePlugin { @Cordova({ platforms: ['iOS'] }) - findAllEventsInNamedCalendar(calendarName: string): Promise { return; } + findAllEventsInNamedCalendar(calendarName: string): Promise { + return; + } /** * Modify an event. (iOS only) @@ -334,7 +388,9 @@ export class Calendar extends IonicNativePlugin { newNotes?: string, newStartDate?: Date, newEndDate?: Date - ): Promise { return; } + ): Promise { + return; + } /** * Modify an event with additional options. (iOS only) @@ -369,7 +425,9 @@ export class Calendar extends IonicNativePlugin { newEndDate?: Date, filterOptions?: CalendarOptions, newOptions?: CalendarOptions - ): Promise { return; } + ): Promise { + return; + } /** * Delete an event. @@ -388,7 +446,9 @@ export class Calendar extends IonicNativePlugin { notes?: string, startDate?: Date, endDate?: Date - ): Promise { return; } + ): Promise { + return; + } /** * Delete an event from the specified Calendar. (iOS only) @@ -411,7 +471,9 @@ export class Calendar extends IonicNativePlugin { startDate?: Date, endDate?: Date, calendarName?: string - ): Promise { return; } + ): Promise { + return; + } /** * Open the calendar at the specified date. @@ -419,6 +481,7 @@ export class Calendar extends IonicNativePlugin { * @return {Promise} Promise returns a promise */ @Cordova() - openCalendar(date: Date): Promise { return; } - + openCalendar(date: Date): Promise { + return; + } }