Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
Updating alert adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
lostintangent committed Apr 8, 2016
1 parent 6df6688 commit 8250fab
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions AlertAdapter.js
Original file line number Diff line number Diff line change
@@ -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 };

0 comments on commit 8250fab

Please sign in to comment.