eletrotupi / tcc/ frontend/app/(tabs)/settings.tsx44b054e4cfc3aeed5d7a44187823bf954d563f71
2.4 KB | 104 lines Raw
1
import { TouchableOpacity, StyleSheet, Text, SectionList, View, StatusBar, Pressable } from 'react-native';
2
import { SafeAreaView, SafeAreaProvider } from 'react-native-safe-area-context';
3
import { useState } from 'react';
4
import ParallaxScrollView from '@/components/misc/parallax-scroll-view';
5
import { Link } from 'expo-router'
6

7
import { ThemedText } from '@/components/misc/themed-text';
8
import { ThemedView } from '@/components/misc/themed-view';
9
import { IconSymbol } from '@/components/ui/icon-symbol';
10
import { Fonts } from '@/constants/theme';
11
import { useThemeColor } from '@/hooks/use-theme-color';
12

13
const SECTIONS = [
14
  {
15
    title: 'Geral',
16
    data: [{
17
      title: 'Perfil & Senha',
18
      path: '/profile'
19
    }]
20
  },
21
  {
22
    title: 'Sobre',
23
    data: [
24
      {
25
        title: 'Sobre o aplicativo',
26
        path: '/about'
27
      },
28
      {
29
        title: 'O que acontece com seus dados?',
30
        path: '/data'
31
      },
32
      {
33
        title: 'Sair',
34
        path: '/logout',
35
        logout: true
36
      }
37
    ]
38
  }
39
]
40

41
export default function Settings() {
42
  const [options] = useState([
43
    { id: 'profile', name: 'Perfil', path: '/profile'}
44
  ])
45

46
  const textColor = useThemeColor({}, 'text');
47
  const tintColor = useThemeColor({}, 'tint');
48

49
  console.log(tintColor, textColor)
50

51
  const renderItem = ({item}) => {
52
    const itemStyle = [
53
      styles.item,
54
    ]
55

56
    const itemColor = { color: item.logout ? '#FF2C2C' : textColor }
57

58
    return (
59
      <View>
60
        <Link key={item.id} href={item.path} asChild style={itemStyle}>
61
          <Pressable>
62
            <Text style={itemColor}>
63
              {item.title}
64
            </Text>
65
          </Pressable>
66
        </Link>
67
      </View>
68
    )
69
  }
70

71
  return (
72
    <SafeAreaProvider>
73
      <SafeAreaView style={styles.container} edges={['top']}>
74
        <StatusBar style='dark' />
75
        <SectionList
76
          sections={SECTIONS}
77
          keyExtractor={(item, index) => item.title + index}
78
          renderItem={renderItem}
79
          renderSectionHeader={({section: {title}}) => (
80
            <ThemedText style={styles.header}>{title}</ThemedText>
81
          )} />
82
      </SafeAreaView>
83
    </SafeAreaProvider>
84
  )
85
}
86

87
const styles = StyleSheet.create({
88
  container: {
89
    flex: 1,
90
    paddingTop: StatusBar.currentHeight,
91
    marginHorizontal: 16
92
  },
93
  item: {
94
    paddingTop: 20,
95
    paddingBottom: 20,
96
  },
97
  header: {
98
    fontSize: 22,
99
    fontWeight: 'bold'
100
  },
101
  logout: {
102
    textColor: '#FF2C2C'
103
  }
104
});