feat: 新增动画资源与庆祝效果,优化布局与标签页配置
This commit is contained in:
62
components/CelebrationAnimation.tsx
Normal file
62
components/CelebrationAnimation.tsx
Normal file
@@ -0,0 +1,62 @@
|
||||
import LottieView from 'lottie-react-native';
|
||||
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
||||
import {
|
||||
Dimensions,
|
||||
StyleSheet,
|
||||
View,
|
||||
} from 'react-native';
|
||||
|
||||
export interface CelebrationAnimationRef {
|
||||
play: () => void;
|
||||
}
|
||||
|
||||
interface CelebrationAnimationProps {
|
||||
visible?: boolean;
|
||||
}
|
||||
|
||||
const CelebrationAnimation = forwardRef<CelebrationAnimationRef, CelebrationAnimationProps>(
|
||||
({ visible = true }, ref) => {
|
||||
const animationRef = useRef<LottieView>(null);
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
play: () => {
|
||||
animationRef.current?.play();
|
||||
},
|
||||
}));
|
||||
|
||||
if (!visible) return null;
|
||||
|
||||
return (
|
||||
<View style={styles.container} pointerEvents="none">
|
||||
<LottieView
|
||||
ref={animationRef}
|
||||
autoPlay={false}
|
||||
loop={false}
|
||||
source={require('@/assets/lottie/Confetti.json')}
|
||||
style={styles.animation}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
zIndex: 9999,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
animation: {
|
||||
width: Dimensions.get('window').width,
|
||||
height: Dimensions.get('window').height,
|
||||
},
|
||||
});
|
||||
|
||||
CelebrationAnimation.displayName = 'CelebrationAnimation';
|
||||
|
||||
export default CelebrationAnimation;
|
||||
Reference in New Issue
Block a user