This repository has been archived by the owner on Oct 7, 2024. It is now read-only.
forked from microsoft/react-native-code-push
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6df6688
commit 8250fab
Showing
1 changed file
with
10 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |