| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import { TabItem } from '@/services/base';
- import { Image } from 'expo-image';
- import React from 'react';
- import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
- // 小程序 item 宽度 162rpx = 81pt
- const ITEM_WIDTH = 81;
- interface QuickEntryProps {
- data: TabItem[];
- onPress?: (item: TabItem) => void;
- }
- export function QuickEntry({ data, onPress }: QuickEntryProps) {
- return (
- <View style={styles.container}>
- <View style={styles.center}>
- {data.map((item, index) => (
- <TouchableOpacity
- key={index}
- style={styles.item}
- activeOpacity={0.7}
- onPress={() => onPress?.(item)}
- >
- <View style={styles.itemBox}>
- <Image source={item.cover} style={styles.icon} contentFit="contain" />
- <Text style={styles.title}>{item.title}</Text>
- </View>
- </TouchableOpacity>
- ))}
- </View>
- </View>
- );
- }
- const styles = StyleSheet.create({
- container: {
- width: '100%',
- marginTop: 10,
- paddingHorizontal: 10,
- },
- center: {
- width: '100%',
- flexDirection: 'row',
- flexWrap: 'wrap',
- justifyContent: 'space-around',
- },
- item: {
- width: ITEM_WIDTH,
- alignItems: 'center',
- },
- itemBox: {
- alignItems: 'center',
- },
- icon: {
- width: ITEM_WIDTH,
- height: ITEM_WIDTH,
- },
- title: {
- fontSize: 10,
- fontWeight: '300',
- color: 'rgba(255,255,255,0.59)',
- },
- });
|