From 63a41f6c9a5e7aa0a8e8fe34cbb798a95259c780 Mon Sep 17 00:00:00 2001 From: Akshay Thakur <78326649+akshaynthakur@users.noreply.github.com> Date: Mon, 13 Nov 2023 23:43:51 -0800 Subject: [PATCH] [home] Implement backend queries & restyle StoryPreview component (#34) * done restyling home screen * cleanup, add author profile pics * updated queries for schema change to jsonb type * pr review changes * fix user not being set from saved session, add onPress functions --- assets/icons.tsx | 2 + src/app/(tabs)/home/index.tsx | 231 +++++++++++------- src/app/(tabs)/home/styles.ts | 34 +-- src/app/(tabs)/search/index.tsx | 6 +- src/app/settings.tsx | 2 +- src/components/ContentCard/ContentCard.tsx | 2 +- src/components/ContentCard/styles.ts | 4 +- src/components/PreviewCard/PreviewCard.tsx | 73 ++++++ .../{SearchCard => PreviewCard}/styles.ts | 61 +++-- src/components/SearchCard/SearchCard.tsx | 51 ---- src/queries/profiles.tsx | 17 ++ src/queries/stories.tsx | 56 ++++- src/queries/types.tsx | 7 + src/styles/colors.ts | 8 +- src/styles/globalStyles.ts | 25 +- src/utils/AuthContext.tsx | 1 + 16 files changed, 390 insertions(+), 190 deletions(-) create mode 100644 src/components/PreviewCard/PreviewCard.tsx rename src/components/{SearchCard => PreviewCard}/styles.ts (54%) delete mode 100644 src/components/SearchCard/SearchCard.tsx create mode 100644 src/queries/profiles.tsx diff --git a/assets/icons.tsx b/assets/icons.tsx index 03a92b5f..7a5ed2ea 100644 --- a/assets/icons.tsx +++ b/assets/icons.tsx @@ -6,12 +6,14 @@ export type IconType = | 'home_outline' | 'document_outline' | 'search_outline' + | 'settings_gear' | 'close_modal_button'; const IconSvgs: Record = { home_outline: , search_outline: , document_outline: , + settings_gear: , close_modal_button: ( ([]); + const [featuredStoriesDescription, setFeaturedStoriesDescription] = + useState(''); + const [recommendedStories, setRecommendedStories] = useState([]); + const [newStories, setNewStories] = useState([]); + + useEffect(() => { + (async () => { + const [ + usernameResponse, + featuredStoryResponse, + featuredStoryDescriptionResponse, + recommendedStoriesResponse, + newStoriesResponse, + ] = await Promise.all([ + fetchUsername(user?.id).catch(() => ''), + fetchFeaturedStoryPreviews().catch(() => []), + fetchFeaturedStoriesDescription().catch(() => ''), + fetchRecommendedStories().catch(() => []), + fetchNewStories().catch(() => []), + ]); + setUsername(usernameResponse); + setFeaturedStories(featuredStoryResponse); + setFeaturedStoriesDescription(featuredStoryDescriptionResponse); + setRecommendedStories(recommendedStoriesResponse); + setNewStories(newStoriesResponse); + })().finally(() => { + setLoading(false); + }); + }, [user]); return ( - + + {loading && ( + + Loading + + )} - Welcome, Brenda - -