feat(challenges): 优化挑战列表与详情页交互体验

- 替换 Image 为 expo-image 并启用缓存策略
- 调整礼物按钮尺寸与图标大小
- 加入挑战失败时弹出 Toast 提示
- 统一异步流程并移除冗余状态监听
- 清理调试日志与多余空行
This commit is contained in:
richarjiang
2025-09-29 09:59:47 +08:00
parent 7259bd7a2c
commit b80af23f4f
3 changed files with 37 additions and 22 deletions

View File

@@ -9,12 +9,12 @@ import {
selectChallengesListStatus,
type ChallengeCardViewModel,
} from '@/store/challengesSlice';
import { Image } from 'expo-image';
import { LinearGradient } from 'expo-linear-gradient';
import { useRouter } from 'expo-router';
import React, { useEffect } from 'react';
import {
ActivityIndicator,
Image,
ScrollView,
StatusBar,
StyleSheet,
@@ -42,6 +42,9 @@ export default function ChallengesScreen() {
const listStatus = useAppSelector(selectChallengesListStatus);
const listError = useAppSelector(selectChallengesListError);
console.log('challenges', challenges);
useEffect(() => {
if (listStatus === 'idle') {
dispatch(fetchChallenges());
@@ -124,7 +127,7 @@ export default function ChallengesScreen() {
end={{ x: 1, y: 1 }}
style={styles.giftButton}
>
<IconSymbol name="gift.fill" size={22} color={colorTokens.onPrimary} />
<IconSymbol name="gift.fill" size={18} color={colorTokens.onPrimary} />
</LinearGradient>
</TouchableOpacity>
</View>
@@ -162,7 +165,7 @@ function ChallengeCard({ challenge, surfaceColor, textColor, mutedColor, onPress
<Image
source={{ uri: challenge.image }}
style={styles.cardImage}
resizeMode="cover"
cachePolicy={'memory-disk'}
/>
<View style={styles.cardContent}>
@@ -252,8 +255,8 @@ const styles = StyleSheet.create({
borderRadius: 26,
},
giftButton: {
width: 52,
height: 52,
width: 32,
height: 32,
borderRadius: 26,
alignItems: 'center',
justifyContent: 'center',