feat(challenges): 移除进度徽章与副标题并动态计算剩余天数
- 使用 dayjs 实时计算挑战结束剩余天数,替代接口返回的固定值 - 删除 badge、subtitle 字段及相关渲染逻辑,简化 UI - 注释掉未使用的打卡操作区块,保持界面整洁
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
||||
} from '@/store/challengesSlice';
|
||||
import { Toast } from '@/utils/toast.utils';
|
||||
import { Ionicons } from '@expo/vector-icons';
|
||||
import dayjs from 'dayjs';
|
||||
import { BlurView } from 'expo-blur';
|
||||
import { LinearGradient } from 'expo-linear-gradient';
|
||||
import { useLocalSearchParams, useRouter } from 'expo-router';
|
||||
@@ -321,25 +322,14 @@ export default function ChallengeDetailScreen() {
|
||||
>
|
||||
<View style={styles.progressHeaderRow}>
|
||||
<View style={styles.progressBadgeRing}>
|
||||
{progress.badge ? (
|
||||
isHttpUrl(progress.badge) ? (
|
||||
<Image source={{ uri: progress.badge }} style={styles.progressBadge} />
|
||||
) : (
|
||||
<View style={styles.progressBadgeFallback}>
|
||||
<Text style={styles.progressBadgeText}>{progress.badge}</Text>
|
||||
</View>
|
||||
)
|
||||
) : (
|
||||
<View style={styles.progressBadgeFallback}>
|
||||
<Text style={styles.progressBadgeText}>打卡中</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
<View style={styles.progressHeadline}>
|
||||
<Text style={styles.progressTitle}>{challenge.title}</Text>
|
||||
{progress.subtitle ? <Text style={styles.progressSubtitle}>{progress.subtitle}</Text> : null}
|
||||
</View>
|
||||
<Text style={styles.progressRemaining}>剩余 {progress.remaining} 天</Text>
|
||||
<Text style={styles.progressRemaining}>剩余 {dayjs(challenge.endAt).diff(dayjs(), 'd') || 0} 天</Text>
|
||||
</View>
|
||||
|
||||
<View style={styles.progressMetaRow}>
|
||||
@@ -368,7 +358,7 @@ export default function ChallengeDetailScreen() {
|
||||
})}
|
||||
</View>
|
||||
|
||||
{isJoined ? (
|
||||
{/* {isJoined ? (
|
||||
<>
|
||||
<View style={styles.progressActionsRow}>
|
||||
<TouchableOpacity
|
||||
@@ -402,7 +392,7 @@ export default function ChallengeDetailScreen() {
|
||||
<Text style={styles.progressErrorText}>{progressActionError}</Text>
|
||||
) : null}
|
||||
</>
|
||||
) : null}
|
||||
) : null} */}
|
||||
</LinearGradient>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -5,9 +5,7 @@ export type ChallengeStatus = 'upcoming' | 'ongoing' | 'expired';
|
||||
export type ChallengeProgressDto = {
|
||||
completed: number;
|
||||
target: number;
|
||||
remaining: number;
|
||||
badge: string;
|
||||
subtitle?: string;
|
||||
remaining: number
|
||||
};
|
||||
|
||||
export type RankingItemDto = {
|
||||
@@ -35,6 +33,7 @@ export type ChallengeListItemDto = {
|
||||
isJoined: boolean;
|
||||
startAt?: string;
|
||||
endAt?: string;
|
||||
minimumCheckInDays: number; // 最小打卡天数
|
||||
};
|
||||
|
||||
export type ChallengeDetailDto = ChallengeListItemDto & {
|
||||
|
||||
Reference in New Issue
Block a user