mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at profile-init 150 lines 3.6 kB view raw
1import React from 'react' 2import {StyleSheet, View} from 'react-native' 3import {observer} from 'mobx-react-lite' 4import {SearchUIModel} from 'state/models/ui/search' 5import {CenteredView, ScrollView} from '../util/Views' 6import {Pager, RenderTabBarFnProps} from 'view/com/pager/Pager' 7import {TabBar} from 'view/com/pager/TabBar' 8import {Post} from 'view/com/post/Post' 9import {ProfileCardWithFollowBtn} from 'view/com/profile/ProfileCard' 10import { 11 PostFeedLoadingPlaceholder, 12 ProfileCardFeedLoadingPlaceholder, 13} from 'view/com/util/LoadingPlaceholder' 14import {Text} from 'view/com/util/text/Text' 15import {usePalette} from 'lib/hooks/usePalette' 16import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' 17import {s} from 'lib/styles' 18 19const SECTIONS = ['Posts', 'Users'] 20 21export const SearchResults = observer(function SearchResultsImpl({ 22 model, 23}: { 24 model: SearchUIModel 25}) { 26 const pal = usePalette('default') 27 const {isMobile} = useWebMediaQueries() 28 29 const renderTabBar = React.useCallback( 30 (props: RenderTabBarFnProps) => { 31 return ( 32 <CenteredView style={[pal.border, pal.view, styles.tabBar]}> 33 <TabBar 34 items={SECTIONS} 35 {...props} 36 key={SECTIONS.join()} 37 indicatorColor={pal.colors.link} 38 /> 39 </CenteredView> 40 ) 41 }, 42 [pal], 43 ) 44 45 return ( 46 <Pager renderTabBar={renderTabBar} tabBarPosition="top" initialPage={0}> 47 <View 48 style={{ 49 paddingTop: isMobile ? 42 : 50, 50 }}> 51 <PostResults key="0" model={model} /> 52 </View> 53 <View 54 style={{ 55 paddingTop: isMobile ? 42 : 50, 56 }}> 57 <Profiles key="1" model={model} /> 58 </View> 59 </Pager> 60 ) 61}) 62 63const PostResults = observer(function PostResultsImpl({ 64 model, 65}: { 66 model: SearchUIModel 67}) { 68 const pal = usePalette('default') 69 if (model.isPostsLoading) { 70 return ( 71 <CenteredView> 72 <PostFeedLoadingPlaceholder /> 73 </CenteredView> 74 ) 75 } 76 77 if (model.posts.length === 0) { 78 return ( 79 <CenteredView> 80 <Text type="xl" style={[styles.empty, pal.text]}> 81 No posts found for "{model.query}" 82 </Text> 83 </CenteredView> 84 ) 85 } 86 87 return ( 88 <ScrollView style={[pal.view]}> 89 {model.posts.map(post => ( 90 <Post key={post.resolvedUri} view={post} hideError /> 91 ))} 92 <View style={s.footerSpacer} /> 93 <View style={s.footerSpacer} /> 94 <View style={s.footerSpacer} /> 95 </ScrollView> 96 ) 97}) 98 99const Profiles = observer(function ProfilesImpl({ 100 model, 101}: { 102 model: SearchUIModel 103}) { 104 const pal = usePalette('default') 105 if (model.isProfilesLoading) { 106 return ( 107 <CenteredView> 108 <ProfileCardFeedLoadingPlaceholder /> 109 </CenteredView> 110 ) 111 } 112 113 if (model.profiles.length === 0) { 114 return ( 115 <CenteredView> 116 <Text type="xl" style={[styles.empty, pal.text]}> 117 No users found for "{model.query}" 118 </Text> 119 </CenteredView> 120 ) 121 } 122 123 return ( 124 <ScrollView style={pal.view}> 125 {model.profiles.map(item => ( 126 <ProfileCardWithFollowBtn key={item.did} profile={item} /> 127 ))} 128 <View style={s.footerSpacer} /> 129 <View style={s.footerSpacer} /> 130 <View style={s.footerSpacer} /> 131 </ScrollView> 132 ) 133}) 134 135const styles = StyleSheet.create({ 136 tabBar: { 137 borderBottomWidth: 1, 138 position: 'absolute', 139 zIndex: 1, 140 left: 0, 141 right: 0, 142 top: 0, 143 flexDirection: 'column', 144 alignItems: 'center', 145 }, 146 empty: { 147 paddingHorizontal: 14, 148 paddingVertical: 16, 149 }, 150})