diff --git a/src/app/(tabs)/settings.tsx b/src/app/(tabs)/settings.tsx index 0c1fa90..50c495f 100644 --- a/src/app/(tabs)/settings.tsx +++ b/src/app/(tabs)/settings.tsx @@ -1,79 +1,95 @@ import Constants from 'expo-constants'; -import { useRouter } from 'expo-router'; -import { Alert, Linking, Platform, View } from 'react-native'; +import { useRouter, type Href } from 'expo-router'; +import { SymbolView, type SymbolViewProps } from 'expo-symbols'; +import { Linking, View } from 'react-native'; import Animated from 'react-native-reanimated'; import { Screen } from '@/components/screen'; -import { Section, Row } from '@/components/section'; +import { Row, Section } from '@/components/section'; import { ScreenHeader } from '@/components/screen-header'; import { ThemedText } from '@/components/themed-text'; -import { Accents, Radius, Spacing, type AccentName } from '@/constants/theme'; -import { - useAccountActions, - useAccountViews, - useAlertSettings, - useBackgroundState, - useNotificationPermission, -} from '@/data/hooks'; +import { Radius, Spacing } from '@/constants/theme'; +import { useAccountViews, useAlertSettings } from '@/data/hooks'; import { useTheme } from '@/hooks/use-theme'; -import { useT, type LocaleSetting, type ThemeSetting } from '@/i18n'; +import { useT } from '@/i18n'; import { usePreferences } from '@/providers/preferences'; -import { Button, ColorSwatches, Segmented } from '@/ui/controls'; -import { haptics } from '@/ui/haptics'; -import { enterFade, enterItem, exitFade, layoutShift } from '@/ui/motion'; -import { ProviderIcon } from '@/ui/provider-icon'; -import { MultiChips, ToggleRow } from '@/ui/toggles'; +import { Button } from '@/ui/controls'; +import { enterItem } from '@/ui/motion'; +import { ACCENT_LABELS } from '@/ui/settings-labels'; const GITHUB_HANDLE = 'nextroad-dev'; const GITHUB_URL = 'https://github.com/nextroad-dev'; const SPONSOR_URL = 'https://afdian.com/a/nextroad'; -/** Spoken and shown names of the theme colours (English keys, translated with t()). */ -const ACCENT_LABELS: Record = { - blue: 'Blue', - indigo: 'Indigo', - violet: 'Violet', - pink: 'Pink', - orange: 'Orange', - green: 'Green', - teal: 'Teal', -}; +/** Small filled square with a white symbol, the familiar settings-menu affordance. */ +function MenuIcon({ name }: { name: SymbolViewProps['name'] }) { + const theme = useTheme(); + return ( + + + + ); +} +/** + * Settings hub: each area opens its own page, and the row shows its current state so most visits + * need no tap at all. + */ export default function SettingsScreen() { const router = useRouter(); const t = useT(); const theme = useTheme(); const accounts = useAccountViews(); - const views = accounts.data ?? []; - const actions = useAccountActions(); - const { settings, update } = useAlertSettings(); - const permission = useNotificationPermission(); - const background = useBackgroundState(settings.backgroundRefresh); - const { - localeSetting, - themeSetting, - accentSetting, - setLocaleSetting, - setThemeSetting, - setAccentSetting, - } = usePreferences(); + const { settings } = useAlertSettings(); + const { localeSetting, themeSetting, accentSetting } = usePreferences(); - const confirmClear = () => - Alert.alert( - t('Delete all data?'), - t('This removes every account, credential and usage history from this device.'), - [ - { text: t('Cancel'), style: 'cancel' }, - { - text: t('Delete everything'), - style: 'destructive', - onPress: () => { - haptics.warning(); - actions.removeAll(); - }, - }, - ], - ); + const language = + localeSetting === 'system' + ? t('Follow system') + : localeSetting === 'zh' + ? t('Chinese') + : t('English'); + const appearance = + themeSetting === 'system' + ? t('Follow system') + : themeSetting === 'light' + ? t('Light') + : t('Dark'); + + const menu: { icon: SymbolViewProps['name']; title: string; value?: string; href: Href }[] = [ + { + icon: { ios: 'paintbrush.fill', android: 'palette', web: 'palette' }, + title: t('Language & appearance'), + value: `${language} · ${appearance} · ${t(ACCENT_LABELS[accentSetting])}`, + href: '/settings/appearance', + }, + { + icon: { ios: 'person.2.fill', android: 'group', web: 'group' }, + title: t('Accounts'), + value: accounts.data ? String(accounts.data.length) : undefined, + href: '/settings/accounts', + }, + { + icon: { ios: 'bell.fill', android: 'notifications', web: 'notifications' }, + title: t('Alerts'), + value: settings.enabled ? t('On') : t('Off'), + href: '/settings/alerts', + }, + { + icon: { ios: 'externaldrive.fill', android: 'storage', web: 'storage' }, + title: t('Data'), + href: '/settings/data', + }, + ]; return ( @@ -98,208 +114,17 @@ export default function SettingsScreen() {