-
-
Save VonD/a530d21a53499a085080 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 | |
*/ | |
'use strict'; | |
var React = require('react-native'); | |
var { | |
AppRegistry, | |
StyleSheet, | |
Text, | |
View, | |
Image, | |
CameraRoll | |
} = React; | |
var TestImagesLoadingTime = React.createClass({ | |
getInitialState: function(){ | |
return {}; | |
}, | |
componentDidMount: function(){ | |
CameraRoll.getPhotos({first: 1}, function(data){ | |
if (!data.edges.length) return; | |
this.setState({ | |
picture: data.edges[0].node.image.uri | |
}); | |
}.bind(this), console.log); | |
}, | |
render: function() { | |
return ( | |
<View style={styles.container}> | |
<Text style={styles.welcome}> | |
Welcome to React Native! | |
</Text> | |
<Text style={styles.instructions}> | |
To get started, edit index.ios.js | |
</Text> | |
<Text style={styles.instructions}> | |
Press Cmd+R to reload,{'\n'} | |
Cmd+Control+Z for dev menu | |
</Text> | |
{ | |
this.state.picture && | |
<Image | |
style={ styles.pic } | |
source={ {uri: this.state.picture} } | |
> | |
<Text style={ styles.loading }>rendering { this.state.picture }…</Text> | |
</Image> | |
} | |
</View> | |
); | |
} | |
}); //source={ {uri: "http://www.counterpunch.org/wp-content/dropzone/2014/09/KillingTrayvons_Cover1-291x450.jpg"} } | |
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, | |
}, | |
loading: { | |
fontSize: 12, | |
color: 'grey' | |
}, | |
pic: { | |
height: 200, | |
width: 200, | |
borderWidth: 1, | |
borderColor: 'red', | |
justifyContent: 'center', | |
alignItems: 'center' | |
} | |
}); | |
AppRegistry.registerComponent('TestImagesLoadingTime', () => TestImagesLoadingTime); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment