import React, { useState, useEffect } from 'react'; import { View, Text, StyleSheet, TouchableOpacity, ScrollView, Image, Dimensions, Alert, } from 'react-native'; import { Ionicons } from '@expo/vector-icons'; import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; import * as ImagePicker from 'expo-image-picker'; import { useAuth } from '../contexts/AuthContext'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; const { width } = Dimensions.get('window'); function HomeTab() { const { user } = useAuth(); const [profileImage, setProfileImage] = useState(null); const pickImage = async () => { const permissionResult = await ImagePicker.requestMediaLibraryPermissionsAsync(); if (permissionResult.granted === false) { Alert.alert('Permission Required', 'Permission to access camera roll is required!'); return; } const result = await ImagePicker.launchImageLibraryAsync({ mediaTypes: ImagePicker.MediaTypeOptions.Images, allowsEditing: true, aspect: [1, 1], quality: 0.5, base64: true, }); if (!result.canceled && result.assets[0].base64) { const base64Image = `data:image/jpeg;base64,${result.assets[0].base64}`; setProfileImage(base64Image); // TODO: Save to backend } }; return ( {/* Header */} {profileImage ? ( ) : ( )} 750 {/* Announcements Widget */} 🎉 Welcome to PezkuwiChain! Start your citizenship journey today 📢 New Feature Vote on governance proposals {/* Quick Actions Grid - 30 Actions */} Quick Actions {QUICK_ACTIONS.map((action, index) => ( {action.label} ))} ); } function WalletTab() { const { user } = useAuth(); const [hezBalance, setHezBalance] = useState('Loading...'); const [pezBalance, setPezBalance] = useState('Loading...'); const [loading, setLoading] = useState(true); const TEST_WALLET = '5GgTgG9sRmPQAYU1RsTejZYnZRjwzKZKWD3awtuqjHioki45'; useEffect(() => { fetchBalance(); }, []); const fetchBalance = async () => { try { const backendUrl = process.env.EXPO_PUBLIC_BACKEND_URL || 'http://localhost:8001'; const controller = new AbortController(); const timeoutId = setTimeout(() => controller.abort(), 5000); // 5 sec timeout const response = await fetch(`${backendUrl}/api/blockchain/balance`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ address: TEST_WALLET, }), signal: controller.signal, }); clearTimeout(timeoutId); if (response.ok) { const data = await response.json(); setHezBalance(parseFloat(data.hez).toFixed(2)); setPezBalance(parseFloat(data.pez).toFixed(2)); } else { setHezBalance('0.00'); setPezBalance('0.00'); } } catch (error) { console.error('Balance fetch error:', error); setHezBalance('0.00'); setPezBalance('0.00'); } finally { setLoading(false); } }; return ( {/* Header */} My Wallet {/* Balance Cards - Side by Side */} HEZ {hezBalance} Hemwelatî Token PEZ {pezBalance} Pezkuwî Token {/* Action Buttons Container */} {/* First Row: Send, Receive, Swap, P2P */} Send Receive Swap P2P {/* Second Row: Vote, DApps, Staking, Connect */} Vote DApps Staking Connect {/* Tokens List */} Tokens {/* USDT with PEZ badge */} USDT PEZ Network 0 $0 {/* Add more tokens as needed */} ); } function CitizensTab() { return ( Citizens Screen ); } function ReferralTab() { return ( Referral Screen ); } function ProfileTab() { return ( Profile Screen ); } const Tab = createBottomTabNavigator(); export default function HomeScreen() { return ( ( ), }} /> ( ), }} /> ( ), }} /> ( ), }} /> ( ), }} /> ); } const QUICK_ACTIONS = [ { id: '1', label: 'Send', icon: 'arrow-forward', color: '#EE2A35' }, { id: '2', label: 'Receive', icon: 'arrow-down', color: '#00A651' }, { id: '3', label: 'Swap', icon: 'swap-horizontal', color: '#FFD700' }, { id: '4', label: 'Vote', icon: 'checkmark-circle', color: '#3B82F6' }, { id: '5', label: 'Stake', icon: 'lock-closed', color: '#8B5CF6' }, { id: '6', label: 'Identity', icon: 'card', color: '#10B981' }, { id: '7', label: 'Passport', icon: 'document-text', color: '#F59E0B' }, { id: '8', label: 'Education', icon: 'school', color: '#EC4899' }, { id: '9', label: 'Business', icon: 'briefcase', color: '#6366F1' }, { id: '10', label: 'Treasury', icon: 'cash', color: '#14B8A6' }, { id: '11', label: 'Proposals', icon: 'bulb', color: '#F97316' }, { id: '12', label: 'More', icon: 'apps', color: '#9333EA' }, ]; const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#F8F9FA', }, scrollContent: { paddingBottom: 80, }, walletScrollContent: { paddingBottom: 80, }, header: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', padding: 16, backgroundColor: '#FFF', borderBottomWidth: 1, borderBottomColor: '#E5E7EB', }, headerLeft: { position: 'relative', }, profileImage: { width: 50, height: 50, borderRadius: 25, backgroundColor: '#F3F4F6', alignItems: 'center', justifyContent: 'center', overflow: 'hidden', }, profileImageSrc: { width: 50, height: 50, }, profileBadge: { position: 'absolute', bottom: -5, right: -5, backgroundColor: '#1F2937', borderRadius: 12, paddingHorizontal: 6, paddingVertical: 2, flexDirection: 'row', alignItems: 'center', gap: 2, }, trustScore: { fontSize: 10, fontWeight: '600', color: '#FFF', }, headerRight: { flexDirection: 'row', gap: 12, }, iconButton: { padding: 8, }, announcementWidget: { padding: 16, }, announcement: { backgroundColor: '#FFF', padding: 16, borderRadius: 12, marginRight: 12, width: width - 64, borderLeftWidth: 4, borderLeftColor: '#EE2A35', }, announcementTitle: { fontSize: 16, fontWeight: '600', color: '#1F2937', marginBottom: 4, }, announcementText: { fontSize: 14, color: '#6B7280', }, quickActionsContainer: { padding: 16, }, sectionTitle: { fontSize: 18, fontWeight: '700', color: '#1F2937', marginBottom: 16, }, actionsGrid: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'space-between', }, actionCard: { width: (width - 64) / 4, backgroundColor: '#FFF', padding: 12, borderRadius: 12, alignItems: 'center', marginBottom: 12, shadowColor: '#000', shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.05, shadowRadius: 4, elevation: 2, }, actionCardFirst: { marginRight: 'auto', }, actionCardLast: { marginLeft: 'auto', }, actionIcon: { width: 50, height: 50, borderRadius: 12, alignItems: 'center', justifyContent: 'center', marginBottom: 8, }, actionLabel: { fontSize: 11, color: '#374151', textAlign: 'center', }, walletHeader: { padding: 20, backgroundColor: '#FFF', borderBottomWidth: 1, borderBottomColor: '#E5E7EB', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', }, walletTitle: { fontSize: 24, fontWeight: '700', color: '#1F2937', }, refreshButton: { padding: 8, borderRadius: 8, backgroundColor: '#FEE2E2', }, balanceCards: { padding: 16, gap: 12, }, balanceCard: { backgroundColor: '#FFF', padding: 20, borderRadius: 16, borderWidth: 1, borderColor: '#E5E7EB', }, balanceCardHeader: { flexDirection: 'row', alignItems: 'center', gap: 8, marginBottom: 12, }, tokenLogo: { width: 32, height: 32, borderRadius: 16, }, tokenSymbol: { fontSize: 18, fontWeight: '700', color: '#1F2937', }, balanceAmount: { fontSize: 32, fontWeight: '700', color: '#1F2937', marginBottom: 4, }, balanceUsd: { fontSize: 16, color: '#6B7280', }, walletActions: { flexDirection: 'row', padding: 16, gap: 12, }, walletActionButton: { flex: 1, backgroundColor: '#EE2A35', padding: 16, borderRadius: 12, alignItems: 'center', gap: 4, }, walletActionText: { color: '#FFF', fontSize: 14, fontWeight: '600', }, placeholderText: { flex: 1, textAlign: 'center', marginTop: 100, fontSize: 18, color: '#6B7280', }, tabBar: { borderTopWidth: 1, borderTopColor: '#E5E7EB', paddingBottom: 20, paddingTop: 8, backgroundColor: '#FFF', }, // New Wallet Styles balanceRow: { flexDirection: 'row', padding: 16, gap: 12, }, balanceCardNew: { flex: 1, backgroundColor: '#FFF', padding: 16, borderRadius: 16, alignItems: 'center', shadowColor: '#000', shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.1, shadowRadius: 8, elevation: 3, }, tokenLogoNew: { width: 48, height: 48, borderRadius: 24, marginBottom: 8, }, tokenSymbolNew: { fontSize: 16, fontWeight: '700', color: '#1F2937', marginBottom: 4, }, balanceAmountNew: { fontSize: 24, fontWeight: '700', color: '#EE2A35', marginBottom: 4, }, tokenNameNew: { fontSize: 12, color: '#6B7280', }, actionsContainer: { margin: 16, backgroundColor: '#FFF', padding: 16, borderRadius: 16, shadowColor: '#000', shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.1, shadowRadius: 8, elevation: 3, }, actionsRow: { flexDirection: 'row', justifyContent: 'space-between', marginBottom: 12, }, actionBtn: { width: (width - 80) / 4, padding: 12, borderRadius: 12, alignItems: 'center', justifyContent: 'center', }, actionBtnText: { color: '#FFF', fontSize: 11, fontWeight: '600', marginTop: 4, }, tokensContainer: { margin: 16, marginTop: 0, }, tokensTitle: { fontSize: 18, fontWeight: '700', color: '#1F2937', marginBottom: 12, paddingHorizontal: 4, }, tokenItem: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', backgroundColor: '#FFF', padding: 16, borderRadius: 12, marginBottom: 8, shadowColor: '#000', shadowOffset: { width: 0, height: 1 }, shadowOpacity: 0.05, shadowRadius: 4, elevation: 2, }, tokenItemLeft: { flexDirection: 'row', alignItems: 'center', gap: 12, }, tokenIconContainer: { position: 'relative', width: 40, height: 40, }, tokenIcon: { width: 40, height: 40, borderRadius: 20, }, networkBadge: { position: 'absolute', right: -4, bottom: -4, width: 16, height: 16, borderRadius: 8, borderWidth: 2, borderColor: '#FFF', }, tokenItemName: { fontSize: 16, fontWeight: '600', color: '#1F2937', }, tokenItemNetwork: { fontSize: 12, color: '#6B7280', }, tokenItemRight: { alignItems: 'flex-end', }, tokenItemBalance: { fontSize: 16, fontWeight: '600', color: '#1F2937', }, tokenItemUsd: { fontSize: 12, color: '#6B7280', }, });