-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
completed search screen, minus composability refactor wip
- Loading branch information
Showing
30 changed files
with
1,993 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React, { useState } from 'react'; | ||
import { ScrollView, Pressable } from 'react-native'; | ||
import { YStack, XStack, Text, Spinner } from 'tamagui'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'; | ||
import { faArrowRight } from '@fortawesome/free-solid-svg-icons'; | ||
import { useNavigation } from '@react-navigation/native'; | ||
import useStorefrontData from '../hooks/use-storefront-data'; | ||
import ProductCard from './ProductCard'; | ||
|
||
const CategoryProductSlider = ({ category, style = {}, onPressCategory }) => { | ||
const navigation = useNavigation(); | ||
const { data: products, loading: isLoadingProducts } = useStorefrontData((storefront) => storefront.products.query({ category: category.id }), { | ||
defaultValue: [], | ||
persistKey: `${category.id}_products`, | ||
}); | ||
|
||
const handleCategoryPress = () => { | ||
if (typeof onPressCategory === 'function') { | ||
onPressCategory(category); | ||
} | ||
}; | ||
|
||
return ( | ||
<YStack space='$3' style={style}> | ||
<XStack justiftContent='space-between' paddingHorizontal='$4'> | ||
<XStack space='$4' alignItems='center'> | ||
<Pressable onPress={handleCategoryPress} hitSlop={20} style={({ pressed }) => [{ opacity: pressed ? 0.5 : 1.0, scale: pressed ? 0.8 : 1.0 }]}> | ||
<XStack alignItems='center'> | ||
<Text fontWeight='bold' fontSize='$7'> | ||
{category.getAttribute('name')} | ||
</Text> | ||
<FontAwesomeIcon icon={faArrowRight} color='black' size={15} style={{ marginLeft: 7 }} /> | ||
</XStack> | ||
</Pressable> | ||
{isLoadingProducts && <Spinner size='sm' color='$color' />} | ||
</XStack> | ||
</XStack> | ||
<ScrollView horizontal showsHorizontalScrollIndicator={false}> | ||
<XStack space='$4' paddingVertical='$1' paddingHorizontal='$4'> | ||
{products.map((product, index) => ( | ||
<ProductCard key={index} product={product} sliderHeight={135} style={{ width: 190 }} /> | ||
))} | ||
</XStack> | ||
</ScrollView> | ||
</YStack> | ||
); | ||
}; | ||
|
||
export default CategoryProductSlider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.