From ad15fa068775a13f8ee8a59ac7c15cc4b4412618 Mon Sep 17 00:00:00 2001 From: Hailey Date: Sun, 5 May 2024 04:18:07 -0700 Subject: [PATCH] add a contained list to storybook --- src/view/com/posts/Feed.tsx | 57 ++++--- src/view/screens/Storybook/ListContained.tsx | 52 ++++++ src/view/screens/Storybook/index.tsx | 164 +++++++++++-------- 3 files changed, 182 insertions(+), 91 deletions(-) create mode 100644 src/view/screens/Storybook/ListContained.tsx diff --git a/src/view/com/posts/Feed.tsx b/src/view/com/posts/Feed.tsx index fb67d35c5c..304200d4f3 100644 --- a/src/view/com/posts/Feed.tsx +++ b/src/view/com/posts/Feed.tsx @@ -28,6 +28,7 @@ import { import {useSession} from '#/state/session' import {useAnalytics} from 'lib/analytics/analytics' import {useInitialNumToRender} from 'lib/hooks/useInitialNumToRender' +import {ScrollProvider} from 'lib/ScrollContext' import {useTheme} from 'lib/ThemeContext' import {List, ListRef} from '../util/List' import {PostFeedLoadingPlaceholder} from '../util/LoadingPlaceholder' @@ -327,33 +328,35 @@ let Feed = ({ return ( - item._reactKey} - renderItem={renderItem} - ListFooterComponent={FeedFooter} - ListHeaderComponent={ListHeaderComponent} - refreshing={isPTRing} - onRefresh={onRefresh} - headerOffset={headerOffset} - contentContainerStyle={{ - minHeight: Dimensions.get('window').height * 1.5, - }} - onScrolledDownChange={onScrolledDownChange} - indicatorStyle={theme.colorScheme === 'dark' ? 'white' : 'black'} - onEndReached={onEndReached} - onEndReachedThreshold={2} // number of posts left to trigger load more - removeClippedSubviews={true} - extraData={extraData} - // @ts-ignore our .web version only -prf - desktopFixedHeight={ - desktopFixedHeightOffset ? desktopFixedHeightOffset : true - } - initialNumToRender={initialNumToRender} - windowSize={11} - /> + + item._reactKey} + renderItem={renderItem} + ListFooterComponent={FeedFooter} + ListHeaderComponent={ListHeaderComponent} + refreshing={isPTRing} + onRefresh={onRefresh} + headerOffset={headerOffset} + contentContainerStyle={{ + minHeight: Dimensions.get('window').height * 1.5, + }} + onScrolledDownChange={onScrolledDownChange} + indicatorStyle={theme.colorScheme === 'dark' ? 'white' : 'black'} + onEndReached={onEndReached} + onEndReachedThreshold={2} // number of posts left to trigger load more + removeClippedSubviews={true} + extraData={extraData} + // @ts-ignore our .web version only -prf + desktopFixedHeight={ + desktopFixedHeightOffset ? desktopFixedHeightOffset : true + } + initialNumToRender={initialNumToRender} + windowSize={11} + /> + ) } diff --git a/src/view/screens/Storybook/ListContained.tsx b/src/view/screens/Storybook/ListContained.tsx new file mode 100644 index 0000000000..5e8ba98e18 --- /dev/null +++ b/src/view/screens/Storybook/ListContained.tsx @@ -0,0 +1,52 @@ +import React from 'react' +import {View} from 'react-native' + +import {ScrollProvider} from 'lib/ScrollContext' +import {List} from 'view/com/util/List' +import {Text} from '#/components/Typography' + +// 100 random messages + +export function ListContained() { + const data = React.useMemo(() => { + return Array.from({length: 100}, (_, i) => ({ + id: i, + text: `Message ${i}`, + })) + }, []) + + return ( + + { + console.log('onScroll') + }}> + { + return ( + + {item.item.text} + + ) + }} + keyExtractor={item => item.id.toString()} + containWeb={true} + style={{flex: 1}} + onStartReached={() => { + console.log('Start Reached') + }} + onEndReached={() => { + console.log('End Reached (threshold of 2)') + }} + onEndReachedThreshold={2} + /> + + + ) +} diff --git a/src/view/screens/Storybook/index.tsx b/src/view/screens/Storybook/index.tsx index 35a6666016..282b3ff5c7 100644 --- a/src/view/screens/Storybook/index.tsx +++ b/src/view/screens/Storybook/index.tsx @@ -1,8 +1,10 @@ import React from 'react' -import {View} from 'react-native' +import {ScrollView, View} from 'react-native' import {useSetThemePrefs} from '#/state/shell' -import {CenteredView, ScrollView} from '#/view/com/util/Views' +import {isWeb} from 'platform/detection' +import {CenteredView} from '#/view/com/util/Views' +import {ListContained} from 'view/screens/Storybook/ListContained' import {atoms as a, ThemeProvider, useTheme} from '#/alf' import {Button, ButtonText} from '#/components/Button' import {Breakpoints} from './Breakpoints' @@ -18,77 +20,111 @@ import {Theming} from './Theming' import {Typography} from './Typography' export function Storybook() { + if (isWeb) return + + return ( + + + + ) +} + +function StorybookInner() { const t = useTheme() const {setColorMode, setDarkTheme} = useSetThemePrefs() + const [showContainedList, setShowContainedList] = React.useState(false) return ( - - - - - - + + + {!showContainedList ? ( + <> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ) : ( + <> - - - - - - - - - - - - - - - - - - - - - - - - - - + + + )} + + ) }