diff --git a/app/screens/HomeScreen.tsx b/app/screens/HomeScreen.tsx
index 6dd87b2..a902832 100644
--- a/app/screens/HomeScreen.tsx
+++ b/app/screens/HomeScreen.tsx
@@ -62,7 +62,6 @@ type SubcategoryItem = {
type CategoryContentType = {
[key: string]: SubcategoryItem[];
};
-
// 懒加载图片组件 - 改进版本
const LazyImage = React.memo(
({
@@ -76,16 +75,13 @@ const LazyImage = React.memo(
}) => {
const [isLoaded, setIsLoaded] = useState(false);
const [hasError, setHasError] = useState(false);
-
const onLoad = useCallback(() => {
setIsLoaded(true);
}, []);
-
const onError = useCallback(() => {
setHasError(true);
setIsLoaded(true); // Also mark as loaded on error to remove placeholder
}, []);
-
return (
{/* Show placeholder while image is loading */}
@@ -98,7 +94,6 @@ const LazyImage = React.memo(
]}
/>
)}
-
{/* Show error state if image failed to load */}
{hasError && (
)}
-
{/* Actual image */}
{
// 创建动画值
const shimmerAnim = useRef(new Animated.Value(0)).current;
-
// 设置动画效果
useEffect(() => {
const shimmerAnimation = Animated.loop(
@@ -144,20 +136,16 @@ const ProductSkeleton = React.memo(() => {
useNativeDriver: true,
})
);
-
shimmerAnimation.start();
-
return () => {
shimmerAnimation.stop();
};
}, []);
-
// 定义动画插值
const shimmerTranslate = shimmerAnim.interpolate({
inputRange: [0, 1],
outputRange: [-200, 200],
});
-
return (
@@ -219,7 +207,6 @@ const ProductSkeleton = React.memo(() => {
);
});
-
// Define the styles type to fix TypeScript errors
type StylesType = {
safeArea: ViewStyle;
@@ -273,6 +260,7 @@ type StylesType = {
productCardList: ViewStyle;
productCardGroup: ViewStyle;
beautyProductCard1: ViewStyle;
+ productCardGroup1: ViewStyle;
beautyCardContainer1: ViewStyle;
vipButtonContainer: ViewStyle;
vipButton: ViewStyle;
@@ -308,7 +296,6 @@ type StylesType = {
imagePickerCancelButton: ViewStyle;
imagePickerCancelText: TextStyle;
};
-
export const HomeScreen = () => {
const [activeIndex, setActiveIndex] = useState(0);
const screenWidth = Dimensions.get("window").width;
@@ -339,7 +326,6 @@ export const HomeScreen = () => {
const [galleryUsed, setGalleryUsed] = useState(false);
const [hotTerms, setHotTerms] = useState([]);
const [isLoadingHotTerms, setIsLoadingHotTerms] = useState(false);
-
// 直接在组件中实现分页加载逻辑
const [products, setProducts] = useState([]);
const [loading, setLoading] = useState(true);
@@ -537,7 +523,6 @@ export const HomeScreen = () => {
setRefreshing(false);
}
}, [hotTerms, getRandomKeyword, fetchInitialProducts]);
-
const handleProductPress = useCallback(
(item: Product) => {
InteractionManager.runAfterInteractions(() => {
@@ -550,7 +535,6 @@ export const HomeScreen = () => {
},
[navigation]
);
-
const categories = [
"Tous",
"Bijoux",
@@ -564,7 +548,6 @@ export const HomeScreen = () => {
"Hygiène et Soins pour le corps",
"Maquillage",
];
-
const defaultSubcategories: SubcategoryItem[] = [
{ id: 1, title: "Jewelry", icon: "diamond-outline" },
{ id: 2, title: "Earrings", icon: "ear-outline" },
@@ -573,7 +556,6 @@ export const HomeScreen = () => {
{ id: 5, title: "Earrings", icon: "ear-outline" },
{ id: 6, title: "Bracelet", icon: "watch-outline" },
];
-
const categoryContent: CategoryContentType = {
Tous: [],
Bijoux: defaultSubcategories,
@@ -587,31 +569,26 @@ export const HomeScreen = () => {
"Hygiène et Soins pour le corps": defaultSubcategories,
Maquillage: defaultSubcategories,
};
-
useEffect(() => {
if (!categoryContent[selectedHorizontalCategory]) {
setSelectedHorizontalCategory("Tous");
}
}, [selectedHorizontalCategory]);
-
const navigateToSearch = useCallback(() => {
InteractionManager.runAfterInteractions(() => {
navigation.navigate("Search");
});
}, [navigation]);
-
const navigateToShippingDetails = useCallback(() => {
InteractionManager.runAfterInteractions(() => {
navigation.navigate("ShippingDetailsSection");
});
}, [navigation]);
-
const navigateToInquiry = useCallback(() => {
InteractionManager.runAfterInteractions(() => {
navigation.navigate("InquiryScreen");
});
}, [navigation]);
-
const scrollToCategory = (category: string) => {
const categoryIndex = categories.findIndex((c) => c === category);
if (categoryIndex !== -1 && horizontalScrollRef.current) {
@@ -626,7 +603,6 @@ export const HomeScreen = () => {
});
}
};
-
const renderProductItem = ({ item }: { item: Product }) => (
handleProductPress(item)}
@@ -645,7 +621,6 @@ export const HomeScreen = () => {
)}
-
{userStore.user?.user_id && (
@@ -677,7 +652,6 @@ export const HomeScreen = () => {
);
-
const renderSkeletonGrid = useCallback(() => {
const skeletonArray = Array(8).fill(null);
return (
@@ -694,7 +668,6 @@ export const HomeScreen = () => {
);
}, []);
-
const cleanupImagePickerCache = async () => {
try {
if (Platform.OS === 'web') {
@@ -712,7 +685,6 @@ export const HomeScreen = () => {
setGalleryUsed(false);
}
};
-
const handleChooseFromGallery = useCallback(async () => {
setShowImagePickerModal(false);
setTimeout(async () => {
@@ -722,14 +694,12 @@ export const HomeScreen = () => {
console.log("相册权限被拒绝");
return;
}
-
const result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
allowsEditing: true,
aspect: [4, 3],
quality: 1,
});
-
if (!result.canceled && result.assets && result.assets.length > 0) {
await cleanupImagePickerCache();
navigation.navigate("ImageSearchResultScreen", {
@@ -743,7 +713,6 @@ export const HomeScreen = () => {
}
}, 500);
}, []);
-
const handleTakePhoto = useCallback(async () => {
setShowImagePickerModal(false);
setTimeout(async () => {
@@ -753,14 +722,12 @@ export const HomeScreen = () => {
console.log("相机权限被拒绝");
return;
}
-
const result = await ImagePicker.launchCameraAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
allowsEditing: true,
aspect: [4, 3],
quality: 1,
});
-
if (!result.canceled && result.assets && result.assets.length > 0) {
await cleanupImagePickerCache();
navigation.navigate("ImageSearchResultScreen", {
@@ -774,25 +741,21 @@ export const HomeScreen = () => {
}
}, 500);
}, []);
-
const resetAppState = useCallback(() => {
setGalleryUsed(false);
cleanupImagePickerCache();
Alert.alert("已重置", "现在您可以使用相机功能了");
}, []);
-
// 优化轮播图切换回调
const handleCarouselSnap = useCallback((index: number) => {
setActiveIndex(index);
}, []);
-
const renderItem = ({ item, index }: { item: Product; index: number }) => {
if (index >= products.length && index < products.length + loadingPlaceholders) {
return ;
}
return renderProductItem({ item });
};
-
const renderHeader = useCallback(() => (
<>
@@ -962,7 +925,6 @@ export const HomeScreen = () => {
) : null}
>
), [activeIndex, selectedHorizontalCategory]);
-
return (
@@ -1179,7 +1141,7 @@ export const HomeScreen = () => {
const rightItem = allItems[i + 1];
rows.push(
-
+
{/* 左侧商品 */}
{leftItem ? (
i >= products.length ? (
@@ -1216,7 +1178,6 @@ export const HomeScreen = () => {
)}
-
{
-
{
重置相机功能
)}
-
-
{
{t("homePage.chooseFromGallery")}
-
-
setShowImagePickerModal(false)}
@@ -1615,6 +1571,11 @@ const styles = StyleSheet.create({
marginBottom: 15,
paddingHorizontal: 15,
},
+ productCardGroup1:{
+ flexDirection: "row",
+ justifyContent: "space-between",
+ marginBottom: 15,
+ },
beautyProductCard1: {
width: "48%",
},
diff --git a/app/utils/languageUtils.ts b/app/utils/languageUtils.ts
index 5dab337..9342fbc 100644
--- a/app/utils/languageUtils.ts
+++ b/app/utils/languageUtils.ts
@@ -55,3 +55,31 @@ export const getSkuTransLanguage = >(data: T): str
// 返回匹配的翻译值,如果没有匹配则返回法语
return (data[matchedField || 'value_trans'] as string) || '';
};
+
+
+
+export const getOrderTransLanguage = >(data: T): string => {
+ // 获取当前i18n语言
+ const currentLang = getCurrentLanguage();
+
+ // 特殊处理中文
+ if (currentLang === 'zh' && 'value' in data) {
+ return data.value as string;
+ }
+
+ // 获取所有subject_trans开头的字段
+ const translationFields = Object.keys(data).filter(key =>
+ key.startsWith('product_name')
+ );
+
+ // 查找匹配的字段
+ const matchedField = translationFields.find(field => {
+ // 从字段名中提取语言代码
+ const langCode = field.replace('product_name', '');
+ // 如果没有后缀,则为法语
+ return langCode === '' ? currentLang === 'fr' : langCode === currentLang;
+ });
+
+ // 返回匹配的翻译值,如果没有匹配则返回法语
+ return (data[matchedField || 'product_name'] as string) || '';
+};