|
| 1 | +import React, { useState } from 'react'; |
| 2 | +import { View, Switch, Text, useColorScheme, TouchableOpacity, StyleSheet } from 'react-native'; |
| 3 | +import { router } from 'expo-router'; |
| 4 | +import LanguagePicker from '../LanguagePicker'; |
| 5 | +import { Dropdown } from 'react-native-element-dropdown'; |
| 6 | + |
| 7 | +const Settings = () => { |
| 8 | + const [emailNotifications, setEmailNotifications] = useState(false); |
| 9 | + const [pushNotifications, setPushNotifications] = useState(false); |
| 10 | + const [selectedTheme, setSelectedTheme] = useState('system'); |
| 11 | + |
| 12 | + const colorScheme = selectedTheme === 'system' ? useColorScheme() : selectedTheme; |
| 13 | + const textStyle = colorScheme === 'dark' ? 'text-gray-100' : 'text-gray-800'; |
| 14 | + const borderColor = colorScheme === 'dark' ? 'border-gray-700' : 'border-gray-300'; |
| 15 | + const containerStyle = colorScheme === 'dark' ? 'bg-primary-dark' : 'bg-primary-light'; |
| 16 | + |
| 17 | + const themeData = [ |
| 18 | + { label: 'System', value: 'system' }, |
| 19 | + { label: 'Light', value: 'light' }, |
| 20 | + { label: 'Dark', value: 'dark' }, |
| 21 | + ]; |
| 22 | + |
| 23 | + return ( |
| 24 | + <View className={`p-4 mb-8 ${containerStyle}`}> |
| 25 | + <Text className={`text-2xl font-extrabold ml-4 mb-4 ${textStyle}`}>Settings</Text> |
| 26 | + |
| 27 | + {/* Profile Section */} |
| 28 | + <View className="mb-6 p-4 rounded-lg flex flex-row justify-center"> |
| 29 | + <View className="flex-1 mr-4"> |
| 30 | + <Text className={`text-xl font-bold ${textStyle}`}>Profile</Text> |
| 31 | + <Text className={`text-lg mt-2 ${textStyle}`}>Edit profile, export account, data…</Text> |
| 32 | + </View> |
| 33 | + <TouchableOpacity className="flex items-end"> |
| 34 | + <Text |
| 35 | + className={`${textStyle} mt-2`} |
| 36 | + onPress={() => router.push('/dashboard/trainee/profile')} |
| 37 | + > |
| 38 | + Change |
| 39 | + </Text> |
| 40 | + </TouchableOpacity> |
| 41 | + </View> |
| 42 | + |
| 43 | + {/* Theme Picker */} |
| 44 | + <View className={`mb-6 p-4 border-t ${borderColor} rounded-lg flex flex-row`}> |
| 45 | + <View className="flex-1 mr-4"> |
| 46 | + <Text className={`text-xl font-bold ${textStyle}`}>Appearance</Text> |
| 47 | + <Text className={`text-lg mt-2 ${textStyle}`}>Theme preferences</Text> |
| 48 | + </View> |
| 49 | + <View className="flex-row items-center gap-5"> |
| 50 | + <Dropdown |
| 51 | + labelField="label" |
| 52 | + valueField="value" |
| 53 | + data={themeData} |
| 54 | + value={selectedTheme} |
| 55 | + onChange={(item) => {}} |
| 56 | + placeholder="Select Theme" |
| 57 | + selectedTextStyle={{ color: colorScheme === 'dark' ? '#fff' : '#000' }} |
| 58 | + //@ts-ignore |
| 59 | + style={styles.picker(colorScheme)} |
| 60 | + /> |
| 61 | + </View> |
| 62 | + </View> |
| 63 | + |
| 64 | + {/* Language Picker */} |
| 65 | + <View className={`mb-6 p-4 border-t ${borderColor} rounded-lg justify-between`}> |
| 66 | + <Text className={`text-xl font-bold ${textStyle}`}>Language</Text> |
| 67 | + <View className="flex-row justify-between w-full mr-4"> |
| 68 | + <Text className={`${textStyle} mt-2 text-lg flex-1`}>Language Preference</Text> |
| 69 | + <View className={`border ${borderColor} flex-1 rounded-md `}> |
| 70 | + <LanguagePicker showFlag={false} /> |
| 71 | + </View> |
| 72 | + </View> |
| 73 | + </View> |
| 74 | + |
| 75 | + {/* Email Notifications */} |
| 76 | + <View className={`mb-6 p-4 border-t ${borderColor} rounded-lg flex-row justify-between`}> |
| 77 | + <View className="flex-1 mr-4"> |
| 78 | + <Text className={`text-xl font-bold ${textStyle}`}>Email Notifications</Text> |
| 79 | + <Text className={`text-lg mt-2 ${textStyle}`}> |
| 80 | + Feedback emails, reminder emails, news emails |
| 81 | + </Text> |
| 82 | + </View> |
| 83 | + <Switch |
| 84 | + value={emailNotifications} |
| 85 | + onValueChange={() => setEmailNotifications((prev) => !prev)} |
| 86 | + thumbColor={emailNotifications ? '#6200ee' : '#f4f3f4'} |
| 87 | + trackColor={{ false: '#767577', true: '#81b0ff' }} |
| 88 | + /> |
| 89 | + </View> |
| 90 | + |
| 91 | + {/* Push Notifications */} |
| 92 | + <View className={`mb-6 p-4 border-t ${borderColor} rounded-lg flex-row justify-between`}> |
| 93 | + <View className="flex-1 mr-4"> |
| 94 | + <Text className={`text-xl font-bold ${textStyle}`}>Push Notifications</Text> |
| 95 | + <Text className={`text-lg mt-2 ${textStyle}`}> |
| 96 | + Grade updates, session reminders, performance comments |
| 97 | + </Text> |
| 98 | + </View> |
| 99 | + <Switch |
| 100 | + value={pushNotifications} |
| 101 | + onValueChange={() => setPushNotifications((prev) => !prev)} |
| 102 | + thumbColor={pushNotifications ? '#6200ee' : '#f4f3f4'} |
| 103 | + trackColor={{ false: '#767577', true: '#81b0ff' }} |
| 104 | + /> |
| 105 | + </View> |
| 106 | + |
| 107 | + {/* Privacy and Security */} |
| 108 | + <View className={`mb-6 p-4 border-t ${borderColor} rounded-lg flex-row justify-center`}> |
| 109 | + <View className="flex-1 mr-4"> |
| 110 | + <Text className={`text-xl font-bold ${textStyle}`}>Privacy and Security</Text> |
| 111 | + <Text className={`text-lg mt-2 ${textStyle}`}>Privacy and Security</Text> |
| 112 | + </View> |
| 113 | + <Text className={`mt-2 ${textStyle}`}>Change</Text> |
| 114 | + </View> |
| 115 | + |
| 116 | + {/* Login Activity */} |
| 117 | + <View className={`p-4 mb-7 border-t ${borderColor} rounded-lg flex flex-row justify-center`}> |
| 118 | + <View className="flex-1 mr-4"> |
| 119 | + <Text className={`text-xl font-bold ${textStyle}`}>Login Activity</Text> |
| 120 | + <Text className={`text-lg ${textStyle}`}>History of Your login session</Text> |
| 121 | + </View> |
| 122 | + <Text className={`mt-2 ${textStyle}`}>View</Text> |
| 123 | + </View> |
| 124 | + </View> |
| 125 | + ); |
| 126 | +}; |
| 127 | + |
| 128 | +const styles = StyleSheet.create({ |
| 129 | + //@ts-ignore |
| 130 | + picker: (colorScheme) => ({ |
| 131 | + height: 50, |
| 132 | + width: 178, |
| 133 | + backgroundColor: colorScheme === 'dark' ? '#070E1C' : '#fff', |
| 134 | + color: colorScheme === 'dark' ? '#fff' : '#000', |
| 135 | + borderColor: colorScheme === 'dark' ? '#374151' : '#ccc', |
| 136 | + borderWidth: 1, |
| 137 | + borderRadius: 8, |
| 138 | + paddingHorizontal: 10, |
| 139 | + }), |
| 140 | +}); |
| 141 | + |
| 142 | +export default Settings; |
0 commit comments