feat: wake页面优化

This commit is contained in:
jinyaqiu 2025-08-05 15:13:56 +08:00
parent aa03a6798a
commit 40b6c89f27
3 changed files with 53 additions and 5 deletions

View File

@ -1,9 +1,8 @@
import IP from '@/assets/icons/svg/ip.svg';
import { checkAuthStatus } from '@/lib/auth'; import { checkAuthStatus } from '@/lib/auth';
import { useRouter } from 'expo-router'; import { useRouter } from 'expo-router';
import React, { useEffect, useRef, useState } from 'react'; import React, { useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Animated, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; import { Animated, Dimensions, Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import { useSafeAreaInsets } from "react-native-safe-area-context"; import { useSafeAreaInsets } from "react-native-safe-area-context";
export default function HomeScreen() { export default function HomeScreen() {
@ -12,6 +11,9 @@ export default function HomeScreen() {
const insets = useSafeAreaInsets(); const insets = useSafeAreaInsets();
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
// 获取屏幕宽度
const screenWidth = Dimensions.get('window').width;
// 动画值 // 动画值
const fadeAnim = useRef(new Animated.Value(0)).current; // IP图标的淡入动画 const fadeAnim = useRef(new Animated.Value(0)).current; // IP图标的淡入动画
const shakeAnim = useRef(new Animated.Value(0)).current; // IP图标的摇晃动画 const shakeAnim = useRef(new Animated.Value(0)).current; // IP图标的摇晃动画
@ -20,6 +22,7 @@ export default function HomeScreen() {
const buttonAnim = useRef(new Animated.Value(0)).current; // 按钮的淡入动画 const buttonAnim = useRef(new Animated.Value(0)).current; // 按钮的淡入动画
const buttonShakeAnim = useRef(new Animated.Value(0)).current; // 按钮的摇晃动画 const buttonShakeAnim = useRef(new Animated.Value(0)).current; // 按钮的摇晃动画
const buttonLoopAnim = useRef<Animated.CompositeAnimation | null>(null); // 按钮循环动画引用 const buttonLoopAnim = useRef<Animated.CompositeAnimation | null>(null); // 按钮循环动画引用
const fadeInAnim = useRef(new Animated.Value(0)).current;
// 文本行动画值 // 文本行动画值
const [textAnimations] = useState(() => ({ const [textAnimations] = useState(() => ({
@ -121,6 +124,20 @@ export default function HomeScreen() {
]).start(() => resolve()); ]).start(() => resolve());
}); });
}; };
// 启动欢迎语动画
const startWelcomeAnimation = () => {
// IP图标显示后淡入描述文本
return new Promise<void>((resolve) => {
Animated.sequence([
Animated.delay(200), // IP图标显示后延迟200ms
Animated.timing(fadeInAnim, {
toValue: 1,
duration: 800,
useNativeDriver: true,
})
]).start(() => resolve());
});
};
// 启动按钮动画 // 启动按钮动画
const startButtonAnimation = () => { const startButtonAnimation = () => {
@ -224,6 +241,7 @@ export default function HomeScreen() {
startShaking(); startShaking();
// IP显示后开始文本动画 // IP显示后开始文本动画
startTextAnimations() startTextAnimations()
.then(() => startWelcomeAnimation())
.then(() => startDescriptionAnimation()) .then(() => startDescriptionAnimation())
.then(() => startButtonAnimation()) .then(() => startButtonAnimation())
.catch(console.error); .catch(console.error);
@ -240,6 +258,7 @@ export default function HomeScreen() {
animationRef.current.stop(); animationRef.current.stop();
} }
}; };
}, []); }, []);
// 动画样式 // 动画样式
@ -342,11 +361,40 @@ export default function HomeScreen() {
{t('auth.welcomeAwaken.slogan', { ns: 'login' })} {t('auth.welcomeAwaken.slogan', { ns: 'login' })}
</Animated.Text> </Animated.Text>
</View> </View>
{/* 欢迎语 */}
<View style={{ alignItems: 'flex-end' }}>
<Animated.View
style={[{
height: screenWidth * 0.3,
width: screenWidth * 0.3,
marginTop: -screenWidth * 0.08,
opacity: fadeInAnim,
transform: [{
translateY: fadeInAnim.interpolate({
inputRange: [0, 1],
outputRange: [20, 0]
})
}]
}]}
>
<Image
source={require('@/assets/images/png/icon/think.png')}
style={{
width: '100%',
height: '100%',
resizeMode: 'contain'
}}
/>
</Animated.View>
</View>
{/* Animated IP */} {/* Animated IP */}
<View style={styles.ipContainer}> <View style={styles.ipContainer}>
<Animated.View style={[styles.ipWrapper, { transform: [{ rotate }] }]}> <Animated.View style={[styles.ipWrapper, { transform: [{ rotate }] }]}>
<IP /> <Image
source={require('@/assets/images/png/icon/ip.png')}
style={{ width: screenWidth * 0.9, marginBottom: - screenWidth * 0.18, marginTop: -screenWidth * 0.22 }}
/>
</Animated.View> </Animated.View>
</View> </View>
@ -373,6 +421,7 @@ export default function HomeScreen() {
{/* 唤醒按钮 */} {/* 唤醒按钮 */}
<Animated.View <Animated.View
style={{ style={{
alignItems: "center",
opacity: buttonAnim, opacity: buttonAnim,
transform: [ transform: [
{ {
@ -469,13 +518,12 @@ const styles = StyleSheet.create({
backgroundColor: '#FFFFFF', backgroundColor: '#FFFFFF',
borderRadius: 28, borderRadius: 28,
paddingVertical: 16, paddingVertical: 16,
paddingHorizontal: 40,
shadowColor: '#000', shadowColor: '#000',
shadowOffset: { width: 0, height: 2 }, shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.1, shadowOpacity: 0.1,
shadowRadius: 4, shadowRadius: 4,
elevation: 2, elevation: 2,
width: '100%', width: '86%',
alignItems: 'center', alignItems: 'center',
marginTop: 24, marginTop: 24,
}, },

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB