Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/components/List/ListAccordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ type Props = {
* Callback which returns a React element to display on the left side.
*/
left?: (props: { color: string }) => React.ReactNode;
/**
* Callback which returns a React element to display on the right side.
*/
right?: (props: { isExpanded: boolean }) => React.ReactNode;
/**
* Whether the accordion is expanded
* If this prop is provided, the accordion will behave as a "controlled component".
Expand Down Expand Up @@ -127,6 +131,7 @@ type Props = {
*/
const ListAccordion = ({
left,
right,
title,
description,
children,
Expand Down Expand Up @@ -224,12 +229,18 @@ const ListAccordion = ({
<View
style={[styles.item, description ? styles.multiline : undefined]}
>
<MaterialCommunityIcon
name={isExpanded ? 'chevron-up' : 'chevron-down'}
color={titleColor}
size={24}
direction={I18nManager.isRTL ? 'rtl' : 'ltr'}
/>
{right ? (
right({
isExpanded: isExpanded,
})
) : (
<MaterialCommunityIcon
name={isExpanded ? 'chevron-up' : 'chevron-down'}
color={titleColor}
size={24}
direction={I18nManager.isRTL ? 'rtl' : 'ltr'}
/>
)}
</View>
</View>
</TouchableRipple>
Expand Down