diff --git a/app/(root)/(tabs)/index.tsx b/app/(root)/(tabs)/index.tsx index cc0f4e0..8524d46 100644 --- a/app/(root)/(tabs)/index.tsx +++ b/app/(root)/(tabs)/index.tsx @@ -1,20 +1,26 @@ import { Link } from "expo-router"; -import { Text, View } from "react-native"; +import {Image, SafeAreaView, Text, View} from "react-native"; +import images from "@/constants/images"; +import icons from "@/constants/icons"; +import search from "@/components/Search"; +import Search from "@/components/Search"; export default function Index() { return ( - - Welcome to mobile.mk - {/*SignIn*/} - {/*explore*/} - {/*profile*/} - {/*car*/} - + + + + + + + + good morning + pero + + + + + + ); } diff --git a/app/(root)/(tabs)/profile.tsx b/app/(root)/(tabs)/profile.tsx index 6a0f09b..346b92e 100644 --- a/app/(root)/(tabs)/profile.tsx +++ b/app/(root)/(tabs)/profile.tsx @@ -1,10 +1,39 @@ -import {View, Text, SafeAreaView, ScrollView, Image, TouchableOpacity} from "react-native"; +import {View, Text, SafeAreaView, ScrollView, Image, TouchableOpacity, ImageSourcePropType, Alert} from "react-native"; import React from "react"; import icons from "@/constants/icons" import images from "@/constants/images"; +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, + title: string, + onPress?: () => void, + textStyle?: string, + showArrow?: boolean, +} +const SettingsItems = ({icon, title, onPress, textStyle, showArrow = true } : SettingsItemsProps) => ( + + + + {title} + + {showArrow && } + +) const Profile = () => { - const handleLogout = async () => {}; + const {user, refetch} = useGlobalContext(); + const handleLogout = async () => { + const result = await logOut(); + if(result) { + Alert.alert('logged out') + refetch(); + } + }; return ( { - + - Dimitar -- test + { user?.name} + + + + + + + + {settings.slice(2).map((item, index ) => ( + + ) )} + + + + + ); diff --git a/components/Search.tsx b/components/Search.tsx new file mode 100644 index 0000000..59c1941 --- /dev/null +++ b/components/Search.tsx @@ -0,0 +1,15 @@ +import {View, Text} from 'react-native' +import React from 'react' +import {useLocalSearchParams, usePathname} from "expo-router"; + +const Search = () => { + const path = usePathname(); + const params = useLocalSearchParams<{query?: string}>(); + + return ( + + Search + + ) +} +export default Search diff --git a/lib/appwrite.ts b/lib/appwrite.ts index c4b4c7a..14a3440 100644 --- a/lib/appwrite.ts +++ b/lib/appwrite.ts @@ -71,12 +71,12 @@ export async function getCurrentUser() { } } -// export async function logOut(): Promise { -// try { -// await account.deleteSession(sessionId: 'current'); -// return true; -// } catch (error) { -// console.error("Failed to log out user:", error); -// return false; -// } -// } \ No newline at end of file +export async function logOut(): Promise { + try { + const result = await account.deleteSession('current'); + return result + } catch (error) { + console.error("Failed to log out user:", error); + return false; + } +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d01fdac..076e4b8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,7 +35,8 @@ "react-native-url-polyfill": "^2.0.0", "react-native-web": "~0.19.13", "react-native-webview": "13.12.5", - "tailwindcss": "^3.4.17" + "tailwindcss": "^3.4.17", + "use-debounce": "^10.0.4" }, "devDependencies": { "@babel/core": "^7.25.2", @@ -17370,6 +17371,18 @@ "requires-port": "^1.0.0" } }, + "node_modules/use-debounce": { + "version": "10.0.4", + "resolved": "https://registry.npmjs.org/use-debounce/-/use-debounce-10.0.4.tgz", + "integrity": "sha512-6Cf7Yr7Wk7Kdv77nnJMf6de4HuDE4dTxKij+RqE9rufDsI6zsbjyAxcH5y2ueJCQAnfgKbzXbZHYlkFwmBlWkw==", + "license": "MIT", + "engines": { + "node": ">= 16.0.0" + }, + "peerDependencies": { + "react": "*" + } + }, "node_modules/use-latest-callback": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/use-latest-callback/-/use-latest-callback-0.2.3.tgz", diff --git a/package.json b/package.json index a59b26c..fbe9d37 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "react-native-url-polyfill": "^2.0.0", "react-native-web": "~0.19.13", "react-native-webview": "13.12.5", - "tailwindcss": "^3.4.17" + "tailwindcss": "^3.4.17", + "use-debounce": "^10.0.4" }, "devDependencies": { "@babel/core": "^7.25.2",