160 lines
3.8 KiB
TypeScript
Raw Normal View History

2016-10-11 09:13:56 -04:00
import {Cordova, Plugin} from './plugin';
2016-02-15 17:22:50 -05:00
export interface DatePickerOptions {
/**
* The mode of the date picker
* Values: date | time | datetime
*/
mode: string;
/**
* Selected date
*/
date: Date | string | number;
/**
* Minimum date
* Default: empty String
*/
minDate?: Date | string | number;
/**
* Maximum date
2016-03-13 20:35:47 -04:00
* Default?: empty String
*/
maxDate?: Date | string | number;
/**
* 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
*/
titleText?: string;
/**
* Label of BUTTON_POSITIVE (done button) on Android
*/
okText?: string;
2016-10-11 09:13:56 -04:00
/**
* Label of BUTTON_NEGATIVE (cancel button). If empty, uses android.R.string.cancel.
*/
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.
*/
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.
*/
nowText?: string;
2016-10-11 09:13:56 -04:00
/**
* Shows time dialog in 24 hours format.
*/
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
*/
androidTheme?: number;
2016-10-11 09:13:56 -04:00
/**
* Shows or hide dates earlier then selected date.
*/
allowOldDate?: boolean;
2016-10-11 09:13:56 -04:00
/**
* Shows or hide dates after selected date.
*/
allowFutureDates?: boolean;
2016-10-11 09:13:56 -04:00
/**
* Label of done button.
*/
doneButtonLabel?: string;
2016-10-11 09:13:56 -04:00
/**
* Hex color of done button.
*/
doneButtonColor?: string;
2016-10-11 09:13:56 -04:00
/**
* Label of cancel button.
*/
cancelButtonLabel?: string;
2016-10-11 09:13:56 -04:00
/**
* Hex color of cancel button.
*/
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.
*/
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.
*/
y?: number;
2016-10-11 09:13:56 -04:00
/**
* Interval between options in the minute section of the date picker.
*/
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.
*/
popoverArrowDirection?: string;
2016-10-11 09:13:56 -04:00
/**
* Force locale for datePicker.
*/
locale?: string;
}
2016-02-15 17:22:50 -05:00
/**
2016-03-13 15:45:07 -04:00
* @name Date Picker
* @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
*
* 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
* ```typescript
* import { DatePicker } from 'ionic-native';
*
*
* 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-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-17 20:33:17 -05:00
name: 'DatePicker',
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
}