@@ -12,66 +12,69 @@ export interface DividerProps extends ViewProps {
1212 orientation ?: 'left' | 'right' | 'center' ;
1313}
1414
15- export default class Divider extends Component < DividerProps > {
16- static defaultProps : DividerProps = {
17- type : 'horizontal' ,
18- gutter : 8 ,
19- orientation : 'center' ,
20- } ;
21- render ( ) {
22- let { children, style, gutter, label, lineStyle, labelStyle, type, orientation, ...restProps } = this . props ;
23- if ( typeof children === 'string' ) {
24- label = children ;
25- children = null ;
26- }
27- const lineStyleArr = [ ] ;
28- const warpperStyles = [ ] ;
29- const startStyles = [ ] ;
30- const endStyles = [ ] ;
31- if ( type === 'horizontal' ) {
32- warpperStyles . unshift ( styles . horizontal ) ;
33- lineStyleArr . unshift ( styles . lineHorizontal ) ;
34- lineStyleArr . unshift ( { marginHorizontal : gutter } ) ;
35- }
36- if ( type === 'vertical' ) {
37- warpperStyles . unshift ( styles . vertical ) ;
38- lineStyleArr . unshift ( styles . lineVertical ) ;
39- lineStyleArr . unshift ( { marginVertical : gutter } ) ;
40- }
41- if ( ! children && label ) {
42- if ( labelStyle && typeof labelStyle === 'number' ) {
43- labelStyle = StyleSheet . flatten ( labelStyle ) ;
44- }
45- children = (
46- < Text testID = "RNE__Divider__label" style = { [ styles . label , labelStyle ] } >
47- { ' ' }
48- { label } { ' ' }
49- </ Text >
50- ) ;
51- }
52- if ( lineStyle && typeof lineStyle === 'number' ) {
53- lineStyle = StyleSheet . flatten ( lineStyle ) ;
54- }
55- if ( orientation === 'left' ) {
56- endStyles . unshift ( { flexGrow : 100 } ) ;
57- }
58- if ( orientation === 'right' ) {
59- startStyles . unshift ( { flexGrow : 100 } ) ;
15+ export default function Divider ( props : DividerProps ) {
16+ let {
17+ children,
18+ style,
19+ gutter = 8 ,
20+ label,
21+ lineStyle,
22+ labelStyle,
23+ type = 'horizontal' ,
24+ orientation = 'center' ,
25+ ...restProps
26+ } = props ;
27+ if ( typeof children === 'string' ) {
28+ label = children ;
29+ children = null ;
30+ }
31+ const lineStyleArr = [ ] ;
32+ const warpperStyles = [ ] ;
33+ const startStyles = [ ] ;
34+ const endStyles = [ ] ;
35+ if ( type === 'horizontal' ) {
36+ warpperStyles . unshift ( styles . horizontal ) ;
37+ lineStyleArr . unshift ( styles . lineHorizontal ) ;
38+ lineStyleArr . unshift ( { marginHorizontal : gutter } ) ;
39+ }
40+ if ( type === 'vertical' ) {
41+ warpperStyles . unshift ( styles . vertical ) ;
42+ lineStyleArr . unshift ( styles . lineVertical ) ;
43+ lineStyleArr . unshift ( { marginVertical : gutter } ) ;
44+ }
45+ if ( ! children && label ) {
46+ if ( labelStyle && typeof labelStyle === 'number' ) {
47+ labelStyle = StyleSheet . flatten ( labelStyle ) ;
6048 }
61- const lineStart = (
62- < View testID = "RNE__Divider__start" style = { [ styles . lineStart , ...lineStyleArr , ...startStyles , lineStyle ] } />
63- ) ;
64- const lineEnd = (
65- < View testID = "RNE__Divider__end" style = { [ styles . lineEnd , ...lineStyleArr , ...endStyles , lineStyle ] } />
66- ) ;
67- return (
68- < View testID = "RNE__Divider__wrap" style = { [ styles . warpper , ...warpperStyles , style ] } { ...restProps } >
69- { lineStart }
70- { children }
71- { children && lineEnd }
72- </ View >
49+ children = (
50+ < Text testID = "RNE__Divider__label" style = { [ styles . label , labelStyle ] } >
51+ { ' ' }
52+ { label } { ' ' }
53+ </ Text >
7354 ) ;
7455 }
56+ if ( lineStyle && typeof lineStyle === 'number' ) {
57+ lineStyle = StyleSheet . flatten ( lineStyle ) ;
58+ }
59+ if ( orientation === 'left' ) {
60+ endStyles . unshift ( { flexGrow : 100 } ) ;
61+ }
62+ if ( orientation === 'right' ) {
63+ startStyles . unshift ( { flexGrow : 100 } ) ;
64+ }
65+ const lineStart = (
66+ < View testID = "RNE__Divider__start" style = { [ styles . lineStart , ...lineStyleArr , ...startStyles , lineStyle ] } />
67+ ) ;
68+ const lineEnd = (
69+ < View testID = "RNE__Divider__end" style = { [ styles . lineEnd , ...lineStyleArr , ...endStyles , lineStyle ] } />
70+ ) ;
71+ return (
72+ < View testID = "RNE__Divider__wrap" style = { [ styles . warpper , ...warpperStyles , style ] } { ...restProps } >
73+ { lineStart }
74+ { children }
75+ { children && lineEnd }
76+ </ View >
77+ ) ;
7578}
7679
7780const styles = StyleSheet . create ( {
0 commit comments