2016-02-16 06:22:50 +08:00
|
|
|
import {Plugin, Cordova} from './plugin';
|
|
|
|
|
2016-03-07 02:51:12 +08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2016-02-16 06:22:50 +08:00
|
|
|
/**
|
|
|
|
* The DatePicker plugin allows the user to fetch date or time using native dialogs.
|
|
|
|
*
|
|
|
|
* Platforms supported: iOS, Android, Windows
|
|
|
|
*
|
2016-03-07 02:51:12 +08:00
|
|
|
* Requires Cordova plugin: `cordova-plugin-datepicker`. For more info, please see the [DatePicker plugin docs](https://github.com/VitaliiBlagodir/cordova-plugin-datepicker).
|
2016-02-16 06:22:50 +08:00
|
|
|
*
|
|
|
|
* Install the plugin by running the following command:
|
|
|
|
* ```shell
|
2016-03-07 02:51:12 +08:00
|
|
|
* cordova plugin add https://github.com/VitaliiBlagodir/cordova-plugin-datepicker.git
|
2016-02-16 06:22:50 +08:00
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* @usage
|
|
|
|
* ```js
|
2016-03-07 02:51:12 +08:00
|
|
|
* DatePicker.show();
|
2016-02-16 06:22:50 +08:00
|
|
|
* ```
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
@Plugin({
|
2016-03-07 02:51:12 +08:00
|
|
|
plugin: 'https://github.com/VitaliiBlagodir/cordova-plugin-datepicker.git',
|
|
|
|
pluginRef: 'datePicker'
|
2016-02-16 06:22:50 +08:00
|
|
|
})
|
|
|
|
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.
|
|
|
|
*/
|
2016-03-05 05:42:21 +08:00
|
|
|
@Cordova()
|
2016-03-07 02:51:12 +08:00
|
|
|
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
|
2016-02-16 06:22:50 +08:00
|
|
|
return new Promise<Date>((res, rej) => {});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|