diff --git a/mobile/src/components/CategoryPill.tsx b/mobile/src/components/CategoryPill.tsx index 328058fc..ab556b55 100644 --- a/mobile/src/components/CategoryPill.tsx +++ b/mobile/src/components/CategoryPill.tsx @@ -2,6 +2,15 @@ import React from "react"; import { TouchableOpacity, Text, StyleSheet } from "react-native"; import { spacing, borderRadius, fontSize, fontWeight } from "../theme"; import { useTheme } from "../context/ThemeContext"; + +function getTextColor(hex: string): string { + const h = hex.replace("#", ""); + const full = h.length === 3 ? h.split("").map((c) => c + c).join("") : h; + const r = parseInt(full.slice(0, 2), 16); + const g = parseInt(full.slice(2, 4), 16); + const b = parseInt(full.slice(4, 6), 16); + return (r * 299 + g * 587 + b * 114) / 1000 > 128 ? "#000000" : "#ffffff"; +} interface CategoryPillProps { label: string; active: boolean; @@ -34,7 +43,7 @@ export default function CategoryPill({ {label} diff --git a/mobile/src/components/ProductCard.tsx b/mobile/src/components/ProductCard.tsx index 18d72bd8..d073dc13 100644 --- a/mobile/src/components/ProductCard.tsx +++ b/mobile/src/components/ProductCard.tsx @@ -10,6 +10,15 @@ import { Pressable, ScrollView, } from "react-native"; + +function getTextColor(hex: string): string { + const h = hex.replace("#", ""); + const full = h.length === 3 ? h.split("").map((c) => c + c).join("") : h; + const r = parseInt(full.slice(0, 2), 16); + const g = parseInt(full.slice(2, 4), 16); + const b = parseInt(full.slice(4, 6), 16); + return (r * 299 + g * 587 + b * 114) / 1000 > 128 ? "#000000" : "#ffffff"; +} import { Ionicons } from "@expo/vector-icons"; import { Video, ResizeMode } from "expo-av"; import { spacing, borderRadius, fontSize, fontWeight } from "../theme"; @@ -190,13 +199,7 @@ export default function ProductCard({ product, onPress, categoryColor }: Product Ajoute ! @@ -219,13 +222,7 @@ export default function ProductCard({ product, onPress, categoryColor }: Product {isSoldOut diff --git a/mobile/src/screens/client/ProductDetailScreen.tsx b/mobile/src/screens/client/ProductDetailScreen.tsx index 2310c1ec..60ef1970 100644 --- a/mobile/src/screens/client/ProductDetailScreen.tsx +++ b/mobile/src/screens/client/ProductDetailScreen.tsx @@ -106,6 +106,15 @@ export default function ProductDetailScreen() { } }; + const catTextColor = (() => { + const h = catColor.replace("#", ""); + const full = h.length === 3 ? h.split("").map((c) => c + c).join("") : h; + const r = parseInt(full.slice(0, 2), 16); + const g = parseInt(full.slice(2, 4), 16); + const b = parseInt(full.slice(4, 6), 16); + return (r * 299 + g * 587 + b * 114) / 1000 > 128 ? "#000000" : "#ffffff"; + })(); + const overlayBg = isDark ? "rgba(255,255,255,0.02)" : "rgba(0,0,0,0.02)"; const overlayBorder = isDark ? "rgba(255,255,255,0.08)" @@ -301,7 +310,7 @@ export default function ProductDetailScreen() { elevation: 0, }, addToCartText: { - color: colors.white, + color: catTextColor, fontSize: fontSize.lg, fontWeight: "700", textTransform: "uppercase", diff --git a/mobile/src/screens/client/ProfileScreen.tsx b/mobile/src/screens/client/ProfileScreen.tsx index 386ade1b..2e9ea588 100644 --- a/mobile/src/screens/client/ProfileScreen.tsx +++ b/mobile/src/screens/client/ProfileScreen.tsx @@ -50,8 +50,6 @@ export default function ProfileScreen() { if (savedAddress !== null) setDefaultAddress(savedAddress); if (savedPhone !== null) setDefaultPhone(savedPhone); - if (savedSignal !== null) setSignalPseudo(savedSignal); - if (profileRes.success && profileRes.client) { const c = profileRes.client; setNom(c.nom ?? ""); @@ -62,6 +60,10 @@ export default function ProfileScreen() { if (savedPhone === null && c.telephone) { setDefaultPhone(c.telephone); } + // Signal pseudo : storage si non vide, sinon username d'enregistrement + setSignalPseudo(savedSignal || c.username || ""); + } else if (savedSignal) { + setSignalPseudo(savedSignal); } setLoadingProfile(false); }, []);