@evlop/native-components 1.0.152 → 1.0.154
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":";AACA,OAAO,EAA6B,KAAK,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/RenderTabs/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAA6B,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAOzE,UAAU,GAAI,SAAQ,KAAK;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,GAAG,EAAE,CAAC;CACjB;AAED,UAAU,eAAe;IACrB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,qBAAqB,CAAC,EAAE,GAAG,CAAC;CAC/B;AAcD,iBAAS,UAAU,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,EAAE,eAAe,eA8DnE;AAgBD,eAAe,UAAU,CAAC"}
|
|
@@ -31,31 +31,45 @@ const react_native_tab_view_1 = require("react-native-tab-view");
|
|
|
31
31
|
const react_native_1 = require("react-native");
|
|
32
32
|
const RenderBlocks_1 = __importDefault(require("../RenderBlocks"));
|
|
33
33
|
const commons_1 = require("@evlop/commons");
|
|
34
|
+
const native_1 = require("@react-navigation/native");
|
|
35
|
+
const View_1 = __importDefault(require("../View"));
|
|
36
|
+
const renderLazyPlaceholder = () => {
|
|
37
|
+
return (react_1.default.createElement(View_1.default, { p: "md" },
|
|
38
|
+
react_1.default.createElement(View_1.default, { width: "100%", height: "100%", backgroundColor: "gray-100", borderRadius: 10 })));
|
|
39
|
+
};
|
|
34
40
|
function RenderTabs({ tabs, animatedScrollPostion }) {
|
|
35
41
|
var _a, _b, _c;
|
|
36
42
|
const layout = (0, react_native_1.useWindowDimensions)();
|
|
37
43
|
const [index, setIndex] = (0, react_1.useState)(0);
|
|
38
44
|
const theme = (0, commons_1.useTheme)();
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
45
|
+
const route = (0, native_1.useRoute)();
|
|
46
|
+
const tabIdFromParams = (_a = route.params) === null || _a === void 0 ? void 0 : _a.tab;
|
|
47
|
+
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'];
|
|
42
49
|
const routes = (0, react_1.useMemo)(() => tabs.map((tab) => ({ key: tab.id, title: tab.label, blocks: tab.blocks })), [tabs]);
|
|
50
|
+
// Watch for tab parameter changes
|
|
51
|
+
(0, react_1.useEffect)(() => {
|
|
52
|
+
if (!tabIdFromParams)
|
|
53
|
+
return;
|
|
54
|
+
const tabIndex = routes.findIndex(route => route.key === tabIdFromParams);
|
|
55
|
+
if (tabIndex >= 0)
|
|
56
|
+
setIndex(tabIndex);
|
|
57
|
+
}, [tabIdFromParams]);
|
|
43
58
|
const tabBarStyles = (0, react_1.useMemo)(() => ({
|
|
44
|
-
tabBar: [styles.tabBar, { backgroundColor: tabBackgroundColor
|
|
59
|
+
tabBar: [styles.tabBar, { backgroundColor: tabBackgroundColor }],
|
|
45
60
|
label: [styles.label, { color: tabTintColor }],
|
|
46
61
|
indicator: [styles.indicator, { backgroundColor: tabTintColor }]
|
|
47
|
-
}), [tabBackgroundColor, tabTintColor
|
|
62
|
+
}), [tabBackgroundColor, tabTintColor]);
|
|
48
63
|
const renderScene = ({ route }) => {
|
|
49
64
|
return (react_1.default.createElement(RenderBlocks_1.default, { blocks: route.blocks, animatedScrollPostion: animatedScrollPostion }));
|
|
50
65
|
};
|
|
51
|
-
const renderTabBar = (props) => (react_1.default.createElement(react_native_tab_view_1.TabBar, Object.assign({}, props, { style: tabBarStyles.tabBar, labelStyle: tabBarStyles.label, indicatorStyle: tabBarStyles.indicator, activeColor: tabTintColor, inactiveColor: tabTintColor })));
|
|
52
|
-
return (react_1.default.createElement(react_native_tab_view_1.TabView, { navigationState: { index, routes }, tabBarPosition: "top", renderScene: renderScene, onIndexChange: setIndex, initialLayout: { width: layout.width }, renderTabBar: renderTabBar }));
|
|
66
|
+
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: tabTintColor })));
|
|
67
|
+
return (react_1.default.createElement(react_native_tab_view_1.TabView, { navigationState: { index, routes }, tabBarPosition: "top", lazy: true, renderScene: renderScene, onIndexChange: setIndex, initialLayout: { width: layout.width }, renderTabBar: renderTabBar, renderLazyPlaceholder: renderLazyPlaceholder }));
|
|
53
68
|
}
|
|
54
69
|
const styles = react_native_1.StyleSheet.create({
|
|
55
70
|
tabBar: {
|
|
56
71
|
elevation: 0,
|
|
57
72
|
shadowOpacity: 0,
|
|
58
|
-
borderBottomWidth: 1,
|
|
59
73
|
},
|
|
60
74
|
indicator: {
|
|
61
75
|
height: 2,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/RenderTabs/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/RenderTabs/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA4D;AAC5D,iEAAyE;AACzE,+CAA+D;AAC/D,mEAA2C;AAC3C,4CAA0C;AAC1C,qDAAoD;AACpD,mDAA2B;AAiB3B,MAAM,qBAAqB,GAAG,GAAG,EAAE;IAC/B,OAAO,CACH,8BAAC,cAAI,IAA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