From 0c3ab5c2a238f0fb5c5a77f62f390fb42086d5b3 Mon Sep 17 00:00:00 2001 From: neodk2004 Date: Sat, 26 Sep 2026 09:07:49 +0200 Subject: [PATCH] fix(mobile): onboarding steps unreadable in dark mode ArachnophobiaOptIn, UploadConsent, OnboardingGuidelines and AvatarStep still used the static light-palette tokens in module-level StyleSheet.create, so titles and checkbox labels rendered dark-on-dark. Switched them to useTheme() + makeStyles(colors) like the other screens. Co-Authored-By: Claude Opus 5.5 --- .../onboarding/ArachnophobiaOptIn.tsx | 68 +++++++++-------- .../src/components/onboarding/AvatarStep.tsx | 76 ++++++++++--------- .../onboarding/OnboardingGuidelines.tsx | 48 +++++++----- .../components/onboarding/UploadConsent.tsx | 72 ++++++++++-------- 4 files changed, 145 insertions(+), 119 deletions(-) diff --git a/mobile/src/components/onboarding/ArachnophobiaOptIn.tsx b/mobile/src/components/onboarding/ArachnophobiaOptIn.tsx index 2605324..c0b32fc 100644 --- a/mobile/src/components/onboarding/ArachnophobiaOptIn.tsx +++ b/mobile/src/components/onboarding/ArachnophobiaOptIn.tsx @@ -1,11 +1,12 @@ -import { useState } from "react"; +import { useMemo, useState } from "react"; import { View, Text, Pressable, StyleSheet } from "react-native"; import { useTranslation } from "react-i18next"; import { useMutation } from "@tanstack/react-query"; import { Bug, Check } from "lucide-react-native"; import { useTRPC } from "../../api/trpc"; import { Button } from "../Button"; -import { colors, radii, typography } from "../../theme/tokens"; +import { radii, getTypography, type ColorTokens, type Typography } from "../../theme/tokens"; +import { useTheme } from "../../context/ThemeContext"; type Props = { onContinue: () => void }; @@ -16,6 +17,8 @@ type Props = { onContinue: () => void }; */ export function ArachnophobiaOptIn({ onContinue }: Props) { const { t } = useTranslation(); + const { colors } = useTheme(); + const styles = useMemo(() => makeStyles(colors), [colors]); const trpc = useTRPC(); const [hideSpiders, setHideSpiders] = useState(false); @@ -53,32 +56,35 @@ export function ArachnophobiaOptIn({ onContinue }: Props) { ); } -const styles = StyleSheet.create({ - container: { padding: 24, gap: 4 }, - titleRow: { flexDirection: "row", alignItems: "center", gap: 8, marginBottom: 4 }, - title: { ...typography.title, fontSize: 18 }, - subtitle: { ...typography.body, color: colors.quietGray, marginBottom: 16 }, - checkboxRow: { - flexDirection: "row", - gap: 12, - padding: 14, - borderRadius: radii.xl, - borderWidth: 1, - borderColor: colors.hairlineGray, - marginBottom: 16, - }, - checkbox: { - width: 20, - height: 20, - borderRadius: 5, - borderWidth: 1.5, - borderColor: colors.hairlineGray, - alignItems: "center", - justifyContent: "center", - marginTop: 2, - }, - checkboxChecked: { backgroundColor: colors.marigoldOrange, borderColor: colors.marigoldOrange }, - checkboxLabel: { ...typography.body, flex: 1, fontSize: 13, lineHeight: 19 }, - hint: { ...typography.label, textTransform: "none", letterSpacing: 0, marginBottom: 16 }, - cta: { marginTop: 4 }, -}); +function makeStyles(colors: ColorTokens) { + const typography: Typography = getTypography(colors); + return StyleSheet.create({ + container: { padding: 24, gap: 4 }, + titleRow: { flexDirection: "row", alignItems: "center", gap: 8, marginBottom: 4 }, + title: { ...typography.title, fontSize: 18 }, + subtitle: { ...typography.body, color: colors.quietGray, marginBottom: 16 }, + checkboxRow: { + flexDirection: "row", + gap: 12, + padding: 14, + borderRadius: radii.xl, + borderWidth: 1, + borderColor: colors.hairlineGray, + marginBottom: 16, + }, + checkbox: { + width: 20, + height: 20, + borderRadius: 5, + borderWidth: 1.5, + borderColor: colors.hairlineGray, + alignItems: "center", + justifyContent: "center", + marginTop: 2, + }, + checkboxChecked: { backgroundColor: colors.marigoldOrange, borderColor: colors.marigoldOrange }, + checkboxLabel: { ...typography.body, flex: 1, fontSize: 13, lineHeight: 19 }, + hint: { ...typography.label, textTransform: "none", letterSpacing: 0, marginBottom: 16 }, + cta: { marginTop: 4 }, + }); +} diff --git a/mobile/src/components/onboarding/AvatarStep.tsx b/mobile/src/components/onboarding/AvatarStep.tsx index fc3f7b8..5ae1509 100644 --- a/mobile/src/components/onboarding/AvatarStep.tsx +++ b/mobile/src/components/onboarding/AvatarStep.tsx @@ -1,4 +1,4 @@ -import { useCallback, useState } from "react"; +import { useCallback, useMemo, useState } from "react"; import { View, Text, Image as RNImage, Pressable, ActivityIndicator, StyleSheet, Alert } from "react-native"; import * as ImagePicker from "expo-image-picker"; import { useTranslation } from "react-i18next"; @@ -9,7 +9,8 @@ import { uploadImageToSupabase } from "../../lib/upload"; import { resizeForUpload } from "../../lib/resize-image"; import { PetAvatar } from "../PetAvatar"; import { Button } from "../Button"; -import { colors, radii, typography } from "../../theme/tokens"; +import { radii, getTypography, type ColorTokens, type Typography } from "../../theme/tokens"; +import { useTheme } from "../../context/ThemeContext"; type Props = { petId: string; @@ -26,6 +27,8 @@ type Props = { */ export function AvatarStep({ petId, petName, onDone }: Props) { const { t } = useTranslation(); + const { colors } = useTheme(); + const styles = useMemo(() => makeStyles(colors), [colors]); const trpc = useTRPC(); const [asset, setAsset] = useState(null); const [uploadedKey, setUploadedKey] = useState(null); @@ -120,36 +123,39 @@ export function AvatarStep({ petId, petName, onDone }: Props) { ); } -const styles = StyleSheet.create({ - container: { padding: 24, gap: 4, alignItems: "center" }, - title: { ...typography.title, fontSize: 18, textAlign: "center" }, - subtitle: { ...typography.body, color: colors.quietGray, textAlign: "center", marginBottom: 20 }, - previewWrap: { width: 96, height: 96, borderRadius: 48, overflow: "hidden", backgroundColor: colors.hairlineGray }, - preview: { width: "100%", height: "100%" }, - previewOverlay: { - position: "absolute", - top: 0, - left: 0, - right: 0, - bottom: 0, - backgroundColor: "rgba(0,0,0,0.4)", - alignItems: "center", - justifyContent: "center", - }, - error: { ...typography.body, color: colors.alertRed, marginTop: 12, textAlign: "center" }, - pickerRow: { flexDirection: "row", gap: 12, marginTop: 20, alignSelf: "stretch" }, - pickerButton: { - flex: 1, - flexDirection: "row", - alignItems: "center", - justifyContent: "center", - gap: 8, - height: 48, - borderRadius: radii.lg, - borderWidth: 1, - borderColor: colors.hairlineGray, - }, - pickerText: { ...typography.body, color: colors.ink }, - cta: { marginTop: 20, alignSelf: "stretch" }, - skipLink: { ...typography.label, textTransform: "none", letterSpacing: 0, color: colors.quietGray, marginTop: 12 }, -}); +function makeStyles(colors: ColorTokens) { + const typography: Typography = getTypography(colors); + return StyleSheet.create({ + container: { padding: 24, gap: 4, alignItems: "center" }, + title: { ...typography.title, fontSize: 18, textAlign: "center" }, + subtitle: { ...typography.body, color: colors.quietGray, textAlign: "center", marginBottom: 20 }, + previewWrap: { width: 96, height: 96, borderRadius: 48, overflow: "hidden", backgroundColor: colors.hairlineGray }, + preview: { width: "100%", height: "100%" }, + previewOverlay: { + position: "absolute", + top: 0, + left: 0, + right: 0, + bottom: 0, + backgroundColor: "rgba(0,0,0,0.4)", + alignItems: "center", + justifyContent: "center", + }, + error: { ...typography.body, color: colors.alertRed, marginTop: 12, textAlign: "center" }, + pickerRow: { flexDirection: "row", gap: 12, marginTop: 20, alignSelf: "stretch" }, + pickerButton: { + flex: 1, + flexDirection: "row", + alignItems: "center", + justifyContent: "center", + gap: 8, + height: 48, + borderRadius: radii.lg, + borderWidth: 1, + borderColor: colors.hairlineGray, + }, + pickerText: { ...typography.body, color: colors.ink }, + cta: { marginTop: 20, alignSelf: "stretch" }, + skipLink: { ...typography.label, textTransform: "none", letterSpacing: 0, color: colors.quietGray, marginTop: 12 }, + }); +} diff --git a/mobile/src/components/onboarding/OnboardingGuidelines.tsx b/mobile/src/components/onboarding/OnboardingGuidelines.tsx index 415a263..2c556ef 100644 --- a/mobile/src/components/onboarding/OnboardingGuidelines.tsx +++ b/mobile/src/components/onboarding/OnboardingGuidelines.tsx @@ -1,12 +1,13 @@ import { View, Text, Pressable, ActivityIndicator, Linking, StyleSheet } from "react-native"; -import { useEffect } from "react"; +import { useEffect, useMemo } from "react"; import { useTranslation } from "react-i18next"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { ScrollText } from "lucide-react-native"; import { useTRPC } from "../../api/trpc"; import { env } from "../../lib/env"; import { Button } from "../Button"; -import { colors, radii, typography } from "../../theme/tokens"; +import { radii, getTypography, type ColorTokens, type Typography } from "../../theme/tokens"; +import { useTheme } from "../../context/ThemeContext"; type Props = { onContinue: () => void }; @@ -18,6 +19,8 @@ type Props = { onContinue: () => void }; */ export function OnboardingGuidelines({ onContinue }: Props) { const { t } = useTranslation(); + const { colors } = useTheme(); + const styles = useMemo(() => makeStyles(colors), [colors]); const trpc = useTRPC(); const queryClient = useQueryClient(); @@ -80,22 +83,25 @@ export function OnboardingGuidelines({ onContinue }: Props) { ); } -const styles = StyleSheet.create({ - center: { flex: 1, alignItems: "center", justifyContent: "center", padding: 40 }, - container: { padding: 24, gap: 4 }, - titleRow: { flexDirection: "row", alignItems: "center", gap: 8, marginBottom: 4 }, - title: { ...typography.title, fontSize: 18 }, - subtitle: { ...typography.body, color: colors.quietGray, marginBottom: 16 }, - card: { - gap: 10, - padding: 14, - borderRadius: radii.xl, - borderWidth: 1, - borderColor: colors.hairlineGray, - backgroundColor: colors.pureWhite, - marginBottom: 16, - }, - summary: { ...typography.body }, - link: { ...typography.label, textTransform: "none", letterSpacing: 0, color: colors.marigoldDeep, marginBottom: 8 }, - cta: { marginTop: 12 }, -}); +function makeStyles(colors: ColorTokens) { + const typography: Typography = getTypography(colors); + return StyleSheet.create({ + center: { flex: 1, alignItems: "center", justifyContent: "center", padding: 40 }, + container: { padding: 24, gap: 4 }, + titleRow: { flexDirection: "row", alignItems: "center", gap: 8, marginBottom: 4 }, + title: { ...typography.title, fontSize: 18 }, + subtitle: { ...typography.body, color: colors.quietGray, marginBottom: 16 }, + card: { + gap: 10, + padding: 14, + borderRadius: radii.xl, + borderWidth: 1, + borderColor: colors.hairlineGray, + backgroundColor: colors.pureWhite, + marginBottom: 16, + }, + summary: { ...typography.body }, + link: { ...typography.label, textTransform: "none", letterSpacing: 0, color: colors.marigoldDeep, marginBottom: 8 }, + cta: { marginTop: 12 }, + }); +} diff --git a/mobile/src/components/onboarding/UploadConsent.tsx b/mobile/src/components/onboarding/UploadConsent.tsx index c92e7e7..741cb4c 100644 --- a/mobile/src/components/onboarding/UploadConsent.tsx +++ b/mobile/src/components/onboarding/UploadConsent.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from "react"; +import { useEffect, useMemo, useState } from "react"; import { View, Text, Pressable, ActivityIndicator, Linking, StyleSheet } from "react-native"; import { useTranslation } from "react-i18next"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; @@ -6,7 +6,8 @@ import { ShieldCheck, Check } from "lucide-react-native"; import { useTRPC } from "../../api/trpc"; import { env } from "../../lib/env"; import { Button } from "../Button"; -import { colors, radii, typography } from "../../theme/tokens"; +import { radii, getTypography, type ColorTokens, type Typography } from "../../theme/tokens"; +import { useTheme } from "../../context/ThemeContext"; type Props = { onContinue: () => void }; @@ -18,6 +19,8 @@ type Props = { onContinue: () => void }; */ export function UploadConsent({ onContinue }: Props) { const { t } = useTranslation(); + const { colors } = useTheme(); + const styles = useMemo(() => makeStyles(colors), [colors]); const trpc = useTRPC(); const queryClient = useQueryClient(); const [contentRightsChecked, setContentRightsChecked] = useState(false); @@ -85,6 +88,8 @@ export function UploadConsent({ onContinue }: Props) { } function ConsentCheckbox({ checked, onToggle, label }: { checked: boolean; onToggle: () => void; label: string }) { + const { colors } = useTheme(); + const styles = useMemo(() => makeStyles(colors), [colors]); return ( @@ -95,33 +100,36 @@ function ConsentCheckbox({ checked, onToggle, label }: { checked: boolean; onTog ); } -const styles = StyleSheet.create({ - center: { flex: 1, alignItems: "center", justifyContent: "center", padding: 40 }, - container: { padding: 24, gap: 4 }, - titleRow: { flexDirection: "row", alignItems: "center", gap: 8, marginBottom: 4 }, - title: { ...typography.title, fontSize: 18 }, - subtitle: { ...typography.body, color: colors.quietGray, marginBottom: 16 }, - checkboxRow: { - flexDirection: "row", - gap: 12, - padding: 14, - borderRadius: radii.xl, - borderWidth: 1, - borderColor: colors.hairlineGray, - marginBottom: 12, - }, - checkbox: { - width: 20, - height: 20, - borderRadius: 5, - borderWidth: 1.5, - borderColor: colors.hairlineGray, - alignItems: "center", - justifyContent: "center", - marginTop: 2, - }, - checkboxChecked: { backgroundColor: colors.marigoldOrange, borderColor: colors.marigoldOrange }, - checkboxLabel: { ...typography.body, flex: 1, fontSize: 13, lineHeight: 19 }, - link: { ...typography.label, textTransform: "none", letterSpacing: 0, color: colors.marigoldDeep, marginBottom: 16, marginTop: 4 }, - cta: { marginTop: 4 }, -}); +function makeStyles(colors: ColorTokens) { + const typography: Typography = getTypography(colors); + return StyleSheet.create({ + center: { flex: 1, alignItems: "center", justifyContent: "center", padding: 40 }, + container: { padding: 24, gap: 4 }, + titleRow: { flexDirection: "row", alignItems: "center", gap: 8, marginBottom: 4 }, + title: { ...typography.title, fontSize: 18 }, + subtitle: { ...typography.body, color: colors.quietGray, marginBottom: 16 }, + checkboxRow: { + flexDirection: "row", + gap: 12, + padding: 14, + borderRadius: radii.xl, + borderWidth: 1, + borderColor: colors.hairlineGray, + marginBottom: 12, + }, + checkbox: { + width: 20, + height: 20, + borderRadius: 5, + borderWidth: 1.5, + borderColor: colors.hairlineGray, + alignItems: "center", + justifyContent: "center", + marginTop: 2, + }, + checkboxChecked: { backgroundColor: colors.marigoldOrange, borderColor: colors.marigoldOrange }, + checkboxLabel: { ...typography.body, flex: 1, fontSize: 13, lineHeight: 19 }, + link: { ...typography.label, textTransform: "none", letterSpacing: 0, color: colors.marigoldDeep, marginBottom: 16, marginTop: 4 }, + cta: { marginTop: 4 }, + }); +}