feat: 新增动画资源与庆祝效果,优化布局与标签页配置

This commit is contained in:
richarjiang
2025-09-03 15:03:26 +08:00
parent 8b6ef378d0
commit 951c02f644
14 changed files with 373 additions and 267 deletions

View File

@@ -1,3 +1,4 @@
import CelebrationAnimation, { CelebrationAnimationRef } from '@/components/CelebrationAnimation';
import GoalTemplateModal from '@/components/GoalTemplateModal';
import { GoalsPageGuide } from '@/components/GoalsPageGuide';
import { GuideTestButton } from '@/components/GuideTestButton';
@@ -20,8 +21,9 @@ import { GoalNotificationHelpers } from '@/utils/notificationHelpers';
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
import { useFocusEffect } from '@react-navigation/native';
import dayjs from 'dayjs';
import * as Haptics from 'expo-haptics';
import { LinearGradient } from 'expo-linear-gradient';
import React, { useCallback, useEffect, useState } from 'react';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { Alert, FlatList, Image, RefreshControl, SafeAreaView, StatusBar, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
export default function GoalsScreen() {
@@ -58,6 +60,9 @@ export default function GoalsScreen() {
const [showGuide, setShowGuide] = useState(false); // 控制引导显示
const [selectedTemplateData, setSelectedTemplateData] = useState<Partial<CreateGoalRequest> | undefined>();
// 庆祝动画引用
const celebrationAnimationRef = useRef<CelebrationAnimationRef>(null);
// 页面聚焦时重新加载数据
useFocusEffect(
useCallback(() => {
@@ -288,10 +293,24 @@ export default function GoalsScreen() {
}
};
// 处理任务完成
const handleTaskCompleted = (completedTask: TaskListItem) => {
// 触发震动反馈
if (process.env.EXPO_OS === 'ios') {
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium);
}
// 播放庆祝动画
celebrationAnimationRef.current?.play();
console.log(`任务 "${completedTask.title}" 已完成,播放庆祝动画`);
};
// 渲染任务项
const renderTaskItem = ({ item }: { item: TaskListItem }) => (
<TaskCard
task={item}
onTaskCompleted={handleTaskCompleted}
/>
);
@@ -542,6 +561,12 @@ export default function GoalsScreen() {
}
}
},
{
text: '测试庆祝动画',
onPress: () => {
celebrationAnimationRef.current?.play();
}
},
]
);
}}
@@ -549,6 +574,9 @@ export default function GoalsScreen() {
<Text style={styles.testButtonText}></Text>
</TouchableOpacity>
)}
{/* 庆祝动画组件 */}
<CelebrationAnimation ref={celebrationAnimationRef} />
</View>
</SafeAreaView>
);