2016-02-16 06:22:50 +08:00
|
|
|
import {Plugin, Cordova} from './plugin';
|
|
|
|
|
2016-04-30 11:56:49 +08:00
|
|
|
export interface DatePickerOptions {
|
2016-03-07 02:51:12 +08:00
|
|
|
/**
|
|
|
|
* Platforms: iOS, Android, Windows
|
|
|
|
* The mode of the date picker
|
|
|
|
* Values: date | time | datetime
|
|
|
|
*/
|
2016-04-30 11:56:49 +08:00
|
|
|
mode: string;
|
2016-03-07 02:51:12 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Platforms: iOS, Android, Windows
|
|
|
|
* Selected date
|
|
|
|
*/
|
2016-04-30 11:56:49 +08:00
|
|
|
date: Date;
|
2016-03-07 02:51:12 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Platforms: iOS, Android, Windows
|
|
|
|
* Minimum date
|
|
|
|
* Type: Date | empty String
|
|
|
|
* Default: empty String
|
|
|
|
*/
|
2016-04-30 11:56:49 +08:00
|
|
|
minDate?: Date;
|
2016-03-07 02:51:12 +08:00
|
|
|
|
|
|
|
/**
|
2016-03-14 08:35:47 +08:00
|
|
|
* Platforms?: iOS, Android, Windows
|
2016-03-07 02:51:12 +08:00
|
|
|
* Maximum date
|
2016-03-14 08:35:47 +08:00
|
|
|
* Type?: Date | empty String
|
|
|
|
* Default?: empty String
|
2016-03-07 02:51:12 +08:00
|
|
|
*/
|
2016-04-30 11:56:49 +08:00
|
|
|
maxDate?: Date;
|
2016-03-07 02:51:12 +08:00
|
|
|
|
|
|
|
/**
|
2016-03-14 08:35:47 +08:00
|
|
|
* Platforms?: Android
|
2016-03-07 02:51:12 +08:00
|
|
|
* Label for the dialog title. If empty, uses android default (Set date/Set time).
|
2016-03-14 08:35:47 +08:00
|
|
|
* Type?: String
|
|
|
|
* Default?: empty String
|
2016-03-07 02:51:12 +08:00
|
|
|
*/
|
2016-04-30 11:56:49 +08:00
|
|
|
titleText?: string;
|
2016-03-07 02:51:12 +08:00
|
|
|
|
|
|
|
/**
|
2016-03-14 08:35:47 +08:00
|
|
|
* Platforms?: Android
|
2016-03-07 02:51:12 +08:00
|
|
|
* Label of BUTTON_POSITIVE (done button) on Android
|
|
|
|
*/
|
2016-04-30 11:56:49 +08:00
|
|
|
okText?: string;
|
2016-03-07 02:51:12 +08:00
|
|
|
|
|
|
|
// TODO complete documentation here, and copy params & docs to main plugin docs
|
2016-04-30 11:56:49 +08:00
|
|
|
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-03-07 02:51:12 +08:00
|
|
|
}
|
|
|
|
|
2016-02-16 06:22:50 +08:00
|
|
|
/**
|
2016-03-14 03:45:07 +08:00
|
|
|
* @name Date Picker
|
2016-03-13 07:30:16 +08:00
|
|
|
* @description
|
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
|
|
|
*
|
|
|
|
* @usage
|
|
|
|
* ```js
|
2016-03-25 01:00:18 +08:00
|
|
|
* import {DatePicker} from 'ionic-native';
|
|
|
|
*
|
|
|
|
*
|
2016-03-07 03:31:00 +08:00
|
|
|
* DatePicker.show({
|
|
|
|
* date: new Date(),
|
|
|
|
* mode: 'date'
|
|
|
|
* }).then(
|
|
|
|
* date => console.log("Got date: ", date),
|
|
|
|
* err => console.log("Error occurred while getting date:", err)
|
|
|
|
* );
|
2016-02-16 06:22:50 +08:00
|
|
|
* ```
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
@Plugin({
|
2016-03-13 07:30:16 +08:00
|
|
|
plugin: 'cordova-plugin-datepicker',
|
2016-03-13 08:08:47 +08:00
|
|
|
pluginRef: 'datePicker',
|
|
|
|
repo: 'https://github.com/VitaliiBlagodir/cordova-plugin-datepicker'
|
2016-02-16 06:22:50 +08:00
|
|
|
})
|
|
|
|
export class DatePicker {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the date and/or time picker dialog(s)
|
2016-07-09 03:19:13 +08:00
|
|
|
* @param {DatePickerOptions} options Options for the date picker.
|
2016-02-16 06:22:50 +08:00
|
|
|
* @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-04-30 11:56:49 +08:00
|
|
|
static show(options: DatePickerOptions): Promise<Date> { return; }
|
2016-02-16 06:22:50 +08:00
|
|
|
|
2016-07-09 03:19:13 +08:00
|
|
|
}
|