Song Card: Rework Layout for responsivity

This commit is contained in:
Arthur Jamet
2023-03-20 09:28:36 +00:00
committed by Clément Le Bihan
parent d5b15cee13
commit 3ca2bdaa90
3 changed files with 18 additions and 24 deletions
+4 -7
View File
@@ -2,23 +2,20 @@ import React from 'react';
import SongCard from './SongCard';
import { FlatGrid } from 'react-native-super-grid';
import { Heading, VStack } from 'native-base';
import { RequireExactlyOne } from 'type-fest';
type SongCardGrid = {
songs: Parameters<typeof SongCard>[0][];
heading?: JSX.Element,
} & RequireExactlyOne<{
maxItemsPerRow: number,
itemDimension: number,
}>
maxItemsPerRow?: number,
style?: Parameters<typeof FlatGrid>[0]['additionalRowStyle']
}
const SongCardGrid = (props: SongCardGrid) => {
return <VStack space={5}>
<Heading>{props.heading}</Heading>
<FlatGrid
maxItemsPerRow={props.maxItemsPerRow}
itemDimension={props.itemDimension ?? (props.maxItemsPerRow ? undefined : 150)}
additionalRowStyle={{ justifyContent: 'flex-start' }}
additionalRowStyle={props.style ?? { justifyContent: 'flex-start' }}
data={props.songs}
renderItem={({ item }) => <SongCard {...item} /> }
spacing={10}