Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.51 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import axios from 'axios'
  3. import { Header, Text, Left, Body, Right, Button, Icon, Thumbnail, Content, Container, Spinner } from 'native-base';
  4. import { TouchableOpacity, ImageBackground, Dimensions, Image, View, Share } from 'react-native';
  5.  
  6. export default class MovieInfo extends Component {
  7. constructor() {
  8. super();
  9. this.state = {
  10. data: null
  11. }
  12. }
  13.  
  14. componentDidMount() {
  15. this.makeRemoteRequest()
  16. }
  17.  
  18. makeRemoteRequest = () => {
  19. const { page, limit } = this.state
  20. const url = 'http://192.168.0.62:3333/movies/' + this.props.navigation.state.params.id
  21. this.setState({ loading: true })
  22. axios.get(url)
  23. .then(async res => {
  24. await this.setState({
  25. data: res.data
  26. })
  27. {console.warm(this.state.data.movies[0].genre.split(','))}
  28. })
  29. .catch(error => {
  30. this.setState({ error, loading: false, refreshing: false })
  31. });
  32. }
  33.  
  34. handleShare = (title,link) => {
  35. Share.share({
  36. message: 'Ayo nonton film '+title+' gratis di '+link,
  37. url: link,
  38. title: 'ELANG 4'
  39. }, {
  40. // Android only:
  41. dialogTitle: 'Bagikan film '+ title,
  42. // iOS only:
  43. excludedActivityTypes: [
  44. 'com.apple.UIKit.activity.PostToTwitter'
  45. ]
  46. })
  47. }
  48. render() {
  49. return (
  50. <Container>
  51. {this.state.data !== null ?
  52. <ImageBackground
  53. source={{ uri: this.props.navigation.state.params.thumbnails }}
  54. style={{ width: '100%', height: '100%', filter: 'blur' }}
  55. blurRadius={3}
  56. >
  57. <Header
  58. transparent
  59. androidStatusBarColor="#d1d1d1"
  60. toolbarDefaultBorder="#ffffff"
  61. style={{ zIndex: 1000 }}
  62. >
  63. <Left>
  64. <TouchableOpacity
  65. onPress={() => this.props.navigation.pop()}
  66. >
  67. <Icon style={{ color: "#fff", fontSize: 25 }} name="arrow-left" type="MaterialCommunityIcons" />
  68. </TouchableOpacity>
  69. </Left>
  70. <Body />
  71. <Right>
  72. <Button transparent>
  73. <Icon onPress={() => this.props.navigation.navigate('Search')} style={{ color: "#fff", fontSize: 25 }} name='search' type="Feather" />
  74. </Button>
  75. </Right>
  76. </Header>
  77. <Content>
  78. <View>
  79. <Body>
  80. <Image backgroundColor='#000' source={{ uri: this.state.data.movies[0].thumbnails }} style={{ width: 218, height: 323, }} />
  81. <Text style={{ color: '#fff', fontWeight: 'bold', marginTop: 10 }}>{this.state.data.movies[0].title.split(' Sub')[0].replace('Nonton', '')}</Text>
  82. <Text style={{ color: '#fff', marginTop: 10 }}>{this.state.data.movies[0].genre.split(',')[0]} | {this.state.data.movies[0].genre.split(',').filter(genre => genre != this.state.data.movies[0].genre.split(',')[0])+','} | {this.state.data.movies[0].rating}</Text>
  83. <View style={{ flex: 1, flexDirection: 'row', marginTop: 10 }}>
  84. <Button
  85. onPress={()=>this.handleShare(this.state.data.movies[0].title.split(' (')[0], "http://192.168.0.23/movies/"+this.state.data.movies[0].slug)}
  86. style={{ borderRadius: 10, shadowColor: 'none', marginLeft: 8, backgroundColor: 'rgba(255,255,255,0.05)' }}>
  87. <Icon name="share" />
  88. </Button>
  89. <Button style={{ borderRadius: 10, shadowColor: 'none', marginLeft: 8, backgroundColor: 'rgba(255,255,255,0.05)' }}>
  90. <Icon name="download" type="FontAwesome" />
  91. </Button>
  92. <Button style={{ borderRadius: 10, shadowColor: 'none', marginLeft: 8, backgroundColor: 'rgba(255,255,255,0.05)' }}>
  93. <Icon name="controller-play" type="Entypo" />
  94. </Button>
  95. </View>
  96.  
  97.  
  98. </Body>
  99. </View>
  100.  
  101. </Content>
  102. </ImageBackground>
  103. :
  104. <ImageBackground
  105. source={{ uri: this.props.navigation.state.params.thumbnails }}
  106. style={{ width: '100%', height: '100%', filter: 'blur' }}
  107. blurRadius={3}
  108. ><Spinner /></ImageBackground>}
  109. </Container>
  110. );
  111. }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement