UNPKG

4.69 kBTypeScriptView Raw
1import { Observable } from 'rxjs/Observable';
2export interface ToastOptions {
3 /**
4 * Message to display
5 */
6 message?: string;
7 /**
8 * Duration in ms to show
9 */
10 duration?: number;
11 /**
12 * Position
13 */
14 position?: string;
15 /**
16 * Add negative value to move it up a bit
17 */
18 addPixelsY?: number;
19 /**
20 * Pass JSON object to be sent back in success callback
21 */
22 data?: any;
23 /**
24 * Styling
25 */
26 styling?: {
27 opacity?: number;
28 backgroundColor?: string;
29 textColor?: string;
30 cornerRadius?: number;
31 horizontalPadding?: number;
32 verticalPadding?: number;
33 };
34}
35/**
36 * @name Toast
37 * @description
38 * This plugin allows you to show a native Toast (a little text popup) on iOS, Android and WP8. It's great for showing a non intrusive native notification which is guaranteed always in the viewport of the browser.
39 *
40 * Requires Cordova plugin: `cordova-plugin-x-toast`. For more info, please see the [Toast plugin docs](https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin).
41 *
42 * @usage
43 * ```typescript
44 * import { Toast } from 'ionic-native';
45 *
46 *
47 * Toast.show("I'm a toast", '5000', 'center').subscribe(
48 * toast => {
49 * console.log(toast);
50 * }
51 * );
52 * ```
53 * @interfaces
54 * ToastOptions
55 */
56export declare class Toast {
57 /**
58 * Show a native toast for the given duration at the specified position.
59 *
60 * @param {string} message The message to display.
61 * @param {string} duration Duration to show the toast, either 'short', 'long' or any number of milliseconds: '1500'.
62 * @param {string} position Where to position the toast, either 'top', 'center', or 'bottom'.
63 * @returns {Observable<any>} Returns an Observable that notifies first on success and then when tapped, rejects on error.
64 */
65 static show(message: string, duration: string, position: string): Observable<any>;
66 /**
67 * Manually hide any currently visible toast.
68 * @returns {Promise<any>} Returns a Promise that resolves on success.
69 */
70 static hide(): Promise<any>;
71 /**
72 * Show a native toast with the given options.
73 *
74 * @param {Object} options Options for showing a toast. Available options:
75 * message The message to display.
76 * duration Duration to show the toast, either 'short', 'long' or any number of milliseconds: '1500'.
77 * position Where to position the toast, either 'top', 'center', or 'bottom'.
78 * addPixelsY Offset in pixels to move the toast up or down from its specified position.
79 *
80 * @returns {Observable<any>} Returns an Observable that notifies first on success and then when tapped, rejects on error.
81 */
82 static showWithOptions(options: ToastOptions): Observable<any>;
83 /**
84 * Shorthand for `show(message, 'short', 'top')`.
85 * @param message {string}
86 * @returns {Observable<any>} Returns an Observable that notifies first on success and then when tapped, rejects on error.
87 */
88 static showShortTop(message: string): Observable<any>;
89 /**
90 * Shorthand for `show(message, 'short', 'center')`.
91 * @param message {string}
92 * @returns {Observable<any>} Returns an Observable that notifies first on success and then when tapped, rejects on error.
93 */
94 static showShortCenter(message: string): Observable<any>;
95 /**
96 * Shorthand for `show(message, 'short', 'bottom')`.
97 * @param message {string}
98 * @returns {Observable<any>} Returns an Observable that notifies first on success and then when tapped, rejects on error.
99 */
100 static showShortBottom(message: string): Observable<any>;
101 /**
102 * Shorthand for `show(message, 'long', 'top')`.
103 * @param message {string}
104 * @returns {Observable<any>} Returns an Observable that notifies first on success and then when tapped, rejects on error.
105 */
106 static showLongTop(message: string): Observable<any>;
107 /**
108 * Shorthand for `show(message, 'long', 'center')`.
109 * @param message {string}
110 * @returns {Observable<any>} Returns an Observable that notifies first on success and then when tapped, rejects on error.
111 */
112 static showLongCenter(message: string): Observable<any>;
113 /**
114 * Shorthand for `show(message, 'long', 'bottom')`.
115 * @param message {string}
116 * @returns {Observable<any>} Returns an Observable that notifies first on success and then when tapped, rejects on error.
117 */
118 static showLongBottom(message: string): Observable<any>;
119}