2016-10-11 09:13:56 -04:00
|
|
|
import {Cordova, Plugin} from './plugin';
|
2016-02-15 17:22:50 -05:00
|
|
|
|
2016-07-20 17:17:09 +02:00
|
|
|
|
2016-04-29 23:56:49 -04:00
|
|
|
export interface DatePickerOptions {
|
2016-03-06 13:51:12 -05:00
|
|
|
/**
|
|
|
|
* The mode of the date picker
|
|
|
|
* Values: date | time | datetime
|
|
|
|
*/
|
2016-04-29 23:56:49 -04:00
|
|
|
mode: string;
|
2016-03-06 13:51:12 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Selected date
|
|
|
|
*/
|
2016-08-15 03:58:06 -04:00
|
|
|
date: Date | string | number;
|
2016-03-06 13:51:12 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Minimum date
|
|
|
|
* Default: empty String
|
|
|
|
*/
|
2016-08-15 03:58:06 -04:00
|
|
|
minDate?: Date | string | number;
|
2016-03-06 13:51:12 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maximum date
|
2016-03-13 20:35:47 -04:00
|
|
|
* Default?: empty String
|
2016-03-06 13:51:12 -05:00
|
|
|
*/
|
2016-08-15 03:58:06 -04:00
|
|
|
maxDate?: Date | string | number;
|
2016-03-06 13:51:12 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Label for the dialog title. If empty, uses android default (Set date/Set time).
|
2016-03-13 20:35:47 -04:00
|
|
|
* Default?: empty String
|
2016-03-06 13:51:12 -05:00
|
|
|
*/
|
2016-04-29 23:56:49 -04:00
|
|
|
titleText?: string;
|
2016-03-06 13:51:12 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Label of BUTTON_POSITIVE (done button) on Android
|
|
|
|
*/
|
2016-04-29 23:56:49 -04:00
|
|
|
okText?: string;
|
2016-10-11 09:13:56 -04:00
|
|
|
/**
|
|
|
|
* Label of BUTTON_NEGATIVE (cancel button). If empty, uses android.R.string.cancel.
|
|
|
|
*/
|
2016-04-29 23:56:49 -04:00
|
|
|
cancelText?: string;
|
2016-10-11 09:13:56 -04:00
|
|
|
/**
|
|
|
|
* Label of today button. If empty, doesn't show the option to select current date.
|
|
|
|
*/
|
2016-04-29 23:56:49 -04:00
|
|
|
todayText?: string;
|
2016-10-11 09:13:56 -04:00
|
|
|
/**
|
|
|
|
* Label of now button. If empty, doesn't show the option to select current time.
|
|
|
|
*/
|
2016-04-29 23:56:49 -04:00
|
|
|
nowText?: string;
|
2016-10-11 09:13:56 -04:00
|
|
|
/**
|
|
|
|
* Shows time dialog in 24 hours format.
|
|
|
|
*/
|
2016-04-29 23:56:49 -04:00
|
|
|
is24Hour?: boolean;
|
2016-10-11 09:13:56 -04:00
|
|
|
/**
|
|
|
|
* Choose the Android theme for the picker. You can use the DatePicker.ANDROID_THEMES property.
|
|
|
|
* Values: 1: THEME_TRADITIONAL | 2: THEME_HOLO_DARK | 3: THEME_HOLO_LIGHT | 4: THEME_DEVICE_DEFAULT_DARK | 5: THEME_DEVICE_DEFAULT_LIGHT
|
|
|
|
*/
|
2016-04-29 23:56:49 -04:00
|
|
|
androidTheme?: number;
|
2016-10-11 09:13:56 -04:00
|
|
|
/**
|
|
|
|
* Shows or hide dates earlier then selected date.
|
|
|
|
*/
|
2016-04-29 23:56:49 -04:00
|
|
|
allowOldDate?: boolean;
|
2016-10-11 09:13:56 -04:00
|
|
|
/**
|
|
|
|
* Shows or hide dates after selected date.
|
|
|
|
*/
|
2016-04-29 23:56:49 -04:00
|
|
|
allowFutureDates?: boolean;
|
2016-10-11 09:13:56 -04:00
|
|
|
/**
|
|
|
|
* Label of done button.
|
|
|
|
*/
|
2016-04-29 23:56:49 -04:00
|
|
|
doneButtonLabel?: string;
|
2016-10-11 09:13:56 -04:00
|
|
|
/**
|
|
|
|
* Hex color of done button.
|
|
|
|
*/
|
2016-04-29 23:56:49 -04:00
|
|
|
doneButtonColor?: string;
|
2016-10-11 09:13:56 -04:00
|
|
|
/**
|
|
|
|
* Label of cancel button.
|
|
|
|
*/
|
2016-04-29 23:56:49 -04:00
|
|
|
cancelButtonLabel?: string;
|
2016-10-11 09:13:56 -04:00
|
|
|
/**
|
|
|
|
* Hex color of cancel button.
|
|
|
|
*/
|
2016-04-29 23:56:49 -04:00
|
|
|
cancelButtonColor?: string;
|
2016-10-11 09:13:56 -04:00
|
|
|
/**
|
|
|
|
* X position of date picker. The position is absolute to the root view of the application.
|
|
|
|
*/
|
2016-04-29 23:56:49 -04:00
|
|
|
x?: number;
|
2016-10-11 09:13:56 -04:00
|
|
|
/**
|
|
|
|
* Y position of date picker. The position is absolute to the root view of the application.
|
|
|
|
*/
|
2016-04-29 23:56:49 -04:00
|
|
|
y?: number;
|
2016-10-11 09:13:56 -04:00
|
|
|
/**
|
|
|
|
* Interval between options in the minute section of the date picker.
|
|
|
|
*/
|
2016-04-29 23:56:49 -04:00
|
|
|
minuteInterval?: number;
|
2016-10-11 09:13:56 -04:00
|
|
|
/**
|
|
|
|
* Force the UIPopoverArrowDirection enum. The value any will revert to default UIPopoverArrowDirectionAny and let the app choose the proper direction itself.
|
|
|
|
*/
|
2016-04-29 23:56:49 -04:00
|
|
|
popoverArrowDirection?: string;
|
2016-10-11 09:13:56 -04:00
|
|
|
/**
|
|
|
|
* Force locale for datePicker.
|
|
|
|
*/
|
2016-04-29 23:56:49 -04:00
|
|
|
locale?: string;
|
2016-03-06 13:51:12 -05:00
|
|
|
}
|
|
|
|
|
2016-02-15 17:22:50 -05:00
|
|
|
/**
|
2016-03-13 15:45:07 -04:00
|
|
|
* @name Date Picker
|
2016-03-12 18:30:16 -05:00
|
|
|
* @description
|
2016-02-15 17:22:50 -05:00
|
|
|
* The DatePicker plugin allows the user to fetch date or time using native dialogs.
|
|
|
|
*
|
|
|
|
* Platforms supported: iOS, Android, Windows
|
|
|
|
*
|
2016-03-06 13:51:12 -05: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-15 17:22:50 -05:00
|
|
|
*
|
|
|
|
* @usage
|
2016-07-20 17:17:09 +02:00
|
|
|
* ```typescript
|
|
|
|
* import { DatePicker } from 'ionic-native';
|
2016-03-24 13:00:18 -04:00
|
|
|
*
|
|
|
|
*
|
2016-03-06 14:31:00 -05:00
|
|
|
* DatePicker.show({
|
|
|
|
* date: new Date(),
|
|
|
|
* mode: 'date'
|
|
|
|
* }).then(
|
2016-07-20 17:17:09 +02:00
|
|
|
* date => console.log('Got date: ', date),
|
|
|
|
* err => console.log('Error occurred while getting date: ', err)
|
2016-03-06 14:31:00 -05:00
|
|
|
* );
|
2016-02-15 17:22:50 -05:00
|
|
|
* ```
|
2016-10-11 09:13:56 -04:00
|
|
|
* @interfaces
|
|
|
|
* DatePickerOptions
|
2016-02-15 17:22:50 -05:00
|
|
|
*/
|
|
|
|
@Plugin({
|
2016-10-27 12:48:50 -05:00
|
|
|
pluginName: 'DatePicker',
|
2016-03-12 18:30:16 -05:00
|
|
|
plugin: 'cordova-plugin-datepicker',
|
2016-03-12 19:08:47 -05:00
|
|
|
pluginRef: 'datePicker',
|
|
|
|
repo: 'https://github.com/VitaliiBlagodir/cordova-plugin-datepicker'
|
2016-02-15 17:22:50 -05:00
|
|
|
})
|
|
|
|
export class DatePicker {
|
|
|
|
|
2016-10-11 09:14:17 -04:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
*/
|
2016-10-11 09:13:56 -04:00
|
|
|
static ANDROID_THEMES = {
|
|
|
|
THEME_TRADITIONAL: 1,
|
|
|
|
THEME_HOLO_DARK: 2,
|
|
|
|
THEME_HOLO_LIGHT: 3,
|
|
|
|
THEME_DEVICE_DEFAULT_DARK: 4,
|
|
|
|
THEME_DEVICE_DEFAULT_LIGHT: 5
|
|
|
|
};
|
|
|
|
|
2016-02-15 17:22:50 -05:00
|
|
|
/**
|
|
|
|
* Shows the date and/or time picker dialog(s)
|
2016-07-08 15:19:13 -04:00
|
|
|
* @param {DatePickerOptions} options Options for the date picker.
|
2016-02-15 17:22:50 -05:00
|
|
|
* @returns {Promise<Date>} Returns a promise that resolves with the picked date and/or time, or rejects with an error.
|
|
|
|
*/
|
2016-03-04 15:42:21 -06:00
|
|
|
@Cordova()
|
2016-10-11 09:13:56 -04:00
|
|
|
static show(options: DatePickerOptions): Promise<Date> {
|
|
|
|
return;
|
|
|
|
}
|
2016-02-15 17:22:50 -05:00
|
|
|
|
2016-07-08 00:50:03 +02:00
|
|
|
}
|