import React, { useState, useEffect } from 'react'; import { View, Text, Image } from 'react-native'; import Swiper from '../swiper'; import SwiperItem from '../swiperitem'; import Icon from '../icon'; import { DemoPage, DemoCard } from '../configprovider/styles/demo.page'; import { useTranslate } from '../utils'; interface T { basic: string; asyc: string; dynamicDel: string; size: string; indicator: string; btns: string; vertical: string; horizontalCenter: string; verticalCenter: string; } const SwiperDemo = () => { const [translated] = useTranslate({ 'zh-CN': { basic: '基本用法', asyc: '异步加载(3s)', dynamicDel: '动态加载', size: '自定义大小', indicator: '自定义指示器', btns: '手动切换', vertical: '垂直方向', horizontalCenter: '水平居中展示', verticalCenter: '垂直居中展示' }, 'en-US': { basic: 'Basic Usage', asyc: 'Asynchronous loading(3s)', dynamicDel: 'Dynamic loading', size: 'Custom size', indicator: 'Custom indicator', btns: 'Manual switching', vertical: 'Vertical direction', horizontalCenter: 'Horizontal center display', verticalCenter: 'Vertical center display' } }); const swiperRef = React.useRef(null); const [list, setList] = useState([]); const [list1, setList1] = useState([ 'https://storage.360buyimg.com/jdc-article/NutUItaro34.jpg', 'https://storage.360buyimg.com/jdc-article/NutUItaro2.jpg', 'https://storage.360buyimg.com/jdc-article/welcomenutui.jpg', 'https://storage.360buyimg.com/jdc-article/fristfabu.jpg' ]); const [current, setCurrent] = useState(1); const [current2, setCurrent2] = useState(1); const onChange3 = (e) => { setCurrent(e + 1); }; const onChange4 = (e) => { setCurrent2(e + 1); }; const handlePrev = () => { swiperRef.current.prev(); }; const handleNext = () => { swiperRef.current.next(); }; useEffect(() => { setTimeout(() => { const arr: string[] = [ 'https://storage.360buyimg.com/jdc-article/NutUItaro34.jpg', 'https://storage.360buyimg.com/jdc-article/NutUItaro2.jpg', 'https://storage.360buyimg.com/jdc-article/welcomenutui.jpg', 'https://storage.360buyimg.com/jdc-article/fristfabu.jpg' ]; setList(arr); }, 3000); }, []); useEffect(() => { setTimeout(() => { const arr = list1.slice(); arr.splice(1, 1); setList1(arr); }, 3000); }, []); return ( {list.map((item) => { return ( ); })} {list1.map((item) => { return ( ); })} {current}/4 } > {current2}/4 )} > {list.map((item) => { return ( ); })} { handlePrev(); }} > { handleNext(); }} > ); }; export default SwiperDemo;