Add profile view

This commit is contained in:
Paul Frazee 2022-07-21 19:55:04 -05:00
parent 29ed3d2ecf
commit cc8a170204
14 changed files with 319 additions and 27 deletions

View file

@ -34,6 +34,7 @@ export const PostThread = ({
// @ts-ignore it's up to the callers to supply correct params -prf
navigation.push(screen, props)
}
return (
<Shell>
<PostThreadComponent uri={uri} onNavigateContent={onNavigateContent} />

View file

@ -1,16 +1,43 @@
import React from 'react'
import React, {useState, useEffect} from 'react'
import {Shell} from '../../shell'
import {View, Text} from 'react-native'
import type {RootTabsScreenProps} from '../../routes/types'
import {FeedViewModel} from '../../../state/models/feed-view'
import {useStores} from '../../../state'
import {ProfileHeader} from '../../com/profile/ProfileHeader'
import {Feed} from '../../com/feed/Feed'
export const Profile = ({
navigation,
route,
}: RootTabsScreenProps<'Profile'>) => {
const store = useStores()
const [feedView, setFeedView] = useState<FeedViewModel | undefined>()
useEffect(() => {
if (feedView?.params.author === route.params.name) {
console.log('Profile feed view')
return // no change needed? or trigger refresh?
}
console.log('Fetching profile feed view', route.params.name)
const newFeedView = new FeedViewModel(store, {author: route.params.name})
setFeedView(newFeedView)
newFeedView.setup().catch(err => console.error('Failed to fetch feed', err))
}, [route.params.name, feedView?.params.author, store])
const onNavigateContent = (screen: string, props: Record<string, string>) => {
// @ts-ignore it's up to the callers to supply correct params -prf
navigation.push(screen, props)
}
export const Profile = ({route}: RootTabsScreenProps<'Profile'>) => {
return (
<Shell>
<View style={{justifyContent: 'center', alignItems: 'center'}}>
<Text style={{fontSize: 20, fontWeight: 'bold'}}>
{route.params?.name}'s profile
</Text>
</View>
<ProfileHeader
user={route.params.name}
onNavigateContent={onNavigateContent}
/>
{feedView && (
<Feed feed={feedView} onNavigateContent={onNavigateContent} />
)}
</Shell>
)
}