frontend: fix status bar & replace pressable with touchable opacity

Pedro Lucas Porcellis porcellis@eletrotupi.com 1 month ago ad3569091b073a36184310365ccb67466041ea37
Parents: 44b054e
1 file(s) changed
  • frontend/app/(tabs)/settings.tsx +33 -7
frontend/app/(tabs)/settings.tsx
@@ -1,14 +1,16 @@
1 - import { TouchableOpacity, StyleSheet, Text, SectionList, View, StatusBar, Pressable } from 'react-native';
1 + import { TouchableOpacity, StyleSheet, Text, SectionList, View, Alert } from 'react-native';
2 2 import { SafeAreaView, SafeAreaProvider } from 'react-native-safe-area-context';
3 3 import { useState } from 'react';
4 4 import ParallaxScrollView from '@/components/misc/parallax-scroll-view';
5 5 import { Link } from 'expo-router'
6 + import { StatusBar } from 'expo-status-bar';
6 7
7 8 import { ThemedText } from '@/components/misc/themed-text';
8 9 import { ThemedView } from '@/components/misc/themed-view';
9 10 import { IconSymbol } from '@/components/ui/icon-symbol';
10 11 import { Fonts } from '@/constants/theme';
11 12 import { useThemeColor } from '@/hooks/use-theme-color';
13 + import { useAuth } from '@/context/AuthContext';
12 14
13 15 const SECTIONS = [
14 16 {
@@ -39,6 +41,7 @@ }
39 41 ]
40 42
41 43 export default function Settings() {
44 + const { user, logout } = useAuth();
42 45 const [options] = useState([
43 46 { id: 'profile', name: 'Perfil', path: '/profile'}
44 47 ])
@@ -46,7 +49,20 @@
46 49 const textColor = useThemeColor({}, 'text');
47 50 const tintColor = useThemeColor({}, 'tint');
48 51
49 - console.log(tintColor, textColor)
52 + const handleLogout = async () => {
53 + Alert.alert(
54 + 'Sair',
55 + 'Tem certeza que quer sair?',
56 + [
57 + { text: 'Cancelar', style: 'cancel' },
58 + {
59 + text: 'Sair',
60 + style: 'destructive',
61 + onPress: logout
62 + },
63 + ]
64 + );
65 + };
50 66
51 67 const renderItem = ({item}) => {
52 68 const itemStyle = [
@@ -55,14 +71,24 @@ ]
55 71
56 72 const itemColor = { color: item.logout ? '#FF2C2C' : textColor }
57 73
74 + if (item.logout) {
75 + return (
76 + <TouchableOpacity onPress={handleLogout} style={itemStyle}>
77 + <Text style={itemColor}>
78 + Sair
79 + </Text>
80 + </TouchableOpacity>
81 + )
82 + }
83 +
58 84 return (
59 85 <View>
60 86 <Link key={item.id} href={item.path} asChild style={itemStyle}>
61 - <Pressable>
87 + <TouchableOpacity>
62 88 <Text style={itemColor}>
63 89 {item.title}
64 90 </Text>
65 - </Pressable>
91 + </TouchableOpacity>
66 92 </Link>
67 93 </View>
68 94 )
@@ -71,7 +97,7 @@
71 97 return (
72 98 <SafeAreaProvider>
73 99 <SafeAreaView style={styles.container} edges={['top']}>
74 - <StatusBar style='dark' />
100 + <StatusBar style="dark" />
75 101 <SectionList
76 102 sections={SECTIONS}
77 103 keyExtractor={(item, index) => item.title + index}
@@ -87,8 +113,8 @@
87 113 const styles = StyleSheet.create({
88 114 container: {
89 115 flex: 1,
90 - paddingTop: StatusBar.currentHeight,
91 - marginHorizontal: 16
116 + marginHorizontal: 16,
117 + paddingTop: 10
92 118 },
93 119 item: {
94 120 paddingTop: 20,