chore: fix bug ui
This commit is contained in:
@@ -2,6 +2,15 @@ import React from "react";
|
|||||||
import { TouchableOpacity, Text, StyleSheet } from "react-native";
|
import { TouchableOpacity, Text, StyleSheet } from "react-native";
|
||||||
import { spacing, borderRadius, fontSize, fontWeight } from "../theme";
|
import { spacing, borderRadius, fontSize, fontWeight } from "../theme";
|
||||||
import { useTheme } from "../context/ThemeContext";
|
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 {
|
interface CategoryPillProps {
|
||||||
label: string;
|
label: string;
|
||||||
active: boolean;
|
active: boolean;
|
||||||
@@ -34,7 +43,7 @@ export default function CategoryPill({
|
|||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
styles.text,
|
styles.text,
|
||||||
{ color: active ? colors.black : colors.textSecondary },
|
{ color: active ? getTextColor(catColor) : colors.textSecondary },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
|
|||||||
@@ -10,6 +10,15 @@ import {
|
|||||||
Pressable,
|
Pressable,
|
||||||
ScrollView,
|
ScrollView,
|
||||||
} from "react-native";
|
} 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 { Ionicons } from "@expo/vector-icons";
|
||||||
import { Video, ResizeMode } from "expo-av";
|
import { Video, ResizeMode } from "expo-av";
|
||||||
import { spacing, borderRadius, fontSize, fontWeight } from "../theme";
|
import { spacing, borderRadius, fontSize, fontWeight } from "../theme";
|
||||||
@@ -190,13 +199,7 @@ export default function ProductCard({ product, onPress, categoryColor }: Product
|
|||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
styles.successText,
|
styles.successText,
|
||||||
{
|
{ color: getTextColor(catColor) },
|
||||||
color: product.category
|
|
||||||
?.toLowerCase()
|
|
||||||
.includes("zipette")
|
|
||||||
? colors.black
|
|
||||||
: colors.white,
|
|
||||||
},
|
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
Ajoute !
|
Ajoute !
|
||||||
@@ -219,13 +222,7 @@ export default function ProductCard({ product, onPress, categoryColor }: Product
|
|||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
styles.quickAddBtnText,
|
styles.quickAddBtnText,
|
||||||
{
|
{ color: getTextColor(catColor) },
|
||||||
color: product.category
|
|
||||||
?.toLowerCase()
|
|
||||||
.includes("zipette")
|
|
||||||
? colors.black
|
|
||||||
: colors.white,
|
|
||||||
},
|
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{isSoldOut
|
{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 overlayBg = isDark ? "rgba(255,255,255,0.02)" : "rgba(0,0,0,0.02)";
|
||||||
const overlayBorder = isDark
|
const overlayBorder = isDark
|
||||||
? "rgba(255,255,255,0.08)"
|
? "rgba(255,255,255,0.08)"
|
||||||
@@ -301,7 +310,7 @@ export default function ProductDetailScreen() {
|
|||||||
elevation: 0,
|
elevation: 0,
|
||||||
},
|
},
|
||||||
addToCartText: {
|
addToCartText: {
|
||||||
color: colors.white,
|
color: catTextColor,
|
||||||
fontSize: fontSize.lg,
|
fontSize: fontSize.lg,
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
textTransform: "uppercase",
|
textTransform: "uppercase",
|
||||||
|
|||||||
@@ -50,8 +50,6 @@ export default function ProfileScreen() {
|
|||||||
|
|
||||||
if (savedAddress !== null) setDefaultAddress(savedAddress);
|
if (savedAddress !== null) setDefaultAddress(savedAddress);
|
||||||
if (savedPhone !== null) setDefaultPhone(savedPhone);
|
if (savedPhone !== null) setDefaultPhone(savedPhone);
|
||||||
if (savedSignal !== null) setSignalPseudo(savedSignal);
|
|
||||||
|
|
||||||
if (profileRes.success && profileRes.client) {
|
if (profileRes.success && profileRes.client) {
|
||||||
const c = profileRes.client;
|
const c = profileRes.client;
|
||||||
setNom(c.nom ?? "");
|
setNom(c.nom ?? "");
|
||||||
@@ -62,6 +60,10 @@ export default function ProfileScreen() {
|
|||||||
if (savedPhone === null && c.telephone) {
|
if (savedPhone === null && c.telephone) {
|
||||||
setDefaultPhone(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);
|
setLoadingProfile(false);
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
Reference in New Issue
Block a user