Colota - Android GPS Location tracker
feat: reorganize settings screen into grouped menu with sub-screens
Max Dietrichad5e6d4cb8f8
diff --git a/apps/mobile/App.tsx b/apps/mobile/App.tsxindex 068a08d5..9ce80783 100644--- a/apps/mobile/App.tsx+++ b/apps/mobile/App.tsx@@ -12,6 +12,7 @@ import { ThemeProvider, useTheme } from "./src/hooks/useTheme"import { fonts } from "./src/styles/typography"import { TrackingProvider } from "./src/contexts/TrackingProvider"import { ErrorBoundary } from "./src/components/ui/ErrorBoundary"+import type { RootStackParamList, RootStackRoute } from "./src/types/navigation"import {ActivityLogScreen,DashboardScreen,@@ -30,7 +31,10 @@ import {ProfileEditorScreen,SetupImportScreen,TripDetailScreen,- OfflineMapsScreen+ OfflineMapsScreen,+ AppearanceScreen,+ ConnectionScreen,+ TrackingSyncScreen} from "./src/screens/"import { BottomTabBar } from "./src/components"import { loadDisplayPreferences } from "./src/utils/geo"@@ -39,9 +43,11 @@ MapLibreGL.setAccessToken(null)// Load display preferences earlyloadDisplayPreferences()-const Stack = createNativeStackNavigator()+const Stack = createNativeStackNavigator<RootStackParamList>()-const SCREEN_CONFIG = [+type ScreenConfig = { name: RootStackRoute; component: React.ComponentType<any>; title: string }++const SCREEN_CONFIG: readonly ScreenConfig[] = [{name: "Dashboard",component: DashboardScreen,@@ -131,8 +137,23 @@ const SCREEN_CONFIG = [name: "Activity Log",component: ActivityLogScreen,title: "Activity Log"+ },+ {+ name: "Appearance",+ component: AppearanceScreen,+ title: "Appearance"+ },+ {+ name: "Connection",+ component: ConnectionScreen,+ title: "Connection"+ },+ {+ name: "Tracking & Sync",+ component: TrackingSyncScreen,+ title: "Tracking & Sync"}-] as const+]const TAB_SCREEN_NAMES = new Set(["Dashboard", "Location History", "Geofences", "Settings"])diff --git a/apps/mobile/src/components/features/dashboard/WelcomeCard.tsx b/apps/mobile/src/components/features/dashboard/WelcomeCard.tsxindex b595e807..b1146149 100644--- a/apps/mobile/src/components/features/dashboard/WelcomeCard.tsx+++ b/apps/mobile/src/components/features/dashboard/WelcomeCard.tsx@@ -17,7 +17,8 @@ interface WelcomeCardProps {colors: ThemeColorsonDismiss: () => voidonStartTracking: () => void- onNavigateToSettings: () => void+ onNavigateToConnection: () => void+ onNavigateToTrackingSync: () => voidonNavigateToApiConfig: () => void}@@ -73,7 +74,8 @@ export function WelcomeCard({colors,onDismiss,onStartTracking,- onNavigateToSettings,+ onNavigateToConnection,+ onNavigateToTrackingSync,onNavigateToApiConfig}: WelcomeCardProps) {const {@@ -94,7 +96,7 @@ export function WelcomeCard({label="2. Configure your server endpoint"completed={hasEndpoint}colors={colors}- onPress={onNavigateToSettings}+ onPress={onNavigateToConnection}/>)}</View>@@ -109,7 +111,7 @@ export function WelcomeCard({</Pressable>)}<Pressable- onPress={onNavigateToSettings}+ onPress={onNavigateToTrackingSync}style={({ pressed }) => pressed && { opacity: colors.pressedOpacity }}><Text style={[styles.link, { color: colors.primaryDark }]}>Tracking presets</Text>diff --git a/apps/mobile/src/components/features/dashboard/__tests__/WelcomeCard.test.tsx b/apps/mobile/src/components/features/dashboard/__tests__/WelcomeCard.test.tsxindex 59064264..de6a291f 100644--- a/apps/mobile/src/components/features/dashboard/__tests__/WelcomeCard.test.tsx+++ b/apps/mobile/src/components/features/dashboard/__tests__/WelcomeCard.test.tsx@@ -45,7 +45,8 @@ const defaultProps = {colors: mockColors,onDismiss: jest.fn(),onStartTracking: jest.fn(),- onNavigateToSettings: jest.fn(),+ onNavigateToConnection: jest.fn(),+ onNavigateToTrackingSync: jest.fn(),onNavigateToApiConfig: jest.fn()}@@ -126,12 +127,28 @@ describe("WelcomeCard", () => {expect(defaultProps.onDismiss).toHaveBeenCalledTimes(1)})- it("calls onNavigateToSettings when Tracking presets is pressed", () => {+ it("calls onNavigateToTrackingSync when Tracking presets is pressed", () => {const { getByText } = render(<WelcomeCard {...defaultProps} />)fireEvent.press(getByText("Tracking presets"))- expect(defaultProps.onNavigateToSettings).toHaveBeenCalledTimes(1)+ expect(defaultProps.onNavigateToTrackingSync).toHaveBeenCalledTimes(1)+ })++ it("calls onNavigateToConnection when Configure your server endpoint is pressed", () => {+ const { getByText } = render(<WelcomeCard {...defaultProps} />)++ fireEvent.press(getByText("2. Configure your server endpoint"))++ expect(defaultProps.onNavigateToConnection).toHaveBeenCalledTimes(1)+ })++ it("calls onNavigateToApiConfig when API field mapping is pressed", () => {+ const { getByText } = render(<WelcomeCard {...defaultProps} />)++ fireEvent.press(getByText("API field mapping"))++ expect(defaultProps.onNavigateToApiConfig).toHaveBeenCalledTimes(1)})it("marks Start tracking as completed when tracking is active", () => {diff --git a/apps/mobile/src/screens/AppearanceScreen.tsx b/apps/mobile/src/screens/AppearanceScreen.tsxnew file mode 100644index 00000000..2c10560d--- /dev/null+++ b/apps/mobile/src/screens/AppearanceScreen.tsx@@ -0,0 +1,303 @@+/**+ * Copyright (C) 2026 Max Dietrich+ * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.+ */++import React, { useState, useCallback, useEffect } from "react"+import { Text, StyleSheet, Switch, View, ScrollView, Pressable, TextInput } from "react-native"+import { ScreenProps } from "../types/global"+import { useTheme } from "../hooks/useTheme"+import NativeLocationService from "../services/NativeLocationService"+import { fonts } from "../styles/typography"+import { Card, Container, Divider, SettingRow } from "../components"+import { ChevronDown, ChevronUp } from "lucide-react-native"+import { logger } from "../utils/logger"+import { loadDisplayPreferences, getUnitSystem, getTimeFormat } from "../utils/geo"+import type { UnitSystem, TimeFormat } from "../utils/geo"++export function AppearanceScreen({}: ScreenProps) {+ const { mode, toggleTheme, colors } = useTheme()++ const [unitSystem, setUnitSystem] = useState<UnitSystem>(getUnitSystem)+ const [timeFormat, setTimeFormat] = useState<TimeFormat>(getTimeFormat)++ const [mapStyleUrlLight, setMapStyleUrlLight] = useState("")+ const [mapStyleUrlDark, setMapStyleUrlDark] = useState("")+ const [showMapTileServer, setShowMapTileServer] = useState(false)++ const selectUnitSystem = useCallback(+ async (value: UnitSystem) => {+ const prev = unitSystem+ setUnitSystem(value)+ try {+ await NativeLocationService.saveSetting("unitSystem", value)+ await loadDisplayPreferences()+ } catch {+ setUnitSystem(prev)+ }+ },+ [unitSystem]+ )++ const selectTimeFormat = useCallback(+ async (value: TimeFormat) => {+ const prev = timeFormat+ setTimeFormat(value)+ try {+ await NativeLocationService.saveSetting("timeFormat", value)+ await loadDisplayPreferences()+ } catch {+ setTimeFormat(prev)+ }+ },+ [timeFormat]+ )++ useEffect(() => {+ Promise.all([+ NativeLocationService.getSetting("mapStyleUrlLight"),+ NativeLocationService.getSetting("mapStyleUrlDark")+ ])+ .then(([light, dark]) => {+ setMapStyleUrlLight(light ?? "")+ setMapStyleUrlDark(dark ?? "")+ })+ .catch(() => {})+ }, [])++ const saveMapStyleUrl = useCallback(async (key: "mapStyleUrlLight" | "mapStyleUrlDark", value: string) => {+ try {+ await NativeLocationService.saveSetting(key, value.trim())+ } catch (err) {+ logger.error("[AppearanceScreen] Failed to save map style URL:", err)+ }+ }, [])++ const resetMapStyle = useCallback(() => {+ setMapStyleUrlLight("")+ setMapStyleUrlDark("")+ Promise.all([+ NativeLocationService.saveSetting("mapStyleUrlLight", ""),+ NativeLocationService.saveSetting("mapStyleUrlDark", "")+ ]).catch((err) => logger.error("[AppearanceScreen] Failed to reset map style URLs:", err))+ }, [])++ return (+ <Container>+ <ScrollView+ contentContainerStyle={styles.scrollContent}+ keyboardShouldPersistTaps="handled"+ showsVerticalScrollIndicator={false}+ >+ <Card>+ <SettingRow label="Dark Mode">+ <Switch+ testID="dark-mode-switch"+ value={mode === "dark"}+ onValueChange={toggleTheme}+ trackColor={{+ false: colors.border,+ true: colors.primary + "80"+ }}+ thumbColor={mode === "dark" ? colors.primary : colors.border}+ />+ </SettingRow>++ <Divider />++ <SettingRow label="Units">+ <View style={styles.chipGroup}>+ {(["metric", "imperial"] as const).map((unit) => {+ const selected = unitSystem === unit+ return (+ <Pressable+ key={unit}+ testID={`unit-${unit}`}+ style={[+ styles.chip,+ {+ backgroundColor: selected ? colors.primary + "15" : colors.background,+ borderColor: selected ? colors.primary : colors.border+ }+ ]}+ onPress={() => selectUnitSystem(unit)}+ >+ <Text style={[styles.chipLabel, { color: selected ? colors.primary : colors.text }]}>+ {unit === "metric" ? "Metric" : "Imperial"}+ </Text>+ </Pressable>+ )+ })}+ </View>+ </SettingRow>++ <Divider />++ <SettingRow label="Time Format">+ <View style={styles.chipGroup}>+ {(["24h", "12h"] as const).map((fmt) => {+ const selected = timeFormat === fmt+ return (+ <Pressable+ key={fmt}+ testID={`time-format-${fmt}`}+ style={[+ styles.chip,+ {+ backgroundColor: selected ? colors.primary + "15" : colors.background,+ borderColor: selected ? colors.primary : colors.border+ }+ ]}+ onPress={() => selectTimeFormat(fmt)}+ >+ <Text style={[styles.chipLabel, { color: selected ? colors.primary : colors.text }]}>{fmt}</Text>+ </Pressable>+ )+ })}+ </View>+ </SettingRow>++ <Divider />++ <Pressable+ testID="map-tile-server-toggle"+ style={({ pressed }) => [styles.linkRow, pressed && { opacity: colors.pressedOpacity }]}+ onPress={() => setShowMapTileServer(!showMapTileServer)}+ >+ <View style={styles.linkContent}>+ <Text style={[styles.linkLabel, { color: colors.text }]}>Map Tile Server</Text>+ <Text style={[styles.linkSub, { color: colors.textSecondary }]}>+ Override the default map tile source+ </Text>+ </View>+ {showMapTileServer ? (+ <ChevronUp size={20} color={colors.textLight} />+ ) : (+ <ChevronDown size={20} color={colors.textLight} />+ )}+ </Pressable>++ {showMapTileServer && (+ <View style={styles.mapTilePanel}>+ <Text style={[styles.mapStyleSub, styles.mapStyleSubFirst, { color: colors.textSecondary }]}>+ Light style URL+ </Text>+ <TextInput+ testID="map-style-url-light"+ style={[+ styles.mapStyleInput,+ { borderColor: colors.border, color: colors.text, backgroundColor: colors.background }+ ]}+ value={mapStyleUrlLight}+ onChangeText={setMapStyleUrlLight}+ onBlur={() => saveMapStyleUrl("mapStyleUrlLight", mapStyleUrlLight)}+ placeholder="Default"+ placeholderTextColor={colors.placeholder}+ autoCapitalize="none"+ autoCorrect={false}+ keyboardType="url"+ />+ <Text style={[styles.mapStyleSub, styles.mapStyleSubSecond, { color: colors.textSecondary }]}>+ Dark style URL+ </Text>+ <TextInput+ testID="map-style-url-dark"+ style={[+ styles.mapStyleInput,+ { borderColor: colors.border, color: colors.text, backgroundColor: colors.background }+ ]}+ value={mapStyleUrlDark}+ onChangeText={setMapStyleUrlDark}+ onBlur={() => saveMapStyleUrl("mapStyleUrlDark", mapStyleUrlDark)}+ placeholder="Default"+ placeholderTextColor={colors.placeholder}+ autoCapitalize="none"+ autoCorrect={false}+ keyboardType="url"+ />+ <View style={styles.mapStyleFooter}>+ <Text style={[styles.mapStyleHint, { color: colors.textLight }]}>Leave empty to use the default</Text>+ {mapStyleUrlLight.trim() || mapStyleUrlDark.trim() ? (+ <Pressable+ onPress={resetMapStyle}+ style={({ pressed }) => pressed && { opacity: colors.pressedOpacity }}+ >+ <Text style={[styles.mapStyleHint, { color: colors.primary }]}>Reset to default</Text>+ </Pressable>+ ) : null}+ </View>+ </View>+ )}+ </Card>+ </ScrollView>+ </Container>+ )+}++const styles = StyleSheet.create({+ scrollContent: {+ paddingHorizontal: 16,+ paddingTop: 16,+ paddingBottom: 16+ },+ linkRow: {+ flexDirection: "row",+ justifyContent: "space-between",+ alignItems: "center",+ paddingVertical: 12+ },+ linkContent: {+ flex: 1+ },+ linkLabel: {+ fontSize: 16,+ ...fonts.semiBold,+ marginBottom: 2+ },+ linkSub: {+ fontSize: 13,+ ...fonts.regular+ },+ chipGroup: {+ flexDirection: "row",+ gap: 8+ },+ chip: {+ paddingHorizontal: 14,+ paddingVertical: 8,+ borderRadius: 10,+ borderWidth: 1.5+ },+ chipLabel: {+ fontSize: 13,+ ...fonts.semiBold+ },+ mapTilePanel: {+ marginTop: 4,+ paddingBottom: 4+ },+ mapStyleSub: {+ fontSize: 12,+ ...fonts.medium,+ marginBottom: 6+ },+ mapStyleSubFirst: { marginTop: 12 },+ mapStyleSubSecond: { marginTop: 10 },+ mapStyleInput: {+ borderWidth: 1.5,+ padding: 12,+ borderRadius: 12,+ fontSize: 13,+ ...fonts.regular+ },+ mapStyleFooter: {+ flexDirection: "row",+ justifyContent: "space-between",+ alignItems: "center",+ marginTop: 8+ },+ mapStyleHint: {+ fontSize: 11,+ ...fonts.regular+ }+})diff --git a/apps/mobile/src/screens/ConnectionScreen.tsx b/apps/mobile/src/screens/ConnectionScreen.tsxnew file mode 100644index 00000000..ed8da034--- /dev/null+++ b/apps/mobile/src/screens/ConnectionScreen.tsx@@ -0,0 +1,65 @@+/**+ * Copyright (C) 2026 Max Dietrich+ * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.+ */++import React, { useState, useCallback, useEffect } from "react"+import { StyleSheet, ScrollView } from "react-native"+import { ScreenProps, Settings } from "../types/global"+import { useTheme } from "../hooks/useTheme"+import { useAutoSave } from "../hooks/useAutoSave"+import { useTracking } from "../contexts/TrackingProvider"+import { FloatingSaveIndicator } from "../components/ui/FloatingSaveIndicator"+import { Container } from "../components"+import { ConnectionSettings } from "../components/features/settings/ConnectionSettings"++export function ConnectionScreen({ navigation }: ScreenProps) {+ const { settings, setSettings, restartTracking } = useTracking()+ const { colors } = useTheme()+ const { saving, saveSuccess, immediateSaveAndRestart } = useAutoSave()++ const [endpointInput, setEndpointInput] = useState(settings.endpoint || "")++ useEffect(() => {+ setEndpointInput(settings.endpoint || "")+ }, [settings.endpoint])++ const handleImmediateSave = useCallback(+ (newSettings: Settings) => {+ immediateSaveAndRestart(+ () => setSettings(newSettings),+ () => restartTracking(newSettings)+ )+ },+ [setSettings, immediateSaveAndRestart, restartTracking]+ )++ return (+ <Container>+ <ScrollView+ contentContainerStyle={styles.scrollContent}+ keyboardShouldPersistTaps="handled"+ showsVerticalScrollIndicator={false}+ >+ <ConnectionSettings+ settings={settings}+ endpointInput={endpointInput}+ onEndpointInputChange={setEndpointInput}+ onSettingsChange={handleImmediateSave}+ colors={colors}+ navigation={navigation}+ />+ </ScrollView>++ <FloatingSaveIndicator saving={saving} success={saveSuccess} colors={colors} />+ </Container>+ )+}++const styles = StyleSheet.create({+ scrollContent: {+ paddingHorizontal: 16,+ paddingTop: 16,+ paddingBottom: 16+ }+})diff --git a/apps/mobile/src/screens/DashboardScreen.tsx b/apps/mobile/src/screens/DashboardScreen.tsxindex 1d3e28a0..be1b0bc1 100644--- a/apps/mobile/src/screens/DashboardScreen.tsx+++ b/apps/mobile/src/screens/DashboardScreen.tsx@@ -203,7 +203,8 @@ export function DashboardScreen({ navigation }: ScreenProps) {colors={colors}onDismiss={() => setSettings({ ...settings, hasCompletedSetup: true })}onStartTracking={handleStart}- onNavigateToSettings={() => navigation.navigate("Settings")}+ onNavigateToConnection={() => navigation.navigate("Connection")}+ onNavigateToTrackingSync={() => navigation.navigate("Tracking & Sync")}onNavigateToApiConfig={() => navigation.navigate("API Config")}/>)}diff --git a/apps/mobile/src/screens/SettingsScreen.tsx b/apps/mobile/src/screens/SettingsScreen.tsxindex 883e5e56..7ba77caa 100644--- a/apps/mobile/src/screens/SettingsScreen.tsx+++ b/apps/mobile/src/screens/SettingsScreen.tsx@@ -3,115 +3,39 @@* Licensed under the GNU AGPLv3. See LICENSE in the project root for details.*/-import React, { useState, useCallback, useEffect } from "react"+import React, { useState, useCallback, useMemo, useEffect } from "react"import { useFocusEffect } from "@react-navigation/native"-import { Text, StyleSheet, Switch, View, ScrollView, Pressable, TextInput, Linking } from "react-native"-import { ScreenProps, Settings } from "../types/global"-import { useTheme } from "../hooks/useTheme"-import { useAutoSave } from "../hooks/useAutoSave"-import { STATS_REFRESH_FAST, STATS_REFRESH_IDLE } from "../constants"+import { StyleSheet, View, ScrollView, Linking, DeviceEventEmitter } from "react-native"+import { TRACKING_PRESETS, API_TEMPLATES } from "../types/global"+import type { RootScreenProps } from "../types/navigation"import NativeLocationService from "../services/NativeLocationService"import { useTracking } from "../contexts/TrackingProvider"-import { FloatingSaveIndicator } from "../components/ui/FloatingSaveIndicator"-import { fonts } from "../styles/typography"-import { SectionTitle, Card, Container, Divider, SettingRow, StatsCard } from "../components"-import { ChevronRight, ChevronDown, ChevronUp, ExternalLink } from "lucide-react-native"+import { SectionTitle, Card, Container, Divider, StatsCard, ListItem } from "../components"+import {+ ExternalLink,+ Cloud,+ Navigation,+ Braces,+ UserRoundPen,+ Palette,+ Database,+ Download,+ Map,+ ScrollText,+ Info,+ Heart+} from "lucide-react-native"import { logger } from "../utils/logger"-import { ConnectionSettings } from "../components/features/settings/ConnectionSettings"-import { SyncStrategySettings } from "../components/features/settings/SyncStrategySettings"-import { loadDisplayPreferences, getUnitSystem, getTimeFormat } from "../utils/geo"-import type { UnitSystem, TimeFormat } from "../utils/geo"-/**- * Settings screen for configuring location tracking.- * Features auto-save, presets, and advanced customization.- */-export function SettingsScreen({ navigation }: ScreenProps) {- const { settings, setSettings, updateSettingsLocal, tracking, restartTracking } = useTracking()- const { mode, toggleTheme, colors } = useTheme()- const { saving, saveSuccess, debouncedSaveAndRestart, immediateSaveAndRestart } = useAutoSave()+type Props = RootScreenProps<"Settings">++export function SettingsScreen({ navigation }: Props) {+ const { settings } = useTracking()- // Statsconst [queueCount, setQueueCount] = useState(0)const [sentCount, setSentCount] = useState(0)const [todayCount, setTodayCount] = useState(0)- // Endpoint input (managed here since ConnectionSettings needs it and we sync with settings)- const [endpointInput, setEndpointInput] = useState(settings.endpoint || "")-- // Display preferences (preselect from locale if not yet saved)- const [unitSystem, setUnitSystem] = useState<UnitSystem>(getUnitSystem)- const [timeFormat, setTimeFormat] = useState<TimeFormat>(getTimeFormat)-- // Map style URLs- const [mapStyleUrlLight, setMapStyleUrlLight] = useState("")- const [mapStyleUrlDark, setMapStyleUrlDark] = useState("")- const [showMapTileServer, setShowMapTileServer] = useState(false)-- const selectUnitSystem = useCallback(- async (value: UnitSystem) => {- const prev = unitSystem- setUnitSystem(value)- try {- await NativeLocationService.saveSetting("unitSystem", value)- await loadDisplayPreferences()- } catch {- setUnitSystem(prev)- }- },- [unitSystem]- )-- const selectTimeFormat = useCallback(- async (value: TimeFormat) => {- const prev = timeFormat- setTimeFormat(value)- try {- await NativeLocationService.saveSetting("timeFormat", value)- await loadDisplayPreferences()- } catch {- setTimeFormat(prev)- }- },- [timeFormat]- )-- // Load map style URLs from settings- useEffect(() => {- Promise.all([- NativeLocationService.getSetting("mapStyleUrlLight"),- NativeLocationService.getSetting("mapStyleUrlDark")- ])- .then(([light, dark]) => {- setMapStyleUrlLight(light ?? "")- setMapStyleUrlDark(dark ?? "")- })- .catch(() => {})- }, [])-- const saveMapStyleUrl = useCallback(async (key: "mapStyleUrlLight" | "mapStyleUrlDark", value: string) => {- try {- await NativeLocationService.saveSetting(key, value.trim())- } catch (err) {- logger.error("[SettingsScreen] Failed to save map style URL:", err)- }- }, [])-- const resetMapStyle = useCallback(() => {- setMapStyleUrlLight("")- setMapStyleUrlDark("")- Promise.all([- NativeLocationService.saveSetting("mapStyleUrlLight", ""),- NativeLocationService.saveSetting("mapStyleUrlDark", "")- ]).catch((err) => logger.error("[SettingsScreen] Failed to reset map style URLs:", err))- }, [])-- // Sync endpoint input with settings changes- useEffect(() => {- setEndpointInput(settings.endpoint || "")- }, [settings.endpoint])-- /** Update stats */const updateStats = useCallback(async () => {try {const stats = await NativeLocationService.getStats()@@ -123,36 +47,48 @@ export function SettingsScreen({ navigation }: ScreenProps) {}}, [])- // Poll stats: 3s when tracking, 30s when idle (only while screen is focused)useFocusEffect(useCallback(() => {updateStats()- const interval = setInterval(updateStats, tracking ? STATS_REFRESH_FAST : STATS_REFRESH_IDLE)- return () => clearInterval(interval)- }, [updateStats, tracking])+ const subs = [+ DeviceEventEmitter.addListener("onLocationUpdate", updateStats),+ DeviceEventEmitter.addListener("onSyncProgress", updateStats),+ DeviceEventEmitter.addListener("onSyncError", updateStats)+ ]+ return () => subs.forEach((s) => s.remove())+ }, [updateStats]))- /** Debounced save + restart for continuous changes (text input, sliders) */- const handleDebouncedSave = useCallback(- (newSettings: Settings) => {- debouncedSaveAndRestart(- () => setSettings(newSettings),- () => restartTracking(newSettings)- )- },- [setSettings, debouncedSaveAndRestart, restartTracking]- )+ useEffect(() => {+ updateStats()+ }, [settings.isOfflineMode, settings.endpoint, updateStats])- /** Immediate save + restart for discrete changes (toggles, presets) */- const handleImmediateSave = useCallback(- (newSettings: Settings) => {- immediateSaveAndRestart(- () => setSettings(newSettings),- () => restartTracking(newSettings)- )- },- [setSettings, immediateSaveAndRestart, restartTracking]- )+ const connectionSummary = useMemo(() => {+ if (settings.isOfflineMode) return "Offline - saved locally"+ if (!settings.endpoint) return "No server configured"+ try {+ return new URL(settings.endpoint).host+ } catch {+ return settings.endpoint+ }+ }, [settings.isOfflineMode, settings.endpoint])++ const syncSummary = useMemo(() => {+ const preset = settings.syncPreset+ if (preset !== "custom" && TRACKING_PRESETS[preset]) {+ return `${TRACKING_PRESETS[preset].label} · every ${settings.interval}s`+ }+ return `Custom · every ${settings.interval}s`+ }, [settings.syncPreset, settings.interval])++ const apiSummary = useMemo(() => {+ const template = settings.apiTemplate+ if (template === "custom") {+ const fieldCount = Object.values(settings.fieldMap).filter(Boolean).length + settings.customFields.length+ return `Custom (${fieldCount} field${fieldCount === 1 ? "" : "s"})`+ }+ return API_TEMPLATES[template]?.label ?? "Custom"+ }, [settings.apiTemplate, settings.fieldMap, settings.customFields])const handleNavigateDataManagement = useCallback(() => {navigation.navigate("Data Management")@@ -165,318 +101,127 @@ export function SettingsScreen({ navigation }: ScreenProps) {keyboardShouldPersistTaps="handled"showsVerticalScrollIndicator={false}>- {/* Header */}- <View style={styles.header}>- <Text style={[styles.title, { color: colors.text }]}>Settings</Text>- </View>-- {/* Stats Card */}<StatsCardqueueCount={queueCount}sentCount={sentCount}todayCount={todayCount}interval={settings.interval.toString()}onManageClick={handleNavigateDataManagement}- colors={colors}- />-- {/* Connection */}- <ConnectionSettings- settings={settings}- endpointInput={endpointInput}- onEndpointInputChange={setEndpointInput}- onSettingsChange={handleImmediateSave}- colors={colors}- navigation={navigation}/>- {/* Tracking Configuration */}- <SyncStrategySettings- settings={settings}- onSettingsChange={updateSettingsLocal}- onDebouncedSave={handleDebouncedSave}- onImmediateSave={handleImmediateSave}- colors={colors}- />-- {/* Appearance */}<View style={styles.section}>- <SectionTitle>Appearance</SectionTitle><Card>- <SettingRow label="Dark Mode">- <Switch- testID="dark-mode-switch"- value={mode === "dark"}- onValueChange={toggleTheme}- trackColor={{- false: colors.border,- true: colors.primary + "80"- }}- thumbColor={mode === "dark" ? colors.primary : colors.border}- />- </SettingRow>-- <Divider />-- <SettingRow label="Units">- <View style={styles.chipGroup}>- {(["metric", "imperial"] as const).map((unit) => {- const selected = unitSystem === unit- return (- <Pressable- key={unit}- testID={`unit-${unit}`}- style={[- styles.chip,- {- backgroundColor: selected ? colors.primary + "15" : colors.background,- borderColor: selected ? colors.primary : colors.border- }- ]}- onPress={() => selectUnitSystem(unit)}- >- <Text style={[styles.chipLabel, { color: selected ? colors.primary : colors.text }]}>- {unit === "metric" ? "Metric" : "Imperial"}- </Text>- </Pressable>- )- })}- </View>- </SettingRow>-+ <ListItem+ testID="nav-connection"+ icon={Cloud}+ label="Connection"+ sub={connectionSummary}+ onPress={() => navigation.navigate("Connection")}+ /><Divider />-- <SettingRow label="Time Format">- <View style={styles.chipGroup}>- {(["24h", "12h"] as const).map((fmt) => {- const selected = timeFormat === fmt- return (- <Pressable- key={fmt}- testID={`time-format-${fmt}`}- style={[- styles.chip,- {- backgroundColor: selected ? colors.primary + "15" : colors.background,- borderColor: selected ? colors.primary : colors.border- }- ]}- onPress={() => selectTimeFormat(fmt)}- >- <Text style={[styles.chipLabel, { color: selected ? colors.primary : colors.text }]}>{fmt}</Text>- </Pressable>- )- })}- </View>- </SettingRow>-- <Divider />-- <Pressable- testID="map-tile-server-toggle"- style={({ pressed }) => [styles.linkRow, pressed && { opacity: colors.pressedOpacity }]}- onPress={() => setShowMapTileServer(!showMapTileServer)}- >- <View style={styles.linkContent}>- <Text style={[styles.linkLabel, { color: colors.text }]}>Map Tile Server</Text>- <Text style={[styles.linkSub, { color: colors.textSecondary }]}>- Override the default map tile source- </Text>- </View>- {showMapTileServer ? (- <ChevronUp size={20} color={colors.textLight} />- ) : (- <ChevronDown size={20} color={colors.textLight} />- )}- </Pressable>-- {showMapTileServer && (- <View style={styles.mapTilePanel}>- <Text style={[styles.mapStyleSub, styles.mapStyleSubFirst, { color: colors.textSecondary }]}>- Light style URL- </Text>- <TextInput- testID="map-style-url-light"- style={[- styles.mapStyleInput,- { borderColor: colors.border, color: colors.text, backgroundColor: colors.background }- ]}- value={mapStyleUrlLight}- onChangeText={setMapStyleUrlLight}- onBlur={() => saveMapStyleUrl("mapStyleUrlLight", mapStyleUrlLight)}- placeholder="Default"- placeholderTextColor={colors.placeholder}- autoCapitalize="none"- autoCorrect={false}- keyboardType="url"- />- <Text style={[styles.mapStyleSub, styles.mapStyleSubSecond, { color: colors.textSecondary }]}>- Dark style URL- </Text>- <TextInput- testID="map-style-url-dark"- style={[- styles.mapStyleInput,- { borderColor: colors.border, color: colors.text, backgroundColor: colors.background }- ]}- value={mapStyleUrlDark}- onChangeText={setMapStyleUrlDark}- onBlur={() => saveMapStyleUrl("mapStyleUrlDark", mapStyleUrlDark)}- placeholder="Default"- placeholderTextColor={colors.placeholder}- autoCapitalize="none"- autoCorrect={false}- keyboardType="url"+ <ListItem+ testID="nav-tracking-sync"+ icon={Navigation}+ label="Tracking & Sync"+ sub={syncSummary}+ onPress={() => navigation.navigate("Tracking & Sync")}+ />+ {!settings.isOfflineMode && (+ <>+ <Divider />+ <ListItem+ testID="nav-api-config"+ icon={Braces}+ label="API Field Mapping"+ sub={apiSummary}+ onPress={() => navigation.navigate("API Config")}/>- <View style={styles.mapStyleFooter}>- <Text style={[styles.mapStyleHint, { color: colors.textLight }]}>Leave empty to use the default</Text>- {mapStyleUrlLight.trim() || mapStyleUrlDark.trim() ? (- <Pressable- onPress={resetMapStyle}- style={({ pressed }) => pressed && { opacity: colors.pressedOpacity }}- >- <Text style={[styles.mapStyleHint, { color: colors.primary }]}>Reset to default</Text>- </Pressable>- ) : null}- </View>- </View>+ </>)}+ <Divider />+ <ListItem+ testID="nav-tracking-profiles"+ icon={UserRoundPen}+ label="Tracking Profiles"+ sub="Auto-switch GPS settings based on conditions"+ onPress={() => navigation.navigate("Tracking Profiles")}+ /></Card></View>- {/* Advanced */}<View style={styles.section}>- <SectionTitle>Advanced</SectionTitle>+ <SectionTitle>Display</SectionTitle><Card>- <Pressable- testID="nav-tracking-profiles"- style={({ pressed }) => [styles.linkRow, pressed && { opacity: colors.pressedOpacity }]}- onPress={() => navigation.navigate("Tracking Profiles")}- >- <View style={styles.linkContent}>- <Text style={[styles.linkLabel, { color: colors.text }]}>Tracking Profiles</Text>- <Text style={[styles.linkSub, { color: colors.textSecondary }]}>- Auto-switch GPS settings based on conditions- </Text>- </View>- <ChevronRight size={20} color={colors.textLight} />- </Pressable>+ <ListItem+ testID="nav-appearance"+ icon={Palette}+ label="Appearance"+ sub="Theme, units, time format and map tiles"+ onPress={() => navigation.navigate("Appearance")}+ />+ </Card>+ </View>+ <View style={styles.section}>+ <SectionTitle>Data</SectionTitle>+ <Card>+ <ListItem+ testID="nav-data-management"+ icon={Database}+ label="Data Management"+ sub="View queue and clear data"+ onPress={() => navigation.navigate("Data Management")}+ /><Divider />-- <Pressable+ <ListItem+ testID="nav-export-data"+ icon={Download}+ label="Export Data"+ sub="Export locations as CSV, GeoJSON, GPX or KML"+ onPress={() => navigation.navigate("Export Data")}+ />+ <Divider />+ <ListItemtestID="nav-offline-maps"- style={({ pressed }) => [styles.linkRow, pressed && { opacity: colors.pressedOpacity }]}+ icon={Map}+ label="Offline Maps"+ sub="Download map tiles for use without internet"onPress={() => navigation.navigate("Offline Maps")}- >- <View style={styles.linkContent}>- <Text style={[styles.linkLabel, { color: colors.text }]}>Offline Maps</Text>- <Text style={[styles.linkSub, { color: colors.textSecondary }]}>- Download map tiles for use without internet- </Text>- </View>- <ChevronRight size={20} color={colors.textLight} />- </Pressable>-- <Divider />-- <Pressable- testID="nav-data-management"- style={({ pressed }) => [styles.linkRow, pressed && { opacity: colors.pressedOpacity }]}- onPress={() => navigation.navigate("Data Management")}- >- <View style={styles.linkContent}>- <Text style={[styles.linkLabel, { color: colors.text }]}>Data Management</Text>- <Text style={[styles.linkSub, { color: colors.textSecondary }]}>View queue and clear data</Text>- </View>- <ChevronRight size={20} color={colors.textLight} />- </Pressable>-- {!settings.isOfflineMode && (- <>- <Divider />-- <Pressable- testID="nav-api-config"- style={({ pressed }) => [styles.linkRow, pressed && { opacity: colors.pressedOpacity }]}- onPress={() => navigation.navigate("API Config")}- >- <View style={styles.linkContent}>- <Text style={[styles.linkLabel, { color: colors.text }]}>API Field Mapping</Text>- <Text style={[styles.linkSub, { color: colors.textSecondary }]}>- Customize JSON payload structure- </Text>- </View>- <ChevronRight size={20} color={colors.textLight} />- </Pressable>- </>- )}-+ /><Divider />-- <Pressable+ <ListItemtestID="nav-activity-log"- style={({ pressed }) => [styles.linkRow, pressed && { opacity: colors.pressedOpacity }]}+ icon={ScrollText}+ label="Activity Log"+ sub="View and export debug logs"onPress={() => navigation.navigate("Activity Log")}- >- <View style={styles.linkContent}>- <Text style={[styles.linkLabel, { color: colors.text }]}>Activity Log</Text>- <Text style={[styles.linkSub, { color: colors.textSecondary }]}>View and export debug logs</Text>- </View>- <ChevronRight size={20} color={colors.textLight} />- </Pressable>-- <Divider />-- <Pressable- testID="nav-export-data"- style={({ pressed }) => [styles.linkRow, pressed && { opacity: colors.pressedOpacity }]}- onPress={() => navigation.navigate("Export Data")}- >- <View style={styles.linkContent}>- <Text style={[styles.linkLabel, { color: colors.text }]}>Export Data</Text>- <Text style={[styles.linkSub, { color: colors.textSecondary }]}>- Export locations as CSV, GeoJSON, GPX or KML- </Text>- </View>- <ChevronRight size={20} color={colors.textLight} />- </Pressable>+ /></Card></View>- {/* About & Support */}<View style={styles.section}><Card>- <Pressable+ <ListItemtestID="nav-about"- style={({ pressed }) => [styles.linkRow, pressed && { opacity: colors.pressedOpacity }]}+ icon={Info}+ label="About Colota"+ sub="Version, licenses and links"onPress={() => navigation.navigate("About Colota")}- >- <View style={styles.linkContent}>- <Text style={[styles.linkLabel, { color: colors.text }]}>About Colota</Text>- <Text style={[styles.linkSub, { color: colors.textSecondary }]}>Version, licenses and links</Text>- </View>- <ChevronRight size={20} color={colors.textLight} />- </Pressable>-+ /><Divider />-- <Pressable+ <ListItemtestID="nav-support"- style={({ pressed }) => [styles.linkRow, pressed && { opacity: colors.pressedOpacity }]}+ icon={Heart}+ label="Support"+ sub="Support development of the app"+ trailingIcon={ExternalLink}+ accessibilityRole="link"+ accessibilityHint="Opens external support page"onPress={() => Linking.openURL("https://mxd.codes/support")}- >- <View style={styles.linkContent}>- <Text style={[styles.linkLabel, { color: colors.text }]}>Support</Text>- <Text style={[styles.linkSub, { color: colors.textSecondary }]}>Support development of the app</Text>- </View>- <ExternalLink size={18} color={colors.textLight} />- </Pressable>+ /></Card></View></ScrollView>-- <FloatingSaveIndicator saving={saving} success={saveSuccess} colors={colors} /></Container>)}@@ -487,75 +232,7 @@ const styles = StyleSheet.create({paddingTop: 16,paddingBottom: 16},- header: {- marginBottom: 20- },- title: {- fontSize: 28,- ...fonts.bold,- letterSpacing: -0.5- },section: {marginBottom: 24- },- linkRow: {- flexDirection: "row",- justifyContent: "space-between",- alignItems: "center",- paddingVertical: 12- },- linkContent: {- flex: 1- },- linkLabel: {- fontSize: 16,- ...fonts.semiBold,- marginBottom: 2- },- linkSub: {- fontSize: 13,- ...fonts.regular- },- chipGroup: {- flexDirection: "row",- gap: 8- },- chip: {- paddingHorizontal: 14,- paddingVertical: 8,- borderRadius: 10,- borderWidth: 1.5- },- chipLabel: {- fontSize: 13,- ...fonts.semiBold- },- mapTilePanel: {- marginTop: 4,- paddingBottom: 4- },- mapStyleSub: {- fontSize: 12,- ...fonts.medium,- marginBottom: 6- },- mapStyleSubFirst: { marginTop: 12 },- mapStyleSubSecond: { marginTop: 10 },- mapStyleInput: {- borderWidth: 1.5,- padding: 12,- borderRadius: 12,- fontSize: 13,- ...fonts.regular- },- mapStyleFooter: {- flexDirection: "row",- justifyContent: "space-between",- alignItems: "center",- marginTop: 8- },- mapStyleHint: {- fontSize: 11,- ...fonts.regular}})diff --git a/apps/mobile/src/screens/TrackingSyncScreen.tsx b/apps/mobile/src/screens/TrackingSyncScreen.tsxnew file mode 100644index 00000000..e0f1f825--- /dev/null+++ b/apps/mobile/src/screens/TrackingSyncScreen.tsx@@ -0,0 +1,68 @@+/**+ * Copyright (C) 2026 Max Dietrich+ * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.+ */++import React, { useCallback } from "react"+import { StyleSheet, ScrollView } from "react-native"+import { ScreenProps, Settings } from "../types/global"+import { useTheme } from "../hooks/useTheme"+import { useAutoSave } from "../hooks/useAutoSave"+import { useTracking } from "../contexts/TrackingProvider"+import { FloatingSaveIndicator } from "../components/ui/FloatingSaveIndicator"+import { Container } from "../components"+import { SyncStrategySettings } from "../components/features/settings/SyncStrategySettings"++export function TrackingSyncScreen({}: ScreenProps) {+ const { settings, setSettings, updateSettingsLocal, restartTracking } = useTracking()+ const { colors } = useTheme()+ const { saving, saveSuccess, debouncedSaveAndRestart, immediateSaveAndRestart } = useAutoSave()++ const handleDebouncedSave = useCallback(+ (newSettings: Settings) => {+ debouncedSaveAndRestart(+ () => setSettings(newSettings),+ () => restartTracking(newSettings)+ )+ },+ [setSettings, debouncedSaveAndRestart, restartTracking]+ )++ const handleImmediateSave = useCallback(+ (newSettings: Settings) => {+ immediateSaveAndRestart(+ () => setSettings(newSettings),+ () => restartTracking(newSettings)+ )+ },+ [setSettings, immediateSaveAndRestart, restartTracking]+ )++ return (+ <Container>+ <ScrollView+ contentContainerStyle={styles.scrollContent}+ keyboardShouldPersistTaps="handled"+ showsVerticalScrollIndicator={false}+ >+ <SyncStrategySettings+ settings={settings}+ onSettingsChange={updateSettingsLocal}+ onDebouncedSave={handleDebouncedSave}+ onImmediateSave={handleImmediateSave}+ colors={colors}+ />+ </ScrollView>++ <FloatingSaveIndicator saving={saving} success={saveSuccess} colors={colors} />+ </Container>+ )+}++const styles = StyleSheet.create({+ scrollContent: {+ paddingHorizontal: 16,+ paddingTop: 16,+ paddingBottom: 40+ }+})diff --git a/apps/mobile/src/screens/__tests__/AppearanceScreen.test.tsx b/apps/mobile/src/screens/__tests__/AppearanceScreen.test.tsxnew file mode 100644index 00000000..39c03ee4--- /dev/null+++ b/apps/mobile/src/screens/__tests__/AppearanceScreen.test.tsx@@ -0,0 +1,125 @@+import React from "react"+import { render, fireEvent, waitFor } from "@testing-library/react-native"++// --- Mocks ---++const mockToggleTheme = jest.fn()++jest.mock("../../hooks/useTheme", () => ({+ useTheme: () => ({+ mode: "light",+ toggleTheme: mockToggleTheme,+ colors: {+ primary: "#0d9488",+ primaryDark: "#115E59",+ border: "#e5e7eb",+ text: "#000",+ textSecondary: "#6b7280",+ textLight: "#9ca3af",+ background: "#fff",+ card: "#fff",+ backgroundElevated: "#f9fafb",+ placeholder: "#9ca3af"+ }+ })+}))++const mockSaveSetting = jest.fn().mockResolvedValue(undefined)++jest.mock("../../services/NativeLocationService", () => ({+ __esModule: true,+ default: {+ saveSetting: (key: string, value: string) => mockSaveSetting(key, value),+ getSetting: jest.fn().mockResolvedValue(null)+ }+}))++jest.mock("../../utils/geo", () => ({+ ...jest.requireActual("../../utils/geo"),+ getUnitSystem: () => "metric",+ getTimeFormat: () => "24h",+ loadDisplayPreferences: jest.fn().mockResolvedValue(undefined)+}))++jest.mock("../../components", () => {+ const R = require("react")+ const { View, Text } = require("react-native")+ return {+ Container: ({ children }: any) => R.createElement(View, null, children),+ Card: ({ children }: any) => R.createElement(View, null, children),+ Divider: () => R.createElement(View, null),+ SettingRow: ({ label, children }: any) => R.createElement(View, null, R.createElement(Text, null, label), children)+ }+})++import { AppearanceScreen } from "../AppearanceScreen"++const mockNavigation = { navigate: jest.fn() } as any++describe("AppearanceScreen", () => {+ beforeEach(() => {+ jest.clearAllMocks()+ })++ it("renders dark mode, units and time format rows", () => {+ const { getByText, getByTestId } = render(<AppearanceScreen navigation={mockNavigation} />)++ expect(getByText("Dark Mode")).toBeTruthy()+ expect(getByText("Units")).toBeTruthy()+ expect(getByText("Time Format")).toBeTruthy()+ expect(getByTestId("dark-mode-switch")).toBeTruthy()+ })++ it("shows unit system chips with Metric and Imperial", () => {+ const { getByText } = render(<AppearanceScreen navigation={mockNavigation} />)++ expect(getByText("Metric")).toBeTruthy()+ expect(getByText("Imperial")).toBeTruthy()+ })++ it("shows time format chips with 24h and 12h", () => {+ const { getByText } = render(<AppearanceScreen navigation={mockNavigation} />)++ expect(getByText("24h")).toBeTruthy()+ expect(getByText("12h")).toBeTruthy()+ })++ it("saves unit system when chip is pressed", async () => {+ const { getByText } = render(<AppearanceScreen navigation={mockNavigation} />)++ fireEvent.press(getByText("Imperial"))++ await waitFor(() => {+ expect(mockSaveSetting).toHaveBeenCalledWith("unitSystem", "imperial")+ })+ })++ it("saves time format when chip is pressed", async () => {+ const { getByText } = render(<AppearanceScreen navigation={mockNavigation} />)++ fireEvent.press(getByText("12h"))++ await waitFor(() => {+ expect(mockSaveSetting).toHaveBeenCalledWith("timeFormat", "12h")+ })+ })++ it("toggles theme when dark mode switch is pressed", () => {+ const { getByTestId } = render(<AppearanceScreen navigation={mockNavigation} />)++ fireEvent(getByTestId("dark-mode-switch"), "valueChange", true)++ expect(mockToggleTheme).toHaveBeenCalled()+ })++ it("toggles the map tile server panel when pressed", () => {+ const { getByTestId, queryByTestId } = render(<AppearanceScreen navigation={mockNavigation} />)++ expect(queryByTestId("map-style-url-light")).toBeNull()++ fireEvent.press(getByTestId("map-tile-server-toggle"))++ expect(queryByTestId("map-style-url-light")).toBeTruthy()+ expect(queryByTestId("map-style-url-dark")).toBeTruthy()+ })+})diff --git a/apps/mobile/src/screens/__tests__/SettingsScreen.test.tsx b/apps/mobile/src/screens/__tests__/SettingsScreen.test.tsxindex 22a567a5..beed0441 100644--- a/apps/mobile/src/screens/__tests__/SettingsScreen.test.tsx+++ b/apps/mobile/src/screens/__tests__/SettingsScreen.test.tsx@@ -1,5 +1,5 @@import React from "react"-import { render, fireEvent, waitFor } from "@testing-library/react-native"+import { render, fireEvent } from "@testing-library/react-native"import { DEFAULT_SETTINGS, Settings } from "../../types/global"// --- Mocks ---@@ -9,17 +9,14 @@ jest.mock("@react-navigation/native", () => ({}))let mockSettings: Settings = { ...DEFAULT_SETTINGS }-const mockSetSettings = jest.fn()-const mockUpdateSettingsLocal = jest.fn()-const mockRestartTracking = jest.fn()let mockTracking = falsejest.mock("../../contexts/TrackingProvider", () => ({useTracking: () => ({settings: mockSettings,- setSettings: mockSetSettings,- updateSettingsLocal: mockUpdateSettingsLocal,- restartTracking: mockRestartTracking,+ setSettings: jest.fn(),+ updateSettingsLocal: jest.fn(),+ restartTracking: jest.fn(),tracking: mockTracking})}))@@ -47,17 +44,6 @@ jest.mock("../../hooks/useTheme", () => ({})}))-jest.mock("../../hooks/useAutoSave", () => ({- useAutoSave: () => ({- saving: false,- saveSuccess: false,- debouncedSaveAndRestart: jest.fn(),- immediateSaveAndRestart: jest.fn()- })-}))--const mockSaveSetting = jest.fn().mockResolvedValue(undefined)-jest.mock("../../services/NativeLocationService", () => ({__esModule: true,default: {@@ -68,65 +54,40 @@ jest.mock("../../services/NativeLocationService", () => ({today: 10,databaseSizeMB: 1.2}),- saveSetting: (...args: any[]) => mockSaveSetting(...args),+ saveSetting: jest.fn().mockResolvedValue(undefined),getSetting: jest.fn().mockResolvedValue(null)}}))-jest.mock("../../utils/geo", () => ({- ...jest.requireActual("../../utils/geo"),- getUnitSystem: () => "metric",- getTimeFormat: () => "24h",- loadDisplayPreferences: jest.fn().mockResolvedValue(undefined)-}))-jest.mock("../../components", () => {const R = require("react")- const { View, Text } = require("react-native")+ const { View, Text, Pressable } = require("react-native")return {Container: ({ children }: any) => R.createElement(View, null, children),SectionTitle: ({ children }: any) => R.createElement(Text, null, children),Card: ({ children }: any) => R.createElement(View, null, children),Divider: () => R.createElement(View, null),- SettingRow: ({ label, children }: any) => R.createElement(View, null, R.createElement(Text, null, label), children),StatsCard: ({ queueCount, sentCount }: any) =>R.createElement(View,{ testID: "StatsCard" },R.createElement(Text, null, `${queueCount}`),R.createElement(Text, null, `${sentCount}`)+ ),+ ListItem: ({ testID, label, sub, onPress }: any) =>+ R.createElement(+ Pressable,+ { testID, onPress },+ R.createElement(Text, null, label),+ sub ? R.createElement(Text, null, sub) : null)}})-jest.mock("../../components/features/settings/ConnectionSettings", () => {- const R = require("react")- const { View } = require("react-native")- return {- ConnectionSettings: () => R.createElement(View, { testID: "ConnectionSettings" })- }-})--jest.mock("../../components/features/settings/SyncStrategySettings", () => {- const R = require("react")- const { View } = require("react-native")- return {- SyncStrategySettings: () => R.createElement(View, { testID: "SyncStrategySettings" })- }-})--jest.mock("../../components/ui/FloatingSaveIndicator", () => {- const R = require("react")- const { View } = require("react-native")- return {- FloatingSaveIndicator: () => R.createElement(View, { testID: "FloatingSaveIndicator" })- }-})-import { SettingsScreen } from "../SettingsScreen"const mockNavigate = jest.fn()-const mockNavigation = { navigate: mockNavigate } as any+const mockProps = { navigation: { navigate: mockNavigate }, route: { key: "Settings", name: "Settings" } } as anydescribe("SettingsScreen", () => {beforeEach(() => {@@ -135,67 +96,89 @@ describe("SettingsScreen", () => {mockTracking = false})- it("renders title and main sections", () => {- const { getByText } = render(<SettingsScreen navigation={mockNavigation} />)+ it("renders grouped section headers", () => {+ const { getByText } = render(<SettingsScreen {...mockProps} />)- expect(getByText("Settings")).toBeTruthy()- expect(getByText("Appearance")).toBeTruthy()- expect(getByText("Advanced")).toBeTruthy()+ expect(getByText("Display")).toBeTruthy()+ expect(getByText("Data")).toBeTruthy()})- it("renders StatsCard with stats", async () => {- const { getByTestId } = render(<SettingsScreen navigation={mockNavigation} />)+ it("renders StatsCard with stats", () => {+ const { getByTestId } = render(<SettingsScreen {...mockProps} />)expect(getByTestId("StatsCard")).toBeTruthy()})- it("renders ConnectionSettings and SyncStrategySettings", () => {- const { getByTestId } = render(<SettingsScreen navigation={mockNavigation} />)+ // --- Summary rows ---++ it("shows the endpoint host as the Connection summary", () => {+ mockSettings = { ...DEFAULT_SETTINGS, endpoint: "https://api.example.com/track" }++ const { getByText } = render(<SettingsScreen {...mockProps} />)- expect(getByTestId("ConnectionSettings")).toBeTruthy()- expect(getByTestId("SyncStrategySettings")).toBeTruthy()+ expect(getByText("api.example.com")).toBeTruthy()})- // --- Chip selectors ---+ it("shows 'No server configured' when endpoint is empty and not offline", () => {+ mockSettings = { ...DEFAULT_SETTINGS, endpoint: "", isOfflineMode: false }- it("shows unit system chips with Metric selected by default", () => {- const { getByText } = render(<SettingsScreen navigation={mockNavigation} />)+ const { getByText } = render(<SettingsScreen {...mockProps} />)- expect(getByText("Metric")).toBeTruthy()- expect(getByText("Imperial")).toBeTruthy()+ expect(getByText("No server configured")).toBeTruthy()})- it("shows time format chips with 24h and 12h", () => {- const { getByText } = render(<SettingsScreen navigation={mockNavigation} />)+ it("shows 'Offline' as the Connection summary in offline mode", () => {+ mockSettings = { ...DEFAULT_SETTINGS, isOfflineMode: true }++ const { getByText } = render(<SettingsScreen {...mockProps} />)- expect(getByText("24h")).toBeTruthy()- expect(getByText("12h")).toBeTruthy()+ expect(getByText("Offline - saved locally")).toBeTruthy()})- it("saves unit system when chip is pressed", async () => {- const { getByText } = render(<SettingsScreen navigation={mockNavigation} />)+ it("shows the preset label as the Sync Strategy summary", () => {+ mockSettings = { ...DEFAULT_SETTINGS, syncPreset: "balanced" }- fireEvent.press(getByText("Imperial"))+ const { getByText } = render(<SettingsScreen {...mockProps} />)- await waitFor(() => {- expect(mockSaveSetting).toHaveBeenCalledWith("unitSystem", "imperial")- })+ expect(getByText(/Balanced/)).toBeTruthy()})- it("saves time format when chip is pressed", async () => {- const { getByText } = render(<SettingsScreen navigation={mockNavigation} />)+ it("shows a custom summary when syncPreset is custom", () => {+ mockSettings = { ...DEFAULT_SETTINGS, syncPreset: "custom", interval: 45 }- fireEvent.press(getByText("12h"))+ const { getByText } = render(<SettingsScreen {...mockProps} />)- await waitFor(() => {- expect(mockSaveSetting).toHaveBeenCalledWith("timeFormat", "12h")- })+ expect(getByText("Custom · every 45s")).toBeTruthy()})// --- Navigation ---+ it("navigates to Appearance", () => {+ const { getByText } = render(<SettingsScreen {...mockProps} />)++ fireEvent.press(getByText("Appearance"))++ expect(mockNavigate).toHaveBeenCalledWith("Appearance")+ })++ it("navigates to Connection", () => {+ const { getByText } = render(<SettingsScreen {...mockProps} />)++ fireEvent.press(getByText("Connection"))++ expect(mockNavigate).toHaveBeenCalledWith("Connection")+ })++ it("navigates to Tracking & Sync", () => {+ const { getByText } = render(<SettingsScreen {...mockProps} />)++ fireEvent.press(getByText("Tracking & Sync"))++ expect(mockNavigate).toHaveBeenCalledWith("Tracking & Sync")+ })+it("navigates to Tracking Profiles", () => {- const { getByText } = render(<SettingsScreen navigation={mockNavigation} />)+ const { getByText } = render(<SettingsScreen {...mockProps} />)fireEvent.press(getByText("Tracking Profiles"))@@ -203,7 +186,7 @@ describe("SettingsScreen", () => {})it("navigates to Data Management", () => {- const { getByText } = render(<SettingsScreen navigation={mockNavigation} />)+ const { getByText } = render(<SettingsScreen {...mockProps} />)fireEvent.press(getByText("Data Management"))@@ -211,7 +194,7 @@ describe("SettingsScreen", () => {})it("navigates to API Config", () => {- const { getByText } = render(<SettingsScreen navigation={mockNavigation} />)+ const { getByText } = render(<SettingsScreen {...mockProps} />)fireEvent.press(getByText("API Field Mapping"))@@ -223,16 +206,17 @@ describe("SettingsScreen", () => {it("hides API Field Mapping link when offline mode is enabled", () => {mockSettings = { ...DEFAULT_SETTINGS, isOfflineMode: true }- const { queryByText } = render(<SettingsScreen navigation={mockNavigation} />)+ const { queryByText } = render(<SettingsScreen {...mockProps} />)expect(queryByText("API Field Mapping")).toBeNull()})- it("still shows Tracking Profiles and Data Management in offline mode", () => {+ it("still shows Connection, Tracking Profiles and Data Management in offline mode", () => {mockSettings = { ...DEFAULT_SETTINGS, isOfflineMode: true }- const { getByText } = render(<SettingsScreen navigation={mockNavigation} />)+ const { getByText } = render(<SettingsScreen {...mockProps} />)+ expect(getByText("Connection")).toBeTruthy()expect(getByText("Tracking Profiles")).toBeTruthy()expect(getByText("Data Management")).toBeTruthy()})diff --git a/apps/mobile/src/screens/index.ts b/apps/mobile/src/screens/index.tsindex f757dd6b..1ce19168 100644--- a/apps/mobile/src/screens/index.ts+++ b/apps/mobile/src/screens/index.ts@@ -18,6 +18,9 @@ export { SettingsScreen } from "./SettingsScreen"export { TrackingProfilesScreen } from "./TrackingProfilesScreen"export { ProfileEditorScreen } from "./ProfileEditorScreen"export { AboutScreen } from "./AboutScreen"+export { AppearanceScreen } from "./AppearanceScreen"+export { ConnectionScreen } from "./ConnectionScreen"+export { TrackingSyncScreen } from "./TrackingSyncScreen"export { SetupImportScreen } from "./SetupImportScreen"export { TripDetailScreen } from "./TripDetailScreen"export { OfflineMapsScreen } from "./OfflineMapsScreen"