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,26 +1,91 @@
import {Plugin, Cordova} from './plugin'; import {Plugin, Cordova} from './plugin';
export interface datePickerOptions {
/**
* Platforms: iOS, Android, Windows
* The mode of the date picker
* Values: date | time | datetime
* Default: date
*/
mode?: string,
/**
* Platforms: iOS, Android, Windows
* Selected date
* Default: new Date()
*/
date?: Date,
/**
* Platforms: iOS, Android, Windows
* Minimum date
* Type: Date | empty String
* Default: empty String
*/
minDate?: Date,
/**
* Platforms: iOS, Android, Windows
* Maximum date
* Type: Date | empty String
* Default: empty String
*/
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,
/**
* Platforms: Android
* Label of BUTTON_POSITIVE (done button) on Android
*/
okText?: string,
// TODO complete documentation here, and copy params & docs to main plugin docs
cancelText?: string,
todayText?: string,
nowText?: string,
is24Hour?: boolean,
androidTheme?: number,
allowOldDate?: boolean,
allowFutureDates?: boolean,
doneButtonLabel?: string,
doneButtonColor?: string,
cancelButtonLabel?: string,
cancelButtonColor?: string,
x?: number,
y?: number,
minuteInterval?: number,
popoverArrowDirection?: string,
locale?: string
}
/** /**
* The DatePicker plugin allows the user to fetch date or time using native dialogs. * The DatePicker plugin allows the user to fetch date or time using native dialogs.
* *
* Platforms supported: iOS, Android, Windows * 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). * 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: * Install the plugin by running the following command:
* ```shell * ```shell
* ionic plugin add cordova-plugin-datepicker * cordova plugin add https://github.com/VitaliiBlagodir/cordova-plugin-datepicker.git
* ``` * ```
* *
* @usage * @usage
* ```js * ```js
* DatePicker. * DatePicker.show();
* ``` * ```
* *
*/ */
@Plugin({ @Plugin({
plugin: 'cordova-plugin-datepicker', plugin: 'https://github.com/VitaliiBlagodir/cordova-plugin-datepicker.git',
pluginRef: 'plugins.datePicker' pluginRef: 'datePicker'
}) })
export class DatePicker { export class DatePicker {
@ -30,30 +95,12 @@ export class DatePicker {
* @returns {Promise<Date>} Returns a promise that resolves with the picked date and/or time, or rejects with an error. * @returns {Promise<Date>} Returns a promise that resolves with the picked date and/or time, or rejects with an error.
*/ */
@Cordova() @Cordova()
static show(options?: { static show(options?: datePickerOptions): Promise<Date> {
mode?: string, // This Promise is replaced by one from the @Cordova decorator that wraps
date?: Date, // the plugin's callbacks. We provide a dummy one here so TypeScript
minDate?: Date, // knows that the correct return type is Promise, because there's no way
maxDate?: Date, // for it to know the return type from a decorator.
titleText?: string, // See https://github.com/Microsoft/TypeScript/issues/4881
okText?: string,
cancelText?: string,
todayText?: string,
nowText?: string,
is24Hour?: boolean,
androidTheme?: number,
allowOldDate?: boolean,
allowFutureDates?: boolean,
doneButtonLabel?: string,
doneButtonColor?: string,
cancelButtonLabel?: string,
cancelButtonColor?: string,
x?: number,
y?: number,
minuteInterval?: number,
popoverArrowDirection?: string,
locale?: string
}): Promise<Date> {
return new Promise<Date>((res, rej) => {}); return new Promise<Date>((res, rej) => {});
} }