import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; import React, { useRef, useState } from 'react'; import { GoGoSpin } from '../src/index'; const prize = [ { name: 'x999', image: require('./images/king.png') }, { name: 'x10', image: require('./images/prize.png') }, { name: 'x50', image: require('./images/prize.png') }, { name: 'x80', image: require('./images/prize.png') }, { name: 'x100', image: require('./images/prize.png') }, { name: 'x200', image: require('./images/prize.png') }, ]; const SIZE = 300; export const App = () => { const spinRef = useRef>(null); const [prizeIdx, setprizeIdx] = useState(-1); const doSpin = () => { const getIdx = Math.floor(Math.random() * prize.length); setprizeIdx(getIdx); spinRef?.current?.doSpinAnimate(getIdx); }; const onEndSpin = (endSuccess: boolean) => { console.log('endSuccess', endSuccess); }; return ( 奖品:{prizeIdx !== -1 ? prize[prizeIdx]?.name : ''} { return ( {data.name} ); }} /> ); }; const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#000', }, startText: { fontSize: 14, color: '#000', fontWeight: 'bold', }, rowContainer: { flexDirection: 'row', alignItems: 'center', alignSelf: 'center', marginVertical: 20, }, prizeText: { color: '#fff', fontSize: 20, fontWeight: 'bold', }, centerWheel: { width: SIZE, height: SIZE, alignSelf: 'center', justifyContent: 'center', alignItems: 'center', }, itemWrapper: { justifyContent: 'center', alignItems: 'center', }, spinBtn: { width: 105, height: 124 }, spinWarp: { position: 'absolute' }, itemWrap: { width: 40, height: 40 }, }); export default App;