From 391a1d4be3842abf692c922cb49e398888c6d514 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 24 Sep 2025 11:05:01 -0500 Subject: [PATCH] Checkpoint Layout.List --- src/components/Layout/index.tsx | 17 +++ src/components/List/index.tsx | 6 +- src/view/screens/StorybookLists/index.tsx | 123 +++++++--------------- 3 files changed, 59 insertions(+), 87 deletions(-) diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx index 5891ca863a..8aa189fc47 100644 --- a/src/components/Layout/index.tsx +++ b/src/components/Layout/index.tsx @@ -23,6 +23,11 @@ import { import {useDialogContext} from '#/components/Dialog' import {CENTER_COLUMN_OFFSET, SCROLLBAR_OFFSET} from '#/components/Layout/const' import {ScrollbarOffsetContext} from '#/components/Layout/context' +import { + List as BaseList, + type ListItem, + type ListProps, +} from '#/components/List' export * from '#/components/Layout/const' export * as Header from '#/components/Layout/Header' @@ -223,3 +228,15 @@ const WebCenterBorders = memo(function LayoutWebCenterBorders() { /> ) : null }) + +export function List(props: ListProps) { + return ( + + {...props} + renderItem={item => { + return
{props.renderItem!(item)}
+ }} + style={[a.h_full_vh, props.style]} + /> + ) +} diff --git a/src/components/List/index.tsx b/src/components/List/index.tsx index 803ca6be85..876bb0ea1d 100644 --- a/src/components/List/index.tsx +++ b/src/components/List/index.tsx @@ -27,7 +27,9 @@ export { export type ListRef = React.MutableRefObject | null> -type ListProps = Omit< +export type ListItem = {key: string} + +export type ListProps = Omit< FlatListProps, | 'onScroll' | 'onScrollBeginDrag' @@ -87,7 +89,7 @@ type ListProps = Omit< onScrolledDownChange?: (isScrolledDown: boolean) => void } -export const List = forwardRef(function List( +export const List = forwardRef(function List( {...props}: ListProps, ref: React.Ref>, ) { diff --git a/src/view/screens/StorybookLists/index.tsx b/src/view/screens/StorybookLists/index.tsx index fb12c7abc8..3a8ccaa0db 100644 --- a/src/view/screens/StorybookLists/index.tsx +++ b/src/view/screens/StorybookLists/index.tsx @@ -1,13 +1,9 @@ -import {useState} from 'react' import {View} from 'react-native' import {runOnJS} from 'react-native-reanimated' -import {ScrollProvider} from '#/lib/ScrollContext' -import {List as OldList} from '#/view/com/util/List' import {atoms as a, useTheme} from '#/alf' -import {Button, ButtonText} from '#/components/Button' import * as Layout from '#/components/Layout' -import {List, ListScrollProvider, useListScrollHandler} from '#/components/List' +import {ListScrollProvider, useListScrollHandler} from '#/components/List' import {Text} from '#/components/Typography' export function StorybookLists() { @@ -36,21 +32,8 @@ type Item = const log = (msg: any) => console.log(msg) -function Header() { - return ( - - - - Storybook - - - - ) -} - export function Inner() { const t = useTheme() - const [old, setOld] = useState(false) const onScrollWorklet = useListScrollHandler(e => { 'worklet' runOnJS(log)(`scroll ${e.contentOffset.y}`) @@ -74,73 +57,43 @@ export function Inner() { }) return ( - - - - + + + data={items} + stickyHeaderIndices={[1]} + renderItem={({item, index}) => { + if (item.type === 'header') { + return ( + + + + Storybook + + + + ) + } + if (item.type === 'spacer') { + return + } - {!old ? ( - - - data={items} - onScrolledDownChange={scrolledDown => { - console.log(`Scrolled down: ${scrolledDown}`) - }} - stickyHeaderIndices={[1]} - renderItem={({item, index}) => { - if (item.type === 'header') { - return
- } - if (item.type === 'spacer') { - return - } - - return ( - - - {item.title} - - - ) - }} - style={[a.h_full_vh]} - /> - - ) : ( - - item.key} - headerOffset={100} - onScrolledDownChange={scrolledDown => { - console.log(`Scrolled down: ${scrolledDown}`) - }} - renderItem={({item}) => ( - - {item.title} - - )} - style={[a.debug]} - desktopFixedHeight - /> - - )} - + return ( + + {item.title} + + ) + }} + onScrolledDownChange={scrolledDown => { + console.log(`Scrolled down: ${scrolledDown}`) + }} + /> + ) }