From d820323887912089cd6ac487a9a71e5cbc101820 Mon Sep 17 00:00:00 2001 From: Rodrigo Angelo Valentini Date: Mon, 11 Feb 2019 16:52:09 -0200 Subject: [PATCH 1/2] toast offset --- index.js | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/index.js b/index.js index ec70f07..cccacd3 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,9 @@ -import {NativeModules,ToastAndroid,Platform} from 'react-native'; +import { NativeModules, ToastAndroid, Platform } from 'react-native'; -var RCTToastAndroid = Platform.OS === 'android' ? ToastAndroid : NativeModules.LRDRCTSimpleToast; +const RCTToastAndroid = + Platform.OS === 'android' ? ToastAndroid : NativeModules.LRDRCTSimpleToast; -var SimpleToast = { +const SimpleToast = { // Toast duration constants SHORT: RCTToastAndroid.SHORT, LONG: RCTToastAndroid.LONG, @@ -12,19 +13,35 @@ var SimpleToast = { BOTTOM: RCTToastAndroid.BOTTOM, CENTER: RCTToastAndroid.CENTER, - show: function ( - message, - duration - ) { - RCTToastAndroid.show(message, duration === undefined ? this.SHORT : duration); + show = (message, duration) => { + RCTToastAndroid.show( + message, + duration === undefined ? this.SHORT : duration, + ); + }, + + showWithGravity = (message, duration, gravity) => { + RCTToastAndroid.showWithGravity( + message, + duration === undefined ? this.SHORT : duration, + gravity, + ); }, - showWithGravity: function ( + showWithGravityAndOffset = ( message, duration, gravity, - ) { - RCTToastAndroid.showWithGravity(message, duration === undefined ? this.SHORT : duration, gravity); + xOffset, + yOffset, + ) => { + RCTToastAndroid.showWithGravityAndOffset( + message, + duration === undefined ? this.SHORT : duration, + gravity, + xOffset === undefined ? 25 : xOffset, + yOffset === undefined ? 50 : yOffset, + ); }, }; From 0fc55bc08cd3ea34c07d07271d684fd4204eebc6 Mon Sep 17 00:00:00 2001 From: Rodrigo Angelo Valentini Date: Mon, 11 Feb 2019 16:59:44 -0200 Subject: [PATCH 2/2] ajuste --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index cccacd3..a7f7568 100644 --- a/index.js +++ b/index.js @@ -13,14 +13,14 @@ const SimpleToast = { BOTTOM: RCTToastAndroid.BOTTOM, CENTER: RCTToastAndroid.CENTER, - show = (message, duration) => { + show: function(message, duration) { RCTToastAndroid.show( message, duration === undefined ? this.SHORT : duration, ); }, - showWithGravity = (message, duration, gravity) => { + showWithGravity: function(message, duration, gravity) { RCTToastAndroid.showWithGravity( message, duration === undefined ? this.SHORT : duration, @@ -28,13 +28,13 @@ const SimpleToast = { ); }, - showWithGravityAndOffset = ( + showWithGravityAndOffset: function( message, duration, gravity, xOffset, yOffset, - ) => { + ) { RCTToastAndroid.showWithGravityAndOffset( message, duration === undefined ? this.SHORT : duration,