Colota - Android GPS Location tracker
refactor: extract shared ListItem and drop colors prop from StatsCard
Max Dietrich140e36ae59b4
diff --git a/apps/mobile/src/components/features/settings/StatsCard.tsx b/apps/mobile/src/components/features/settings/StatsCard.tsxindex 94397351..10104dbf 100644--- a/apps/mobile/src/components/features/settings/StatsCard.tsx+++ b/apps/mobile/src/components/features/settings/StatsCard.tsx@@ -5,8 +5,8 @@import React from "react"import { View, Text, StyleSheet, Pressable } from "react-native"import { AlertTriangle, ChevronRight } from "lucide-react-native"-import { ThemeColors } from "../../../types/global"import { useTracking } from "../../../contexts/TrackingProvider"+import { useTheme } from "../../../hooks/useTheme"import { getQueueColor } from "../../../utils/queueStatus"import { fonts } from "../../../styles/typography"import { HIGH_QUEUE_THRESHOLD, CRITICAL_QUEUE_THRESHOLD } from "../../../constants"@@ -17,7 +17,6 @@ interface StatsCardProps {todayCount?: numberinterval: stringonManageClick?: () => void- colors: ThemeColors}type WarningLevel = "normal" | "warning" | "critical"@@ -31,8 +30,9 @@ type WarningLevel = "normal" | "warning" | "critical"* - Improved warning states* - More prominent CTA when needed*/-export function StatsCard({ queueCount, sentCount, todayCount, interval, onManageClick, colors }: StatsCardProps) {+export function StatsCard({ queueCount, sentCount, todayCount, interval, onManageClick }: StatsCardProps) {const { settings } = useTracking()+ const { colors } = useTheme()const isOfflineMode = settings.isOfflineModeconst getWarningLevel = (): WarningLevel => {if (queueCount > CRITICAL_QUEUE_THRESHOLD) return "critical"diff --git a/apps/mobile/src/components/features/settings/__tests__/StatsCard.test.tsx b/apps/mobile/src/components/features/settings/__tests__/StatsCard.test.tsxindex 1f227459..813c0fbd 100644--- a/apps/mobile/src/components/features/settings/__tests__/StatsCard.test.tsx+++ b/apps/mobile/src/components/features/settings/__tests__/StatsCard.test.tsx@@ -9,6 +9,22 @@ jest.mock("../../../../contexts/TrackingProvider", () => ({})}))+jest.mock("../../../../hooks/useTheme", () => ({+ useTheme: () => ({+ colors: {+ primary: "#0d9488",+ text: "#000",+ textSecondary: "#6b7280",+ success: "#22c55e",+ warning: "#f59e0b",+ error: "#ef4444",+ info: "#3b82f6",+ card: "#fff",+ border: "#e5e7eb"+ }+ })+}))+jest.mock("../../../../utils/queueStatus", () => ({getQueueColor: () => "#000"}))@@ -24,24 +40,11 @@ jest.mock("lucide-react-native", () => {import { StatsCard } from "../StatsCard"-const mockColors = {- primary: "#0d9488",- text: "#000",- textSecondary: "#6b7280",- success: "#22c55e",- warning: "#f59e0b",- error: "#ef4444",- info: "#3b82f6",- card: "#fff",- border: "#e5e7eb"-} as any-const baseProps = {queueCount: 5,sentCount: 100,todayCount: 8,- interval: "30",- colors: mockColors+ interval: "30"}describe("StatsCard", () => {diff --git a/apps/mobile/src/components/index.ts b/apps/mobile/src/components/index.tsindex dddb77a7..add64ec6 100644--- a/apps/mobile/src/components/index.ts+++ b/apps/mobile/src/components/index.ts@@ -30,6 +30,7 @@ export { FormatOption } from "./ui/FormatOption"export { FormatSelector } from "./ui/FormatSelector"export { RadioDot } from "./ui/RadioDot"export { SettingRow } from "./ui/SettingRow"+export { ListItem } from "./ui/ListItem"export { BottomTabBar } from "./ui/BottomTabBar"// ============================================================================diff --git a/apps/mobile/src/components/ui/ListItem.tsx b/apps/mobile/src/components/ui/ListItem.tsxnew file mode 100644index 00000000..4cd41024--- /dev/null+++ b/apps/mobile/src/components/ui/ListItem.tsx@@ -0,0 +1,87 @@+/**+ * Copyright (C) 2026 Max Dietrich+ * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.+ */++import React from "react"+import { Text, StyleSheet, View, Pressable } from "react-native"+import { ChevronRight } from "lucide-react-native"+import { useTheme } from "../../hooks/useTheme"+import { fonts } from "../../styles/typography"++type IconComponent = React.ComponentType<{ size?: number; color?: string; strokeWidth?: number }>++type ListItemProps = {+ label: string+ sub?: string+ icon?: IconComponent+ trailingIcon?: IconComponent+ onPress: () => void+ testID?: string+ accessibilityRole?: "button" | "link"+ accessibilityHint?: string+}++export function ListItem({+ label,+ sub,+ icon: Icon,+ trailingIcon: TrailingIcon = ChevronRight,+ onPress,+ testID,+ accessibilityRole = "button",+ accessibilityHint+}: ListItemProps) {+ const { colors } = useTheme()+ return (+ <Pressable+ testID={testID}+ accessibilityRole={accessibilityRole}+ accessibilityLabel={label}+ accessibilityHint={accessibilityHint ?? `Opens ${label}`}+ android_ripple={{ color: colors.border }}+ onPress={onPress}+ style={({ pressed }) => [styles.row, pressed && { opacity: colors.pressedOpacity }]}+ >+ {Icon && (+ <View style={styles.icon}>+ <Icon size={22} color={colors.textLight} />+ </View>+ )}+ <View style={styles.content}>+ <Text style={[styles.label, { color: colors.text }]}>{label}</Text>+ {sub ? (+ <Text style={[styles.sub, { color: colors.textSecondary }]} numberOfLines={1}>+ {sub}+ </Text>+ ) : null}+ </View>+ <TrailingIcon size={20} color={colors.textLight} />+ </Pressable>+ )+}++const styles = StyleSheet.create({+ row: {+ flexDirection: "row",+ alignItems: "center",+ minHeight: 56,+ paddingVertical: 10+ },+ icon: {+ marginRight: 16+ },+ content: {+ flex: 1,+ paddingRight: 8+ },+ label: {+ fontSize: 16,+ ...fonts.semiBold,+ marginBottom: 2+ },+ sub: {+ fontSize: 13,+ ...fonts.regular+ }+})diff --git a/apps/mobile/src/components/ui/SectionTitle.tsx b/apps/mobile/src/components/ui/SectionTitle.tsxindex 763a964c..d1aa0ad8 100644--- a/apps/mobile/src/components/ui/SectionTitle.tsx+++ b/apps/mobile/src/components/ui/SectionTitle.tsx@@ -19,7 +19,7 @@ export function SectionTitle({ children, style, color }: SectionTitleProps) {return (<View style={style}>- <Text style={[styles.sectionTitle, { color: color ? color : colors.text }]}>{children}</Text>+ <Text style={[styles.sectionTitle, { color: color ? color : colors.primary }]}>{children}</Text></View>)}diff --git a/apps/mobile/src/screens/AboutScreen.tsx b/apps/mobile/src/screens/AboutScreen.tsxindex c230b8a0..bcb6cbaa 100644--- a/apps/mobile/src/screens/AboutScreen.tsx+++ b/apps/mobile/src/screens/AboutScreen.tsx@@ -67,7 +67,7 @@ const LinkRow = ({style={({ pressed }) => [styles.linkRow, pressed && { opacity: colors.pressedOpacity }]}onPress={() => onOpenURL(url)}>- <Icon size={20} color={colors.primaryDark} />+ <Icon size={20} color={colors.textLight} /><View style={styles.linkTextContainer}><Text style={[styles.linkTitle, { color: colors.text }]}>{title}</Text><Text style={[styles.linkSubtitle, { color: colors.textLight }]}>{subtitle}</Text>