2015-11-01 17:28:44 +00:00
|
|
|
import React from 'react-native';
|
2015-10-31 19:30:01 +00:00
|
|
|
var {
|
|
|
|
AppRegistry,
|
|
|
|
StyleSheet,
|
|
|
|
Text,
|
|
|
|
View,
|
|
|
|
NativeModules,
|
|
|
|
TouchableNativeFeedback,
|
2015-11-01 18:04:45 +00:00
|
|
|
ScrollView,
|
2015-11-01 18:27:21 +00:00
|
|
|
ToolbarAndroid,
|
2015-10-31 19:30:01 +00:00
|
|
|
} = React;
|
|
|
|
|
2015-11-01 17:28:44 +00:00
|
|
|
import DialogAndroid from 'react-native-dialogs';
|
|
|
|
|
|
|
|
import dialogData from './dialogData.js';
|
2015-11-01 18:04:45 +00:00
|
|
|
import {MKButton } from 'react-native-material-kit';
|
|
|
|
|
2015-10-31 19:30:01 +00:00
|
|
|
class ExampleApp extends React.Component {
|
2015-11-01 17:28:44 +00:00
|
|
|
showDialog(options) {
|
|
|
|
var dialog = new DialogAndroid();
|
|
|
|
dialog.set(options);
|
|
|
|
dialog.show();
|
2015-10-31 19:30:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2015-11-01 17:28:44 +00:00
|
|
|
|
|
|
|
var dialogs = dialogData.map((section, i) => {
|
2015-11-01 18:04:45 +00:00
|
|
|
var sectionDialogNodes = section.dialogs.map((op, j) => {
|
|
|
|
const ColoredRaisedButton = MKButton.coloredButton()
|
|
|
|
.withText(op.buttonText)
|
|
|
|
.withOnPress(c => this.showDialog(
|
|
|
|
op.data || { title: "NOT IMPLEMENTED!! :-(", positiveText: "OK"}))
|
|
|
|
.withStyle({width: 200})
|
|
|
|
.build();
|
|
|
|
return (
|
|
|
|
<View style={{padding: 5}}>
|
|
|
|
<ColoredRaisedButton />
|
2015-11-01 17:28:44 +00:00
|
|
|
</View>
|
2015-11-01 18:04:45 +00:00
|
|
|
);
|
|
|
|
});
|
2015-11-01 17:28:44 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<View key={i}>
|
|
|
|
<Text style={styles.welcome}>{section.sectionTitle}</Text>
|
|
|
|
{sectionDialogNodes}
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2015-10-31 19:30:01 +00:00
|
|
|
return (
|
2015-11-01 18:27:21 +00:00
|
|
|
<View style={{flex:1}}>
|
|
|
|
<ToolbarAndroid title="React Native Dialogs" style={styles.toolbar} titleColor="#ddd"/>
|
2015-11-01 18:04:45 +00:00
|
|
|
<ScrollView>
|
|
|
|
<View style={styles.container}>
|
|
|
|
{dialogs}
|
|
|
|
</View>
|
|
|
|
</ScrollView>
|
2015-11-01 18:27:21 +00:00
|
|
|
</View>
|
2015-10-31 19:30:01 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-01 17:28:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2015-10-31 19:30:01 +00:00
|
|
|
var styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
flex: 1,
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
|
|
|
backgroundColor: '#F5FCFF',
|
|
|
|
},
|
|
|
|
welcome: {
|
|
|
|
fontSize: 20,
|
|
|
|
textAlign: 'center',
|
|
|
|
margin: 10,
|
|
|
|
},
|
|
|
|
instructions: {
|
|
|
|
textAlign: 'center',
|
|
|
|
color: '#333333',
|
|
|
|
marginBottom: 5,
|
2015-11-01 18:27:21 +00:00
|
|
|
},
|
|
|
|
toolbar: {
|
|
|
|
backgroundColor: '#311B92',
|
|
|
|
height: 56,
|
|
|
|
},
|
2015-10-31 19:30:01 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
AppRegistry.registerComponent('ExampleApp', () => ExampleApp);
|
2015-11-01 17:28:44 +00:00
|
|
|
|
|
|
|
|