From 8250fab38b679c4b70264fab5c48efcc47e16cf8 Mon Sep 17 00:00:00 2001 From: Jonathan Carter Date: Fri, 8 Apr 2016 14:11:37 -0700 Subject: [PATCH] Updating alert adapter --- AlertAdapter.js | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/AlertAdapter.js b/AlertAdapter.js index 2fce5d025..124375891 100644 --- a/AlertAdapter.js +++ b/AlertAdapter.js @@ -1,34 +1,24 @@ -'use strict'; - -var { Platform } = require("react-native"); -var Alert; +import React, { Platform } from "react-native"; +let { Alert } = React; if (Platform.OS === "android") { - var CodePushDialog = require("react-native").NativeModules.CodePushDialog; + const { NativeModules: { CodePushDialog } } = React; + Alert = { - alert: function(title, message, buttons) { + alert(title, message, buttons) { if (buttons.length > 2) { throw "Can only show 2 buttons for Android dialog."; } - var button1Text = buttons[0] ? buttons[0].text : null; - var button2Text = buttons[1] ? buttons[1].text : null; + const button1Text = buttons[0] ? buttons[0].text : null, + button2Text = buttons[1] ? buttons[1].text : null; CodePushDialog.showDialog( title, message, button1Text, button2Text, - (buttonPressedId) => { - buttons[buttonPressedId].onPress && buttons[buttonPressedId].onPress(); - }, - (error) => { - throw error; - }); + (buttonId) => { buttons[buttonId].onPress && buttons[buttonId].onPress(); }, + (error) => { throw error; }); } }; -} else if (Platform.OS === "ios") { - var { AlertIOS } = require("react-native"); - Alert = AlertIOS; } -module.exports = { - Alert: Alert -} \ No newline at end of file +module.exports = { Alert }; \ No newline at end of file