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;
|
opened?: boolean;
|
||||||
unmountWhenCollapsed?: boolean;
|
unmountWhenCollapsed?: boolean;
|
||||||
enabled?: boolean;
|
enabled?: boolean;
|
||||||
children?: React.ReactNode;
|
renderItem: () => React.ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
function AnimatedAccordion(props: PropsType) {
|
function AnimatedAccordion(props: PropsType) {
|
||||||
|
@ -96,6 +96,8 @@ function AnimatedAccordion(props: PropsType) {
|
||||||
|
|
||||||
const toggleAccordion = () => setExpanded(!expanded);
|
const toggleAccordion = () => setExpanded(!expanded);
|
||||||
|
|
||||||
|
const renderChildren =
|
||||||
|
!props.unmountWhenCollapsed || (props.unmountWhenCollapsed && expanded);
|
||||||
return (
|
return (
|
||||||
<View style={props.style}>
|
<View style={props.style}>
|
||||||
<List.Item
|
<List.Item
|
||||||
|
@ -125,10 +127,7 @@ function AnimatedAccordion(props: PropsType) {
|
||||||
/>
|
/>
|
||||||
{enabled ? (
|
{enabled ? (
|
||||||
<Collapsible collapsed={!expanded}>
|
<Collapsible collapsed={!expanded}>
|
||||||
{!props.unmountWhenCollapsed ||
|
{renderChildren ? props.renderItem() : null}
|
||||||
(props.unmountWhenCollapsed && expanded)
|
|
||||||
? props.children
|
|
||||||
: null}
|
|
||||||
</Collapsible>
|
</Collapsible>
|
||||||
) : null}
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -94,13 +94,16 @@ function ClubListHeader(props: PropsType) {
|
||||||
icon="star"
|
icon="star"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
opened
|
opened={true}
|
||||||
>
|
renderItem={() => (
|
||||||
|
<View>
|
||||||
<Text style={styles.text}>
|
<Text style={styles.text}>
|
||||||
{i18n.t('screens.clubs.categoriesFilterMessage')}
|
{i18n.t('screens.clubs.categoriesFilterMessage')}
|
||||||
</Text>
|
</Text>
|
||||||
<View style={styles.chipContainer}>{getCategoriesRender()}</View>
|
<View style={styles.chipContainer}>{getCategoriesRender()}</View>
|
||||||
</AnimatedAccordion>
|
</View>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ function DashboardEditAccordion(props: PropsType) {
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
renderItem={() => (
|
||||||
<FlatList
|
<FlatList
|
||||||
data={item.content}
|
data={item.content}
|
||||||
extraData={props.activeDashboard.toString()}
|
extraData={props.activeDashboard.toString()}
|
||||||
|
@ -92,9 +92,10 @@ function DashboardEditAccordion(props: PropsType) {
|
||||||
listKey={item.key}
|
listKey={item.key}
|
||||||
// Performance props, see https://reactnative.dev/docs/optimizing-flatlist-configuration
|
// Performance props, see https://reactnative.dev/docs/optimizing-flatlist-configuration
|
||||||
getItemLayout={getItemLayout}
|
getItemLayout={getItemLayout}
|
||||||
removeClippedSubviews
|
removeClippedSubviews={true}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
</AnimatedAccordion>
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ function GroupListAccordion(props: PropsType) {
|
||||||
(isFavorite && !isEmptyFavorite)
|
(isFavorite && !isEmptyFavorite)
|
||||||
}
|
}
|
||||||
enabled={!isEmptyFavorite}
|
enabled={!isEmptyFavorite}
|
||||||
>
|
renderItem={() => (
|
||||||
<FlatList
|
<FlatList
|
||||||
data={props.item.content}
|
data={props.item.content}
|
||||||
extraData={props.currentSearchString + props.favorites.length}
|
extraData={props.currentSearchString + props.favorites.length}
|
||||||
|
@ -116,7 +116,8 @@ function GroupListAccordion(props: PropsType) {
|
||||||
getItemLayout={itemLayout}
|
getItemLayout={itemLayout}
|
||||||
removeClippedSubviews={true}
|
removeClippedSubviews={true}
|
||||||
/>
|
/>
|
||||||
</AnimatedAccordion>
|
)}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue