react-navigation-reanimated-top-tabs 0.2.0
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.
- package/LICENSE +20 -0
- package/README.md +26 -0
- package/lib/commonjs/components/ReanimatedTopTab/AnimationHelper.js +76 -0
- package/lib/commonjs/components/ReanimatedTopTab/AnimationHelper.js.map +1 -0
- package/lib/commonjs/components/ReanimatedTopTab/ReanimatedTabView.js +125 -0
- package/lib/commonjs/components/ReanimatedTopTab/ReanimatedTabView.js.map +1 -0
- package/lib/commonjs/components/ReanimatedTopTab/types.js +8 -0
- package/lib/commonjs/components/ReanimatedTopTab/types.js.map +1 -0
- package/lib/commonjs/components/elements/TabBarBaseComponent.js +71 -0
- package/lib/commonjs/components/elements/TabBarBaseComponent.js.map +1 -0
- package/lib/commonjs/components/elements/TabBarLabelBaseComponent.js +48 -0
- package/lib/commonjs/components/elements/TabBarLabelBaseComponent.js.map +1 -0
- package/lib/commonjs/components/wrappers/GestureWrapper.js +100 -0
- package/lib/commonjs/components/wrappers/GestureWrapper.js.map +1 -0
- package/lib/commonjs/components/wrappers/ScreenWrapper.js +34 -0
- package/lib/commonjs/components/wrappers/ScreenWrapper.js.map +1 -0
- package/lib/commonjs/components/wrappers/ScrollView.js +58 -0
- package/lib/commonjs/components/wrappers/ScrollView.js.map +1 -0
- package/lib/commonjs/context/TopTabContext.hooks.js +48 -0
- package/lib/commonjs/context/TopTabContext.hooks.js.map +1 -0
- package/lib/commonjs/context/TopTabContext.js +86 -0
- package/lib/commonjs/context/TopTabContext.js.map +1 -0
- package/lib/commonjs/hooks/TopTab.hooks.js +120 -0
- package/lib/commonjs/hooks/TopTab.hooks.js.map +1 -0
- package/lib/commonjs/index.js +92 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/navigator/createReanimatedTopTabNavigator.js +141 -0
- package/lib/commonjs/navigator/createReanimatedTopTabNavigator.js.map +1 -0
- package/lib/commonjs/types.js +8 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/components/ReanimatedTopTab/AnimationHelper.js +72 -0
- package/lib/module/components/ReanimatedTopTab/AnimationHelper.js.map +1 -0
- package/lib/module/components/ReanimatedTopTab/ReanimatedTabView.js +119 -0
- package/lib/module/components/ReanimatedTopTab/ReanimatedTabView.js.map +1 -0
- package/lib/module/components/ReanimatedTopTab/types.js +4 -0
- package/lib/module/components/ReanimatedTopTab/types.js.map +1 -0
- package/lib/module/components/elements/TabBarBaseComponent.js +64 -0
- package/lib/module/components/elements/TabBarBaseComponent.js.map +1 -0
- package/lib/module/components/elements/TabBarLabelBaseComponent.js +41 -0
- package/lib/module/components/elements/TabBarLabelBaseComponent.js.map +1 -0
- package/lib/module/components/wrappers/GestureWrapper.js +94 -0
- package/lib/module/components/wrappers/GestureWrapper.js.map +1 -0
- package/lib/module/components/wrappers/ScreenWrapper.js +28 -0
- package/lib/module/components/wrappers/ScreenWrapper.js.map +1 -0
- package/lib/module/components/wrappers/ScrollView.js +52 -0
- package/lib/module/components/wrappers/ScrollView.js.map +1 -0
- package/lib/module/context/TopTabContext.hooks.js +44 -0
- package/lib/module/context/TopTabContext.hooks.js.map +1 -0
- package/lib/module/context/TopTabContext.js +82 -0
- package/lib/module/context/TopTabContext.js.map +1 -0
- package/lib/module/hooks/TopTab.hooks.js +110 -0
- package/lib/module/hooks/TopTab.hooks.js.map +1 -0
- package/lib/module/index.js +11 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/navigator/createReanimatedTopTabNavigator.js +134 -0
- package/lib/module/navigator/createReanimatedTopTabNavigator.js.map +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/components/ReanimatedTopTab/AnimationHelper.d.ts +11 -0
- package/lib/typescript/commonjs/src/components/ReanimatedTopTab/AnimationHelper.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/ReanimatedTopTab/ReanimatedTabView.d.ts +14 -0
- package/lib/typescript/commonjs/src/components/ReanimatedTopTab/ReanimatedTabView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/ReanimatedTopTab/types.d.ts +30 -0
- package/lib/typescript/commonjs/src/components/ReanimatedTopTab/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/elements/TabBarBaseComponent.d.ts +24 -0
- package/lib/typescript/commonjs/src/components/elements/TabBarBaseComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/elements/TabBarLabelBaseComponent.d.ts +8 -0
- package/lib/typescript/commonjs/src/components/elements/TabBarLabelBaseComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/wrappers/GestureWrapper.d.ts +2 -0
- package/lib/typescript/commonjs/src/components/wrappers/GestureWrapper.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/wrappers/ScreenWrapper.d.ts +6 -0
- package/lib/typescript/commonjs/src/components/wrappers/ScreenWrapper.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/wrappers/ScrollView.d.ts +6 -0
- package/lib/typescript/commonjs/src/components/wrappers/ScrollView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/context/TopTabContext.d.ts +4 -0
- package/lib/typescript/commonjs/src/context/TopTabContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/context/TopTabContext.hooks.d.ts +5 -0
- package/lib/typescript/commonjs/src/context/TopTabContext.hooks.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/TopTab.hooks.d.ts +33 -0
- package/lib/typescript/commonjs/src/hooks/TopTab.hooks.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +10 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/navigator/createReanimatedTopTabNavigator.d.ts +4 -0
- package/lib/typescript/commonjs/src/navigator/createReanimatedTopTabNavigator.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types.d.ts +56 -0
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/components/ReanimatedTopTab/AnimationHelper.d.ts +11 -0
- package/lib/typescript/module/src/components/ReanimatedTopTab/AnimationHelper.d.ts.map +1 -0
- package/lib/typescript/module/src/components/ReanimatedTopTab/ReanimatedTabView.d.ts +14 -0
- package/lib/typescript/module/src/components/ReanimatedTopTab/ReanimatedTabView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/ReanimatedTopTab/types.d.ts +30 -0
- package/lib/typescript/module/src/components/ReanimatedTopTab/types.d.ts.map +1 -0
- package/lib/typescript/module/src/components/elements/TabBarBaseComponent.d.ts +24 -0
- package/lib/typescript/module/src/components/elements/TabBarBaseComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/components/elements/TabBarLabelBaseComponent.d.ts +8 -0
- package/lib/typescript/module/src/components/elements/TabBarLabelBaseComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/components/wrappers/GestureWrapper.d.ts +2 -0
- package/lib/typescript/module/src/components/wrappers/GestureWrapper.d.ts.map +1 -0
- package/lib/typescript/module/src/components/wrappers/ScreenWrapper.d.ts +6 -0
- package/lib/typescript/module/src/components/wrappers/ScreenWrapper.d.ts.map +1 -0
- package/lib/typescript/module/src/components/wrappers/ScrollView.d.ts +6 -0
- package/lib/typescript/module/src/components/wrappers/ScrollView.d.ts.map +1 -0
- package/lib/typescript/module/src/context/TopTabContext.d.ts +4 -0
- package/lib/typescript/module/src/context/TopTabContext.d.ts.map +1 -0
- package/lib/typescript/module/src/context/TopTabContext.hooks.d.ts +5 -0
- package/lib/typescript/module/src/context/TopTabContext.hooks.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/TopTab.hooks.d.ts +33 -0
- package/lib/typescript/module/src/hooks/TopTab.hooks.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +10 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/navigator/createReanimatedTopTabNavigator.d.ts +4 -0
- package/lib/typescript/module/src/navigator/createReanimatedTopTabNavigator.d.ts.map +1 -0
- package/lib/typescript/module/src/types.d.ts +56 -0
- package/lib/typescript/module/src/types.d.ts.map +1 -0
- package/package.json +204 -0
- package/src/components/ReanimatedTopTab/AnimationHelper.ts +94 -0
- package/src/components/ReanimatedTopTab/ReanimatedTabView.tsx +200 -0
- package/src/components/ReanimatedTopTab/types.ts +29 -0
- package/src/components/elements/TabBarBaseComponent.tsx +99 -0
- package/src/components/elements/TabBarLabelBaseComponent.tsx +63 -0
- package/src/components/wrappers/GestureWrapper.tsx +135 -0
- package/src/components/wrappers/ScreenWrapper.tsx +27 -0
- package/src/components/wrappers/ScrollView.tsx +59 -0
- package/src/context/TopTabContext.hooks.ts +55 -0
- package/src/context/TopTabContext.tsx +115 -0
- package/src/hooks/TopTab.hooks.ts +112 -0
- package/src/index.tsx +15 -0
- package/src/navigator/createReanimatedTopTabNavigator.tsx +192 -0
- package/src/types.ts +63 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_reactNativeGestureHandler","_reactNativeReanimated","_interopRequireDefault","_TopTabHooks","_react","_native","_jsxRuntime","e","__esModule","default","ScrollView","children","style","props","gesture","useScreenGesture","animatedStyle","scrollProps","useScreenScrollable","innerLayout","useScreenProperties","screenRefs","useTabContext","key","useRoute","_ref","useRef","onLayout","event","value","nativeEvent","layout","setRef","jsx","GestureDetector","ref","contentContainerStyle","_style","exports","StyleSheet","create","flexGrow"],"sourceRoot":"../../../../src","sources":["components/wrappers/ScrollView.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAAC,0BAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAMA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AAAoD,IAAAO,WAAA,GAAAP,OAAA;AAAA,SAA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AAAA,UAAA;AAEF,MAAM2B,MAAM,GAAGE,uBAAU,CAACC,MAAM,CAAC;EAC/BJ,qBAAqB,EAAE;IACrBK,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TopTabContextHooks = void 0;
|
|
7
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
8
|
+
const useResetApproachingScreenScrollOffset = ({
|
|
9
|
+
screenRefs,
|
|
10
|
+
transformationX,
|
|
11
|
+
screenProperties,
|
|
12
|
+
currentYPosition
|
|
13
|
+
}) => {
|
|
14
|
+
const resetApproachingScreenOffset = (index, shouldReset) => {
|
|
15
|
+
if (shouldReset) {
|
|
16
|
+
//NOTE: use reanimated scrollTo does not work
|
|
17
|
+
const {
|
|
18
|
+
scrollTo
|
|
19
|
+
} = Object.values(screenRefs.refs.current)[index]?.current ?? {
|
|
20
|
+
scrollTo: () => null
|
|
21
|
+
};
|
|
22
|
+
scrollTo({
|
|
23
|
+
y: 0,
|
|
24
|
+
animated: false
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
(0, _reactNativeReanimated.useAnimatedReaction)(() => transformationX.value, (current, previous) => {
|
|
29
|
+
const approachingIndex = getTargetIndex(current, previous);
|
|
30
|
+
const approachingScreenOffset = Object.values(screenProperties).map(({
|
|
31
|
+
scrollY
|
|
32
|
+
}) => scrollY.value)[approachingIndex] ?? -1;
|
|
33
|
+
(0, _reactNativeReanimated.runOnJS)(resetApproachingScreenOffset)(approachingIndex, approachingScreenOffset > 0 && currentYPosition.value === 0);
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
function getTargetIndex(currentValue, previousValue) {
|
|
37
|
+
'worklet';
|
|
38
|
+
|
|
39
|
+
if (currentValue > (previousValue ?? 0)) {
|
|
40
|
+
return Math.ceil(currentValue);
|
|
41
|
+
} else {
|
|
42
|
+
return Math.floor(currentValue);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const TopTabContextHooks = exports.TopTabContextHooks = {
|
|
46
|
+
useResetApproachingScreenScrollOffset
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=TopTabContext.hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeReanimated","require","useResetApproachingScreenScrollOffset","screenRefs","transformationX","screenProperties","currentYPosition","resetApproachingScreenOffset","index","shouldReset","scrollTo","Object","values","refs","current","y","animated","useAnimatedReaction","value","previous","approachingIndex","getTargetIndex","approachingScreenOffset","map","scrollY","runOnJS","currentValue","previousValue","Math","ceil","floor","TopTabContextHooks","exports"],"sourceRoot":"../../../src","sources":["context/TopTabContext.hooks.ts"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAGA,MAAMC,qCAAqC,GAAGA,CAAC;EAC7CC,UAAU;EACVC,eAAe;EACfC,gBAAgB;EAChBC;AAIF,CAAC,KAAK;EACJ,MAAMC,4BAA4B,GAAGA,CACnCC,KAAa,EACbC,WAAoB,KACjB;IACH,IAAIA,WAAW,EAAE;MACf;MACA,MAAM;QAAEC;MAAS,CAAC,GAAGC,MAAM,CAACC,MAAM,CAACT,UAAU,CAACU,IAAI,CAACC,OAAO,CAAC,CAACN,KAAK,CAAC,EAC9DM,OAAO,IAAI;QAAEJ,QAAQ,EAAEA,CAAA,KAAM;MAAK,CAAC;MAEvCA,QAAQ,CAAC;QAAEK,CAAC,EAAE,CAAC;QAAEC,QAAQ,EAAE;MAAM,CAAC,CAAC;IACrC;EACF,CAAC;EAED,IAAAC,0CAAmB,EACjB,MAAMb,eAAe,CAACc,KAAK,EAC3B,CAACJ,OAAO,EAAEK,QAAQ,KAAK;IACrB,MAAMC,gBAAgB,GAAGC,cAAc,CAACP,OAAO,EAAEK,QAAQ,CAAC;IAE1D,MAAMG,uBAAuB,GAC3BX,MAAM,CAACC,MAAM,CAACP,gBAAgB,CAAC,CAACkB,GAAG,CAAC,CAAC;MAAEC;IAAQ,CAAC,KAAKA,OAAO,CAACN,KAAK,CAAC,CACjEE,gBAAgB,CACjB,IAAI,CAAC,CAAC;IAET,IAAAK,8BAAO,EAAClB,4BAA4B,CAAC,CACnCa,gBAAgB,EAChBE,uBAAuB,GAAG,CAAC,IAAIhB,gBAAgB,CAACY,KAAK,KAAK,CAC5D,CAAC;EACH,CACF,CAAC;AACH,CAAC;AAED,SAASG,cAAcA,CAACK,YAAoB,EAAEC,aAA4B,EAAE;EAC1E,SAAS;;EACT,IAAID,YAAY,IAAIC,aAAa,IAAI,CAAC,CAAC,EAAE;IACvC,OAAOC,IAAI,CAACC,IAAI,CAACH,YAAY,CAAC;EAChC,CAAC,MAAM;IACL,OAAOE,IAAI,CAACE,KAAK,CAACJ,YAAY,CAAC;EACjC;AACF;AAEO,MAAMK,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG;EAChC7B;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Provider = exports.Context = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNativeGestureHandler = require("react-native-gesture-handler");
|
|
9
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
10
|
+
var _TopTabHooks = require("../hooks/TopTab.hooks.js");
|
|
11
|
+
var _TopTabContextHooks = require("./TopTabContext.hooks.js");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
const Context = exports.Context = /*#__PURE__*/(0, _react.createContext)({});
|
|
14
|
+
const Provider = exports.Provider = /*#__PURE__*/(0, _react.memo)(({
|
|
15
|
+
children,
|
|
16
|
+
config,
|
|
17
|
+
screenProperties
|
|
18
|
+
}) => {
|
|
19
|
+
const transformationY = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
20
|
+
const transformationX = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
21
|
+
const currentYPosition = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
22
|
+
const gestureEnabled = (0, _reactNativeReanimated.useSharedValue)(true);
|
|
23
|
+
const currentScreenIndex = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
24
|
+
const navHeight = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
25
|
+
const headerHeight = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
26
|
+
const closeOffset = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
27
|
+
const topTabHeight = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
28
|
+
const topTapNativeRef = (0, _react.useRef)(_reactNativeGestureHandler.Gesture.Native()).current;
|
|
29
|
+
const screenRefs = (0, _TopTabHooks.useScreenRefs)(Object.keys(screenProperties));
|
|
30
|
+
|
|
31
|
+
//Hide header base on config
|
|
32
|
+
const inputRange = (0, _reactNativeReanimated.useDerivedValue)(() => config.map((_, idx) => idx), [config]);
|
|
33
|
+
const outputRange = (0, _reactNativeReanimated.useDerivedValue)(() => config.map(type => {
|
|
34
|
+
switch (type) {
|
|
35
|
+
case 'normal':
|
|
36
|
+
return 0;
|
|
37
|
+
case 'minimalized':
|
|
38
|
+
return -headerHeight.value;
|
|
39
|
+
default:
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
}), [config]);
|
|
43
|
+
(0, _reactNativeReanimated.useAnimatedReaction)(() => transformationX.value, value => {
|
|
44
|
+
if (currentYPosition.value === -headerHeight.value) return;
|
|
45
|
+
transformationY.value = (0, _reactNativeReanimated.interpolate)(value, inputRange.value, outputRange.value, 'clamp');
|
|
46
|
+
});
|
|
47
|
+
_TopTabContextHooks.TopTabContextHooks.useResetApproachingScreenScrollOffset({
|
|
48
|
+
screenRefs,
|
|
49
|
+
currentYPosition,
|
|
50
|
+
screenProperties,
|
|
51
|
+
transformationX
|
|
52
|
+
});
|
|
53
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Context.Provider, {
|
|
54
|
+
value: {
|
|
55
|
+
closeOffset,
|
|
56
|
+
config,
|
|
57
|
+
currentScreenIndex,
|
|
58
|
+
currentYPosition,
|
|
59
|
+
gestureEnabled,
|
|
60
|
+
headerHeight,
|
|
61
|
+
navHeight,
|
|
62
|
+
screenProperties,
|
|
63
|
+
topTabHeight,
|
|
64
|
+
topTapNativeRef,
|
|
65
|
+
transformationX,
|
|
66
|
+
transformationY,
|
|
67
|
+
screenRefs
|
|
68
|
+
},
|
|
69
|
+
children: children({
|
|
70
|
+
screenRefs,
|
|
71
|
+
closeOffset,
|
|
72
|
+
config,
|
|
73
|
+
currentScreenIndex,
|
|
74
|
+
currentYPosition,
|
|
75
|
+
gestureEnabled,
|
|
76
|
+
headerHeight,
|
|
77
|
+
navHeight,
|
|
78
|
+
screenProperties,
|
|
79
|
+
topTabHeight,
|
|
80
|
+
topTapNativeRef,
|
|
81
|
+
transformationX,
|
|
82
|
+
transformationY
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
//# sourceMappingURL=TopTabContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNativeGestureHandler","_reactNativeReanimated","_TopTabHooks","_TopTabContextHooks","_jsxRuntime","Context","exports","createContext","Provider","memo","children","config","screenProperties","transformationY","useSharedValue","transformationX","currentYPosition","gestureEnabled","currentScreenIndex","navHeight","headerHeight","closeOffset","topTabHeight","topTapNativeRef","useRef","Gesture","Native","current","screenRefs","useScreenRefs","Object","keys","inputRange","useDerivedValue","map","_","idx","outputRange","type","value","useAnimatedReaction","interpolate","TopTabContextHooks","useResetApproachingScreenScrollOffset","jsx"],"sourceRoot":"../../../src","sources":["context/TopTabContext.tsx"],"mappings":";;;;;;AACA,IAAAA,MAAA,GA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":[]}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useTabContext = exports.useScreenScrollable = exports.useScreenRefs = exports.useScreenProperties = exports.useScreenGesture = exports.useHeader = void 0;
|
|
7
|
+
var _native = require("@react-navigation/native");
|
|
8
|
+
var _TopTabContext = require("../context/TopTabContext.js");
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
11
|
+
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
|
|
12
|
+
var _reactNative = require("react-native");
|
|
13
|
+
const useTabContext = () => (0, _react.useContext)(_TopTabContext.Context);
|
|
14
|
+
exports.useTabContext = useTabContext;
|
|
15
|
+
const useScreenGesture = () => {
|
|
16
|
+
const {
|
|
17
|
+
key
|
|
18
|
+
} = (0, _native.useRoute)();
|
|
19
|
+
const {
|
|
20
|
+
screenProperties
|
|
21
|
+
} = useTabContext();
|
|
22
|
+
const nativeRef = screenProperties[key]?.nativeGesture;
|
|
23
|
+
if (!nativeRef) throw 'GestureRef does not exist for this route';
|
|
24
|
+
return nativeRef;
|
|
25
|
+
};
|
|
26
|
+
exports.useScreenGesture = useScreenGesture;
|
|
27
|
+
const useScreenScrollable = () => {
|
|
28
|
+
const {
|
|
29
|
+
key
|
|
30
|
+
} = (0, _native.useRoute)();
|
|
31
|
+
const {
|
|
32
|
+
height
|
|
33
|
+
} = (0, _reactNative.useWindowDimensions)();
|
|
34
|
+
const {
|
|
35
|
+
bottom
|
|
36
|
+
} = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
|
|
37
|
+
const {
|
|
38
|
+
currentYPosition,
|
|
39
|
+
gestureEnabled,
|
|
40
|
+
headerHeight,
|
|
41
|
+
screenProperties,
|
|
42
|
+
topTabHeight,
|
|
43
|
+
transformationY
|
|
44
|
+
} = useTabContext();
|
|
45
|
+
|
|
46
|
+
//TODO: Navigation header hook is available if Tabs are rendered inside the Stack (createNavigationStack())
|
|
47
|
+
//useHeaderHeight();
|
|
48
|
+
const navigationHeader = 50;
|
|
49
|
+
const animatedProps = (0, _reactNativeReanimated.useAnimatedProps)(() => ({
|
|
50
|
+
scrollEnabled: !gestureEnabled.value || currentYPosition.value === -headerHeight.value
|
|
51
|
+
}));
|
|
52
|
+
const onScroll = (0, _reactNativeReanimated.useAnimatedScrollHandler)(({
|
|
53
|
+
contentOffset
|
|
54
|
+
}) => {
|
|
55
|
+
const scrollPosition = screenProperties[key]?.scrollY;
|
|
56
|
+
if (!scrollPosition) throw 'ScrollPosition property does not exist for this route';
|
|
57
|
+
scrollPosition.value = contentOffset.y;
|
|
58
|
+
});
|
|
59
|
+
const oppositeHeaderState = (0, _reactNativeReanimated.useDerivedValue)(() => transformationY.value >= 0 ? headerHeight.value : 0);
|
|
60
|
+
const style = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
|
|
61
|
+
minHeight: height - topTabHeight.value - oppositeHeaderState.value - navigationHeader
|
|
62
|
+
}));
|
|
63
|
+
return {
|
|
64
|
+
animatedProps,
|
|
65
|
+
bounces: false,
|
|
66
|
+
contentContainerStyle: {
|
|
67
|
+
paddingBottom: bottom
|
|
68
|
+
},
|
|
69
|
+
onScroll,
|
|
70
|
+
style
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
exports.useScreenScrollable = useScreenScrollable;
|
|
74
|
+
const useScreenProperties = () => {
|
|
75
|
+
const {
|
|
76
|
+
key
|
|
77
|
+
} = (0, _native.useRoute)();
|
|
78
|
+
const {
|
|
79
|
+
screenProperties
|
|
80
|
+
} = useTabContext();
|
|
81
|
+
const screen = screenProperties[key];
|
|
82
|
+
if (!screen) throw 'No screen properties registered for this route';
|
|
83
|
+
return screen;
|
|
84
|
+
};
|
|
85
|
+
exports.useScreenProperties = useScreenProperties;
|
|
86
|
+
const useHeader = () => {
|
|
87
|
+
const {
|
|
88
|
+
headerHeight,
|
|
89
|
+
transformationX
|
|
90
|
+
} = useTabContext();
|
|
91
|
+
const hideHeader = () => {
|
|
92
|
+
transformationX.value = (0, _reactNativeReanimated.withTiming)(-headerHeight.value);
|
|
93
|
+
};
|
|
94
|
+
return {
|
|
95
|
+
hideHeader
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
exports.useHeader = useHeader;
|
|
99
|
+
const useScreenRefs = keys => {
|
|
100
|
+
const refs = {
|
|
101
|
+
current: keys.reduce((prev, key) => ({
|
|
102
|
+
...prev,
|
|
103
|
+
[key]: {
|
|
104
|
+
current: null
|
|
105
|
+
}
|
|
106
|
+
}), {})
|
|
107
|
+
};
|
|
108
|
+
const setRef = (key, ref) => {
|
|
109
|
+
refs.current = {
|
|
110
|
+
...refs.current,
|
|
111
|
+
[key]: ref
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
setRef,
|
|
116
|
+
refs
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
exports.useScreenRefs = useScreenRefs;
|
|
120
|
+
//# sourceMappingURL=TopTab.hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_native","require","_TopTabContext","_react","_reactNativeReanimated","_reactNativeSafeAreaContext","_reactNative","useTabContext","useContext","Context","exports","useScreenGesture","key","useRoute","screenProperties","nativeRef","nativeGesture","useScreenScrollable","height","useWindowDimensions","bottom","useSafeAreaInsets","currentYPosition","gestureEnabled","headerHeight","topTabHeight","transformationY","navigationHeader","animatedProps","useAnimatedProps","scrollEnabled","value","onScroll","useAnimatedScrollHandler","contentOffset","scrollPosition","scrollY","y","oppositeHeaderState","useDerivedValue","style","useAnimatedStyle","minHeight","bounces","contentContainerStyle","paddingBottom","useScreenProperties","screen","useHeader","transformationX","hideHeader","withTiming","useScreenRefs","keys","refs","current","reduce","prev","setRef","ref"],"sourceRoot":"../../../src","sources":["hooks/TopTab.hooks.ts"],"mappings":";;;;;;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AAGA,CAAA,KAAM;IACvBD,eAAe,CAAClB,KAAK,GAAG,IAAAoB,iCAAU,EAAC,CAAC3B,YAAY,CAACO,KAAK,CAAC;EACzD,CAAC;EAED,OAAO;IAAEmB;EAAW,CAAC;AACvB,CAAC;AAACxC,OAAA,CAAAsC,SAAA,GAAAA,SAAA;AAEK,MAAMI,aAAa,GAAIC,IAAc,IAAK;EAC/C,MAAMC,IAAI,GAAG;IACXC,OAAO,EAAEF,IAAI,CAACG,MAAM,CAClB,CAACC,IAAI,EAAE7C,GAAG,MAAM;MACd,GAAG6C,IAAI;MACP,CAAC7C,GAAG,GAAG;QAAE2C,OAAO,EAAE;MAAK;IACzB,CAAC,CAAC,EACF,CAAC,CACH;EACF,CAAC;EAED,MAAMG,MAAM,GAAGA,CAAC9C,GAAW,EAAE+C,GAAQ,KAAK;IACxCL,IAAI,CAACC,OAAO,GAAG;MAAE,GAAGD,IAAI,CAACC,OAAO;MAAE,CAAC3C,GAAG,GAAG+C;IAAI,CAAC;EAChD,CAAC;EAED,OAAO;IAAED,MAAM;IAAEJ;EAAK,CAAC;AACzB,CAAC;AAAC5C,OAAA,CAAA0C,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Context", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _TopTabContext.Context;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "GestureWrapper", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _GestureWrapper.GestureWrapper;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "Provider", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _TopTabContext.Provider;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "ScreenWrapper", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _ScreenWrapper.ScreenWrapper;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "ScrollView", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _ScrollView.ScrollView;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "TabBarBaseComponent", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _TabBarBaseComponent.TabBarBaseComponent;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "TabBarLabelBaseComponent", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _TabBarLabelBaseComponent.TabBarLabelBaseComponent;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "createReanimatedTopTabNavigator", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _createReanimatedTopTabNavigator.createReanimatedTopTabNavigator;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "useHeader", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _TopTabHooks.useHeader;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "useScreenGesture", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _TopTabHooks.useScreenGesture;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "useScreenProperties", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _TopTabHooks.useScreenProperties;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "useScreenScrollable", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () {
|
|
75
|
+
return _TopTabHooks.useScreenScrollable;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "useTabContext", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function () {
|
|
81
|
+
return _TopTabHooks.useTabContext;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
var _TopTabContext = require("./context/TopTabContext.js");
|
|
85
|
+
var _createReanimatedTopTabNavigator = require("./navigator/createReanimatedTopTabNavigator.js");
|
|
86
|
+
var _ScrollView = require("./components/wrappers/ScrollView.js");
|
|
87
|
+
var _ScreenWrapper = require("./components/wrappers/ScreenWrapper.js");
|
|
88
|
+
var _GestureWrapper = require("./components/wrappers/GestureWrapper.js");
|
|
89
|
+
var _TabBarBaseComponent = require("./components/elements/TabBarBaseComponent.js");
|
|
90
|
+
var _TabBarLabelBaseComponent = require("./components/elements/TabBarLabelBaseComponent.js");
|
|
91
|
+
var _TopTabHooks = require("./hooks/TopTab.hooks.js");
|
|
92
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_TopTabContext","require","_createReanimatedTopTabNavigator","_ScrollView","_ScreenWrapper","_GestureWrapper","_TabBarBaseComponent","_TabBarLabelBaseComponent","_TopTabHooks"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,gCAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AACA,IAAAM,yBAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createReanimatedTopTabNavigator = void 0;
|
|
7
|
+
var _native = require("@react-navigation/native");
|
|
8
|
+
var _GestureWrapper = require("../components/wrappers/GestureWrapper.js");
|
|
9
|
+
var _TabBarBaseComponent = require("../components/elements/TabBarBaseComponent.js");
|
|
10
|
+
var _TopTabContext = require("../context/TopTabContext.js");
|
|
11
|
+
var _lodash = require("lodash");
|
|
12
|
+
var _react = require("react");
|
|
13
|
+
var _reactNativeGestureHandler = require("react-native-gesture-handler");
|
|
14
|
+
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
15
|
+
var _ReanimatedTabView = require("../components/ReanimatedTopTab/ReanimatedTabView.js");
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
|
+
const TabViewNavigator = ({
|
|
20
|
+
HeaderComponent,
|
|
21
|
+
TabBarComponent = _TabBarBaseComponent.TabBarBaseComponent,
|
|
22
|
+
children,
|
|
23
|
+
config,
|
|
24
|
+
initialRouteName,
|
|
25
|
+
screenOptions = {}
|
|
26
|
+
}) => {
|
|
27
|
+
const {
|
|
28
|
+
NavigationContent,
|
|
29
|
+
descriptors,
|
|
30
|
+
navigation,
|
|
31
|
+
state
|
|
32
|
+
} = (0, _native.useNavigationBuilder)(_native.TabRouter, {
|
|
33
|
+
children,
|
|
34
|
+
defaultScreenOptions: screenOptions,
|
|
35
|
+
initialRouteName,
|
|
36
|
+
screenOptions
|
|
37
|
+
});
|
|
38
|
+
let _config = config;
|
|
39
|
+
if (!config) {
|
|
40
|
+
_config = state.routes.map(() => 'normal');
|
|
41
|
+
}
|
|
42
|
+
const screenProperties = (0, _react.useRef)(state.routes.reduce((prev, route) => ({
|
|
43
|
+
...prev,
|
|
44
|
+
[route.key]: {
|
|
45
|
+
innerLayout: (0, _reactNativeReanimated.makeMutable)({
|
|
46
|
+
height: 0,
|
|
47
|
+
width: 0,
|
|
48
|
+
x: 0,
|
|
49
|
+
y: 0
|
|
50
|
+
}),
|
|
51
|
+
nativeGesture: _reactNativeGestureHandler.Gesture.Native(),
|
|
52
|
+
outerLayout: (0, _reactNativeReanimated.makeMutable)({
|
|
53
|
+
height: 0,
|
|
54
|
+
width: 0,
|
|
55
|
+
x: 0,
|
|
56
|
+
y: 0
|
|
57
|
+
}),
|
|
58
|
+
scrollY: (0, _reactNativeReanimated.makeMutable)(0)
|
|
59
|
+
}
|
|
60
|
+
}), {})).current;
|
|
61
|
+
const onIndexChange = (currentScreenIndex, gestureEnabled) => index => {
|
|
62
|
+
navigation.navigate(state.routes[index]?.name ?? '');
|
|
63
|
+
currentScreenIndex.value = index;
|
|
64
|
+
switch (_config[index]) {
|
|
65
|
+
case 'normal':
|
|
66
|
+
{
|
|
67
|
+
gestureEnabled.value = true;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
case 'minimalized':
|
|
71
|
+
{
|
|
72
|
+
gestureEnabled.value = false;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const navigationState = (0, _react.useMemo)(() => ({
|
|
78
|
+
index: state.index,
|
|
79
|
+
routes: state.routes.map((route, index) => {
|
|
80
|
+
const restOptions = (0, _lodash.omit)(descriptors[route.key]?.options, 'tabBarLabel');
|
|
81
|
+
const tabBarLabel = descriptors[route.key]?.options.tabBarLabel ? () => descriptors[route.key]?.options.tabBarLabel?.({
|
|
82
|
+
focused: state.index === index,
|
|
83
|
+
title: descriptors[route.key]?.options.title || route.name,
|
|
84
|
+
index
|
|
85
|
+
}) : undefined;
|
|
86
|
+
return {
|
|
87
|
+
...route,
|
|
88
|
+
...restOptions,
|
|
89
|
+
tabBarLabel,
|
|
90
|
+
title: descriptors[route.key]?.options.title || route.name
|
|
91
|
+
};
|
|
92
|
+
})
|
|
93
|
+
}), [state]);
|
|
94
|
+
const navigate = route => {
|
|
95
|
+
navigation.dispatch({
|
|
96
|
+
..._native.TabActions.jumpTo(route.name, route.params),
|
|
97
|
+
target: state.key
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
const renderTabBar = (0, _react.useCallback)(props => /*#__PURE__*/(0, _jsxRuntime.jsx)(TabBarComponent, {
|
|
101
|
+
...props,
|
|
102
|
+
navigate: navigate
|
|
103
|
+
}), []);
|
|
104
|
+
const renderScene = ({
|
|
105
|
+
route
|
|
106
|
+
}) => descriptors[route.key]?.render();
|
|
107
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_TopTabContext.Provider, {
|
|
108
|
+
config: _config,
|
|
109
|
+
screenProperties: screenProperties,
|
|
110
|
+
children: ({
|
|
111
|
+
currentScreenIndex,
|
|
112
|
+
gestureEnabled,
|
|
113
|
+
headerHeight,
|
|
114
|
+
transformationY
|
|
115
|
+
}) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
116
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
|
|
117
|
+
onLayout: ({
|
|
118
|
+
nativeEvent
|
|
119
|
+
}) => {
|
|
120
|
+
headerHeight.value = nativeEvent.layout.height;
|
|
121
|
+
},
|
|
122
|
+
children: HeaderComponent ? /*#__PURE__*/(0, _jsxRuntime.jsx)(HeaderComponent, {
|
|
123
|
+
headerHeight: headerHeight,
|
|
124
|
+
transformationY: transformationY
|
|
125
|
+
}) : null
|
|
126
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(NavigationContent, {
|
|
127
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_GestureWrapper.GestureWrapper, {
|
|
128
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ReanimatedTabView.ReanimatedTabView, {
|
|
129
|
+
navigationState: navigationState,
|
|
130
|
+
onIndexChange: onIndexChange(currentScreenIndex, gestureEnabled),
|
|
131
|
+
renderScene: renderScene,
|
|
132
|
+
renderTabBar: renderTabBar
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
})]
|
|
136
|
+
})
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
const createReanimatedTopTabNavigator = () => (0, _native.createNavigatorFactory)(TabViewNavigator)();
|
|
140
|
+
exports.createReanimatedTopTabNavigator = createReanimatedTopTabNavigator;
|
|
141
|
+
//# sourceMappingURL=createReanimatedTopTabNavigator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_native","require","_GestureWrapper","_TabBarBaseComponent","_TopTabContext","_lodash","_react","_reactNativeGestureHandler","_reactNativeReanimated","_interopRequireWildcard","_ReanimatedTabView","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","TabViewNavigator","HeaderComponent","TabBarComponent","TabBarBaseComponent","children","config","initialRouteName","screenOptions","NavigationContent","descriptors","navigation","state","useNavigationBuilder","TabRouter","defaultScreenOptions","_config","routes","map","screenProperties","useRef","reduce","prev","route","key","innerLayout","makeMutable","height","width","x","y","nativeGesture","Gesture","Native","outerLayout","scrollY","current","onIndexChange","currentScreenIndex","gestureEnabled","index","navigate","name","value","navigationState","useMemo","restOptions","omit","options","tabBarLabel","focused","title","undefined","dispatch","TabActions","jumpTo","params","target","renderTabBar","useCallback","props","jsx","renderScene","render","Provider","headerHeight","transformationY","jsxs","Fragment","View","onLayout","nativeEvent","layout","GestureWrapper","ReanimatedTabView","createReanimatedTopTabNavigator","createNavigatorFactory","exports"],"sourceRoot":"../../../src","sources":["navigator/createReanimatedTopTabNavigator.tsx"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AASA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AAIA,IAAAG,cAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,0BAAA,GAAAN,OAAA;AACA,IAAAO,sBAAA,GAAAC,uBAAA,CAAAR,OAAA;AAKA,IAAAS,kBAAA,GAAAT,OAAA;AAAqF,IAAAU,WAAA,GAAAV,OAAA;AAAA,SAAAW,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OA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ts"],"mappings":";;;;;;IAQiBA,0BAA0B,GAAAC,OAAA,CAAAD,0BAAA","ignoreList":[]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { withTiming as reanimatedWithTiming } from 'react-native-reanimated';
|
|
4
|
+
const onChange = (event, animationValue, width, navigationState) => {
|
|
5
|
+
'worklet';
|
|
6
|
+
|
|
7
|
+
if (animationValue > 0) {
|
|
8
|
+
return 0;
|
|
9
|
+
}
|
|
10
|
+
const routesLength = navigationState.routes.length - 1;
|
|
11
|
+
if (animationValue < -width * routesLength) {
|
|
12
|
+
return -width * routesLength;
|
|
13
|
+
}
|
|
14
|
+
return animationValue + event.changeX;
|
|
15
|
+
};
|
|
16
|
+
const getIndex = (navigationState, type) => {
|
|
17
|
+
'worklet';
|
|
18
|
+
|
|
19
|
+
if (type === 'increment') {
|
|
20
|
+
return navigationState.index === navigationState.routes.length - 1 ? navigationState.index : navigationState.index + 1;
|
|
21
|
+
}
|
|
22
|
+
return navigationState.index === 0 ? navigationState.index : navigationState.index - 1;
|
|
23
|
+
};
|
|
24
|
+
const onEnd = (event, minimumValueToChangeView, width, navigationState) => {
|
|
25
|
+
'worklet';
|
|
26
|
+
|
|
27
|
+
if (event.velocityX < -200) {
|
|
28
|
+
return {
|
|
29
|
+
index: getIndex(navigationState, 'increment'),
|
|
30
|
+
value: -width * (navigationState.index + 1)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (event.velocityX > 200) {
|
|
34
|
+
return {
|
|
35
|
+
index: getIndex(navigationState, 'decrement'),
|
|
36
|
+
value: -width * (navigationState.index - 1)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (event.translationX < 0) {
|
|
40
|
+
if (event.translationX < -minimumValueToChangeView) {
|
|
41
|
+
return {
|
|
42
|
+
index: getIndex(navigationState, 'increment'),
|
|
43
|
+
value: -width * (navigationState.index + 1)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (event.translationX > 0) {
|
|
48
|
+
if (event.translationX > minimumValueToChangeView) {
|
|
49
|
+
return {
|
|
50
|
+
index: getIndex(navigationState, 'decrement'),
|
|
51
|
+
value: -width * (navigationState.index - 1)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
index: navigationState.index,
|
|
57
|
+
value: -width * navigationState.index
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
const animation = (newValue, duration = 200) => {
|
|
61
|
+
'worklet';
|
|
62
|
+
|
|
63
|
+
return reanimatedWithTiming(newValue, {
|
|
64
|
+
duration
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
export const AnimationHelper = {
|
|
68
|
+
animation,
|
|
69
|
+
onChange,
|
|
70
|
+
onEnd
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=AnimationHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["withTiming","reanimatedWithTiming","onChange","event","animationValue","width","navigationState","routesLength","routes","length","changeX","getIndex","type","index","onEnd","minimumValueToChangeView","velocityX","value","translationX","animation","newValue","duration","AnimationHelper"],"sourceRoot":"../../../../src","sources":["components/ReanimatedTopTab/AnimationHelper.ts"],"mappings":";;AAMA,SAASA,UAAU,IAAIC,oBAAoB,QAAQ,yBAAyB;AAG5E,MAAMC,QAAQ,GAAGA,CACfC,KAEC,EACDC,cAAsB,EACtBC,KAAa,EACbC,eAAuD,KACpD;EACH,SAAS;;EACT,IAAIF,cAAc,GAAG,CAAC,EAAE;IACtB,OAAO,CAAC;EACV;EACA,MAAMG,YAAY,GAAGD,eAAe,CAACE,MAAM,CAACC,MAAM,GAAG,CAAC;EACtD,IAAIL,cAAc,GAAG,CAACC,KAAK,GAAGE,YAAY,EAAE;IAC1C,OAAO,CAACF,KAAK,GAAGE,YAAY;EAC9B;EACA,OAAOH,cAAc,GAAGD,KAAK,CAACO,OAAO;AAC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