Kantongku: fix posisi effect animasi bar (setelah deklarasi hpPct)
This commit is contained in:
@@ -224,6 +224,33 @@ export function DashboardScreen() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hasTodayActivity = today.income > 0 || today.expense > 0;
|
||||||
|
const monthNet = monthIncome - monthExpense;
|
||||||
|
|
||||||
|
// Nyawa keuangan (health bar)
|
||||||
|
const hpPct =
|
||||||
|
avgDailyExpense > 0
|
||||||
|
? Math.min(100, Math.round(((coverageDays ?? 0) / remainingDays) * 100))
|
||||||
|
: 100;
|
||||||
|
let hpStatus = 'SEHAT';
|
||||||
|
let hpColor = '#16A34A';
|
||||||
|
let hpBarColor = '#22C55E';
|
||||||
|
let hpMsg =
|
||||||
|
avgDailyExpense > 0
|
||||||
|
? `Nyawa aman — saldo cukup ${coverageDays} hari (sisa ${remainingDays}) 🛡️`
|
||||||
|
: 'Belum ada pengeluaran bulan ini — nyawa penuh! 😎';
|
||||||
|
if (avgDailyExpense > 0 && hpPct < 40) {
|
||||||
|
hpStatus = 'KRITIS';
|
||||||
|
hpColor = '#DC2626';
|
||||||
|
hpBarColor = '#EF4444';
|
||||||
|
hpMsg = `Saldo cukup ${coverageDays} dari ${remainingDays} hari — kurangi belanja! 🚨`;
|
||||||
|
} else if (avgDailyExpense > 0 && hpPct < 75) {
|
||||||
|
hpStatus = 'WASPADA';
|
||||||
|
hpColor = '#D97706';
|
||||||
|
hpBarColor = '#F59E0B';
|
||||||
|
hpMsg = `Saldo cukup ${coverageDays} dari ${remainingDays} hari — jaga pengeluaran ⚔️`;
|
||||||
|
}
|
||||||
|
|
||||||
// Bar HP: width bergerak halus mengikuti data
|
// Bar HP: width bergerak halus mengikuti data
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Animated.timing(hpAnim, {
|
Animated.timing(hpAnim, {
|
||||||
@@ -271,33 +298,6 @@ export function DashboardScreen() {
|
|||||||
return () => loop?.stop();
|
return () => loop?.stop();
|
||||||
}, [hpPct, pulse]);
|
}, [hpPct, pulse]);
|
||||||
|
|
||||||
const hasTodayActivity = today.income > 0 || today.expense > 0;
|
|
||||||
const monthNet = monthIncome - monthExpense;
|
|
||||||
|
|
||||||
// Nyawa keuangan (health bar)
|
|
||||||
const hpPct =
|
|
||||||
avgDailyExpense > 0
|
|
||||||
? Math.min(100, Math.round(((coverageDays ?? 0) / remainingDays) * 100))
|
|
||||||
: 100;
|
|
||||||
let hpStatus = 'SEHAT';
|
|
||||||
let hpColor = '#16A34A';
|
|
||||||
let hpBarColor = '#22C55E';
|
|
||||||
let hpMsg =
|
|
||||||
avgDailyExpense > 0
|
|
||||||
? `Nyawa aman — saldo cukup ${coverageDays} hari (sisa ${remainingDays}) 🛡️`
|
|
||||||
: 'Belum ada pengeluaran bulan ini — nyawa penuh! 😎';
|
|
||||||
if (avgDailyExpense > 0 && hpPct < 40) {
|
|
||||||
hpStatus = 'KRITIS';
|
|
||||||
hpColor = '#DC2626';
|
|
||||||
hpBarColor = '#EF4444';
|
|
||||||
hpMsg = `Saldo cukup ${coverageDays} dari ${remainingDays} hari — kurangi belanja! 🚨`;
|
|
||||||
} else if (avgDailyExpense > 0 && hpPct < 75) {
|
|
||||||
hpStatus = 'WASPADA';
|
|
||||||
hpColor = '#D97706';
|
|
||||||
hpBarColor = '#F59E0B';
|
|
||||||
hpMsg = `Saldo cukup ${coverageDays} dari ${remainingDays} hari — jaga pengeluaran ⚔️`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SafeAreaView style={styles.safe} edges={['top']}>
|
<SafeAreaView style={styles.safe} edges={['top']}>
|
||||||
<View style={styles.contentWrap}>
|
<View style={styles.contentWrap}>
|
||||||
|
|||||||
Reference in New Issue
Block a user