1 | import * as React from 'react';
|
2 | import {
|
3 | View,
|
4 | ViewStyle,
|
5 | StyleSheet,
|
6 | StyleProp,
|
7 | TextStyle,
|
8 | } from 'react-native';
|
9 | import ListSubheader from './ListSubheader';
|
10 | import { withTheme } from '../../core/theming';
|
11 |
|
12 | type Props = React.ComponentPropsWithRef<typeof View> & {
|
13 | |
14 |
|
15 |
|
16 | title?: string;
|
17 | |
18 |
|
19 |
|
20 | children: React.ReactNode;
|
21 | |
22 |
|
23 |
|
24 | theme: ReactNativePaper.Theme;
|
25 | |
26 |
|
27 |
|
28 | titleStyle?: StyleProp<TextStyle>;
|
29 | style?: StyleProp<ViewStyle>;
|
30 | };
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | const ListSection = ({
|
59 | children,
|
60 | title,
|
61 | titleStyle,
|
62 | style,
|
63 | ...rest
|
64 | }: Props) => (
|
65 | <View {...rest} style={[styles.container, style]}>
|
66 | {title ? <ListSubheader style={titleStyle}>{title}</ListSubheader> : null}
|
67 | {children}
|
68 | </View>
|
69 | );
|
70 |
|
71 | ListSection.displayName = 'List.Section';
|
72 |
|
73 | const styles = StyleSheet.create({
|
74 | container: {
|
75 | marginVertical: 8,
|
76 | },
|
77 | });
|
78 |
|
79 | export default withTheme(ListSection);
|