-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
87 additions
and
20 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 |
---|---|---|
@@ -1,19 +1,77 @@ | ||
import React from "react"; | ||
import { SafeAreaView } from "react-native-safe-area-context"; | ||
import { ActivityIndicator } from "react-native"; | ||
import { | ||
AnimatedImage, | ||
BorderRadiuses, | ||
Card, | ||
Spacings, | ||
Text, | ||
View, | ||
} from "react-native-ui-lib"; | ||
import { Link } from "expo-router"; | ||
import { api } from "@/utils/api"; | ||
import colors from "@/utils/colors"; | ||
import { FlashList } from "@shopify/flash-list"; | ||
|
||
export default function HomeScreen() { | ||
// const utils = api.useContext(); | ||
|
||
// const postQuery = api.post.all.useQuery(); | ||
|
||
// const deletePostMutation = api.post.delete.useMutation({ | ||
// onSettled: () => utils.post.all.invalidate(), | ||
// }); | ||
const { data, refetch, isFetching } = api.category.getCategories.useQuery(); | ||
|
||
return ( | ||
<SafeAreaView> | ||
{/* Changes page title visible on the header */} | ||
{/* <Stack.Screen options={{ title: "Home Page" }} /> */} | ||
</SafeAreaView> | ||
<View flex bg-primary> | ||
<AnimatedImage | ||
source={{ uri: "https://picsum.photos/200/160" }} | ||
// source={{ uri: data?.image }} | ||
height={124} | ||
style={{ borderRadius: BorderRadiuses.br60 }} | ||
containerStyle={{ | ||
paddingHorizontal: Spacings.s10, | ||
paddingTop: Spacings.s2, | ||
paddingBottom: Spacings.s6, | ||
backgroundColor: colors.primary, | ||
}} | ||
loader={<ActivityIndicator color={colors.secondary} size="large" />} | ||
/> | ||
<View bg-white br50 flex padding-s4 className="rounded-b-none"> | ||
<FlashList | ||
data={data} | ||
numColumns={2} | ||
estimatedItemSize={50} | ||
onRefresh={() => refetch()} | ||
refreshing={isFetching} | ||
renderItem={({ item }) => { | ||
return ( | ||
<View centerH flex margin-8 className="space-y-2"> | ||
<Link | ||
asChild | ||
href={{ | ||
pathname: "/search", | ||
params: { | ||
categoryId: item.id, | ||
}, | ||
}} | ||
> | ||
<Card flex-1 enableShadow> | ||
<AnimatedImage | ||
source={{ uri: item.imageUrl }} | ||
height={124} | ||
width={123} | ||
borderRadius={BorderRadiuses.br50} | ||
loader={ | ||
<ActivityIndicator | ||
color={colors.secondary} | ||
size="large" | ||
className="mb-24" | ||
/> | ||
} | ||
/> | ||
</Card> | ||
</Link> | ||
<Text>{item.name}</Text> | ||
</View> | ||
); | ||
}} | ||
/> | ||
</View> | ||
</View> | ||
); | ||
} |
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
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
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
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