diff --git a/app/(tabs)/_layout.tsx b/app/(tabs)/_layout.tsx index 3c4359c..3e9277e 100644 --- a/app/(tabs)/_layout.tsx +++ b/app/(tabs)/_layout.tsx @@ -10,7 +10,7 @@ const TabLayout = () => { { const scheme = useColorScheme() ?? 'light'; - const [pushToken, setPushToken] = useState(null); + const [userData, setUserData] = useState(null); useEffect(() => { const fetchUserData = async () => { - const userData = await getUserData(); - if (userData) { - setPushToken(userData.pushToken); + try { + const data = await getUserData(); + setUserData(data); + } catch (error) { + console.error("Error fetching user data:", error); + Alert.alert("Error", "Failed to load user data"); } }; + fetchUserData(); }, []); - const sendPushNotification = async () => { - if (!pushToken) { - Alert.alert('Error', 'Push token not available'); - return; + const handleUpdateProfilePicture = async () => { + const permissionResult = await ImagePicker.requestMediaLibraryPermissionsAsync(); + + if (permissionResult.granted === false) { + Alert.alert("Permission Required", "You need to grant permission to access your photos"); + return; } - const message = { - to: pushToken, - sound: 'default', - title: 'Hey Baby!', - body: 'Are you ready for push notifications?!?', - data: { - someData: 'goes here' - }, - }; + const result = await ImagePicker.launchImageLibraryAsync({ + mediaTypes: ImagePicker.MediaTypeOptions.Images, + allowsEditing: true, + aspect: [1, 1], + quality: 1, + }); - try { - const response = await fetch(`https://exp.host/--/api/v2/push/send`, { - method: 'POST', - headers: { - Accept: 'application/json', - 'Accept-encoding': 'gzip, deflate', - 'Content-Type': 'application/json', - }, - body: JSON.stringify(message), - }); - - const result = await response.json(); - console.log('Result:', result); - Alert.alert('Success', 'Push notification sent successfully'); - - } catch (error) { - console.error('Error sending push notification:', error); - Alert.alert('Error', 'Failed to send push notification'); + if (!result.canceled) { + // Here you would typically upload the image to your server + // and update the user's profile picture URL + console.log("Selected image:", result.assets[0].uri); + // For now, let's just update the local state + setUserData(prevData => prevData ? {...prevData, pfpURL: result.assets[0].uri} : null); } }; return ( - - Home Screen - + {userData ? ( + + + + + {userData.fullName} + {userData.appleEmail} + + ) : ( + Loading user data... + )} - + {/* Add your relationship request button or other components here */} ); } + export default Index; const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', - justifyContent: 'center', }, - text: { + profileContainer: { + alignItems: 'center', + marginTop: 20, + marginBottom: 20, + }, + profilePicture: { + width: 100, + height: 100, + borderRadius: 50, + marginBottom: 10, + }, + name: { fontSize: 24, + fontWeight: 'bold', + marginBottom: 5, + }, + email: { + fontSize: 16, + marginBottom: 20, }, footerContainer: { flex: 1 / 3, alignItems: 'center', }, - buttonLabel: { - fontSize: 16, - }, - buttonIcon: { - paddingRight: 8, - }, }); diff --git a/app/(tabs)/messages.tsx b/app/(tabs)/messages.tsx index cc95d10..6c35b87 100644 --- a/app/(tabs)/messages.tsx +++ b/app/(tabs)/messages.tsx @@ -11,25 +11,19 @@ import { SystemMessage, } from 'react-native-gifted-chat' import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context' -import NavBar from '@/components/chat/NavBar' import AccessoryBar from '@/components/chat/AccessoryBar' import CustomActions from '@/components/chat/CustomActions' import CustomView from '@/components/chat/CustomView' import earlierMessages from '@/components/chat/data/earlierMessages' import messagesData from '@/components/chat/data/messages' import * as Clipboard from 'expo-clipboard' +//import NavBar from '@/components/chat/NavBar' const user = { _id: 1, name: 'Developer', } -// const otherUser = { -// _id: 2, -// name: 'React Native', -// avatar: 'https://facebook.github.io/react/img/logo_og.png', -// } - interface IState { messages: any[] step: number @@ -125,7 +119,7 @@ const App = () => { { pattern: /#(\w+)/, style: { textDecorationLine: 'underline', color: 'darkorange' }, - onPress: () => Linking.openURL('http://gifted.chat'), + onPress: () => Linking.openURL('https://gbrown.org'), }, ] }, []) @@ -264,7 +258,6 @@ const App = () => { return ( - { fontWeight: '200', }} renderQuickReplySend={renderQuickReplySend} - renderAccessory={renderAccessory} + //renderAccessory={renderAccessory} renderActions={renderCustomActions} renderSystemMessage={renderSystemMessage} renderCustomView={renderCustomView} @@ -315,6 +308,8 @@ const styles = StyleSheet.create({ fill: { flex: 1, }, + sendLine: { + } }) export default AppWrapper diff --git a/assets/images/default-profile.png b/assets/images/default-profile.png new file mode 100644 index 0000000..0f5b1ff Binary files /dev/null and b/assets/images/default-profile.png differ diff --git a/components/auth/SignInScreen.tsx b/components/auth/SignInScreen.tsx index 645a2f9..5812d66 100644 --- a/components/auth/SignInScreen.tsx +++ b/components/auth/SignInScreen.tsx @@ -7,13 +7,6 @@ import * as Notifications from 'expo-notifications'; import Constants from 'expo-constants'; import { saveUserData } from '@/components/services/securestorage/UserData'; -type UserData = { - appleId: string; - appleEmail: string; - fullName: string; - pushToken: string; -}; - export default function SignInScreen({ onSignIn }: { onSignIn: () => void }) { const scheme = useColorScheme() ?? 'light'; diff --git a/components/chat/CustomView.tsx b/components/chat/CustomView.tsx index 98a8e81..ec0bd7a 100644 --- a/components/chat/CustomView.tsx +++ b/components/chat/CustomView.tsx @@ -82,7 +82,8 @@ const CustomView = ({ export default CustomView const styles = StyleSheet.create({ - container: {}, + container: { + }, mapView: { width: 150, height: 100, diff --git a/components/home/TestPush.tsx b/components/home/TestPush.tsx new file mode 100644 index 0000000..0884e77 --- /dev/null +++ b/components/home/TestPush.tsx @@ -0,0 +1,89 @@ +import React, { useEffect, useState } from "react"; +import { StyleSheet, Alert } from "react-native"; +import { ThemedText } from "@/components/ThemedText"; +import { Colors } from '@/constants/Colors'; +import { useColorScheme } from '@/hooks/useColorScheme'; +import FontAwesome from "@expo/vector-icons/FontAwesome"; +import Button from "@/components/buttons/Button"; +import { getUserData } from "@/components/services/securestorage/UserData"; + +const TestPush = () => { + const scheme = useColorScheme() ?? 'light'; + const [pushToken, setPushToken] = useState(null); + + useEffect(() => { + const fetchUserData = async () => { + const userData = await getUserData(); + if (userData) { + setPushToken(userData.pushToken); + } + }; + fetchUserData(); + }, []); + + const sendPushNotification = async () => { + if (!pushToken) { + Alert.alert('Error', 'Push token not available'); + return; + } + + const message = { + to: pushToken, + sound: 'default', + title: 'Hey Baby!', + body: 'Are you ready for push notifications?!?', + data: { + someData: 'goes here' + }, + }; + + try { + const response = await fetch(`https://exp.host/--/api/v2/push/send`, { + method: 'POST', + headers: { + Accept: 'application/json', + 'Accept-encoding': 'gzip, deflate', + 'Content-Type': 'application/json', + }, + body: JSON.stringify(message), + }); + + const result = await response.json(); + console.log('Result:', result); + Alert.alert('Success', 'Push notification sent successfully'); + + } catch (error) { + console.error('Error sending push notification:', error); + Alert.alert('Error', 'Failed to send push notification'); + } + }; + + return ( + + ); + +}; +export default TestPush; + +const styles = StyleSheet.create({ + buttonLabel: { + fontSize: 16, + }, + buttonIcon: { + paddingRight: 8, + }, +}); diff --git a/components/services/securestorage/UserData.tsx b/components/services/securestorage/UserData.tsx index 6268a12..22ba941 100644 --- a/components/services/securestorage/UserData.tsx +++ b/components/services/securestorage/UserData.tsx @@ -1,12 +1,5 @@ import * as SecureStore from 'expo-secure-store'; -type UserData = { - appleId: string; - appleEmail: string; - fullName: string; - pushToken: string; -}; - export const saveUserData = async (userData: any) => { try { await SecureStore.setItemAsync('userData', JSON.stringify(userData));