import Ionicons from '@expo/vector-icons/Ionicons'; import { useRouter } from 'expo-router'; import React, { useMemo, useState } from 'react'; import { FlatList, StatusBar, StyleSheet, Text, TouchableOpacity, View, } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; type LedgerKind = 'obtained' | 'consumed'; type LedgerEntry = { id: string; title: string; happenedAt: string; amount: number; kind: LedgerKind; }; type FilterKey = 'all' | LedgerKind; const screenPalette = { background: '#080808', surface: '#111111', surfaceActive: '#1C1C1C', divider: '#1A1A1A', primaryText: '#F5F5F5', secondaryText: '#6C6C6C', accent: '#FEB840', accentHalo: 'rgba(254, 184, 64, 0.18)', negative: '#B3B3B3', }; const FILTERS: { key: FilterKey; label: string }[] = [ { key: 'all', label: 'All records' }, { key: 'consumed', label: 'Consumed' }, { key: 'obtained', label: 'Obtained' }, ]; const LEDGER: LedgerEntry[] = [ { id: 'obtained-1', title: 'Income Name', happenedAt: '2025-10-22 11:11', amount: 60, kind: 'obtained', }, { id: 'consumed-1', title: 'Expenditure Name', happenedAt: '2025-10-22 11:11', amount: -60, kind: 'consumed', }, { id: 'consumed-2', title: 'Expenditure Name', happenedAt: '2025-10-22 11:11', amount: -60, kind: 'consumed', }, { id: 'obtained-2', title: 'Income Name', happenedAt: '2025-10-22 11:11', amount: 60, kind: 'obtained', }, { id: 'obtained-3', title: 'Income Name', happenedAt: '2025-10-22 11:11', amount: 60, kind: 'obtained', }, { id: 'obtained-4', title: 'Income Name', happenedAt: '2025-10-22 11:11', amount: 60, kind: 'obtained', }, { id: 'consumed-3', title: 'Expenditure Name', happenedAt: '2025-10-22 11:11', amount: -60, kind: 'consumed', }, ]; export default function PointsDetailsScreen() { const insets = useSafeAreaInsets(); const router = useRouter(); const [activeFilter, setActiveFilter] = useState('all'); const filteredEntries = useMemo(() => { if (activeFilter === 'all') { return LEDGER; } return LEDGER.filter(entry => entry.kind === activeFilter); }, [activeFilter]); return ( router.back()} style={styles.iconButton} hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }} > Points Details 60 {FILTERS.map(filter => { const isActive = filter.key === activeFilter; return ( setActiveFilter(filter.key)} accessibilityRole="button" > {filter.label} ); })} item.id} style={styles.list} contentContainerStyle={{ paddingBottom: Math.max(insets.bottom + 24, 64) }} showsVerticalScrollIndicator={false} ItemSeparatorComponent={() => } renderItem={({ item }) => { const amount = Math.abs(item.amount); const isPositive = item.amount > 0; return ( {item.title} {item.happenedAt} {isPositive ? `+ ${amount}` : `- ${amount}`} ); }} /> ); } const styles = StyleSheet.create({ screen: { flex: 1, backgroundColor: screenPalette.background, paddingHorizontal: 20, }, headerRow: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', }, iconButton: { width: 44, height: 44, borderRadius: 22, alignItems: 'center', justifyContent: 'center', }, headerTitle: { fontSize: 18, fontWeight: '600', color: screenPalette.primaryText, letterSpacing: 0.3, }, balanceCluster: { alignItems: 'center', marginTop: 28, marginBottom: 32, gap: 12, }, energyOrb: { width: 56, height: 56, borderRadius: 28, backgroundColor: screenPalette.accentHalo, alignItems: 'center', justifyContent: 'center', }, balanceValue: { fontSize: 44, fontWeight: '700', color: screenPalette.primaryText, letterSpacing: 1, }, segmentRail: { flexDirection: 'row', backgroundColor: screenPalette.surface, padding: 6, borderRadius: 28, }, segmentChip: { flex: 1, borderRadius: 22, alignItems: 'center', justifyContent: 'center', paddingVertical: 10, }, segmentChipActive: { backgroundColor: screenPalette.surfaceActive, }, segmentLabel: { fontSize: 14, color: screenPalette.secondaryText, fontWeight: '500', }, segmentLabelActive: { color: screenPalette.primaryText, }, list: { flex: 1, marginTop: 32, }, listDivider: { height: 1, backgroundColor: screenPalette.divider, marginVertical: 6, }, recordRow: { flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'space-between', paddingVertical: 10, }, recordTitle: { fontSize: 16, fontWeight: '600', color: screenPalette.primaryText, }, recordTimestamp: { marginTop: 4, fontSize: 13, color: screenPalette.secondaryText, }, recordValue: { fontSize: 16, fontWeight: '600', }, valuePositive: { color: screenPalette.accent, }, valueNegative: { color: screenPalette.negative, }, });