import { useState } from 'react'; import { Alert, Pressable, ScrollView, StyleSheet, Text, TextInput, View } from 'react-native'; import { router } from 'expo-router'; import { useAuthStore, type AuthState } from '../../store/auth-store'; import { getFeedbackClient } from '../../lib/feedback-client'; import { APP_PLATFORM } from '../../lib/app-metadata'; import { colors } from '../../theme'; type FeedbackType = 'bug' | 'feature' | 'praise' | 'other'; export default function SettingsScreen() { const email = useAuthStore((state: AuthState) => state.email); const signOut = useAuthStore((state: AuthState) => state.signOut); const [feedbackType, setFeedbackType] = useState('bug'); const [feedbackTitle, setFeedbackTitle] = useState(''); const [feedbackBody, setFeedbackBody] = useState(''); const [isSubmitting, setIsSubmitting] = useState(false); async function submitFeedback(): Promise { const title = feedbackTitle.trim(); if (!title || isSubmitting) { return; } setIsSubmitting(true); try { await getFeedbackClient().submitWithScreenshot({ type: feedbackType, title, body: feedbackBody.trim() || undefined, platform: APP_PLATFORM, }); setFeedbackTitle(''); setFeedbackBody(''); Alert.alert('Feedback sent', 'Thanks for sharing your feedback.'); } catch { Alert.alert('Feedback failed', 'Unable to submit feedback right now. Please try again later.'); } finally { setIsSubmitting(false); } } return ( Settings Manage account and share feedback from mobile. Account Signed in as {email ?? 'Unknown account'} { signOut(); router.replace('/auth'); }} > Sign out Send feedback {(['bug', 'feature', 'praise', 'other'] as const).map((type) => { const isActive = type === feedbackType; return ( setFeedbackType(type)} > {type} ); })} { void submitFeedback(); }} > {isSubmitting ? 'Submitting…' : 'Submit feedback'} ); } const styles = StyleSheet.create({ container: { backgroundColor: colors.bgCanvas, minHeight: '100%', padding: 20, gap: 14, }, title: { color: colors.textPrimary, fontSize: 28, fontWeight: '700', }, subtitle: { color: colors.textSecondary, fontSize: 15, lineHeight: 21, }, card: { borderRadius: 16, borderWidth: 1, borderColor: colors.borderDefault, backgroundColor: colors.surfaceCard, padding: 16, gap: 10, }, cardTitle: { color: colors.textPrimary, fontSize: 17, fontWeight: '700', }, metaLabel: { color: colors.textSecondary, fontSize: 13, textTransform: 'uppercase', letterSpacing: 0.8, }, metaValue: { color: colors.textPrimary, fontSize: 15, fontWeight: '600', }, typeRow: { flexDirection: 'row', flexWrap: 'wrap', gap: 8, }, typeChip: { borderRadius: 999, borderWidth: 1, borderColor: colors.borderDefault, backgroundColor: colors.bgElevated, paddingHorizontal: 10, paddingVertical: 6, }, typeChipActive: { borderColor: colors.accentPrimary, backgroundColor: colors.accentPrimary, }, typeChipText: { color: colors.textSecondary, fontSize: 12, fontWeight: '600', textTransform: 'capitalize', }, typeChipTextActive: { color: colors.textPrimary, }, input: { borderRadius: 12, borderWidth: 1, borderColor: colors.borderDefault, backgroundColor: colors.bgElevated, color: colors.textPrimary, paddingHorizontal: 12, paddingVertical: 10, }, bodyInput: { minHeight: 96, }, primaryButton: { borderRadius: 10, backgroundColor: colors.accentPrimary, paddingHorizontal: 14, paddingVertical: 10, alignItems: 'center', }, primaryButtonText: { color: colors.textPrimary, fontWeight: '700', }, secondaryButton: { borderRadius: 10, borderWidth: 1, borderColor: colors.borderDefault, paddingHorizontal: 14, paddingVertical: 10, alignItems: 'center', }, secondaryButtonText: { color: colors.textSecondary, fontWeight: '600', }, buttonDisabled: { opacity: 0.6, }, });