UNPKG

2.66 kBJavaScriptView Raw
1var __rest = (this && this.__rest) || function (s, e) {
2 var t = {};
3 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4 t[p] = s[p];
5 if (s != null && typeof Object.getOwnPropertySymbols === "function")
6 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8 t[p[i]] = s[p[i]];
9 }
10 return t;
11};
12var _a, _b;
13import React from 'react';
14import { View, StyleSheet, Text, } from 'react-native';
15import { withTheme } from '../config';
16import Theme from '../config/theme';
17const Divider = (_a) => {
18 var { color, inset = false, insetType = 'left', orientation = 'horizontal', style, subHeader, subHeaderStyle, theme, width } = _a, rest = __rest(_a, ["color", "inset", "insetType", "orientation", "style", "subHeader", "subHeaderStyle", "theme", "width"]);
19 return (<>
20 <View style={StyleSheet.flatten([
21 styles.divider,
22 style,
23 inset &&
24 (insetType === 'left'
25 ? styles.leftInset
26 : insetType === 'right'
27 ? styles.rightInset
28 : Object.assign(Object.assign({}, styles.leftInset), styles.rightInset)),
29 orientation === 'vertical' && styles.vertical,
30 width &&
31 (orientation === 'horizontal'
32 ? { borderBottomWidth: width }
33 : { borderRightWidth: width }),
34 color &&
35 (orientation === 'horizontal'
36 ? { borderBottomColor: color }
37 : { borderRightColor: color }),
38 ])} {...rest}/>
39 {subHeader && orientation === 'horizontal' ? (<Text style={StyleSheet.flatten([
40 styles.subHeader,
41 subHeaderStyle,
42 inset && styles.leftInset,
43 ])}>
44 {subHeader}
45 </Text>) : null}
46 </>);
47};
48const styles = StyleSheet.create({
49 divider: {
50 borderBottomWidth: StyleSheet.hairlineWidth,
51 borderBottomColor: (_a = Theme === null || Theme === void 0 ? void 0 : Theme.colors) === null || _a === void 0 ? void 0 : _a.divider,
52 },
53 leftInset: {
54 marginLeft: 72,
55 },
56 rightInset: {
57 marginRight: 72,
58 },
59 vertical: {
60 borderRightWidth: StyleSheet.hairlineWidth,
61 borderRightColor: (_b = Theme === null || Theme === void 0 ? void 0 : Theme.colors) === null || _b === void 0 ? void 0 : _b.divider,
62 height: 'auto',
63 alignSelf: 'stretch',
64 },
65 subHeader: {
66 includeFontPadding: false,
67 },
68});
69export { Divider };
70export default withTheme(Divider, 'Divider');