feat(whole project): huge changes, huge updates
This commit is contained in:
196 files changed
+9146
-4316
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { View, Text, TouchableOpacity } from 'react-native'
|
||||
import React from 'react'
|
||||
import React, { useState } from 'react'
|
||||
import { widthPercentageToDP as wp, heightPercentageToDP as hp } from 'react-native-responsive-screen';
|
||||
import { MinusIcon, PlusIcon } from 'react-native-heroicons/outline'
|
||||
|
||||
/**
|
||||
@@ -13,34 +14,34 @@ import { MinusIcon, PlusIcon } from 'react-native-heroicons/outline'
|
||||
* @param {Object} props.containerStyle Additional styles for the container
|
||||
* @returns {React.Component} Quantity selector component
|
||||
*/
|
||||
export default function ProductQuantityInput({
|
||||
quantity = 1,
|
||||
onIncrease,
|
||||
onDecrease,
|
||||
label = "Quantity",
|
||||
containerStyle = {}
|
||||
}) {
|
||||
return (
|
||||
<View style={containerStyle}>
|
||||
{label && <Text className="text-[17px] font-medium mb-2">{label}</Text>}
|
||||
<View className="flex-row items-center">
|
||||
<TouchableOpacity
|
||||
onPress={onDecrease}
|
||||
className={`bg-primary/40 rounded-lg p-1 ${quantity <= 1 ? 'opacity-50' : ''}`}
|
||||
disabled={quantity <= 1}
|
||||
>
|
||||
<MinusIcon color={quantity <= 1 ? "gray" : "black"} size={25} />
|
||||
</TouchableOpacity>
|
||||
|
||||
<Text className="mx-4 text-xl">{quantity}</Text>
|
||||
|
||||
<TouchableOpacity
|
||||
onPress={onIncrease}
|
||||
className="bg-primary rounded-lg p-1"
|
||||
>
|
||||
<PlusIcon color="white" size={25} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
const ProductQuantityInput = ({ initialQuantity = 1, onQuantityChange }) => {
|
||||
const [quantity, setQuantity] = useState(initialQuantity);
|
||||
|
||||
const handleDecrease = () => {
|
||||
if (quantity > 1) {
|
||||
const newQuantity = quantity - 1;
|
||||
setQuantity(newQuantity);
|
||||
onQuantityChange(newQuantity);
|
||||
}
|
||||
};
|
||||
|
||||
const handleIncrease = () => {
|
||||
const newQuantity = quantity + 1;
|
||||
setQuantity(newQuantity);
|
||||
onQuantityChange(newQuantity);
|
||||
};
|
||||
|
||||
return (
|
||||
<View className="flex-row items-center justify-between border border-gray-300 rounded-full px-4 py-2" style={{ width: wp('30%') }}>
|
||||
<TouchableOpacity onPress={handleDecrease} disabled={quantity <= 1}>
|
||||
<MinusIcon size={wp('5%')} color={quantity <= 1 ? '#ccc' : '#000'} />
|
||||
</TouchableOpacity>
|
||||
<Text style={{ fontSize: wp('4%') }} className="font-semibold">{quantity}</Text>
|
||||
<TouchableOpacity onPress={handleIncrease}>
|
||||
<PlusIcon size={wp('5%')} color="#000" />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export default ProductQuantityInput;
|
||||
Reference in new issue
Block a user