@evlop/native-components 1.0.155 → 1.0.156
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/RenderTabs/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/RenderTabs/index.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,KAAK,EAAkC,MAAM,uBAAuB,CAAC;AAK9E,UAAU,GAAI,SAAQ,KAAK;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,GAAG,EAAE,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,eAAe;IACrB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,qBAAqB,CAAC,EAAE,GAAG,CAAC;CAC/B;AAqBD,iBAAS,UAAU,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,EAAE,eAAe,eAgFnE;AA0BD,eAAe,UAAU,CAAC"}
|
|
@@ -26,27 +26,42 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const commons_1 = require("@evlop/commons");
|
|
30
|
+
const native_1 = require("@react-navigation/native");
|
|
29
31
|
const react_1 = __importStar(require("react"));
|
|
30
|
-
const react_native_tab_view_1 = require("react-native-tab-view");
|
|
31
32
|
const react_native_1 = require("react-native");
|
|
33
|
+
const react_native_tab_view_1 = require("react-native-tab-view");
|
|
34
|
+
const Icon_1 = require("../Icon");
|
|
32
35
|
const RenderBlocks_1 = __importDefault(require("../RenderBlocks"));
|
|
33
|
-
const commons_1 = require("@evlop/commons");
|
|
34
|
-
const native_1 = require("@react-navigation/native");
|
|
35
36
|
const View_1 = __importDefault(require("../View"));
|
|
37
|
+
const tabViewCommonOptions = {
|
|
38
|
+
icon: (props) => {
|
|
39
|
+
if (!props.route.icon)
|
|
40
|
+
return null;
|
|
41
|
+
return (react_1.default.createElement(Icon_1.BaseIcon, { icon: props.route.icon, color: props.color, size: 16 }));
|
|
42
|
+
},
|
|
43
|
+
};
|
|
36
44
|
const renderLazyPlaceholder = () => {
|
|
37
45
|
return (react_1.default.createElement(View_1.default, { p: "md" },
|
|
38
46
|
react_1.default.createElement(View_1.default, { width: "100%", height: "100%", backgroundColor: "gray-100", borderRadius: 10 })));
|
|
39
47
|
};
|
|
40
48
|
function RenderTabs({ tabs, animatedScrollPostion }) {
|
|
41
|
-
var _a, _b, _c;
|
|
49
|
+
var _a, _b, _c, _d, _e;
|
|
42
50
|
const layout = (0, react_native_1.useWindowDimensions)();
|
|
43
51
|
const [index, setIndex] = (0, react_1.useState)(0);
|
|
44
52
|
const theme = (0, commons_1.useTheme)();
|
|
45
53
|
const route = (0, native_1.useRoute)();
|
|
46
54
|
const tabIdFromParams = (_a = route.params) === null || _a === void 0 ? void 0 : _a.tab;
|
|
47
55
|
const tabBackgroundColor = (_b = theme === null || theme === void 0 ? void 0 : theme.colors) === null || _b === void 0 ? void 0 : _b['body-background'];
|
|
48
|
-
const tabTintColor = (_c = theme === null || theme === void 0 ? void 0 : theme.colors) === null || _c === void 0 ? void 0 : _c['primary'];
|
|
49
|
-
const
|
|
56
|
+
const tabTintColor = (_c = theme === null || theme === void 0 ? void 0 : theme.colors) === null || _c === void 0 ? void 0 : _c['primary-700'];
|
|
57
|
+
const tabInactiveTintColor = (_d = theme === null || theme === void 0 ? void 0 : theme.colors) === null || _d === void 0 ? void 0 : _d['gray-700'];
|
|
58
|
+
const tabBorderColor = (_e = theme === null || theme === void 0 ? void 0 : theme.colors) === null || _e === void 0 ? void 0 : _e['gray-200'];
|
|
59
|
+
const tabRoutes = (0, react_1.useMemo)(() => tabs.map((tab) => ({
|
|
60
|
+
key: tab.id,
|
|
61
|
+
title: tab.label,
|
|
62
|
+
blocks: tab.blocks,
|
|
63
|
+
icon: tab.icon,
|
|
64
|
+
})), [tabs]);
|
|
50
65
|
const onIndexChange = (0, react_1.useCallback)((index) => {
|
|
51
66
|
setIndex(index);
|
|
52
67
|
if (react_native_1.Platform.OS === 'web') {
|
|
@@ -63,20 +78,22 @@ function RenderTabs({ tabs, animatedScrollPostion }) {
|
|
|
63
78
|
setIndex(tabIndex);
|
|
64
79
|
}, [tabIdFromParams]);
|
|
65
80
|
const tabBarStyles = (0, react_1.useMemo)(() => ({
|
|
66
|
-
tabBar: [styles.tabBar, { backgroundColor: tabBackgroundColor }],
|
|
81
|
+
tabBar: [styles.tabBar, { backgroundColor: tabBackgroundColor, borderColor: tabBorderColor }],
|
|
67
82
|
label: [styles.label, { color: tabTintColor }],
|
|
68
|
-
indicator: [styles.indicator, { backgroundColor: tabTintColor }]
|
|
69
|
-
|
|
83
|
+
indicator: [styles.indicator, { backgroundColor: tabTintColor }],
|
|
84
|
+
tab: styles.tab
|
|
85
|
+
}), [tabBackgroundColor, tabTintColor, tabBorderColor]);
|
|
70
86
|
const renderScene = ({ route }) => {
|
|
71
87
|
return (react_1.default.createElement(RenderBlocks_1.default, { blocks: route.blocks, animatedScrollPostion: animatedScrollPostion }));
|
|
72
88
|
};
|
|
73
|
-
const renderTabBar = (props) => (react_1.default.createElement(react_native_tab_view_1.TabBar, Object.assign({}, props, { scrollEnabled: true, style: tabBarStyles.tabBar, labelStyle: tabBarStyles.label, indicatorStyle: tabBarStyles.indicator, activeColor: tabTintColor, inactiveColor:
|
|
74
|
-
return (react_1.default.createElement(react_native_tab_view_1.TabView, { navigationState: { index, routes: tabRoutes }, tabBarPosition: "top", lazy: true, renderScene: renderScene, onIndexChange: onIndexChange, initialLayout: { width: layout.width }, renderTabBar: renderTabBar, renderLazyPlaceholder: renderLazyPlaceholder }));
|
|
89
|
+
const renderTabBar = (props) => (react_1.default.createElement(react_native_tab_view_1.TabBar, Object.assign({}, props, { scrollEnabled: true, style: tabBarStyles.tabBar, labelStyle: tabBarStyles.label, indicatorStyle: tabBarStyles.indicator, tabStyle: tabBarStyles.tab, activeColor: tabTintColor, inactiveColor: tabInactiveTintColor })));
|
|
90
|
+
return (react_1.default.createElement(react_native_tab_view_1.TabView, { navigationState: { index, routes: tabRoutes }, tabBarPosition: "top", lazy: true, renderScene: renderScene, onIndexChange: onIndexChange, initialLayout: { width: layout.width }, renderTabBar: renderTabBar, renderLazyPlaceholder: renderLazyPlaceholder, commonOptions: tabViewCommonOptions }));
|
|
75
91
|
}
|
|
76
92
|
const styles = react_native_1.StyleSheet.create({
|
|
77
93
|
tabBar: {
|
|
78
94
|
elevation: 0,
|
|
79
95
|
shadowOpacity: 0,
|
|
96
|
+
borderBottomWidth: 1,
|
|
80
97
|
},
|
|
81
98
|
indicator: {
|
|
82
99
|
height: 2,
|
|
@@ -84,6 +101,15 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
84
101
|
label: {
|
|
85
102
|
fontWeight: '600',
|
|
86
103
|
textTransform: 'none',
|
|
104
|
+
fontSize: 13,
|
|
105
|
+
marginVertical: 0,
|
|
106
|
+
marginHorizontal: 4,
|
|
107
|
+
},
|
|
108
|
+
tab: {
|
|
109
|
+
width: 'auto',
|
|
110
|
+
flexDirection: 'row',
|
|
111
|
+
alignItems: 'center',
|
|
112
|
+
justifyContent: 'center',
|
|
87
113
|
},
|
|
88
114
|
});
|
|
89
115
|
exports.default = RenderTabs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/RenderTabs/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAyE;AACzE
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/RenderTabs/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAwE;AACxE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