Update Storybook ListContained to use new List
This commit is contained in:
@@ -1,19 +1,18 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {View} from 'react-native'
|
import {type FlatList, View} from 'react-native'
|
||||||
|
|
||||||
import {ScrollProvider} from '#/lib/ScrollContext'
|
|
||||||
import {List, type ListMethods} from '#/view/com/util/List'
|
|
||||||
import {Button, ButtonText} from '#/components/Button'
|
import {Button, ButtonText} from '#/components/Button'
|
||||||
import * as Toggle from '#/components/forms/Toggle'
|
import * as Toggle from '#/components/forms/Toggle'
|
||||||
|
import {List, ListScrollProvider} from '#/components/List'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
|
||||||
export function ListContained() {
|
export function ListContained() {
|
||||||
const [animated, setAnimated] = React.useState(false)
|
const [animated, setAnimated] = React.useState(false)
|
||||||
const ref = React.useRef<ListMethods>(null)
|
const ref = React.useRef<FlatList>(null)
|
||||||
|
|
||||||
const data = React.useMemo(() => {
|
const data = React.useMemo(() => {
|
||||||
return Array.from({length: 100}, (_, i) => ({
|
return Array.from({length: 100}, (_, i) => ({
|
||||||
id: i,
|
key: i + '',
|
||||||
text: `Message ${i}`,
|
text: `Message ${i}`,
|
||||||
}))
|
}))
|
||||||
}, [])
|
}, [])
|
||||||
@@ -21,7 +20,7 @@ export function ListContained() {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<View style={{width: '100%', height: 300}}>
|
<View style={{width: '100%', height: 300}}>
|
||||||
<ScrollProvider
|
<ListScrollProvider
|
||||||
onScroll={e => {
|
onScroll={e => {
|
||||||
'worklet'
|
'worklet'
|
||||||
console.log(
|
console.log(
|
||||||
@@ -33,6 +32,7 @@ export function ListContained() {
|
|||||||
)
|
)
|
||||||
}}>
|
}}>
|
||||||
<List
|
<List
|
||||||
|
ref={ref}
|
||||||
data={data}
|
data={data}
|
||||||
renderItem={item => {
|
renderItem={item => {
|
||||||
return (
|
return (
|
||||||
@@ -46,8 +46,8 @@ export function ListContained() {
|
|||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
keyExtractor={item => item.id.toString()}
|
keyExtractor={item => item.key.toString()}
|
||||||
disableFullWindowScroll={true}
|
// disableFullWindowScroll={true}
|
||||||
style={{flex: 1}}
|
style={{flex: 1}}
|
||||||
onStartReached={() => {
|
onStartReached={() => {
|
||||||
console.log('Start Reached')
|
console.log('Start Reached')
|
||||||
@@ -56,10 +56,9 @@ export function ListContained() {
|
|||||||
console.log('End Reached (threshold of 2)')
|
console.log('End Reached (threshold of 2)')
|
||||||
}}
|
}}
|
||||||
onEndReachedThreshold={2}
|
onEndReachedThreshold={2}
|
||||||
ref={ref}
|
|
||||||
disableVirtualization={true}
|
disableVirtualization={true}
|
||||||
/>
|
/>
|
||||||
</ScrollProvider>
|
</ListScrollProvider>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={{flexDirection: 'row', gap: 10, alignItems: 'center'}}>
|
<View style={{flexDirection: 'row', gap: 10, alignItems: 'center'}}>
|
||||||
|
|||||||
Reference in New Issue
Block a user