Skip to content

Commit d9381b7

Browse files
authored
Add settings screen (#543)
1 parent 9bad403 commit d9381b7

File tree

1 file changed

+224
-14
lines changed

1 file changed

+224
-14
lines changed
Lines changed: 224 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,156 @@
11
import React from "react";
2-
import { StyleSheet, Text, View } from "react-native";
2+
import {
3+
StyleSheet,
4+
Text,
5+
View,
6+
SafeAreaView,
7+
ScrollView,
8+
TouchableOpacity,
9+
Pressable,
10+
} from "react-native";
11+
import { MaterialIcons } from "@expo/vector-icons";
12+
import { Colors } from "@/constants/Colors";
13+
14+
type SettingsItemType = {
15+
id: string;
16+
title: string;
17+
icon: keyof typeof MaterialIcons.glyphMap;
18+
route: string;
19+
subtitle?: string;
20+
};
21+
22+
const settingsItems: SettingsItemType[] = [
23+
{
24+
id: "account",
25+
title: "Account",
26+
icon: "person",
27+
route: "/settings/account",
28+
},
29+
{
30+
id: "notifications",
31+
title: "Notifications",
32+
icon: "notifications",
33+
route: "/settings/notifications",
34+
},
35+
{
36+
id: "privacy",
37+
title: "Data & Privacy",
38+
icon: "security",
39+
route: "/settings/privacy",
40+
},
41+
{
42+
id: "legal",
43+
title: "Legal",
44+
icon: "description",
45+
route: "/settings/legal",
46+
},
47+
{
48+
id: "support",
49+
title: "Support",
50+
icon: "help-outline",
51+
route: "/settings/support",
52+
},
53+
{
54+
id: "about",
55+
title: "About",
56+
icon: "info-outline",
57+
route: "/settings/about",
58+
},
59+
{
60+
id: "feedback",
61+
title: "Send feedback",
62+
subtitle: "App version 1.0",
63+
icon: "feedback",
64+
route: "/settings/feedback",
65+
},
66+
];
67+
68+
const SettingsItem = ({
69+
item,
70+
onPress,
71+
}: {
72+
item: SettingsItemType;
73+
onPress: () => void;
74+
}) => {
75+
return (
76+
<Pressable
77+
style={({ pressed }) => [
78+
styles.settingsItem,
79+
pressed && styles.pressedItem
80+
]}
81+
onPress={onPress}
82+
android_ripple={{ color: '#e0e0e0' }}
83+
accessibilityRole="button"
84+
accessibilityLabel={`${item.title}${item.subtitle ? `, ${item.subtitle}` : ''}`}
85+
>
86+
<View style={styles.itemLeftSection}>
87+
<View style={styles.iconContainer}>
88+
<MaterialIcons name={item.icon} size={24} color="#666" />
89+
</View>
90+
<View style={styles.textContainer}>
91+
<Text style={styles.itemTitle}>{item.title}</Text>
92+
{item.subtitle && (
93+
<Text style={styles.itemSubtitle}>{item.subtitle}</Text>
94+
)}
95+
</View>
96+
</View>
97+
<MaterialIcons name="chevron-right" size={24} color="#666" />
98+
</Pressable>
99+
);
100+
};
3101

4102
export default function Settings() {
103+
const handleItemPress = (route: string) => {
104+
// Navigation logic would go here
105+
console.log(`Navigate to: ${route}`);
106+
};
107+
108+
const handleLogout = () => {
109+
// Logout logic would go here
110+
console.log("Logging out...");
111+
};
112+
5113
return (
6-
<View>
7-
<Text>Settings</Text>
8-
</View>
114+
<SafeAreaView style={styles.safeArea}>
115+
{/* Header - commented out because header should not be implemented but ready to be added back or replaced.
116+
<View style={styles.header}>
117+
<Ionicons name="arrow-back" size={24} color="#666" />
118+
<Text style={styles.headerTitle}>Settings</Text>
119+
<Ionicons name="settings-outline" size={24} color="#666" />
120+
</View>
121+
*/}
122+
123+
<ScrollView style={styles.scrollContainer}>
124+
{/* Settings Title */}
125+
<Text style={styles.settingsTitle}>Settings</Text>
126+
127+
{/* Settings Items */}
128+
<View style={styles.settingsContainer}>
129+
{settingsItems.map((item, index) => (
130+
<View key={item.id}>
131+
<SettingsItem
132+
item={item}
133+
onPress={() => handleItemPress(item.route)}
134+
/>
135+
{index < settingsItems.length - 1 && (
136+
<View style={styles.separator} />
137+
)}
138+
</View>
139+
))}
140+
</View>
141+
142+
{/* Logout Button */}
143+
<View style={styles.logoutContainer}>
144+
<Pressable
145+
onPress={handleLogout}
146+
accessibilityRole="button"
147+
accessibilityLabel="Log out"
148+
>
149+
<Text style={styles.logoutText}>LOG OUT</Text>
150+
</Pressable>
151+
</View>
152+
</ScrollView>
153+
</SafeAreaView>
9154
);
10155
}
11156

@@ -14,21 +159,86 @@ const styles = StyleSheet.create({
14159
flex: 1,
15160
backgroundColor: "#f5f5f5",
16161
},
17-
container: {
162+
// Header styles
163+
// header: {
164+
// flexDirection: "row",
165+
// justifyContent: "space-between",
166+
// alignItems: "center",
167+
// paddingHorizontal: 16,
168+
// paddingVertical: 12,
169+
// backgroundColor: "#f5f5f5",
170+
// },
171+
// headerTitle: {
172+
// fontSize: 18,
173+
// fontWeight: "600",
174+
// color: "#333",
175+
// },
176+
scrollContainer: {
18177
flex: 1,
178+
paddingHorizontal: 16,
179+
},
180+
settingsTitle: {
181+
fontSize: 24,
182+
fontWeight: "600",
183+
color: "#333",
184+
marginTop: 24,
185+
marginBottom: 16,
186+
},
187+
settingsContainer: {
188+
backgroundColor: Colors.white,
189+
borderRadius: 8,
190+
marginBottom: 24,
191+
},
192+
settingsItem: {
193+
flexDirection: "row",
19194
justifyContent: "space-between",
20195
alignItems: "center",
21-
padding: 32,
22-
backgroundColor: "#f5f5f5",
196+
paddingHorizontal: 16,
197+
paddingVertical: 16,
198+
},
199+
pressedItem: {
200+
backgroundColor: "#f0f0f0",
201+
},
202+
itemLeftSection: {
203+
flexDirection: "row",
204+
alignItems: "center",
205+
flex: 1,
206+
},
207+
iconContainer: {
208+
width: 40,
209+
height: 40,
210+
borderRadius: 20,
211+
backgroundColor: "#f8f9fa",
212+
justifyContent: "center",
213+
alignItems: "center",
214+
marginRight: 12,
215+
},
216+
textContainer: {
217+
flex: 1,
218+
},
219+
itemTitle: {
220+
fontSize: 16,
221+
fontWeight: "500",
222+
color: "#333",
223+
marginBottom: 2,
23224
},
24-
content: {
25-
marginTop: 32,
225+
itemSubtitle: {
226+
fontSize: 12,
227+
color: "#666",
26228
},
27-
commonText: {
28-
textAlign: "center",
29-
color: "#222629DE",
229+
separator: {
230+
height: 1,
231+
backgroundColor: "#e0e0e0",
232+
marginLeft: 68,
233+
},
234+
logoutContainer: {
235+
marginBottom: 32,
236+
alignItems: "center",
30237
},
31-
description: {
32-
fontSize: 20,
238+
logoutText: {
239+
fontSize: 16,
240+
fontWeight: "600",
241+
color: "#333",
242+
textTransform: "uppercase",
33243
},
34244
});

0 commit comments

Comments
 (0)