minor reorg/cleanup

This commit is contained in:
austinried
2022-04-28 15:41:45 +09:00
parent 2bf3e8853d
commit 27754bd3c3
29 changed files with 403 additions and 386 deletions

View File

@@ -4,18 +4,18 @@ import colors from '@app/styles/colors'
import GradientBackground, { GradientBackgroundProps } from '@app/components/GradientBackground'
import { useLayout } from '@react-native-community/hooks'
import NothingHere from './NothingHere'
import ImageGradientBackground, { ImageGradientBackgroundProps } from './ImageGradientBackground'
import GradientImageBackground, { GradientImageBackgroundProps } from './GradientImageBackground'
export type BackgroundHeaderFlatListPropsBase<ItemT> = FlatListProps<ItemT> & {
export type GradientBackgroundHeaderFlatListPropsBase<ItemT> = FlatListProps<ItemT> & {
contentMarginTop?: number
}
export type BackgroundHeaderFlatListProp<ItemT> = BackgroundHeaderFlatListPropsBase<ItemT> & {
BackgroundComponent: typeof ImageGradientBackground | typeof GradientBackground
backgroundProps?: ImageGradientBackgroundProps | GradientBackgroundProps
export type GradientBackgroundHeaderFlatListProp<ItemT> = GradientBackgroundHeaderFlatListPropsBase<ItemT> & {
BackgroundComponent: typeof GradientImageBackground | typeof GradientBackground
backgroundProps?: GradientImageBackgroundProps | GradientBackgroundProps
}
function BackgroundHeaderFlatList<ItemT>(props: BackgroundHeaderFlatListProp<ItemT>) {
function GradientBackgroundHeaderFlatList<ItemT>(props: GradientBackgroundHeaderFlatListProp<ItemT>) {
const window = useWindowDimensions()
const headerLayout = useLayout()
@@ -51,4 +51,4 @@ const styles = StyleSheet.create({
},
})
export default BackgroundHeaderFlatList
export default GradientBackgroundHeaderFlatList

View File

@@ -1,13 +1,15 @@
import GradientBackground, { GradientBackgroundProps } from '@app/components/GradientBackground'
import React from 'react'
import BackgroundHeaderFlatList, { BackgroundHeaderFlatListPropsBase } from './BackgroundHeaderFlatList'
import GradientBackgroundHeaderFlatList, {
GradientBackgroundHeaderFlatListPropsBase,
} from './GradientBackgroundHeaderFlatList'
export type GradientFlatListProps<ItemT> = BackgroundHeaderFlatListPropsBase<ItemT> & {
export type GradientFlatListProps<ItemT> = GradientBackgroundHeaderFlatListPropsBase<ItemT> & {
backgroundProps?: GradientBackgroundProps
}
function GradientFlatList<ItemT>(props: GradientFlatListProps<ItemT>) {
return <BackgroundHeaderFlatList BackgroundComponent={GradientBackground} {...props} />
return <GradientBackgroundHeaderFlatList BackgroundComponent={GradientBackground} {...props} />
}
export default GradientFlatList

View File

@@ -5,12 +5,12 @@ import { AndroidImageColors } from 'react-native-image-colors/lib/typescript/typ
import colors from '@app/styles/colors'
import GradientBackground, { GradientBackgroundPropsBase } from '@app/components/GradientBackground'
export type ImageGradientBackgroundProps = GradientBackgroundPropsBase & {
export type GradientImageBackgroundProps = GradientBackgroundPropsBase & {
imagePath?: string
onGetColor?: (color: string) => void
}
const ImageGradientBackground: React.FC<ImageGradientBackgroundProps> = ({
const GradientImageBackground: React.FC<GradientImageBackgroundProps> = ({
height,
width,
position,
@@ -83,4 +83,4 @@ const ImageGradientBackground: React.FC<ImageGradientBackgroundProps> = ({
)
}
export default ImageGradientBackground
export default GradientImageBackground

View File

@@ -0,0 +1,15 @@
import React from 'react'
import GradientBackgroundHeaderFlatList, {
GradientBackgroundHeaderFlatListPropsBase,
} from './GradientBackgroundHeaderFlatList'
import GradientImageBackground, { GradientImageBackgroundProps } from './GradientImageBackground'
export type GradientImageFlatListProps<ItemT> = GradientBackgroundHeaderFlatListPropsBase<ItemT> & {
backgroundProps?: GradientImageBackgroundProps
}
function GradientImageFlatList<ItemT>(props: GradientImageFlatListProps<ItemT>) {
return <GradientBackgroundHeaderFlatList BackgroundComponent={GradientImageBackground} {...props} />
}
export default GradientImageFlatList

View File

@@ -1,11 +1,11 @@
import ImageGradientBackground, { ImageGradientBackgroundProps } from '@app/components/ImageGradientBackground'
import GradientImageBackground, { GradientImageBackgroundProps } from '@app/components/GradientImageBackground'
import colors from '@app/styles/colors'
import dimensions from '@app/styles/dimensions'
import React from 'react'
import { ScrollView, ScrollViewProps, useWindowDimensions } from 'react-native'
import { useSafeAreaInsets } from 'react-native-safe-area-context'
const ImageGradientScrollView: React.FC<ScrollViewProps & ImageGradientBackgroundProps> = props => {
const GradientImageScrollView: React.FC<ScrollViewProps & GradientImageBackgroundProps> = props => {
const layout = useWindowDimensions()
const paddingTop = useSafeAreaInsets().top
@@ -22,10 +22,10 @@ const ImageGradientScrollView: React.FC<ScrollViewProps & ImageGradientBackgroun
},
]}
contentContainerStyle={[{ minHeight }, props.contentContainerStyle]}>
<ImageGradientBackground height={minHeight} imagePath={props.imagePath} onGetColor={props.onGetColor} />
<GradientImageBackground height={minHeight} imagePath={props.imagePath} onGetColor={props.onGetColor} />
{props.children}
</ScrollView>
)
}
export default ImageGradientScrollView
export default GradientImageScrollView

View File

@@ -1,13 +0,0 @@
import React from 'react'
import BackgroundHeaderFlatList, { BackgroundHeaderFlatListPropsBase } from './BackgroundHeaderFlatList'
import ImageGradientBackground, { ImageGradientBackgroundProps } from './ImageGradientBackground'
export type ImageGradientFlatListProps<ItemT> = BackgroundHeaderFlatListPropsBase<ItemT> & {
backgroundProps?: ImageGradientBackgroundProps
}
function ImageGradientFlatList<ItemT>(props: ImageGradientFlatListProps<ItemT>) {
return <BackgroundHeaderFlatList BackgroundComponent={ImageGradientBackground} {...props} />
}
export default ImageGradientFlatList