import React from 'react'; import { ImageBackground, StyleSheet, Text, TouchableOpacity, View, } from 'react-native'; import { Images } from '@/constants/images'; // Helper to determine background image based on type const getBtnBg = (type: 'one' | 'five' | 'many') => { switch (type) { case 'one': return Images.common.butBgV; case 'five': return Images.common.butBgL; case 'many': return Images.common.butBgH; default: return Images.common.butBgV; } }; interface PurchaseBarProps { price: number; specialPrice?: number; specialPriceFive?: number; onBuy: (count: number) => void; onBuyMany: () => void; } export default function PurchaseBar({ price, specialPrice, specialPriceFive, onBuy, onBuyMany }: PurchaseBarProps) { return ( {/* Buy One */} onBuy(1)} style={styles.btnWrapper}> 购买一盒 (¥{specialPrice ?? price}) {/* Buy Five */} onBuy(5)} style={styles.btnWrapper}> 购买五盒 (¥{specialPriceFive ?? price * 5}) {/* Buy Many */} 购买多盒 ); } const styles = StyleSheet.create({ container: { width: '100%', height: 100, // Adjust based on background aspect ratio justifyContent: 'center', paddingBottom: 20, // Safe area padding simulation }, btnRow: { flexDirection: 'row', justifyContent: 'space-around', alignItems: 'center', paddingHorizontal: 10, }, btnWrapper: { flex: 1, height: 50, marginHorizontal: 5, }, btnBg: { width: '100%', height: '100%', justifyContent: 'center', alignItems: 'center', }, btnTitle: { color: '#fff', fontSize: 14, fontWeight: 'bold', textShadowColor: '#000', textShadowOffset: { width: 1, height: 1 }, textShadowRadius: 1, }, btnPrice: { color: '#fff', fontSize: 10, fontWeight: 'bold', textShadowColor: '#000', textShadowOffset: { width: 1, height: 1 }, textShadowRadius: 1, } });