Guest User

Untitled

a guest
Feb 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. import React, { Component } from 'react'
  2. import {
  3. StyleSheet,
  4. View,
  5. Image,
  6. Text } from 'react-native'
  7. import Swiper from 'react-native-swiper'
  8. import { connect } from 'react-redux'
  9. import { fetchBanners } from '../actions'
  10.  
  11.  
  12. const styles = StyleSheet.create({
  13. slide1: {
  14. flex: 1,
  15. justifyContent: 'center',
  16. alignItems: 'center',
  17. backgroundColor: '#9DD6EB',
  18. },
  19. slide2: {
  20. flex: 1,
  21. justifyContent: 'center',
  22. alignItems: 'center',
  23. backgroundColor: '#97CAE5',
  24. },
  25. slide3: {
  26. flex: 1,
  27. justifyContent: 'center',
  28. alignItems: 'center',
  29. backgroundColor: '#92BBD9',
  30. },
  31. text: {
  32. color: '#fff',
  33. fontSize: 30,
  34. fontWeight: 'bold',
  35. }
  36. })
  37.  
  38.  
  39.  
  40. class Banners extends Component {
  41. componentDidMount(){
  42. this.props.dispatch(fetchBanners())
  43. }
  44.  
  45. render(){
  46. return (
  47. <Swiper style={{ flex: 1 }} showsButtons={true}>
  48. {
  49. !this.props.isFetchingBanners &&
  50. this.props.data_banners.length > 0 &&
  51. this.props.data_banners.map((data, index) => (
  52. <View style={styles.slide1} key={index} >
  53. <Image
  54. style={{ height: '100%', width: '100%' }}
  55. source={{ uri: data.image }} />
  56. </View>
  57. ))
  58. }
  59. </Swiper>
  60. )
  61. }
  62. }
  63.  
  64.  
  65. const mapStateToProps = (state) => {
  66. return {
  67. isFetchingBanners: state.banners.isFetching,
  68. data_banners: state.banners.items
  69. }
  70. }
  71.  
  72. export default connect(mapStateToProps)(Banners)
Add Comment
Please, Sign In to add comment