forked from vonovak/react-native-simple-toast
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
49 lines (43 loc) · 1.15 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { NativeModules, Platform } from 'react-native';
const RCTToast = Platform.select({
ios: NativeModules.LRDRCTSimpleToast,
android: NativeModules.ToastModule,
});
const DEFAULT_SHORT = 1.5
export default {
// Toast duration constants
SHORT: RCTToast.SHORT,
LONG: RCTToast.LONG,
// Toast gravity constants
TOP: RCTToast.TOP,
BOTTOM: RCTToast.BOTTOM,
CENTER: RCTToast.CENTER,
show(message, duration, viewControllerBlacklist) {
Platform.OS == 'android'
? RCTToast.showWithGravity(
message,
duration === undefined ? DEFAULT_SHORT : duration,
RCTToast.CENTER
)
: RCTToast.showWithGravity(
message,
duration === undefined ? DEFAULT_SHORT : duration,
RCTToast.CENTER,
viewControllerBlacklist
);
},
showWithGravity(message, duration, gravity, viewControllerBlacklist) {
Platform.OS == 'android'
? RCTToast.showWithGravity(
message,
duration === undefined ? RCTToast.SHORT : duration,
gravity
)
: RCTToast.showWithGravity(
message,
duration === undefined ? RCTToast.SHORT : duration,
gravity,
viewControllerBlacklist
);
},
};