Created
May 14, 2017 13:46
-
-
Save drmas/406a5b041dcd153065cfa4b004b56e84 to your computer and use it in GitHub Desktop.
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
/** | |
* Sample React Native App | |
* https://github.com/facebook/react-native | |
* @flow | |
*/ | |
import React, { Component } from 'react'; | |
import { | |
AppRegistry, | |
StyleSheet, | |
Text, | |
View, | |
TextInput, | |
ListView | |
} from 'react-native'; | |
const ds = new ListView.DataSource({ | |
rowHasChanged: (r1, r2) => r1 !== r2 | |
}) | |
const data = ['Add item', 'Delete item'] | |
class Project extends Component { | |
state = { | |
dataSource: ds.cloneWithRows(data) | |
} | |
renderRow = (rowData) => { | |
return ( | |
<View style={styles.itemContainer} > | |
<Text style={styles.item} >{rowData}</Text> | |
</View> | |
) | |
} | |
render() { | |
return ( | |
<View style={styles.container}> | |
<Text style={styles.welcome}> | |
TODO | |
</Text> | |
<TextInput | |
style={styles.textInput} | |
placeholder='Add item todo' | |
/> | |
<ListView | |
dataSource={this.state.dataSource} | |
renderRow={this.renderRow} | |
/> | |
</View> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
alignItems: 'stretch', | |
backgroundColor: '#fff', | |
}, | |
welcome: { | |
fontSize: 20, | |
textAlign: 'center', | |
marginTop: 22, | |
}, | |
instructions: { | |
textAlign: 'center', | |
color: '#333333', | |
marginBottom: 5, | |
}, | |
textInput: { | |
height: 50, | |
padding: 8, | |
borderWidth: 1, | |
borderColor: '#eaeaea', | |
margin: 8 | |
}, | |
itemContainer: { | |
padding: 8, | |
borderBottomWidth: 1, | |
borderColor: '#eaeaea' | |
}, | |
item: { | |
fontSize: 18 | |
} | |
}); | |
AppRegistry.registerComponent('Project', () => Project); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment