chore: fix bug ui

This commit is contained in:
2026-03-17 11:31:14 +01:00
parent c52cc280ac
commit a82097a228
4 changed files with 35 additions and 18 deletions
+10 -1
View File
@@ -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({
<Text
style={[
styles.text,
{ color: active ? colors.black : colors.textSecondary },
{ color: active ? getTextColor(catColor) : colors.textSecondary },
]}
>
{label}
+11 -14
View File
@@ -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
<Text
style={[
styles.successText,
{
color: product.category
?.toLowerCase()
.includes("zipette")
? colors.black
: colors.white,
},
{ color: getTextColor(catColor) },
]}
>
Ajoute !
@@ -219,13 +222,7 @@ export default function ProductCard({ product, onPress, categoryColor }: Product
<Text
style={[
styles.quickAddBtnText,
{
color: product.category
?.toLowerCase()
.includes("zipette")
? colors.black
: colors.white,
},
{ color: getTextColor(catColor) },
]}
>
{isSoldOut
@@ -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",
+4 -2
View File
@@ -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);
}, []);