Self-hosted fitness tracker. Log workouts, track nutrition, and monitor progress. Docker deployment, mobile-friendly.
Mobile: semantic colour is the theme's decision, held to AA (#178)
Carter2c78fcf50eda
diff --git a/mobile/app/(tabs)/index.tsx b/mobile/app/(tabs)/index.tsxindex c5eba94..47da6fa 100644--- a/mobile/app/(tabs)/index.tsx+++ b/mobile/app/(tabs)/index.tsx@@ -7,10 +7,10 @@ import {eachDayOfInterval, endOfWeek, format, isSameDay, startOfWeek, subWeeks,} from 'date-fns'import {- Activity, AlertCircle, ArrowRight, BookOpen, ChevronRight, Dumbbell, Play, Plus, Scale, Timer, TrendingUp,+ Activity, ArrowRight, BookOpen, ChevronRight, Dumbbell, Play, Plus, Scale, Timer, TrendingUp,} from 'lucide-react-native'import { activeSessionExercisesForDay, dayLabel, displayVolume, displayWeight, sessionNameForDay, weightShort, type DailyStats, type Program, type WeightLog, type WeightStats, type Workout, workoutDay, entryDay, nextStartableDay, muscleRoast, muscleHex, calcVolume, greeting, formatDay } from '@lyftr/shared'-import { AppText, Card, IconButton, Label, Screen, SectionHeader, SegmentedControl } from '../../src/components/ui'+import { Alert, AppText, Card, IconButton, Label, Screen, SectionHeader, SegmentedControl } from '../../src/components/ui'import { ExerciseImage } from '../../src/components/workouts/ExerciseImage'import {MuscleDonut, MuscleSparkline, VolumeBarChart, WeightSparkline,@@ -143,10 +143,7 @@ export default function Dashboard() {return (<Screen><View className="py-4">- <View className="flex-row items-center gap-2 rounded-xl border border-error-500/20 bg-error-500/10 px-4 py-3">- <AlertCircle size={18} color={brand.errorSoft} />- <Text className="flex-1 font-sans text-sm text-error-400">{error}</Text>- </View>+ <Alert variant="error" size="compact">{error}</Alert></View></Screen>)@@ -291,7 +288,7 @@ export default function Dashboard() {<Timer size={18} color={brand.warningSoft} /></View><View>- <Text className="font-sans-semibold text-sm text-warning-400">Workout in progress</Text>+ <AppText variant="bodySemibold" color="warning">Workout in progress</AppText><Text className="text-xs" style={{ color: brand.warningSoft, opacity: 0.7 }}>{session.name} — tap to resume</Text></View></View>@@ -358,7 +355,7 @@ export default function Dashboard() {const isFuture = day > nowreturn (<View key={i} className="items-center gap-1.5">- <Text className={`text-[10px] font-sans-semibold ${isToday ? 'text-brand-400' : 'text-tx-muted'}`}>{format(day, 'EEEEE')}</Text>+ <AppText variant="label" color={isToday ? 'brand' : 'muted'} className="text-[10px]">{format(day, 'EEEEE')}</AppText><View className={`h-3.5 w-3.5 rounded-full ${hasWorkout ? 'bg-brand-500' : isToday ? 'border-2 border-brand-500/60' : isFuture ? 'bg-surface-border/20' : 'bg-surface-border/60'}`} />diff --git a/mobile/app/(tabs)/nutrition/[id].tsx b/mobile/app/(tabs)/nutrition/[id].tsxindex 9c3d536..fffa865 100644--- a/mobile/app/(tabs)/nutrition/[id].tsx+++ b/mobile/app/(tabs)/nutrition/[id].tsx@@ -1,9 +1,9 @@import { useEffect, useState } from 'react'-import { Image, Pressable, ScrollView, Text, View } from 'react-native'+import { Image, Pressable, ScrollView, View } from 'react-native'import { router, useLocalSearchParams } from 'expo-router'-import { AlertCircle, ArrowLeft, Edit2, Flame, Trash2 } from 'lucide-react-native'+import { ArrowLeft, Edit2, Flame, Trash2 } from 'lucide-react-native'import { useAsyncAction, entryDay, type FoodLog, formatDay } from '@lyftr/shared'-import {+import { Alert,AppText, Card, ConfirmSheet, Loading, Screen, deleteConfirmProps,} from '../../../src/components/ui'import {@@ -18,7 +18,7 @@ import { useTheme } from '../../../src/theme/useTheme'// refetches on focus, so a delete/edit here is reflected when we pop back.export default function NutritionDetail() {const { id } = useLocalSearchParams<{ id: string }>()- const { colors, accent, brand } = useTheme()+ const { colors, accent } = useTheme()const [entry, setEntry] = useState<FoodLog | null>(null)const [loading, setLoading] = useState(true)@@ -52,10 +52,7 @@ export default function NutritionDetail() {<ArrowLeft size={16} color={colors.txMuted} /><AppText variant="body" color="muted">Nutrition</AppText></Pressable>- <View className="flex-row items-center gap-2 rounded-xl border border-error-500/20 bg-error-500/10 px-4 py-3">- <AlertCircle size={18} color={brand.errorSoft} />- <Text className="flex-1 font-sans text-sm text-error-400">{error || 'Entry not found'}</Text>- </View>+ <Alert variant="error" size="compact">{error || 'Entry not found'}</Alert></View></Screen>)diff --git a/mobile/app/(tabs)/programs/[id]/edit.tsx b/mobile/app/(tabs)/programs/[id]/edit.tsxindex 82af72e..1258857 100644--- a/mobile/app/(tabs)/programs/[id]/edit.tsx+++ b/mobile/app/(tabs)/programs/[id]/edit.tsx@@ -48,9 +48,6 @@ export default function EditProgram() {fetchSettings()}, [fetchSettings])- useEffect(() => {- if (error) scrollRef.current?.scrollTo({ y: 0, animated: true })- }, [error])useEffect(() => {const programId = Number(id)@@ -124,6 +121,10 @@ export default function EditProgram() {router.dismissTo('/programs')}, 'Failed to update program')+ useEffect(() => {+ if (error || save.error) scrollRef.current?.scrollTo({ y: 0, animated: true })+ }, [error, save.error])+const handleSubmit = async () => {if (!formData.name.trim()) { setError('Program name required'); return }if (formData.days.length === 0) { setError('Add at least one day'); return }diff --git a/mobile/app/(tabs)/programs/new.tsx b/mobile/app/(tabs)/programs/new.tsxindex e6858a8..1da34af 100644--- a/mobile/app/(tabs)/programs/new.tsx+++ b/mobile/app/(tabs)/programs/new.tsx@@ -50,9 +50,6 @@ export default function AddProgram() {fetchSettings()}, [fetchSettings])- useEffect(() => {- if (error) scrollRef.current?.scrollTo({ y: 0, animated: true })- }, [error])const goBack = () => (router.canGoBack() ? router.back() : router.replace('/programs'))@@ -82,6 +79,10 @@ export default function AddProgram() {router.dismissTo('/programs')}, 'Failed to create program')+ useEffect(() => {+ if (error || save.error) scrollRef.current?.scrollTo({ y: 0, animated: true })+ }, [error, save.error])+const handleSubmit = async () => {if (!formData.name.trim()) { setError('Program name required'); return }if (formData.days.length === 0) { setError('Add at least one day'); return }diff --git a/mobile/app/(tabs)/settings/index.tsx b/mobile/app/(tabs)/settings/index.tsxindex 0c0f046..6fee5b0 100644--- a/mobile/app/(tabs)/settings/index.tsx+++ b/mobile/app/(tabs)/settings/index.tsx@@ -368,7 +368,7 @@ export default function SettingsScreen() {keyboardType="url"placeholder="https://your-server.example.com"/>- {serverMsg ? <AppText variant="caption" className="mt-2 text-brand-400">{serverMsg}</AppText> : null}+ {serverMsg ? <AppText variant="caption" color="brand" className="mt-2">{serverMsg}</AppText> : null}{insecureServer ? (<View className="mt-2 flex-row items-start gap-1.5"><AlertTriangle size={13} color={brand.warning} strokeWidth={2.4} style={{ marginTop: 1 }} />diff --git a/mobile/app/(tabs)/weight/[id].tsx b/mobile/app/(tabs)/weight/[id].tsxindex a9c3f82..c38923e 100644--- a/mobile/app/(tabs)/weight/[id].tsx+++ b/mobile/app/(tabs)/weight/[id].tsx@@ -1,10 +1,10 @@import { useEffect, useState } from 'react'-import { Pressable, ScrollView, Text, View } from 'react-native'+import { Pressable, ScrollView, View } from 'react-native'import { router, useLocalSearchParams } from 'expo-router'import * as Haptics from 'expo-haptics'-import { AlertCircle, ArrowLeft, Edit2, Scale, Trash2 } from 'lucide-react-native'+import { ArrowLeft, Edit2, Scale, Trash2 } from 'lucide-react-native'import { useAsyncAction, apiErrorMessage, dayToInstant, displayWeight, maxWeight, resolveWeightLbs, weightError, weightShort, type WeightLog, entryDay, BODYWEIGHT_STEP, clampStep, formatDay } from '@lyftr/shared'-import {+import { Alert,AppText, Button, Card, ConfirmSheet, DateInput, Field, Label, Loading, NumberField,NumericKeyboardAccessory, NUMERIC_ACCESSORY_ID, Screen, StepperTile, deleteConfirmProps,} from '../../../src/components/ui'@@ -16,7 +16,7 @@ export default function WeightDetail() {const settings = useSettingsStore((s) => s.settings)const unit = settings.weight_unitconst wUnit = weightShort(unit)- const { colors, accent, brand } = useTheme()+ const { colors, accent } = useTheme()const [log, setLog] = useState<WeightLog | null>(null)const [loading, setLoading] = useState(true)@@ -104,10 +104,7 @@ export default function WeightDetail() {<ArrowLeft size={16} color={colors.txMuted} /><AppText variant="body" color="muted">Weight</AppText></Pressable>- <View className="flex-row items-center gap-2 rounded-xl border border-error-500/20 bg-error-500/10 px-4 py-3">- <AlertCircle size={18} color={brand.errorSoft} />- <Text className="flex-1 font-sans text-sm text-error-400">{error || 'Entry not found'}</Text>- </View>+ <Alert variant="error" size="compact">{error || 'Entry not found'}</Alert></View></Screen>)@@ -183,10 +180,7 @@ export default function WeightDetail() {<AppText variant="heading" className="mb-4">Edit Entry</AppText><View className="gap-4">{editError || saveEdit.error ? (- <View className="flex-row items-center gap-2 rounded-xl border border-error-500/20 bg-error-500/10 px-4 py-3">- <AlertCircle size={16} color={brand.errorSoft} />- <Text className="flex-1 font-sans text-sm text-error-400">{editError || saveEdit.error}</Text>- </View>+ <Alert variant="error" size="compact">{editError || saveEdit.error}</Alert>) : null}<StepperTilediff --git a/mobile/app/(tabs)/weight/index.tsx b/mobile/app/(tabs)/weight/index.tsxindex abda641..31bdf3e 100644--- a/mobile/app/(tabs)/weight/index.tsx+++ b/mobile/app/(tabs)/weight/index.tsx@@ -8,7 +8,7 @@ import {TrendingDown, TrendingUp, X,} from 'lucide-react-native'import { useAsyncAction, apiErrorMessage, dayToInstant, daysAgoStr, displayToLbs, displayWeight, maxWeight, todayStr, weightError, weightShort, type WeightLog, type WeightStats, entryDay, dayToLocalDate, BODYWEIGHT_STEP, clampStep, formatDay } from '@lyftr/shared'-import {+import { Alert,AppText, Button, Card, DateInput, Field, Label, NumberField, NumericKeyboardAccessory,NUMERIC_ACCESSORY_ID, PageHeader, Screen, SegmentedControl, StepperTile,} from '../../../src/components/ui'@@ -17,6 +17,7 @@ import { WeightEntryRow } from '../../../src/components/weight/WeightEntryRow'import { WeightSkeleton } from '../../../src/components/weight/WeightSkeleton'import { useServerInfiniteList } from '../../../src/hooks/useServerInfiniteList'import { client, useSettingsStore } from '../../../src/lib/lyftr'+import { semanticInk } from '../../../src/theme/theme'import { useTheme } from '../../../src/theme/useTheme'const PERIODS = ['7d', '30d', '90d', 'All'] as const@@ -29,7 +30,8 @@ export default function Weight() {const fetchSettings = useSettingsStore((s) => s.fetch)const unit = settings.weight_unitconst wUnit = weightShort(unit)- const { colors, accent, brand } = useTheme()+ const { colors, accent, brand, isDark } = useTheme()+ const warningInk = semanticInk[isDark ? 'dark' : 'light'].warningconst [period, setPeriod] = useState<Period>('30d')const [stats, setStats] = useState<WeightStats | null>(null)@@ -215,13 +217,6 @@ export default function Weight() {}/>- {error || log.error ? (- <View className="flex-row items-center gap-2 rounded-xl border border-error-500/20 bg-error-500/10 px-4 py-3">- <AlertCircle size={18} color={brand.errorSoft} />- <Text className="flex-1 font-sans text-sm text-error-400">{error || log.error}</Text>- </View>- ) : null}-{/* Quick log — kept at the top so entry is reachable on first paint. */}<Card><View className="mb-3 flex-row items-center justify-between">@@ -280,11 +275,15 @@ export default function Weight() {</Pressable>)}+ {error || log.error ? (+ <Alert variant="error" size="compact">{error || log.error}</Alert>+ ) : null}+{showDuplicateWarning && items.length > 0 ? (<View className="flex-row items-start gap-3 rounded-xl border border-warning-500/20 bg-warning-500/10 px-4 py-3">- <AlertCircle size={16} color={brand.warningSoft} style={{ marginTop: 2 }} />+ <AlertCircle size={16} color={warningInk} style={{ marginTop: 2 }} /><View className="min-w-0 flex-1">- <Text className="font-sans-semibold text-sm text-warning-400">+ <Text className="font-sans-semibold text-sm" style={{ color: warningInk }}>Already logged on {formatDay(entryDay(items[0]), 'MMM d')} ({displayWeight(items[0].weight, unit)} {wUnit}). Log again anyway?</Text><View className="mt-2 flex-row gap-2">@@ -300,9 +299,9 @@ export default function Weight() {setShowDuplicateWarning(false)handleLog()}}- className="rounded-lg border border-warning-500/30 bg-warning-500/20 px-3 py-1 active:opacity-70"+ className="rounded-lg bg-warning-500 px-3 py-1 active:opacity-80">- <Text className="font-sans-semibold text-xs text-warning-400">Log Anyway</Text>+ <Text className="font-sans-semibold text-xs" style={{ color: brand.warningText }}>Log Anyway</Text></Pressable></View></View>diff --git a/mobile/app/(tabs)/workouts/[id]/edit.tsx b/mobile/app/(tabs)/workouts/[id]/edit.tsxindex 0b21c44..802bf06 100644--- a/mobile/app/(tabs)/workouts/[id]/edit.tsx+++ b/mobile/app/(tabs)/workouts/[id]/edit.tsx@@ -71,9 +71,6 @@ export default function EditWorkout() {fetchSettings()}, [fetchSettings])- useEffect(() => {- if (error) scrollRef.current?.scrollTo({ y: 0, animated: true })- }, [error])useEffect(() => {const workoutId = Number(id)@@ -202,6 +199,10 @@ export default function EditWorkout() {router.dismissTo('/workouts')}, 'Failed to update workout')+ useEffect(() => {+ if (error || save.error) scrollRef.current?.scrollTo({ y: 0, animated: true })+ }, [error, save.error])+const handleSubmit = async () => {if (!formData.name.trim()) { setError('Workout name required'); return }if (formData.exercises.length === 0) { setError('Add at least one exercise'); return }diff --git a/mobile/app/(tabs)/workouts/new.tsx b/mobile/app/(tabs)/workouts/new.tsxindex 9259d4a..1a51777 100644--- a/mobile/app/(tabs)/workouts/new.tsx+++ b/mobile/app/(tabs)/workouts/new.tsx@@ -73,10 +73,6 @@ export default function AddWorkout() {fetchSettings()}, [fetchSettings])- // Web scrolls the window to top on error; here the ScrollView.- useEffect(() => {- if (error) scrollRef.current?.scrollTo({ y: 0, animated: true })- }, [error])const goBack = () => (router.canGoBack() ? router.back() : router.replace('/workouts'))@@ -181,6 +177,11 @@ export default function AddWorkout() {router.dismissTo('/workouts')}, 'Failed to create workout')+ // Web scrolls the window to top on error; here the ScrollView.+ useEffect(() => {+ if (error || save.error) scrollRef.current?.scrollTo({ y: 0, animated: true })+ }, [error, save.error])+const handleSubmit = async () => {if (!formData.name.trim()) { setError('Workout name required'); return }if (formData.exercises.length === 0) { setError('Add at least one exercise'); return }diff --git a/mobile/src/components/dashboard/QuickWeighInSheet.tsx b/mobile/src/components/dashboard/QuickWeighInSheet.tsxindex e0850b1..c6d1b13 100644--- a/mobile/src/components/dashboard/QuickWeighInSheet.tsx+++ b/mobile/src/components/dashboard/QuickWeighInSheet.tsx@@ -4,10 +4,11 @@ import * as Haptics from 'expo-haptics'import { AlertCircle, Scale, X } from 'lucide-react-native'import { useAsyncAction, dayToInstant, displayToLbs, maxWeight, todayStr, weightError, weightShort, type WeightLog, entryDay, BODYWEIGHT_STEP, clampStep } from '@lyftr/shared'import {- AppText, Button, DateInput, Field, NumberField, NumericKeyboardAccessory, NUMERIC_ACCESSORY_ID,+ Alert, AppText, Button, DateInput, Field, NumberField, NumericKeyboardAccessory, NUMERIC_ACCESSORY_ID,Sheet, StepperTile,} from '../ui'import { client, useSettingsStore } from '../../lib/lyftr'+import { semanticInk } from '@lyftr/shared'import { useTheme } from '../../theme/useTheme'interface Props {@@ -27,7 +28,8 @@ export function QuickWeighInSheet({ open, lastValue, lastLog, onClose, onSuccessconst settings = useSettingsStore((s) => s.settings)const unit = settings.weight_unitconst wUnit = weightShort(unit)- const { colors, accent, brand } = useTheme()+ const { colors, accent, brand, isDark } = useTheme()+ const warningInk = semanticInk[isDark ? 'dark' : 'light'].warningconst [value, setValue] = useState('')const [date, setDate] = useState(todayStr())@@ -95,27 +97,24 @@ export function QuickWeighInSheet({ open, lastValue, lastLog, onClose, onSuccess<View className="gap-4">{(error || save.error) ? (- <View className="flex-row items-center gap-2 rounded-xl border border-error-500/20 bg-error-500/10 px-4 py-3">- <AlertCircle size={16} color={brand.errorSoft} />- <Text className="flex-1 font-sans text-sm text-error-400">{error || save.error}</Text>- </View>+ <Alert variant="error" size="compact">{error || save.error}</Alert>) : null}{showDuplicateWarning && lastLog ? (<View className="flex-row items-start gap-3 rounded-xl border border-warning-500/20 bg-warning-500/10 px-4 py-3">- <AlertCircle size={16} color={brand.warningSoft} style={{ marginTop: 2 }} />+ <AlertCircle size={16} color={warningInk} style={{ marginTop: 2 }} /><View className="min-w-0 flex-1">- <Text className="font-sans-semibold text-sm text-warning-400">+ <AppText variant="bodySemibold" color="warning">Already logged today ({Math.round(lastValue ?? 0)} {wUnit}). Log again anyway?- </Text>+ </AppText><View className="mt-2 flex-row gap-2"><Pressable onPress={() => setShowDuplicateWarning(false)}className="rounded-lg border border-surface-border bg-surface-overlay px-3 py-1 active:opacity-70"><AppText variant="caption" color="secondary">Cancel</AppText></Pressable><Pressable onPress={() => { setDupDismissed(true); setShowDuplicateWarning(false); submit(true) }}- className="rounded-lg border border-warning-500/30 bg-warning-500/20 px-3 py-1 active:opacity-70">- <Text className="font-sans-semibold text-xs text-warning-400">Log Anyway</Text>+ className="rounded-lg bg-warning-500 px-3 py-1 active:opacity-80">+ <Text className="font-sans-semibold text-xs" style={{ color: brand.warningText }}>Log Anyway</Text></Pressable></View></View>diff --git a/mobile/src/components/ui/Alert.tsx b/mobile/src/components/ui/Alert.tsxindex 44b04e0..a73eace 100644--- a/mobile/src/components/ui/Alert.tsx+++ b/mobile/src/components/ui/Alert.tsx@@ -1,6 +1,7 @@import type { ReactNode } from 'react'import { View } from 'react-native'import { AlertCircle, CheckCircle2, Info, TriangleAlert } from 'lucide-react-native'+import { semanticInk } from '../../theme/theme'import { useTheme } from '../../theme/useTheme'import { AppText } from './Typography'@@ -15,11 +16,11 @@ type Variant = 'error' | 'success' | 'warning' | 'info'// idea; screens built on the standard ui kit should use this one.// The `Soft` tokens are the 400s — web's alerts colour their text and icon at 400, not// the 500 used for the tint and border.-const TONES: Record<Variant, { icon: typeof AlertCircle; tone: 'errorSoft' | 'successSoft' | 'warningSoft' | 'cyanLight' }> = {- error: { icon: AlertCircle, tone: 'errorSoft' },- success: { icon: CheckCircle2, tone: 'successSoft' },- warning: { icon: TriangleAlert, tone: 'warningSoft' },- info: { icon: Info, tone: 'cyanLight' },+const ICONS: Record<Variant, typeof AlertCircle> = {+ error: AlertCircle,+ success: CheckCircle2,+ warning: TriangleAlert,+ info: Info,}const SURFACES: Record<Variant, string> = {@@ -39,9 +40,9 @@ interface Props {}export function Alert({ variant, children, className = '', size = 'default' }: Props) {- const { brand } = useTheme()- const { icon: Icon, tone } = TONES[variant]- const color = brand[tone]+ const { isDark } = useTheme()+ const Icon = ICONS[variant]+ const color = semanticInk[isDark ? 'dark' : 'light'][variant]const compact = size === 'compact'return (diff --git a/mobile/src/components/ui/Button.tsx b/mobile/src/components/ui/Button.tsxindex e44b0cd..917df97 100644--- a/mobile/src/components/ui/Button.tsx+++ b/mobile/src/components/ui/Button.tsx@@ -1,4 +1,5 @@import { Pressable, Text, ActivityIndicator } from 'react-native'+import { semanticInk, type SemanticTone } from '@lyftr/shared'import { useTheme } from '../../theme/useTheme'type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger'@@ -12,11 +13,13 @@ interface Props {className?: string}-const VARIANT: Record<ButtonVariant, { bg: string; text: string }> = {+const VARIANT: Record<ButtonVariant, { bg: string; text: string; tone?: SemanticTone }> = {primary: { bg: 'bg-brand-500 active:bg-brand-700', text: 'text-white' },secondary: { bg: 'bg-surface-muted border border-surface-border', text: 'text-tx-primary' },ghost: { bg: '', text: 'text-tx-muted' },- danger: { bg: 'bg-error-500/10 border border-error-500/20', text: 'text-error-400' },+ // Label colour comes from the theme: text-error-400 on this tint measures 2.4:1 on a+ // light surface, and light is this app's default.+ danger: { bg: 'bg-error-500/10 border border-error-500/20', text: '', tone: 'error' },}export function Button({@@ -27,8 +30,9 @@ export function Button({disabled = false,className = '',}: Props) {- const { accent } = useTheme()+ const { accent, isDark } = useTheme()const v = VARIANT[variant]+ const toneColor = v.tone ? semanticInk[isDark ? 'dark' : 'light'][v.tone] : undefinedconst isDisabled = disabled || loadingreturn (<Pressable@@ -51,7 +55,7 @@ export function Button({// background, where a white spinner would vanish on the light theme.<ActivityIndicator color={variant === 'primary' ? '#fff' : accent} />) : (- <Text className={`font-sans-bold text-sm ${v.text}`}>{title}</Text>+ <Text className={`font-sans-bold text-sm ${v.text}`} style={toneColor ? { color: toneColor } : undefined}>{title}</Text>)}</Pressable>)diff --git a/mobile/src/components/ui/Field.tsx b/mobile/src/components/ui/Field.tsxindex c137f1a..818aeab 100644--- a/mobile/src/components/ui/Field.tsx+++ b/mobile/src/components/ui/Field.tsx@@ -1,5 +1,5 @@import type { ReactNode } from 'react'-import { Text, TextInput, TextInputProps, View } from 'react-native'+import { TextInput, TextInputProps, View } from 'react-native'import type { LucideIcon } from 'lucide-react-native'import Reanimated, {useSharedValue,@@ -8,7 +8,7 @@ import Reanimated, {interpolateColor,} from 'react-native-reanimated'import { useTheme } from '../../theme/useTheme'-import { Label } from './Typography'+import { AppText, Label } from './Typography'interface Props extends TextInputProps {label?: string@@ -84,7 +84,7 @@ export function Field({ label, error, className = '', leftIcon: LeftIcon, rightS/>{rightSlot ? <View style={{ marginLeft: 8 }}>{rightSlot}</View> : null}</Reanimated.View>- {error ? <Text className="font-sans text-xs text-error-400">{error}</Text> : null}+ {error ? <AppText variant="caption" color="error">{error}</AppText> : null}</View>)}diff --git a/mobile/src/components/ui/NumericKeyboardAccessory.tsx b/mobile/src/components/ui/NumericKeyboardAccessory.tsxindex 5edef92..3a4cca8 100644--- a/mobile/src/components/ui/NumericKeyboardAccessory.tsx+++ b/mobile/src/components/ui/NumericKeyboardAccessory.tsx@@ -1,4 +1,5 @@-import { InputAccessoryView, Keyboard, Platform, Pressable, Text, View } from 'react-native'+import { InputAccessoryView, Keyboard, Platform, Pressable, View } from 'react-native'+import { AppText } from './Typography'// iOS number-pad / decimal-pad keyboards have NO return key, so there's no built-in way// to dismiss them once you're done typing reps/weights. This is the standard fix: a thin@@ -14,7 +15,7 @@ export function NumericKeyboardAccessory() {<InputAccessoryView nativeID={NUMERIC_ACCESSORY_ID}><View className="flex-row justify-end border-t border-surface-border bg-surface-raised px-2 py-1.5"><Pressable onPress={() => Keyboard.dismiss()} hitSlop={8} accessibilityLabel="Dismiss keyboard" className="rounded-lg px-4 py-1.5 active:opacity-60">- <Text className="font-sans-bold text-base text-brand-500">Done</Text>+ <AppText variant="bodySemibold" color="brand">Done</AppText></Pressable></View></InputAccessoryView>diff --git a/mobile/src/components/ui/SettingsRow.tsx b/mobile/src/components/ui/SettingsRow.tsxindex dc75409..94b5899 100644--- a/mobile/src/components/ui/SettingsRow.tsx+++ b/mobile/src/components/ui/SettingsRow.tsx@@ -68,7 +68,7 @@ export function SettingsRow({</View>) : null}<View className="flex-1 pr-3">- <AppText variant="bodySemibold" className={destructive ? 'text-error-400' : ''}>+ <AppText variant="bodySemibold" color={destructive ? 'error' : undefined}>{label}</AppText>{description ? (diff --git a/mobile/src/components/ui/Typography.tsx b/mobile/src/components/ui/Typography.tsxindex 3dff438..66548d2 100644--- a/mobile/src/components/ui/Typography.tsx+++ b/mobile/src/components/ui/Typography.tsx@@ -1,5 +1,7 @@import { ReactNode } from 'react'import { Text as RNText, TextProps, TextStyle } from 'react-native'+import { semanticInk, type SemanticTone } from '@lyftr/shared'+import { useTheme } from '../../theme/useTheme'// The ONLY sanctioned way to render text. The brand fonts (Outfit for display,// Plus Jakarta Sans for body) are loaded per-weight in app/_layout.tsx — each weight@@ -47,13 +49,26 @@ const COLOR: Record<TextColor, string> = {secondary: 'text-tx-secondary',muted: 'text-tx-muted',inverse: 'text-tx-inverse',- brand: 'text-brand-500',- success: 'text-success-500',- warning: 'text-warning-400',- error: 'text-error-400',+ brand: '',+ success: '',+ warning: '',+ error: '',white: 'text-white',}+// The four semantic colours resolve per theme rather than to a fixed shade. They+// used to be text-error-400 and friends, which measure 2.8:1 (error) and 1.5:1+// (warning) on a light card, below WCAG AA — and mobile is light-first, so every+// field error and destructive label in the app was failing it. semanticInk is the+// one place those pairings are decided, and alertContrast.test.ts fails the build if+// any of them stops clearing AA.+const SEMANTIC: Partial<Record<TextColor, SemanticTone>> = {+ brand: 'info',+ success: 'success',+ warning: 'warning',+ error: 'error',+}+// Small print defaults to the softer text color so callers don't have to repeat it.const DEFAULT_COLOR: Record<TextVariant, TextColor> = {display: 'primary',@@ -85,11 +100,17 @@ export function AppText({style,...rest}: AppTextProps) {- const resolved = COLOR[color ?? DEFAULT_COLOR[variant]]+ const { isDark } = useTheme()+ const key = color ?? DEFAULT_COLOR[variant]+ const tone = SEMANTIC[key]+ const inkStyle: TextStyle | undefined = tone+ ? { color: semanticInk[isDark ? 'dark' : 'light'][tone] }+ : undefined+ const styles = [variant === 'numeric' ? TABULAR : undefined, inkStyle, style].filter(Boolean)return (<RNText- className={`${VARIANT[variant]} ${resolved} ${className}`}- style={variant === 'numeric' ? [TABULAR, style] : style}+ className={`${VARIANT[variant]} ${COLOR[key]} ${className}`}+ style={styles}{...rest}/>)diff --git a/mobile/src/components/ui/semanticColor.guard.test.ts b/mobile/src/components/ui/semanticColor.guard.test.tsnew file mode 100644index 0000000..f2d8a01--- /dev/null+++ b/mobile/src/components/ui/semanticColor.guard.test.ts@@ -0,0 +1,55 @@+import { readFileSync, readdirSync } from 'fs'+import { join, sep } from 'path'++// THE RULE: a semantic colour is chosen by the theme, never written as a fixed shade.+//+// The 400 rungs are legible on a dark surface and fail WCAG AA on every light one —+// 2.8:1 for error, 1.5:1 for warning on a white card — and this app is light-first. That+// was true of every alert, every field validation message and every destructive label in+// the app, and it survived review for a simple reason: contrast is not something you+// notice by looking, so a reviewer reading `text-error-400` sees the word "error" and+// moves on.+//+// So the shade is not a call site's decision any more. `<AppText color="error">` and+// `<Alert variant="error">` resolve through semanticInk, which packages/shared's+// alertContrast test holds to AA in both themes. This fails if anyone writes the shade+// by hand again — including in the tempting case, a one-off bit of red text.+const MOBILE = join(__dirname, '..', '..', '..')+const SKIP = new Set(['node_modules', '.expo', 'android', 'ios', 'dist'])++// Text utilities only. `bg-error-500/10` and `border-error-500/20` are the tint and edge+// of the alert surface itself, which are fine — it is the FOREGROUND that has to react to+// the theme.+const FIXED_SEMANTIC_TEXT = /\btext-(error|warning|success|brand)-\d{3}\b/++// Where the mapping itself lives, and is supposed to name shades.+const ALLOWED = new Set(['src/components/ui/Typography.tsx', 'src/theme/theme.ts'])++const stripComments = (src: string): string =>+ src+ // JSX block comments as well as line comments — a note ABOUT this rule is not a+ // violation of it, and ExerciseFormCard carries one.+ .replace(/\{\/\*[\s\S]*?\*\/\}/g, '')+ .split(/\r?\n/)+ .map((l) => l.replace(/\/\/.*/, ''))+ .filter((l) => !l.trim().startsWith('*'))+ .join('\n')++function sources(dir: string): string[] {+ return readdirSync(dir, { withFileTypes: true }).flatMap((e) => {+ if (e.name.startsWith('.') || SKIP.has(e.name)) return []+ const p = join(dir, e.name)+ if (e.isDirectory()) return sources(p)+ const code = e.name.endsWith('.ts') || e.name.endsWith('.tsx')+ return code && !e.name.includes('.test.') ? [p] : []+ })+}++it('never hard-codes a semantic text shade', () => {+ const offenders = [...sources(join(MOBILE, 'src')), ...sources(join(MOBILE, 'app'))]+ .filter((p) => FIXED_SEMANTIC_TEXT.test(stripComments(readFileSync(p, 'utf8'))))+ .map((p) => p.slice(MOBILE.length + 1).split(sep).join('/'))+ .filter((p) => !ALLOWED.has(p))++ expect(offenders).toEqual([])+})