import * as React from 'react'; import { StyleProp, StyleSheet, TextStyle, View, ViewStyle, } from 'react-native'; import ListSubheader from './ListSubheader'; import { useInternalTheme } from '../../core/theming'; import type { ThemeProp } from '../../types'; export type Props = React.ComponentPropsWithRef & { /** * Title text for the section. */ title?: string; /** * Content of the section. */ children: React.ReactNode; /** * @optional */ theme?: ThemeProp; /** * Style that is passed to Title element. */ titleStyle?: StyleProp; style?: StyleProp; }; /** * A component used to group list items. * * ## Usage * ```js * import * as React from 'react'; * import { List, MD3Colors } from 'react-native-paper'; * * const MyComponent = () => ( * * Some title * } /> * } * /> * * ); * * export default MyComponent; * ``` */ const ListSection = ({ children, title, titleStyle, style, theme: themeOverrides, ...rest }: Props) => { const theme = useInternalTheme(themeOverrides); const viewProps = { ...rest, theme }; return ( {title ? ( {title} ) : null} {children} ); }; ListSection.displayName = 'List.Section'; const styles = StyleSheet.create({ container: { marginVertical: 8, }, }); export default ListSection;