add horizontal margin to the generic list component
This commit is contained in:
@@ -1,11 +1,13 @@
|
|||||||
import React, {memo} from 'react'
|
import React, {memo} from 'react'
|
||||||
import {FlatListProps, RefreshControl} from 'react-native'
|
import {FlatListProps, RefreshControl, useWindowDimensions} from 'react-native'
|
||||||
import {FlatList_INTERNAL} from './Views'
|
|
||||||
import {addStyle} from 'lib/styles'
|
|
||||||
import {useScrollHandlers} from '#/lib/ScrollContext'
|
|
||||||
import {runOnJS, useSharedValue} from 'react-native-reanimated'
|
import {runOnJS, useSharedValue} from 'react-native-reanimated'
|
||||||
|
|
||||||
import {useAnimatedScrollHandler} from '#/lib/hooks/useAnimatedScrollHandler_FIXED'
|
import {useAnimatedScrollHandler} from '#/lib/hooks/useAnimatedScrollHandler_FIXED'
|
||||||
import {usePalette} from '#/lib/hooks/usePalette'
|
import {usePalette} from '#/lib/hooks/usePalette'
|
||||||
|
import {useScrollHandlers} from '#/lib/ScrollContext'
|
||||||
|
import {isNativeTablet} from '#/platform/detection'
|
||||||
|
import {addStyle} from 'lib/styles'
|
||||||
|
import {FlatList_INTERNAL} from './Views'
|
||||||
|
|
||||||
export type ListMethods = FlatList_INTERNAL
|
export type ListMethods = FlatList_INTERNAL
|
||||||
export type ListProps<ItemT> = Omit<
|
export type ListProps<ItemT> = Omit<
|
||||||
@@ -37,6 +39,7 @@ function ListImpl<ItemT>(
|
|||||||
const isScrolledDown = useSharedValue(false)
|
const isScrolledDown = useSharedValue(false)
|
||||||
const contextScrollHandlers = useScrollHandlers()
|
const contextScrollHandlers = useScrollHandlers()
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
|
const {width} = useWindowDimensions()
|
||||||
|
|
||||||
function handleScrolledDownChange(didScrollDown: boolean) {
|
function handleScrolledDownChange(didScrollDown: boolean) {
|
||||||
onScrolledDownChange?.(didScrollDown)
|
onScrolledDownChange?.(didScrollDown)
|
||||||
@@ -91,6 +94,17 @@ function ListImpl<ItemT>(
|
|||||||
refreshControl={refreshControl}
|
refreshControl={refreshControl}
|
||||||
onScroll={scrollHandler}
|
onScroll={scrollHandler}
|
||||||
scrollEventThrottle={1}
|
scrollEventThrottle={1}
|
||||||
|
contentContainerStyle={
|
||||||
|
isNativeTablet && [
|
||||||
|
{
|
||||||
|
marginLeft: (width - 600) / 2 - 77,
|
||||||
|
marginRight: (width - 600) / 2,
|
||||||
|
borderLeftWidth: 1,
|
||||||
|
borderRightWidth: 1,
|
||||||
|
},
|
||||||
|
pal.border,
|
||||||
|
]
|
||||||
|
}
|
||||||
style={style}
|
style={style}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user