App : page des récompenses retravaillée
Solde aux couleurs de la carte, récompenses en deux sections (Disponibles / Prochainement), bouton « Utiliser » en pastille, barre de progression vers les récompenses pas encore atteintes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5f354e8987
commit
e7e00b9a6f
1 changed files with 84 additions and 36 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { useState } from 'react';
|
||||
import { ActivityIndicator, Alert, Pressable, View } from 'react-native';
|
||||
import { ActivityIndicator, Alert, Pressable, StyleSheet, View } from 'react-native';
|
||||
import { router } from 'expo-router';
|
||||
import * as Haptics from 'expo-haptics';
|
||||
import { api, Reward } from '../../../src/api';
|
||||
|
|
@ -50,14 +50,12 @@ export default function Rewards() {
|
|||
|
||||
const sorted = [...store.design.rewards].sort((a, b) => Number(b.cost <= card.balance) - Number(a.cost <= card.balance) || a.cost - b.cost);
|
||||
|
||||
return (
|
||||
<Screen scroll>
|
||||
<T v="muted">
|
||||
Solde de {card.firstName} : <T style={{ fontFamily: font.bold }}>{card.balance} {unit(mode, card.balance)}</T>
|
||||
</T>
|
||||
<View style={{ gap: 12 }}>
|
||||
{sorted.map((r) => {
|
||||
const available = sorted.filter((r) => r.cost <= card.balance);
|
||||
const later = sorted.filter((r) => r.cost > card.balance);
|
||||
|
||||
const item = (r: Reward) => {
|
||||
const ok = r.cost <= card.balance;
|
||||
const progress = Math.min(card.balance / r.cost, 1);
|
||||
return (
|
||||
<Pressable
|
||||
key={r.id}
|
||||
|
|
@ -66,28 +64,78 @@ export default function Rewards() {
|
|||
disabled={!ok || !!busy}
|
||||
onPress={() => confirm(r)}
|
||||
style={({ pressed }) => ({
|
||||
minHeight: 72,
|
||||
padding: 16,
|
||||
borderRadius: 16,
|
||||
borderWidth: ok ? 2 : 1,
|
||||
borderRadius: 18,
|
||||
borderWidth: ok ? 2 : StyleSheet.hairlineWidth,
|
||||
borderColor: ok ? c.primary : c.border,
|
||||
backgroundColor: ok ? (pressed ? c.primarySoft : c.surface) : c.surface2,
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
gap: 12,
|
||||
backgroundColor: ok ? (pressed ? c.primarySoft : c.surface) : c.surface,
|
||||
gap: 10,
|
||||
opacity: ok ? 1 : 0.75,
|
||||
})}
|
||||
>
|
||||
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 12 }}>
|
||||
<View style={{ width: 46, height: 46, borderRadius: 23, backgroundColor: ok ? c.warnBg : c.surface2, alignItems: 'center', justifyContent: 'center' }}>
|
||||
<T style={{ fontSize: 22 }}>{ok ? '🎁' : '🔒'}</T>
|
||||
</View>
|
||||
<View style={{ flex: 1, gap: 2 }}>
|
||||
<T v="label" style={{ fontSize: 17, color: ok ? c.text : c.text3 }}>{r.label}</T>
|
||||
<T v="muted" style={{ fontSize: 14 }}>
|
||||
{ok ? `${r.cost} ${unit(mode, r.cost)}` : `Encore ${r.cost - card.balance} ${unit(mode, r.cost - card.balance)}`}
|
||||
{r.cost} {unit(mode, r.cost)}
|
||||
{!ok && ` · encore ${r.cost - card.balance}`}
|
||||
</T>
|
||||
</View>
|
||||
{busy === r.id ? <ActivityIndicator /> : ok && <T style={{ color: c.primary, fontFamily: font.bold }}>Utiliser</T>}
|
||||
{busy === r.id ? (
|
||||
<ActivityIndicator />
|
||||
) : (
|
||||
ok && (
|
||||
<View style={{ paddingHorizontal: 14, paddingVertical: 8, borderRadius: 999, backgroundColor: c.primary }}>
|
||||
<T style={{ color: c.onPrimary, fontFamily: font.bold, fontSize: 15 }}>Utiliser</T>
|
||||
</View>
|
||||
)
|
||||
)}
|
||||
</View>
|
||||
{/* Progression vers une récompense pas encore atteinte */}
|
||||
{!ok && (
|
||||
<View style={{ height: 6, borderRadius: 3, backgroundColor: c.surface2, overflow: 'hidden' }}>
|
||||
<View style={{ width: `${Math.round(progress * 100)}%`, height: 6, borderRadius: 3, backgroundColor: c.accent }} />
|
||||
</View>
|
||||
)}
|
||||
</Pressable>
|
||||
);
|
||||
})}
|
||||
};
|
||||
|
||||
return (
|
||||
<Screen scroll>
|
||||
{/* Solde du client aux couleurs de la carte */}
|
||||
<View style={{ backgroundColor: store.design.backgroundColor, borderRadius: 20, padding: 18, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||
<View>
|
||||
<T style={{ color: store.design.foregroundColor, opacity: 0.8, fontSize: 14 }}>Solde de {card.firstName}</T>
|
||||
<T style={{ color: store.design.foregroundColor, fontFamily: font.extrabold, fontSize: 32, lineHeight: 38 }}>
|
||||
{card.balance} <T style={{ color: store.design.foregroundColor, fontSize: 18 }}>{unit(mode, card.balance)}</T>
|
||||
</T>
|
||||
</View>
|
||||
<T style={{ fontSize: 34 }}>⭐</T>
|
||||
</View>
|
||||
|
||||
{available.length > 0 ? (
|
||||
<View style={{ gap: 10 }}>
|
||||
<T v="label" style={{ color: c.text3, textTransform: 'uppercase', fontSize: 13, letterSpacing: 0.5 }}>Disponibles</T>
|
||||
{available.map(item)}
|
||||
</View>
|
||||
) : (
|
||||
<View style={{ alignItems: 'center', gap: 6, paddingVertical: 12 }}>
|
||||
<T style={{ fontSize: 32 }}>⏳</T>
|
||||
<T v="muted" style={{ textAlign: 'center' }}>Aucune récompense disponible pour l'instant.</T>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{later.length > 0 && (
|
||||
<View style={{ gap: 10 }}>
|
||||
<T v="label" style={{ color: c.text3, textTransform: 'uppercase', fontSize: 13, letterSpacing: 0.5 }}>Prochainement</T>
|
||||
{later.map(item)}
|
||||
</View>
|
||||
)}
|
||||
|
||||
<View style={{ flex: 1 }} />
|
||||
<Button label="Retour" variant="secondary" onPress={() => router.back()} />
|
||||
</Screen>
|
||||
|
|
|
|||
Loading…
Reference in a new issue