import React from 'react'; import { View, Text, StyleSheet, TouchableOpacity, ScrollView, Image } from 'react-native'; import { SafeAreaView } from 'react-native-safe-area-context'; import { StatusBar } from 'expo-status-bar'; import { useRouter } from 'expo-router'; /** * Demo index page for showcasing implemented React Query features. * This page serves as a central hub for navigating to different test components * that demonstrate various aspects of the React Query integration. */ export default function ReactQueryDemoIndex() { const router = useRouter(); // Only include the demo options that are currently available const demoOptions = [ { id: 'react-query-auth-test', title: 'Authentication Demo', description: 'Demonstrates authentication flow using React Query, including login, logout, and profile management.', icon: '🔐', }, { id: 'auth-test', title: 'Legacy Auth Demo', description: 'Original authentication implementation for comparison.', icon: '👤', }, { id: 'simple-auth', title: 'Simple Auth Demo', description: 'Simpler authentication implementation for testing.', icon: '🔑', }, { id: 'robohash', title: 'Robohash Avatar Demo', description: 'Demonstrates the Robohash avatar generation system.', icon: '🤖', }, { id: 'cache-test', title: 'Image Cache Demo', description: 'Tests React Query integration with profile and banner image caching.', icon: '🖼️', } ]; return ( React Query Integration Phase 1 Implementation Demo 🚀 Implementation Complete Phase 1 of the React Query integration has been implemented. This includes: • Authentication with React Query • Profile data management • Network connectivity tracking • Optimized query client configuration • Standardized query key structure Select a demo below to explore the implementation. Available Demos {demoOptions.map((demo) => ( router.push({ pathname: `/test/${demo.id}` as any })} > {demo.icon} {demo.title} {demo.description} ))} 📝 Implementation Notes This implementation follows the phased approach outlined in the React Query Integration Plan. Phase 1 focuses on core authentication and network status management. Note: Test components have been updated with isolated providers to prevent hook ordering conflicts. Each test now uses dedicated providers and properly manages its own state. The hooks are designed to be drop-in replacements for existing hooks, with enhanced functionality: • Automatic loading states • Standardized error handling • Optimistic updates • Smart caching and refetching • Automatic query invalidation Next Steps: 1. Implement domain-specific hooks (workouts, exercises, templates) 2. Integrate with UI components 3. Add advanced features (prefetching, suspense) 4. Complete full migration of state management ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#f5f5f5', }, scrollContent: { padding: 16, paddingBottom: 40, }, header: { fontSize: 28, fontWeight: 'bold', textAlign: 'center', marginTop: 8, color: '#333', }, subheader: { fontSize: 18, color: '#666', textAlign: 'center', marginBottom: 24, }, infoCard: { backgroundColor: 'white', borderRadius: 12, padding: 16, marginBottom: 24, shadowColor: '#000', shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.1, shadowRadius: 4, elevation: 3, }, cardTitle: { fontSize: 18, fontWeight: 'bold', marginBottom: 12, color: '#333', }, cardText: { fontSize: 15, color: '#555', lineHeight: 22, marginBottom: 12, }, bulletList: { marginLeft: 8, marginBottom: 16, }, bulletItem: { fontSize: 15, color: '#555', lineHeight: 24, }, sectionTitle: { fontSize: 20, fontWeight: 'bold', marginBottom: 16, color: '#333', }, demoOption: { backgroundColor: 'white', borderRadius: 12, marginBottom: 12, padding: 16, flexDirection: 'row', shadowColor: '#000', shadowOffset: { width: 0, height: 1 }, shadowOpacity: 0.1, shadowRadius: 2, elevation: 2, }, iconContainer: { width: 48, height: 48, borderRadius: 24, backgroundColor: '#f0f0f0', justifyContent: 'center', alignItems: 'center', marginRight: 16, }, icon: { fontSize: 24, }, demoContent: { flex: 1, justifyContent: 'center', }, demoTitle: { fontSize: 16, fontWeight: 'bold', marginBottom: 4, color: '#333', }, demoDescription: { fontSize: 14, color: '#666', lineHeight: 20, }, nextSteps: { backgroundColor: '#e6f7ff', borderRadius: 12, padding: 16, marginTop: 8, borderLeftWidth: 4, borderLeftColor: '#1890ff', }, nextStepsTitle: { fontSize: 16, fontWeight: 'bold', marginBottom: 12, color: '#333', }, nextStepsText: { fontSize: 14, color: '#444', lineHeight: 24, }, });