import React from 'react';
import {
View,
Text,
StyleSheet,
ScrollView,
TouchableOpacity,
Alert,
} from 'react-native';
import { useAuth } from '../../src/context/AuthContext';
import AsyncStorage from '@react-native-async-storage/async-storage';
export default function SettingsScreen() {
const { user, logout } = useAuth();
const handleLogout = () => {
Alert.alert(
'Logout',
'Are you sure you want to logout?',
[
{ text: 'Cancel', style: 'cancel' },
{
text: 'Logout',
style: 'destructive',
onPress: async () => {
await logout();
},
},
]
);
};
const handleClearData = () => {
Alert.alert(
'Clear Data',
'This will clear all stored data. Are you sure?',
[
{ text: 'Cancel', style: 'cancel' },
{
text: 'Clear',
style: 'destructive',
onPress: async () => {
try {
await AsyncStorage.clear();
Alert.alert('Success', 'All data cleared');
} catch (error) {
Alert.alert('Error', 'Failed to clear data');
}
},
},
]
);
};
const SettingItem = ({
label,
value,
onPress
}: {
label: string;
value?: string;
onPress?: () => void;
}) => (
{label}
{value || 'N/A'}
);
const ActionButton = ({
title,
onPress,
destructive = false,
}: {
title: string;
onPress: () => void;
destructive?: boolean;
}) => (
{title}
);
return (
User Information
Server
App Info
Actions
UpSnap Mobile App
Connect to your UpSnap server
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f5f5f5',
},
content: {
padding: 20,
},
section: {
backgroundColor: '#fff',
borderRadius: 12,
marginBottom: 20,
overflow: 'hidden',
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.1,
shadowRadius: 4,
elevation: 3,
},
sectionTitle: {
fontSize: 14,
fontWeight: 'bold',
color: '#666',
paddingHorizontal: 15,
paddingTop: 15,
paddingBottom: 10,
backgroundColor: '#f9f9f9',
},
settingItem: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
paddingHorizontal: 15,
paddingVertical: 15,
borderBottomWidth: 1,
borderBottomColor: '#f0f0f0',
},
settingLabel: {
fontSize: 16,
color: '#333',
flex: 1,
},
settingValueContainer: {
flex: 1,
alignItems: 'flex-end',
},
settingValue: {
fontSize: 14,
color: '#666',
maxWidth: 200,
},
actionButton: {
backgroundColor: '#007AFF',
margin: 15,
padding: 15,
borderRadius: 8,
alignItems: 'center',
},
actionButtonDestructive: {
backgroundColor: '#f44336',
},
actionButtonText: {
color: '#fff',
fontSize: 16,
fontWeight: 'bold',
},
actionButtonTextDestructive: {
color: '#fff',
},
footer: {
alignItems: 'center',
paddingVertical: 30,
},
footerText: {
fontSize: 14,
color: '#999',
marginBottom: 5,
},
});