Skip to content

Instantly share code, notes, and snippets.

@bt4R9
Created October 5, 2015 08:18
Show Gist options
  • Save bt4R9/0c2adcff55407be857d9 to your computer and use it in GitHub Desktop.
Save bt4R9/0c2adcff55407be857d9 to your computer and use it in GitHub Desktop.
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
ListView,
AlertIOS
} = React;
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF'
},
welcome: {
fontSize: 26,
textAlign: 'center',
margin: 10
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5
},
st2: {
textAlign: 'center',
color: 'rgba(0,0,0, 0.5)',
backgroundColor: '#F5FCFF',
height: 30
}
});
var AwesomeProject = React.createClass({
getInitialState: function() {
var mockedData = [
<Text onPress={() => this._pressRow()} style={styles.st2}>message1</Text>,
<Text onPress={() => this._pressRow()} style={styles.st2}>message2</Text>,
<Text onPress={() => this._pressRow()} style={styles.st2}>message3</Text>,
<Text onPress={() => this._pressRow()} style={styles.st2}>message4</Text>,
<Text onPress={() => this._pressRow()} style={styles.st2}>message5</Text>,
];
var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
return {
dataSource: ds.cloneWithRows(mockedData)
};
},
_pressRow: function(data) {
AlertIOS.alert('ololo');
},
render: function() {
return (
<View style={styles.container}>
<ListView
dataSource={this.state.dataSource}
renderRow={(rowData) => rowData}
/>
</View>
);
}
});
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment