yosadade

TerkiniTab.js

Feb 16th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.01 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { Container, Content, Text } from 'native-base'
  3. import { Image, SafeAreaView, FlatList, TouchableOpacity, StyleSheet, View } from 'react-native'
  4.  
  5. // import DATA from '../data/Data.json';
  6. import TerkiniMain from '../mainscreens/TerkiniMain';
  7. import SplashScreen from '../../login/SplashScreen';
  8.  
  9. export default class Terkini extends Component {
  10. constructor(props){
  11. super(props)
  12. this.state = {
  13. terkiniBeritas: [
  14. {
  15. id: 1,
  16. judul: 'Ekonomi Yogyakarta pada Kuartal II 2019 Tumbuh 6,80%',
  17. ilustrasi: 'https://pict.sindonews.net/dyn/180/content/2019/08/06/33/1427094/ekonomi-yogyakarta-pada-kuartal-ii-2019-tumbuh-6-80-ATR-thumb.jpg',
  18. kategori: 'Ekonomi',
  19. tgl: 'Selasa, 6 Agustus 2019 - 00.60 WIB',
  20. isi: ''
  21. },
  22. {
  23. id: 2,
  24. judul: 'Ekonomi Yogyakarta pada Kuartal II 2019 Tumbuh 6,80%',
  25. ilustrasi: 'http://www.rmolsumsel.com/images/berita/normal/2019/10/445389_09523421102019_nadiem.jpg',
  26. kategori: 'Ekonomi',
  27. tgl: 'Selasa, 6 Agustus 2019 - 00.60 WIB',
  28. isi: ''
  29. },
  30. {
  31. id: 3,
  32. judul: 'Wishnutama Calon Menteri Jokowi 2019 sampai 2024, Ini Profilnya',
  33. ilustrasi: 'https://akcdn.detik.net.id/community/media/visual/2019/10/21/8dcddc8a-f578-4f3d-8f6f-9c18c2b2d997_43.jpeg?w=780&q=90',
  34. kategori: 'Politik',
  35. tgl: 'Selasa, 6 Agustus 2019 - 00.60 WIB',
  36. isi: ''
  37. },
  38. {
  39. id: 4,
  40. judul: 'Erick Thohir Bersedia Jadi Menteri Meski Berat Tinggalkan Bisnisnya',
  41. ilustrasi: 'https://asset.kompas.com/crops/tpxTuMItA9KrUsJe1bf73_2Imd0=/325x53:1473x818/750x500/data/photo/2019/10/21/5dad343d66fca.jpg',
  42. kategori: 'Olahraga',
  43. tgl: 'Selasa, 6 Agustus 2019 - 00.60 WIB',
  44. isi: ''
  45. },
  46. {
  47. id: 5,
  48. judul: 'Anak Muda, 8 Calon Menteri Jokowi: 2 Anak Eks Presiden',
  49. ilustrasi: 'https://cdn2.tstatic.net/makassar/foto/bank/images/presiden-joko-widodo-atau-jokowi-2-120092019.jpg',
  50. kategori: 'Hiburan',
  51. tgl: 'Selasa, 6 Agustus 2019 - 00.60 WIB',
  52. isi: ''
  53. },
  54. {
  55. id: 6,
  56. judul: 'Jadwal Siaran Langsung SCTV Liga Champions Pekan Ini: 22 Dan 23 Oktober 2019',
  57. ilustrasi: 'https://cdn0-production-images-kly.akamaized.net/bLyQUozygokhj5PFx9YJMMWiAno=/640x360/smart/filters:quality(75):strip_icc():format(webp)/kly-media-production/medias/1065523/original/000761100_1448366132-CL-logo.jpg',
  58. kategori: 'Olahraga',
  59. tgl: 'Selasa, 6 Agustus 2019 - 00.60 WIB',
  60. isi: ''
  61. },
  62. ]
  63. }
  64. }
  65.  
  66. render() {
  67. console.log(this.props)
  68. const data = this.state.terkiniBeritas
  69. if (data.lenght===0){
  70. return <SplashScreen/>
  71. }
  72. return (
  73. <Container style={{backgroundColor: 'black'}}>
  74. <Content>
  75.  
  76. {/* header mainscreens */}
  77.  
  78. <View style={{flex: 1, backgroundColor: '#2E3136'}}>
  79. <TouchableOpacity
  80. onPress={() => this.props.navigation.navigate('TerkiniDesc')}
  81. >
  82. <Image source={{uri: this.state.terkiniBeritas[0].ilustrasi}} style={darkStyles.imageHeadline} />
  83. <View style={darkStyles.backgroundHeadline}/>
  84. <Text note numberOfLines={1} style={darkStyles.kategoriHeadline}>{ this.state.terkiniBeritas[0].kategori }</Text>
  85. <Text numberOfLines={2} style={darkStyles.judulHeadline}>{ this.state.terkiniBeritas[0].judul }</Text>
  86. <Text note numberOfLines={1} style={darkStyles.tglHeadline}>{ this.state.terkiniBeritas[0].tgl }</Text>
  87. </TouchableOpacity>
  88. </View>
  89.  
  90. <SafeAreaView style={{borderTopLeftRadius: 17,borderTopRightRadius: 17, backgroundColor: '#FFFFFF'}}>
  91. <FlatList
  92. // jika dari Data.json
  93. // data = {DATA}
  94. data = {this.state.terkiniBeritas}
  95. renderItem = {({ item }) => {
  96. return(
  97. <TerkiniMain
  98. judul={item.judul}
  99. ilustrasi={item.ilustrasi}
  100. tgl={item.tgl}
  101. kategori={item.kategori}
  102. navigation={this.props.navigation}
  103. />
  104. )
  105. }}
  106. keyExtractor= {(item, index) => index.toString()}
  107. />
  108. </SafeAreaView>
  109. </Content>
  110. </Container>
  111. )
  112. }
  113. }
  114.  
  115. const darkStyles = StyleSheet.create({
  116. container: {
  117. flex: 1,
  118. backgroundColor: '#2E3136'
  119. },
  120. backgroundHeadline: {
  121. backgroundColor:'black',
  122. position:'absolute',
  123. width:'100%',
  124. height:220,
  125. opacity: 0.5,
  126. },
  127. imageHeadline: {
  128. height: 240,
  129. width: null,
  130. flex: 1,
  131. },
  132. judulHeadline: {
  133. marginHorizontal: 10,
  134. fontSize: 22 ,
  135. color: 'white',
  136. position: 'absolute',
  137. textAlign: 'left',
  138. alignSelf: 'center',
  139. marginTop: 150,
  140. fontWeight: '700'
  141. },
  142. kategoriHeadline: {
  143. marginHorizontal: 10,
  144. fontSize: 17 ,
  145. color: 'white',
  146. position: 'absolute',
  147. textAlign: 'center',
  148. justifyContent: 'center',
  149. marginTop: 125,
  150. fontWeight: '700',
  151. width: 80,
  152. backgroundColor: '#2980b9'
  153. },
  154. tglHeadline: {
  155. marginHorizontal: 10,
  156. fontSize: 14,
  157. position: 'absolute',
  158. textAlign: 'center',
  159. justifyContent: 'center',
  160. marginTop: 205,
  161. fontWeight: '500',
  162. color: '#dcdede'
  163. },
  164. })
Add Comment
Please, Sign In to add comment