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 responsive-updates 138 lines 3.5 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(({model}: {model: SearchUIModel}) => { 22 const pal = usePalette('default') 23 const {isMobile} = useWebMediaQueries() 24 25 const renderTabBar = React.useCallback( 26 (props: RenderTabBarFnProps) => { 27 return ( 28 <CenteredView style={[pal.border, pal.view, styles.tabBar]}> 29 <TabBar 30 items={SECTIONS} 31 {...props} 32 key={SECTIONS.join()} 33 indicatorColor={pal.colors.link} 34 /> 35 </CenteredView> 36 ) 37 }, 38 [pal], 39 ) 40 41 return ( 42 <Pager renderTabBar={renderTabBar} tabBarPosition="top" initialPage={0}> 43 <View 44 style={{ 45 paddingTop: isMobile ? 42 : 50, 46 }}> 47 <PostResults key="0" model={model} /> 48 </View> 49 <View 50 style={{ 51 paddingTop: isMobile ? 42 : 50, 52 }}> 53 <Profiles key="1" model={model} /> 54 </View> 55 </Pager> 56 ) 57}) 58 59const PostResults = observer(({model}: {model: SearchUIModel}) => { 60 const pal = usePalette('default') 61 if (model.isPostsLoading) { 62 return ( 63 <CenteredView> 64 <PostFeedLoadingPlaceholder /> 65 </CenteredView> 66 ) 67 } 68 69 if (model.posts.length === 0) { 70 return ( 71 <CenteredView> 72 <Text type="xl" style={[styles.empty, pal.text]}> 73 No posts found for "{model.query}" 74 </Text> 75 </CenteredView> 76 ) 77 } 78 79 return ( 80 <ScrollView style={[pal.view]}> 81 {model.posts.map(post => ( 82 <Post key={post.resolvedUri} view={post} hideError /> 83 ))} 84 <View style={s.footerSpacer} /> 85 <View style={s.footerSpacer} /> 86 <View style={s.footerSpacer} /> 87 </ScrollView> 88 ) 89}) 90 91const Profiles = observer(({model}: {model: SearchUIModel}) => { 92 const pal = usePalette('default') 93 if (model.isProfilesLoading) { 94 return ( 95 <CenteredView> 96 <ProfileCardFeedLoadingPlaceholder /> 97 </CenteredView> 98 ) 99 } 100 101 if (model.profiles.length === 0) { 102 return ( 103 <CenteredView> 104 <Text type="xl" style={[styles.empty, pal.text]}> 105 No users found for "{model.query}" 106 </Text> 107 </CenteredView> 108 ) 109 } 110 111 return ( 112 <ScrollView style={pal.view}> 113 {model.profiles.map(item => ( 114 <ProfileCardWithFollowBtn key={item.did} profile={item} /> 115 ))} 116 <View style={s.footerSpacer} /> 117 <View style={s.footerSpacer} /> 118 <View style={s.footerSpacer} /> 119 </ScrollView> 120 ) 121}) 122 123const styles = StyleSheet.create({ 124 tabBar: { 125 borderBottomWidth: 1, 126 position: 'absolute', 127 zIndex: 1, 128 left: 0, 129 right: 0, 130 top: 0, 131 flexDirection: 'column', 132 alignItems: 'center', 133 }, 134 empty: { 135 paddingHorizontal: 14, 136 paddingVertical: 16, 137 }, 138})