-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (34 loc) · 1.46 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { NativeModules, processColor } from 'react-native';
const { RNAlertView } = NativeModules;
export default {
/*
* config:
* {
* title(string) // ios/android
* message(string) // ios/android
* preferredStyle(one of actionSheet/alert) // (ios supports both. android supports only alert)
* textAlignment(one of left/right/center) // (ios supports all. android no support. Defaults to left)
* buttons(object): {
* title(string) // ios/android
* style(one of default/cancel/destructive) // (ios supports all. android defaults to positive for first button and negative for second button)
* alignment(one of justified(default)/right/left/center) // (ios only. android no support. Defaults to justified.)
* backgroundColor(one of supported formats: https://facebook.github.io/react-native/docs/colors.html), // ios/android
* textColor(one of supported formats: https://facebook.github.io/react-native/docs/colors.html), // ios/android
* }
* }
*
* calback: Returns the index of the button clicked as the first argument
*
*/
show(config, callback) {
config.buttons = config.buttons.map((button) => {
const { backgroundColor = 'white', textColor = 'white', ...rest } = button;
return {
backgroundColor: processColor(backgroundColor),
textColor: processColor(textColor),
...rest
};
});
RNAlertView.show(config, callback);
}
};