1
- 'use strict' ;
2
-
3
- var { Platform } = require ( "react-native" ) ;
4
- var Alert ;
1
+ import React , { Platform } from "react-native" ;
2
+ let { Alert } = React ;
5
3
6
4
if ( Platform . OS === "android" ) {
7
- var CodePushDialog = require ( "react-native" ) . NativeModules . CodePushDialog ;
5
+ const { NativeModules : { CodePushDialog } } = React ;
6
+
8
7
Alert = {
9
- alert : function ( title , message , buttons ) {
8
+ alert ( title , message , buttons ) {
10
9
if ( buttons . length > 2 ) {
11
10
throw "Can only show 2 buttons for Android dialog." ;
12
11
}
13
12
14
- var button1Text = buttons [ 0 ] ? buttons [ 0 ] . text : null ;
15
- var button2Text = buttons [ 1 ] ? buttons [ 1 ] . text : null ;
13
+ const button1Text = buttons [ 0 ] ? buttons [ 0 ] . text : null ,
14
+ button2Text = buttons [ 1 ] ? buttons [ 1 ] . text : null ;
16
15
17
16
CodePushDialog . showDialog (
18
17
title , message , button1Text , button2Text ,
19
- ( buttonPressedId ) => {
20
- buttons [ buttonPressedId ] . onPress && buttons [ buttonPressedId ] . onPress ( ) ;
21
- } ,
22
- ( error ) => {
23
- throw error ;
24
- } ) ;
18
+ ( buttonId ) => { buttons [ buttonId ] . onPress && buttons [ buttonId ] . onPress ( ) ; } ,
19
+ ( error ) => { throw error ; } ) ;
25
20
}
26
21
} ;
27
- } else if ( Platform . OS === "ios" ) {
28
- var { AlertIOS } = require ( "react-native" ) ;
29
- Alert = AlertIOS ;
30
22
}
31
23
32
- module . exports = {
33
- Alert : Alert
34
- }
24
+ module . exports = { Alert } ;
0 commit comments