| 1 | import { Image } from 'expo-image';
|
| 2 | import { Platform, StyleSheet, TouchableOpacity, Alert } from 'react-native';
|
| 3 |
|
| 4 | import { HelloWave } from '@/components/hello-wave';
|
| 5 | import ParallaxScrollView from '@/components/misc/parallax-scroll-view';
|
| 6 | import { ThemedText } from '@/components/misc/themed-text';
|
| 7 | import { ThemedView } from '@/components/misc/themed-view';
|
| 8 | import { Link } from 'expo-router';
|
| 9 | import { useAuth } from '@/context/AuthContext';
|
| 10 | import { Button } from '@/components/ui';
|
| 11 |
|
| 12 | export default function HomeScreen() {
|
| 13 | const { user, logout } = useAuth();
|
| 14 |
|
| 15 | const handleLogout = async () => {
|
| 16 | Alert.alert(
|
| 17 | 'Sair',
|
| 18 | 'Tem certeza que quer sair?',
|
| 19 | [
|
| 20 | { text: 'Cancelar', style: 'cancel' },
|
| 21 | {
|
| 22 | text: 'Sair',
|
| 23 | style: 'destructive',
|
| 24 | onPress: logout
|
| 25 | },
|
| 26 | ]
|
| 27 | );
|
| 28 | };
|
| 29 |
|
| 30 | return (
|
| 31 | <ParallaxScrollView
|
| 32 | headerBackgroundColor={{ light: '#A1CEDC', dark: '#1D3D47' }}
|
| 33 | headerImage={
|
| 34 | <Image
|
| 35 | source={require('@/assets/images/partial-react-logo.png')}
|
| 36 | style={styles.reactLogo}
|
| 37 | />
|
| 38 | }>
|
| 39 | <ThemedView style={styles.titleContainer}>
|
| 40 | <ThemedText type="title">Bem vindo{user?.firstName ? `, ${user.firstName}` : ''}!</ThemedText>
|
| 41 | <HelloWave />
|
| 42 | </ThemedView>
|
| 43 | <ThemedView style={styles.stepContainer}>
|
| 44 | <Button
|
| 45 | title="Sair"
|
| 46 | variant="outline"
|
| 47 | onPress={handleLogout}
|
| 48 | />
|
| 49 | </ThemedView>
|
| 50 | <ThemedView style={styles.stepContainer}>
|
| 51 | <ThemedText type="subtitle">Step 1: Try it</ThemedText>
|
| 52 | <ThemedText>
|
| 53 | Edit <ThemedText type="defaultSemiBold">app/(tabs)/index.tsx</ThemedText> to see changes.
|
| 54 | Press{' '}
|
| 55 | <ThemedText type="defaultSemiBold">
|
| 56 | {Platform.select({
|
| 57 | ios: 'cmd + d',
|
| 58 | android: 'cmd + m',
|
| 59 | web: 'F12',
|
| 60 | })}
|
| 61 | </ThemedText>{' '}
|
| 62 | to open developer tools.
|
| 63 | </ThemedText>
|
| 64 | </ThemedView>
|
| 65 | <ThemedView style={styles.stepContainer}>
|
| 66 | <Link href="/modal">
|
| 67 | <Link.Trigger>
|
| 68 | <ThemedText type="subtitle">Step 2: Explore</ThemedText>
|
| 69 | </Link.Trigger>
|
| 70 | <Link.Preview />
|
| 71 | <Link.Menu>
|
| 72 | <Link.MenuAction title="Action" icon="cube" onPress={() => alert('Action pressed')} />
|
| 73 | <Link.MenuAction
|
| 74 | title="Share"
|
| 75 | icon="square.and.arrow.up"
|
| 76 | onPress={() => alert('Share pressed')}
|
| 77 | />
|
| 78 | <Link.Menu title="More" icon="ellipsis">
|
| 79 | <Link.MenuAction
|
| 80 | title="Delete"
|
| 81 | icon="trash"
|
| 82 | destructive
|
| 83 | onPress={() => alert('Delete pressed')}
|
| 84 | />
|
| 85 | </Link.Menu>
|
| 86 | </Link.Menu>
|
| 87 | </Link>
|
| 88 |
|
| 89 | <ThemedText>
|
| 90 | {`Tap the Explore tab to learn more about what's included in this starter app.`}
|
| 91 | </ThemedText>
|
| 92 | </ThemedView>
|
| 93 | <ThemedView style={styles.stepContainer}>
|
| 94 | <ThemedText type="subtitle">Step 3: Get a fresh start</ThemedText>
|
| 95 | <ThemedText>
|
| 96 | {`When you're ready, run `}
|
| 97 | <ThemedText type="defaultSemiBold">npm run reset-project</ThemedText> to get a fresh{' '}
|
| 98 | <ThemedText type="defaultSemiBold">app</ThemedText> directory. This will move the current{' '}
|
| 99 | <ThemedText type="defaultSemiBold">app</ThemedText> to{' '}
|
| 100 | <ThemedText type="defaultSemiBold">app-example</ThemedText>.
|
| 101 | </ThemedText>
|
| 102 | </ThemedView>
|
| 103 | </ParallaxScrollView>
|
| 104 | );
|
| 105 | }
|
| 106 |
|
| 107 | const styles = StyleSheet.create({
|
| 108 | titleContainer: {
|
| 109 | flexDirection: 'row',
|
| 110 | alignItems: 'center',
|
| 111 | gap: 8,
|
| 112 | },
|
| 113 | stepContainer: {
|
| 114 | gap: 8,
|
| 115 | marginBottom: 8,
|
| 116 | },
|
| 117 | reactLogo: {
|
| 118 | height: 178,
|
| 119 | width: 290,
|
| 120 | bottom: 0,
|
| 121 | left: 0,
|
| 122 | position: 'absolute',
|
| 123 | },
|
| 124 | });
|