| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import { GoodsItem } from '@/services/mall';
- import React from 'react';
- import { StyleSheet, Text, View } from 'react-native';
- import { GoodsCard } from './GoodsCard';
- interface GoodsListProps {
- data: GoodsItem[];
- onItemPress?: (item: GoodsItem) => void;
- }
- export function GoodsList({ data, onItemPress }: GoodsListProps) {
- if (!data || data.length === 0) {
- return (
- <View style={styles.empty}>
- <Text style={styles.emptyText}>暂无商品</Text>
- </View>
- );
- }
- return (
- <View style={styles.container}>
- {data.map((item) => (
- <GoodsCard key={item.id} data={item} onPress={onItemPress} />
- ))}
- </View>
- );
- }
- const styles = StyleSheet.create({
- container: {
- flexDirection: 'row',
- flexWrap: 'wrap',
- justifyContent: 'space-between',
- marginHorizontal: 7,
- marginTop: 10,
- paddingBottom: 100,
- },
- empty: {
- paddingVertical: 50,
- alignItems: 'center',
- },
- emptyText: {
- color: '#666',
- fontSize: 14,
- },
- });
|