This commit is contained in:
Jonathan Carter 2016-04-08 14:11:37 -07:00
Родитель 6df6688739
Коммит 8250fab38b
1 изменённых файлов: 10 добавлений и 20 удалений

Просмотреть файл

@ -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
}
module.exports = { Alert };