fix(datepicker): fix plugin functionality

This commit is contained in:
Ibrahim Hadeed 2016-03-06 13:51:12 -05:00
parent ce6adccb9a
commit 91de9715fe

View File

@ -1,42 +1,52 @@
import {Plugin, Cordova} from './plugin'; import {Plugin, Cordova} from './plugin';
/** export interface datePickerOptions {
* The DatePicker plugin allows the user to fetch date or time using native dialogs. /**
* * Platforms: iOS, Android, Windows
* Platforms supported: iOS, Android, Windows * The mode of the date picker
* * Values: date | time | datetime
* Requires Cordova plugin: `cordova-plugin-datepicker`. For more info, please see the [Datepicker plugin docs](https://github.com/VitaliiBlagodir/cordova-plugin-datepicker). * Default: date
*
* Install the plugin by running the following command:
* ```shell
* ionic plugin add cordova-plugin-datepicker
* ```
*
* @usage
* ```js
* DatePicker.
* ```
*
*/ */
@Plugin({ mode?: string,
plugin: 'cordova-plugin-datepicker',
pluginRef: 'plugins.datePicker'
})
export class DatePicker {
/** /**
* Shows the date and/or time picker dialog(s) * Platforms: iOS, Android, Windows
* @param options * Selected date
* @returns {Promise<Date>} Returns a promise that resolves with the picked date and/or time, or rejects with an error. * Default: new Date()
*/ */
@Cordova()
static show(options?: {
mode?: string,
date?: Date, date?: Date,
/**
* Platforms: iOS, Android, Windows
* Minimum date
* Type: Date | empty String
* Default: empty String
*/
minDate?: Date, minDate?: Date,
/**
* Platforms: iOS, Android, Windows
* Maximum date
* Type: Date | empty String
* Default: empty String
*/
maxDate?: Date, maxDate?: Date,
/**
* Platforms: Android
* Label for the dialog title. If empty, uses android default (Set date/Set time).
* Type: String
* Default: empty String
*/
titleText?: string, titleText?: string,
/**
* Platforms: Android
* Label of BUTTON_POSITIVE (done button) on Android
*/
okText?: string, okText?: string,
// TODO complete documentation here, and copy params & docs to main plugin docs
cancelText?: string, cancelText?: string,
todayText?: string, todayText?: string,
nowText?: string, nowText?: string,
@ -53,7 +63,44 @@ export class DatePicker {
minuteInterval?: number, minuteInterval?: number,
popoverArrowDirection?: string, popoverArrowDirection?: string,
locale?: string locale?: string
}): Promise<Date> { }
/**
* The DatePicker plugin allows the user to fetch date or time using native dialogs.
*
* Platforms supported: iOS, Android, Windows
*
* Requires Cordova plugin: `cordova-plugin-datepicker`. For more info, please see the [DatePicker plugin docs](https://github.com/VitaliiBlagodir/cordova-plugin-datepicker).
*
* Install the plugin by running the following command:
* ```shell
* cordova plugin add https://github.com/VitaliiBlagodir/cordova-plugin-datepicker.git
* ```
*
* @usage
* ```js
* DatePicker.show();
* ```
*
*/
@Plugin({
plugin: 'https://github.com/VitaliiBlagodir/cordova-plugin-datepicker.git',
pluginRef: 'datePicker'
})
export class DatePicker {
/**
* Shows the date and/or time picker dialog(s)
* @param options
* @returns {Promise<Date>} Returns a promise that resolves with the picked date and/or time, or rejects with an error.
*/
@Cordova()
static show(options?: datePickerOptions): Promise<Date> {
// This Promise is replaced by one from the @Cordova decorator that wraps
// the plugin's callbacks. We provide a dummy one here so TypeScript
// knows that the correct return type is Promise, because there's no way
// for it to know the return type from a decorator.
// See https://github.com/Microsoft/TypeScript/issues/4881
return new Promise<Date>((res, rej) => {}); return new Promise<Date>((res, rej) => {});
} }