Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. <Content>
  2. <Grid style={{flexWrap: 'wrap', flex: 1}}>
  3. {this.state.stories.map(function(story, index){
  4. if (index % 2 === 0) {
  5. return <Col key={ index } style={{margin: 5, width: Dimensions.get('window').width / 2.2}}>
  6. <View>
  7. <Image style={{ height: 250, borderRadius: 10}} source={{uri: story.picture_url}} />
  8. </View>
  9. </Col>
  10. } else{
  11. return <Col key={ index } style={{margin: 5, width: Dimensions.get('window').width / 2.2}}>
  12. <View style={{marginTop: 25}}>
  13. <Image style={{height: 250, borderRadius: 10}} source={{uri: story.picture_url}} />
  14. </View>
  15. </Col>
  16. }
  17. }.bind(this))
  18. }
  19. </Grid>
  20. </Content>
  21.  
  22. /**
  23. * Sample React Native App
  24. * https://github.com/facebook/react-native
  25. * @flow
  26. */
  27.  
  28. import React, { Component } from 'react';
  29. import {
  30. AppRegistry,
  31. StyleSheet,
  32. Text,
  33. View
  34. } from 'react-native';
  35.  
  36. export default class layout extends Component {
  37. render() {
  38. return (
  39. <View style={styles.container}>
  40. <View style={styles.column}>
  41. <View style={[styles.box, {backgroundColor:'red'}]}/>
  42. <View style={[styles.box, {backgroundColor:'pink'}]}/>
  43. <View style={[styles.box, {backgroundColor:'orange'}]}/>
  44. </View>
  45. <View style={styles.space_between_columns}/>
  46. <View style={styles.column}>
  47. <View style={[styles.box, {backgroundColor:'blue'}]}/>
  48. <View style={[styles.box, {backgroundColor:'green'}]}/>
  49. <View style={[styles.box, {backgroundColor:'purple'}]}/>
  50. </View>
  51. </View>
  52. );
  53. }
  54. }
  55.  
  56. const styles = StyleSheet.create({
  57. container: {
  58. flex: 1,
  59. flexDirection:'row',
  60. justifyContent: 'center',
  61. alignItems: 'center',
  62. backgroundColor: '#F5FCFF',
  63. },
  64. column: {
  65. flexDirection:'column',
  66. justifyContent:'space-between',
  67. alignItems:'center',
  68. height:200,
  69. width:50
  70. },
  71. space_between_columns:{
  72. width:100
  73. },
  74. box: {
  75. height:50,
  76. width:50
  77. }
  78. });
  79.  
  80. AppRegistry.registerComponent('layout', () => layout);
  81.  
  82. <Content>
  83. <Grid style={{flexWrap: 'wrap', flex: 1}}>
  84. {this.state.stories.map(function(story, index){
  85. if (index % 2 === 0) {
  86. return
  87. <Row style={{flex:1}}>
  88. <Col key={ index } style={{margin: 5, flex:.5}}>
  89. <View>
  90. <Image style={{ height: 250, borderRadius: 10}} source={{uri: story.picture_url}} />
  91. </View>
  92. </Col>
  93. {(() => { if (index + 1 < (this.state.subjects.length - 1)) {
  94. return <Col key={ index + 1 } style={{margin: 5, flex:.5}}>
  95. <View style={{marginTop: 25}}>
  96. <Image style={{height: 250, borderRadius: 10}} source={{uri: this.state.stories[index+1].picture_url}} />
  97. </View>
  98. </Col>
  99. }
  100. else
  101. {
  102. return <Col style={{margin: 5, flex:.5}}/>
  103. }
  104. })()}
  105.  
  106. }
  107.  
  108. }.bind(this))
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement