-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angeline assignment2 #2
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
EXPO_PUBLIC_SUPABASE_URL=https://vaimftgbjqbylduffpkw.supabase.co | ||
EXPO_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZhaW1mdGdianFieWxkdWZmcGt3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjgwMDM3NzMsImV4cCI6MjA0MzU3OTc3M30.7uvkyKie49rkNr-fG0E77PsdMreHvAmb9hmSOIdh2Sc |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,117 @@ | ||
import { Text, View } from 'react-native'; | ||
import React, { useEffect, useState } from 'react'; | ||
import { Image, Text, View } from 'react-native'; | ||
import supabase from 'supabase/client'; | ||
import HeartIcon from '../../assets/heart-icon.svg'; | ||
import ShareIcon from '../../assets/messenger-icon.svg'; | ||
import ProfilePlaceholder from '../../assets/profile-placeholder-icon.svg'; | ||
import { styles } from './styles'; | ||
|
||
export default function PostScreen() { | ||
interface Post { | ||
id: number; | ||
created_at: string; | ||
description: string; | ||
username: string; | ||
image_url: string; | ||
like_count: number; | ||
} | ||
|
||
const getPostData = async (): Promise<Post[]> => { | ||
const { data, error } = await supabase | ||
.from('posts') | ||
.select('*') | ||
.eq('username', 'rbeggs'); | ||
|
||
if (error) { | ||
throw new Error(`Error fetching post: ${error.message}`); | ||
} | ||
return data as Post[]; | ||
}; | ||
|
||
const [postData, setPostData] = useState<Post[]>([]); | ||
|
||
useEffect(() => { | ||
fetchPostData(); | ||
}, []); | ||
|
||
const fetchPostData = async () => { | ||
try { | ||
const data = await getPostData(); | ||
setPostData(data); | ||
} catch (error) { | ||
console.error('Error fetching data:', error); | ||
} | ||
}; | ||
Comment on lines
+37
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if you necessarily need a |
||
|
||
return ( | ||
<View style={styles.container}> | ||
<ProfilePlaceholder /> | ||
<Text>rbeggs</Text> | ||
<Text>September 19</Text> | ||
<Text> | ||
In response to the growing homelessness crisis in San Francisco, a local | ||
nonprofit organization, Code Tenderloin, has launched a comprehensive | ||
initiative aimed at providing long-term solutions for individuals | ||
experiencing homelessness. The organization, founded in 2015, is | ||
dedicated to addressing both immediate needs and underlying causes of | ||
homelessness through a combination of shelter services, job training | ||
programs, and mental health support. read more online: | ||
https://www.codetenderloin.org/ | ||
</Text> | ||
<Text> | ||
Image URL: | ||
'https://cdn.britannica.com/51/178051-050-3B786A55/San-Francisco.jpg' | ||
</Text> | ||
<HeartIcon /> | ||
<Text>256 Likes</Text> | ||
<ShareIcon /> | ||
<ProfilePlaceholder /> | ||
<Text>philip_ye</Text> | ||
<Text>September 20</Text> | ||
<Text> | ||
This organization is doing amazing work tackling the complex root causes | ||
of the issue. | ||
</Text> | ||
<ProfilePlaceholder /> | ||
<Text>vppraggie</Text> | ||
<Text>September 21</Text> | ||
<Text>Thanks for sharing!</Text> | ||
{postData.map(post => ( | ||
<View key={post.id}> | ||
{/* Profile Header */} | ||
<View style={styles.profileHeader}> | ||
<View style={{ flexDirection: 'row', alignItems: 'center' }}> | ||
<ProfilePlaceholder style={styles.profileIcon} /> | ||
<Text style={styles.profileName}>{post.username}</Text> | ||
</View> | ||
<Text style={styles.postDate}> | ||
{new Date(post.created_at).toLocaleDateString('en-US', { | ||
year: 'numeric', | ||
month: 'long', | ||
day: 'numeric', | ||
})} | ||
</Text> | ||
</View> | ||
|
||
{/* Post Text */} | ||
<View style={styles.postTextContainer}> | ||
<Text style={styles.postText}>{post.description}</Text> | ||
</View> | ||
|
||
{/* Post Image */} | ||
{post.image_url ? ( | ||
<Image source={{ uri: post.image_url }} style={styles.postImage} /> | ||
) : null} | ||
|
||
{/* Interaction Row */} | ||
<View style={styles.interactionRow}> | ||
<View style={{ flexDirection: 'row', alignItems: 'center' }}> | ||
<HeartIcon style={styles.icon} /> | ||
<Text style={styles.likesText}>{post.like_count} Likes</Text> | ||
</View> | ||
<ShareIcon style={styles.icon} /> | ||
</View> | ||
|
||
{/* Comment Section */} | ||
<View style={styles.commentSection}> | ||
{/* First Comment */} | ||
<View style={styles.comment}> | ||
<ProfilePlaceholder style={styles.commentIcon} /> | ||
<View style={styles.commentBody}> | ||
<View style={styles.commentHeader}> | ||
<Text style={styles.commentName}>philip_ye</Text> | ||
<Text style={styles.commentDate}>September 20</Text> | ||
</View> | ||
<Text style={styles.commentText}> | ||
This organization is doing amazing work tackling the complex | ||
root causes of the issue. | ||
</Text> | ||
</View> | ||
</View> | ||
Comment on lines
+85
to
+99
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that there are so many divs for each div, might be helpful to create a separate There's also a comments table that you can pull this data from! |
||
|
||
{/* Second Comment */} | ||
<View style={styles.comment}> | ||
<ProfilePlaceholder style={styles.commentIcon} /> | ||
<View style={styles.commentBody}> | ||
<View style={styles.commentHeader}> | ||
<Text style={styles.commentName}>vppraggie</Text> | ||
<Text style={styles.commentDate}>September 21</Text> | ||
</View> | ||
<Text style={styles.commentText}>Thanks for sharing!</Text> | ||
</View> | ||
</View> | ||
</View> | ||
</View> | ||
))} | ||
</View> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,103 @@ export const styles = StyleSheet.create({ | |
container: { | ||
flex: 1, | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
backgroundColor: 'white', | ||
padding: 10, | ||
}, | ||
profileHeader: { | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
marginBottom: 8, | ||
justifyContent: 'space-between', | ||
}, | ||
profileName: { | ||
fontWeight: 'bold', | ||
fontSize: 16, | ||
marginLeft: 8, | ||
}, | ||
postDate: { | ||
color: 'gray', | ||
paddingLeft: 120, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should be able to create an offset like this using |
||
}, | ||
postTextContainer: { | ||
marginBottom: 10, | ||
}, | ||
postText: { | ||
fontSize: 14, | ||
lineHeight: 20, | ||
}, | ||
inlineLink: { | ||
fontSize: 14, | ||
color: 'black', | ||
}, | ||
linkText: { | ||
color: '#1E90FF', | ||
textDecorationLine: 'underline', | ||
}, | ||
postImage: { | ||
width: '100%', | ||
height: 200, | ||
borderRadius: 10, | ||
marginVertical: 10, | ||
}, | ||
interactionRow: { | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
marginVertical: 10, | ||
width: '100%', | ||
}, | ||
icon: { | ||
marginRight: 8, | ||
}, | ||
likesText: { | ||
marginLeft: 5, | ||
}, | ||
commentSection: { | ||
borderTopWidth: 1, | ||
borderTopColor: '#ccc', | ||
paddingTop: 10, | ||
marginTop: 20, | ||
paddingRight: 10, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid asymmetric spacing attributes. See if you can achieve this styling using flexbox properties. |
||
}, | ||
commentIcon: { | ||
width: 30, | ||
height: 30, | ||
marginRight: 10, | ||
}, | ||
commentBody: { | ||
flex: 1, | ||
}, | ||
profileIcon: { | ||
width: 40, | ||
}, | ||
comment: { | ||
flexDirection: 'row', | ||
alignItems: 'flex-start', | ||
marginBottom: 10, | ||
paddingRight: 10, | ||
}, | ||
commentHeader: { | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
width: '100%', | ||
columnGap: 10, | ||
}, | ||
commentName: { | ||
fontWeight: 'bold', | ||
fontSize: 14, | ||
}, | ||
commentDate: { | ||
color: 'gray', | ||
paddingRight: 12, | ||
}, | ||
commentTextContainer: { | ||
marginTop: 4, | ||
}, | ||
commentText: { | ||
marginTop: 2, | ||
fontSize: 14, | ||
lineHeight: 18, | ||
}, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#supabase | ||
.env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure you don't commit
.env
files! Add.env
to you.gitignore
file.