Bluesky app fork with some witchin' additions 馃挮
0
fork

Configure Feed

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

at 967b3b49d9b0bdbe9c8fd7ea802ecf780b9e1a0c 70 lines 2.0 kB view raw
1import React, {useCallback} from 'react' 2import {type ListRenderItemInfo, View} from 'react-native' 3import {type AppBskyFeedDefs} from '@atproto/api' 4 5import {useBottomBarOffset} from '#/lib/hooks/useBottomBarOffset' 6import {List, type ListRef} from '#/view/com/util/List' 7import {type SectionRef} from '#/screens/Profile/Sections/types' 8import {atoms as a, useTheme} from '#/alf' 9import * as FeedCard from '#/components/FeedCard' 10import {IS_NATIVE, IS_WEB} from '#/env' 11 12function keyExtractor(item: AppBskyFeedDefs.GeneratorView) { 13 return item.uri 14} 15 16interface ProfilesListProps { 17 feeds: AppBskyFeedDefs.GeneratorView[] 18 headerHeight: number 19 scrollElRef: ListRef 20} 21 22export const FeedsList = React.forwardRef<SectionRef, ProfilesListProps>( 23 function FeedsListImpl({feeds, headerHeight, scrollElRef}, ref) { 24 const [initialHeaderHeight] = React.useState(headerHeight) 25 const bottomBarOffset = useBottomBarOffset(20) 26 const t = useTheme() 27 28 const onScrollToTop = useCallback(() => { 29 scrollElRef.current?.scrollToOffset({ 30 animated: IS_NATIVE, 31 offset: -headerHeight, 32 }) 33 }, [scrollElRef, headerHeight]) 34 35 React.useImperativeHandle(ref, () => ({ 36 scrollToTop: onScrollToTop, 37 })) 38 39 const renderItem = ({ 40 item, 41 index, 42 }: ListRenderItemInfo<AppBskyFeedDefs.GeneratorView>) => { 43 return ( 44 <View 45 style={[ 46 a.p_lg, 47 (IS_WEB || index !== 0) && a.border_t, 48 t.atoms.border_contrast_low, 49 ]}> 50 <FeedCard.Default view={item} /> 51 </View> 52 ) 53 } 54 55 return ( 56 <List 57 data={feeds} 58 renderItem={renderItem} 59 keyExtractor={keyExtractor} 60 ref={scrollElRef} 61 headerOffset={headerHeight} 62 ListFooterComponent={ 63 <View style={[{height: initialHeaderHeight + bottomBarOffset}]} /> 64 } 65 showsVerticalScrollIndicator={false} 66 desktopFixedHeight={true} 67 /> 68 ) 69 }, 70)