mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-22 19:39:40 +08:00
Expose offset parameters for ToastAndroid
Reviewed By: brosenfeld Differential Revision: D5560628 fbshipit-source-id: b1457493e8429958fbd7bc9c490cffaa33b4a95a
This commit is contained in:
committed by
Facebook Github Bot
parent
f3feca91fc
commit
546a43bda0
@@ -7,6 +7,7 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule ToastAndroid
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@@ -23,10 +24,14 @@ var RCTToastAndroid = require('NativeModules').ToastAndroid;
|
||||
* There is also a function `showWithGravity` to specify the layout gravity. May be
|
||||
* ToastAndroid.TOP, ToastAndroid.BOTTOM, ToastAndroid.CENTER.
|
||||
*
|
||||
* The 'showWithGravityWithOffset' function adds on the ability to specify offset
|
||||
* These offset values will translate to pixels.
|
||||
*
|
||||
* Basic usage:
|
||||
* ```javascript
|
||||
* ToastAndroid.show('A pikachu appeared nearby !', ToastAndroid.SHORT);
|
||||
* ToastAndroid.showWithGravity('All Your Base Are Belong To Us', ToastAndroid.SHORT, ToastAndroid.CENTER);
|
||||
* ToastAndroid.showWithGravityAndOffset('A wild toast appeared!', ToastAndroid.LONG, ToastAndroid.BOTTOM, 25, 50);
|
||||
* ```
|
||||
*/
|
||||
|
||||
@@ -55,6 +60,16 @@ var ToastAndroid = {
|
||||
): void {
|
||||
RCTToastAndroid.showWithGravity(message, duration, gravity);
|
||||
},
|
||||
|
||||
showWithGravityAndOffset: function (
|
||||
message: string,
|
||||
duration: number,
|
||||
gravity: number,
|
||||
xOffset: number,
|
||||
yOffset: number,
|
||||
): void {
|
||||
RCTToastAndroid.showWithGravityAndOffset(message, duration, gravity, xOffset, yOffset);
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = ToastAndroid;
|
||||
|
||||
Reference in New Issue
Block a user