react-native-code-push/AlertAdapter.js

24 строки
703 B
JavaScript
Исходник Обычный вид История

2016-04-09 00:11:37 +03:00
import React, { Platform } from "react-native";
let { Alert } = React;
2015-11-23 23:02:01 +03:00
if (Platform.OS === "android") {
2016-04-09 00:11:37 +03:00
const { NativeModules: { CodePushDialog } } = React;
2015-11-23 23:02:01 +03:00
Alert = {
2016-04-09 00:11:37 +03:00
alert(title, message, buttons) {
2015-11-23 23:02:01 +03:00
if (buttons.length > 2) {
throw "Can only show 2 buttons for Android dialog.";
}
2016-04-09 00:11:37 +03:00
const button1Text = buttons[0] ? buttons[0].text : null,
button2Text = buttons[1] ? buttons[1].text : null;
2015-11-23 23:02:01 +03:00
CodePushDialog.showDialog(
title, message, button1Text, button2Text,
2016-04-09 00:11:37 +03:00
(buttonId) => { buttons[buttonId].onPress && buttons[buttonId].onPress(); },
(error) => { throw error; });
2015-11-23 23:02:01 +03:00
}
};
}
2016-04-09 00:11:37 +03:00
module.exports = { Alert };