Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add prop right to List Accordion #2531

Merged
merged 1 commit into from
Apr 9, 2021
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