diff --git a/app/(root)/(tabs)/index.tsx b/app/(root)/(tabs)/index.tsx index d712636..8cc4f54 100644 --- a/app/(root)/(tabs)/index.tsx +++ b/app/(root)/(tabs)/index.tsx @@ -1,27 +1,38 @@ import { Link } from "expo-router"; -import {Image, SafeAreaView, Text, View} from "react-native"; +import {Image, SafeAreaView, Text, TouchableOpacity, View} from "react-native"; import images from "@/constants/images"; import icons from "@/constants/icons"; import search from "@/components/Search"; import Search from "@/components/Search"; +import {useGlobalContext} from "@/lib/globalProvider"; export default function Index() { +// create func that determines the time od day [morning, evening, night] + const {user, refetch} = useGlobalContext(); return ( - - - - good morning - pero + + + + good morning + {user?.name} - - + + + + featured + + see all + + + + ); } diff --git a/app/(root)/(tabs)/profile.tsx b/app/(root)/(tabs)/profile.tsx index 346b92e..5621595 100644 --- a/app/(root)/(tabs)/profile.tsx +++ b/app/(root)/(tabs)/profile.tsx @@ -6,7 +6,6 @@ import {settings} from "@/constants/data"; import {useGlobalContext} from "@/lib/globalProvider"; import {logOut} from "@/lib/appwrite"; import {parseJson} from "ajv/dist/runtime/parseJson"; -import message = parseJson.message; interface SettingsItemsProps{ icon: ImageSourcePropType, diff --git a/components/Cards.tsx b/components/Cards.tsx new file mode 100644 index 0000000..db4ec87 --- /dev/null +++ b/components/Cards.tsx @@ -0,0 +1,11 @@ +import {View, Text} from 'react-native' +import React from 'react' + +const Cards = () => { + return ( + + Cards + + ) +} +export default Cards diff --git a/components/Search.tsx b/components/Search.tsx index 49d88e0..3926eb6 100644 --- a/components/Search.tsx +++ b/components/Search.tsx @@ -1,16 +1,25 @@ -import {View, Text, TextInput, SafeAreaView, Image} from 'react-native' +import {View, Text, TextInput, SafeAreaView, Image, TouchableOpacity} from 'react-native' import React, {useState} from 'react' -import {useLocalSearchParams, usePathname} from "expo-router"; +import {router, useLocalSearchParams, usePathname} from "expo-router"; import icons from "@/constants/icons"; +import {useDebouncedCallback} from "use-debounce"; const Search = () => { const path = usePathname(); const params = useLocalSearchParams<{query?: string}>(); const [search, setSearch] = useState(params.query); + // we will optimize search with debounce + + const debounceSearch = useDebouncedCallback( + (text: string) => router.setParams({ query: text }), + 300 // debounce delay in milliseconds + ); + const handleSearch = (text: string) => { - // console.log(search) - setSearch(text) + console.log(search) + setSearch(text); + debounceSearch(text) } return ( @@ -23,6 +32,9 @@ const Search = () => { style={{flex: 1, marginLeft: 10}} /> + + + ) }