forked from vergnet/application-amicale
Move accordion children in prop
This commit is contained in:
parent
52651ecf85
commit
a1cfb0385a
4 changed files with 39 additions and 35 deletions
|
@ -38,7 +38,7 @@ type PropsType = {
|
|||
opened?: boolean;
|
||||
unmountWhenCollapsed?: boolean;
|
||||
enabled?: boolean;
|
||||
children?: React.ReactNode;
|
||||
renderItem: () => React.ReactNode;
|
||||
};
|
||||
|
||||
function AnimatedAccordion(props: PropsType) {
|
||||
|
@ -96,6 +96,8 @@ function AnimatedAccordion(props: PropsType) {
|
|||
|
||||
const toggleAccordion = () => setExpanded(!expanded);
|
||||
|
||||
const renderChildren =
|
||||
!props.unmountWhenCollapsed || (props.unmountWhenCollapsed && expanded);
|
||||
return (
|
||||
<View style={props.style}>
|
||||
<List.Item
|
||||
|
@ -125,10 +127,7 @@ function AnimatedAccordion(props: PropsType) {
|
|||
/>
|
||||
{enabled ? (
|
||||
<Collapsible collapsed={!expanded}>
|
||||
{!props.unmountWhenCollapsed ||
|
||||
(props.unmountWhenCollapsed && expanded)
|
||||
? props.children
|
||||
: null}
|
||||
{renderChildren ? props.renderItem() : null}
|
||||
</Collapsible>
|
||||
) : null}
|
||||
</View>
|
||||
|
|
|
@ -94,13 +94,16 @@ function ClubListHeader(props: PropsType) {
|
|||
icon="star"
|
||||
/>
|
||||
)}
|
||||
opened
|
||||
>
|
||||
<Text style={styles.text}>
|
||||
{i18n.t('screens.clubs.categoriesFilterMessage')}
|
||||
</Text>
|
||||
<View style={styles.chipContainer}>{getCategoriesRender()}</View>
|
||||
</AnimatedAccordion>
|
||||
opened={true}
|
||||
renderItem={() => (
|
||||
<View>
|
||||
<Text style={styles.text}>
|
||||
{i18n.t('screens.clubs.categoriesFilterMessage')}
|
||||
</Text>
|
||||
<View style={styles.chipContainer}>{getCategoriesRender()}</View>
|
||||
</View>
|
||||
)}
|
||||
/>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -84,17 +84,18 @@ function DashboardEditAccordion(props: PropsType) {
|
|||
/>
|
||||
)
|
||||
}
|
||||
>
|
||||
<FlatList
|
||||
data={item.content}
|
||||
extraData={props.activeDashboard.toString()}
|
||||
renderItem={getRenderItem}
|
||||
listKey={item.key}
|
||||
// Performance props, see https://reactnative.dev/docs/optimizing-flatlist-configuration
|
||||
getItemLayout={getItemLayout}
|
||||
removeClippedSubviews
|
||||
/>
|
||||
</AnimatedAccordion>
|
||||
renderItem={() => (
|
||||
<FlatList
|
||||
data={item.content}
|
||||
extraData={props.activeDashboard.toString()}
|
||||
renderItem={getRenderItem}
|
||||
listKey={item.key}
|
||||
// Performance props, see https://reactnative.dev/docs/optimizing-flatlist-configuration
|
||||
getItemLayout={getItemLayout}
|
||||
removeClippedSubviews={true}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -105,18 +105,19 @@ function GroupListAccordion(props: PropsType) {
|
|||
(isFavorite && !isEmptyFavorite)
|
||||
}
|
||||
enabled={!isEmptyFavorite}
|
||||
>
|
||||
<FlatList
|
||||
data={props.item.content}
|
||||
extraData={props.currentSearchString + props.favorites.length}
|
||||
renderItem={getRenderItem}
|
||||
keyExtractor={keyExtractor}
|
||||
listKey={props.item.id.toString()}
|
||||
// Performance props, see https://reactnative.dev/docs/optimizing-flatlist-configuration
|
||||
getItemLayout={itemLayout}
|
||||
removeClippedSubviews={true}
|
||||
/>
|
||||
</AnimatedAccordion>
|
||||
renderItem={() => (
|
||||
<FlatList
|
||||
data={props.item.content}
|
||||
extraData={props.currentSearchString + props.favorites.length}
|
||||
renderItem={getRenderItem}
|
||||
keyExtractor={keyExtractor}
|
||||
listKey={props.item.id.toString()}
|
||||
// Performance props, see https://reactnative.dev/docs/optimizing-flatlist-configuration
|
||||
getItemLayout={itemLayout}
|
||||
removeClippedSubviews={true}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue