Swiper.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * @param:
  3. * autoPlay: 是否自动播放;
  4. * loop: 是否循环,无缝滚动
  5. * ifShowMiddle: 轮播图是否从中间的索引开始
  6. * @todo: 首页轮播图和主题适用
  7. */
  8. import React, { Component } from "react";
  9. import {
  10. StyleSheet,
  11. View,
  12. Image
  13. } from "react-native";
  14. import Dimensions from '../utils/dimensions';
  15. import Swiper from "react-native-swiper";
  16. export default class Swipers extends Component {
  17. render() {
  18. return (
  19. <View style={styles.Carousel}>
  20. <Swiper
  21. style={{ flex: 1 }}
  22. horizontal={true}
  23. autoplayTimeout={5}
  24. autoplay={this.props.autoplay}
  25. loop={this.props.loop}
  26. index={this.props.ifShowMiddle ? 1 : 0}
  27. activeDotColor="#fff"
  28. showsPagination={false}
  29. >
  30. <View style={styles.slide}>
  31. <Image
  32. source={{
  33. uri:
  34. "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1295208965,3056573814&fm=26&gp=0.jpg"
  35. }}
  36. style={styles.img}
  37. />
  38. </View>
  39. <View style={styles.slide}>
  40. <Image
  41. source={{
  42. uri:
  43. "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1295208965,3056573814&fm=26&gp=0.jpg"
  44. }}
  45. style={styles.img}
  46. />
  47. </View>
  48. </Swiper>
  49. </View>
  50. );
  51. }
  52. }
  53. const styles = StyleSheet.create({
  54. Carousel: {
  55. // width: '100%',
  56. // height: 153,
  57. flex:1,
  58. borderRadius: 10,
  59. overflow: 'hidden'
  60. },
  61. wrapper: {
  62. width: '100%'
  63. },
  64. slide: {
  65. width: 352,
  66. height: 153,
  67. justifyContent: "center",
  68. alignItems: "center",
  69. borderRadius: 10,
  70. marginHorizontal:6
  71. },
  72. img: {
  73. width: 352,
  74. height: 153,
  75. borderRadius: 10
  76. }
  77. });