rn-vs-lb 1.0.31 → 1.0.32

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.
@@ -52,10 +52,13 @@ var renderIcon = function (tab) {
52
52
  }
53
53
  };
54
54
  var BottomTab = function (_a) {
55
- var tabs = _a.tabs, onPress = _a.onPress;
56
- var _b = (0, react_1.useState)(0), activeTab = _b[0], setActiveTab = _b[1];
55
+ var tabs = _a.tabs, onPress = _a.onPress, activeTabIndex = _a.activeTabIndex;
56
+ var _b = (0, react_1.useState)(activeTabIndex), activeTab = _b[0], setActiveTab = _b[1];
57
+ (0, react_1.useEffect)(function () {
58
+ setActiveTab(activeTabIndex);
59
+ }, [activeTabIndex]);
57
60
  var tabWidth = theme_1.SIZES.width;
58
- var tabW = tabWidth < theme_1.SIZES.container ? tabWidth / 5 : theme_1.SIZES.container / 5;
61
+ var tabW = tabWidth < theme_1.SIZES.container ? tabWidth / tabs.length : theme_1.SIZES.container / tabs.length;
59
62
  var circlePosition = (0, react_1.useRef)(new react_native_1.Animated.Value(tabWidth < theme_1.SIZES.container ? tabWidth / 2.5 : theme_1.SIZES.container / 2.5)).current;
60
63
  (0, react_1.useEffect)(function () {
61
64
  react_native_1.Animated.spring(circlePosition, {
@@ -63,9 +66,6 @@ var BottomTab = function (_a) {
63
66
  useNativeDriver: true,
64
67
  }).start();
65
68
  }, [activeTab]);
66
- var handleTabPress = function (index) {
67
- setActiveTab(index);
68
- };
69
69
  return (react_1.default.createElement(react_native_1.View, { style: styles.tabContainer },
70
70
  react_1.default.createElement(react_native_1.Animated.View, { style: [
71
71
  styles.circle,
@@ -75,7 +75,10 @@ var BottomTab = function (_a) {
75
75
  },
76
76
  ] },
77
77
  react_1.default.createElement(react_native_1.View, { style: styles.circleInner })),
78
- tabs.map(function (tab, index) { return (react_1.default.createElement(react_native_1.TouchableOpacity, { key: index, activeOpacity: 0.8, onPress: function () { return onPress(tab.route); }, style: styles.tabButton }, renderIcon(tab))); })));
78
+ tabs.map(function (tab, index) { return (react_1.default.createElement(react_native_1.TouchableOpacity, { key: index, activeOpacity: 0.8, onPress: function () {
79
+ setActiveTab(index);
80
+ onPress(tab.route);
81
+ }, style: styles.tabButton }, renderIcon(tab))); })));
79
82
  };
80
83
  exports.BottomTab = BottomTab;
81
84
  var styles = react_native_1.StyleSheet.create({
@@ -14,6 +14,7 @@ interface Tab {
14
14
  type BottomTabProps = {
15
15
  tabs: Tab[];
16
16
  onPress: (route: string) => void;
17
+ activeTabIndex: number;
17
18
  };
18
19
  export declare const BottomTab: React.FC<BottomTabProps>;
19
20
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rn-vs-lb",
3
- "version": "1.0.31",
3
+ "version": "1.0.32",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/types/index.d.ts",
6
6
  "scripts": {