Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions packages/core/src/components/SectionList/SectionHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ const SectionHeader: React.FC<React.PropsWithChildren<SectionHeaderProps>> = ({
interface DefaultSectionHeaderProps {
title: string;
theme: ReadTheme;
backgroundColor?: string;
textColor?: string;
}
export const DefaultSectionHeader = withTheme(
({ title, theme }: DefaultSectionHeaderProps) => {
({ title, theme, backgroundColor, textColor }: DefaultSectionHeaderProps) => {
return (
<Text
testID="default-section-header"
style={{
color: theme.colors.background.base,
backgroundColor: theme.colors.branding.primary,
color: textColor ?? theme.colors.background.base,
backgroundColor: backgroundColor ?? theme.colors.branding.primary,
fontSize: 16,
padding: 10,
}}
Expand Down
10 changes: 9 additions & 1 deletion packages/core/src/components/SectionList/SectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ interface AdditionalSectionListProps<T> {
}) => JSX.Element;
keyExtractor?: (item: T, index: number) => string;
listComponent?: ListComponentType;
sectionHeaderBackgroundColor?: string;
sectionHeaderTextColor?: string;
}

export type FlatListSectionListProps<T> = Omit<FlatListProps<T>, "renderItem"> &
Expand Down Expand Up @@ -52,6 +54,8 @@ const SectionList = React.forwardRef(
data: dataProp,
renderItem: renderItemProp,
keyExtractor: keyExtractorProp,
sectionHeaderBackgroundColor,
sectionHeaderTextColor,
...rest
}: FlatListSectionListProps<T> | FlashListSectionListProps<T>,
ref: React.Ref<FlatListComponent | FlashList<any>>
Expand Down Expand Up @@ -161,7 +165,11 @@ const SectionList = React.forwardRef(
});
return (
extractSectionHeader(renderedItem) || (
<DefaultSectionHeader title={item.title} />
<DefaultSectionHeader
title={item.title}
backgroundColor={sectionHeaderBackgroundColor}
textColor={sectionHeaderTextColor}
/>
)
);
}
Expand Down
Loading