import React, { useRef, useState } from 'react'; import { View, Image, Text } from 'react-native'; import { Swiper, Button, Size } from '@xrnjs/ui'; import Card from '_global/Card'; import styles from './style'; import type { SwiperInstance } from '../interface'; const logo = { uri: 'https://reactnative.dev/img/tiny_logo.png', width: 200, height: 200, }; const AdvancedFeatures = () => { const swiperRef = useRef(null); const [currentIndex, setCurrentIndex] = useState(0); const [isPaused, setIsPaused] = useState(false); const handleSwipeNext = () => { swiperRef.current?.swipeNext(); }; const handleSwipePrev = () => { swiperRef.current?.swipePrev(); }; const handleSwipeTo = (index: number) => { swiperRef.current?.swipeTo(index); }; const handleTogglePause = () => { if (isPaused) { swiperRef.current?.resume(); } else { swiperRef.current?.pause(); } setIsPaused(!isPaused); }; const handleChange = (index: number) => { setCurrentIndex(index); }; return ( 手动控制轮播 通过 ref 手动控制轮播行为 {Array.from({ length: 5 }).map((_, index) => ( 第{index + 1}页 ))} {Array.from({ length: 5 }).map((_, index) => ( ))} 禁用手势滑动 禁用手势滑动,只能自动轮播 {Array.from({ length: 3 }).map((_, index) => ( 第{index + 1}页 ))} 后台继续播放 App 切换到后台时继续自动播放 {Array.from({ length: 3 }).map((_, index) => ( 第{index + 1}页 ))} 自定义尺寸 自定义轮播图的宽度和高度 {Array.from({ length: 3 }).map((_, index) => ( 第{index + 1}页 ))} ); }; export default AdvancedFeatures;