react-native-tab-view 3.1.1 → 3.2.1
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/README.md +13 -1
- package/lib/commonjs/Pager.android.js.map +1 -1
- package/lib/commonjs/Pager.ios.js.map +1 -1
- package/lib/commonjs/Pager.js.map +1 -1
- package/lib/commonjs/PagerViewAdapter.js +40 -22
- package/lib/commonjs/PagerViewAdapter.js.map +1 -1
- package/lib/commonjs/PanResponderAdapter.js +41 -29
- package/lib/commonjs/PanResponderAdapter.js.map +1 -1
- package/lib/commonjs/PlatformPressable.js +19 -15
- package/lib/commonjs/PlatformPressable.js.map +1 -1
- package/lib/commonjs/SceneMap.js +14 -11
- package/lib/commonjs/SceneMap.js.map +1 -1
- package/lib/commonjs/SceneView.js +2 -2
- package/lib/commonjs/SceneView.js.map +1 -1
- package/lib/commonjs/TabBar.js +124 -81
- package/lib/commonjs/TabBar.js.map +1 -1
- package/lib/commonjs/TabBarIndicator.js +7 -6
- package/lib/commonjs/TabBarIndicator.js.map +1 -1
- package/lib/commonjs/TabBarItem.js +7 -6
- package/lib/commonjs/TabBarItem.js.map +1 -1
- package/lib/commonjs/TabView.js +42 -33
- package/lib/commonjs/TabView.js.map +1 -1
- package/lib/commonjs/index.js +6 -6
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js +4 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/useAnimatedValue.js.map +1 -1
- package/lib/module/Pager.android.js.map +1 -1
- package/lib/module/Pager.ios.js.map +1 -1
- package/lib/module/Pager.js.map +1 -1
- package/lib/module/PagerViewAdapter.js +40 -22
- package/lib/module/PagerViewAdapter.js.map +1 -1
- package/lib/module/PanResponderAdapter.js +41 -28
- package/lib/module/PanResponderAdapter.js.map +1 -1
- package/lib/module/PlatformPressable.js +19 -15
- package/lib/module/PlatformPressable.js.map +1 -1
- package/lib/module/SceneMap.js +14 -11
- package/lib/module/SceneMap.js.map +1 -1
- package/lib/module/SceneView.js +2 -2
- package/lib/module/SceneView.js.map +1 -1
- package/lib/module/TabBar.js +125 -81
- package/lib/module/TabBar.js.map +1 -1
- package/lib/module/TabBarIndicator.js +7 -6
- package/lib/module/TabBarIndicator.js.map +1 -1
- package/lib/module/TabBarItem.js +7 -6
- package/lib/module/TabBarItem.js.map +1 -1
- package/lib/module/TabView.js +41 -32
- package/lib/module/TabView.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/useAnimatedValue.js.map +1 -1
- package/lib/typescript/PagerViewAdapter.d.ts +1 -1
- package/lib/typescript/PanResponderAdapter.d.ts +1 -1
- package/lib/typescript/TabBar.d.ts +3 -1
- package/lib/typescript/TabBarIndicator.d.ts +1 -0
- package/lib/typescript/TabView.d.ts +2 -1
- package/lib/typescript/types.d.ts +1 -0
- package/package.json +19 -18
- package/src/PagerViewAdapter.tsx +23 -9
- package/src/PanResponderAdapter.tsx +23 -17
- package/src/TabBar.tsx +75 -31
- package/src/TabBarIndicator.tsx +14 -5
- package/src/TabView.tsx +5 -0
- package/src/types.tsx +1 -0
package/README.md
CHANGED
|
@@ -308,6 +308,10 @@ String indicating whether the keyboard gets dismissed in response to a drag gest
|
|
|
308
308
|
|
|
309
309
|
Boolean indicating whether to enable swipe gestures. Swipe gestures are enabled by default. Passing `false` will disable swipe gestures, but the user can still switch tabs by pressing the tab bar.
|
|
310
310
|
|
|
311
|
+
#### `animationEnabled`
|
|
312
|
+
|
|
313
|
+
Enables animation when changing tab. By default it's true.
|
|
314
|
+
|
|
311
315
|
##### `onSwipeStart`
|
|
312
316
|
|
|
313
317
|
Callback which is called when the swipe gesture starts, i.e. the user touches the screen and moves it.
|
|
@@ -331,6 +335,10 @@ Object containing the initial height and width of the screens. Passing this will
|
|
|
331
335
|
|
|
332
336
|
Style to apply to the view wrapping each screen. You can pass this to override some default styles such as overflow clipping:
|
|
333
337
|
|
|
338
|
+
##### `pagerStyle`
|
|
339
|
+
|
|
340
|
+
Style to apply to the pager view wrapping all the scenes.
|
|
341
|
+
|
|
334
342
|
##### `style`
|
|
335
343
|
|
|
336
344
|
Style to apply to the tab view container.
|
|
@@ -408,7 +416,7 @@ Function which takes an object with the current route, focused status and color
|
|
|
408
416
|
<TabBar
|
|
409
417
|
renderIcon={({ route, focused, color }) => (
|
|
410
418
|
<Icon
|
|
411
|
-
name={focused ? '
|
|
419
|
+
name={focused ? 'albums' : 'albums-outlined'}
|
|
412
420
|
color={color}
|
|
413
421
|
/>
|
|
414
422
|
)}
|
|
@@ -518,6 +526,10 @@ Style to apply to the inner container for tabs.
|
|
|
518
526
|
|
|
519
527
|
Style to apply to the tab bar container.
|
|
520
528
|
|
|
529
|
+
### `gap`
|
|
530
|
+
|
|
531
|
+
Define a spacing between tabs.
|
|
532
|
+
|
|
521
533
|
## Using with other libraries
|
|
522
534
|
|
|
523
535
|
### [React Navigation](https://github.com/react-navigation/react-navigation)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Pager.android.tsx"],"
|
|
1
|
+
{"version":3,"names":[],"sources":["Pager.android.tsx"],"sourcesContent":["export { default } from './PagerViewAdapter';\n"],"mappings":";;;;;;;;;;;;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Pager.ios.tsx"],"
|
|
1
|
+
{"version":3,"names":[],"sources":["Pager.ios.tsx"],"sourcesContent":["export { default } from './PagerViewAdapter';\n"],"mappings":";;;;;;;;;;;;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":[],"sources":["Pager.tsx"],"sourcesContent":["export { default } from './PanResponderAdapter';\n"],"mappings":";;;;;;;;;;;;AAAA"}
|
|
@@ -19,21 +19,23 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
19
19
|
|
|
20
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
21
|
|
|
22
|
-
function _extends() { _extends = Object.assign
|
|
22
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
23
23
|
|
|
24
24
|
const AnimatedViewPager = _reactNative.Animated.createAnimatedComponent(_reactNativePagerView.default);
|
|
25
25
|
|
|
26
|
-
function PagerViewAdapter({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
function PagerViewAdapter(_ref) {
|
|
27
|
+
let {
|
|
28
|
+
keyboardDismissMode = 'auto',
|
|
29
|
+
swipeEnabled = true,
|
|
30
|
+
navigationState,
|
|
31
|
+
onIndexChange,
|
|
32
|
+
onSwipeStart,
|
|
33
|
+
onSwipeEnd,
|
|
34
|
+
children,
|
|
35
|
+
style,
|
|
36
|
+
animationEnabled,
|
|
37
|
+
...rest
|
|
38
|
+
} = _ref;
|
|
37
39
|
const {
|
|
38
40
|
index
|
|
39
41
|
} = navigationState;
|
|
@@ -47,22 +49,37 @@ function PagerViewAdapter({
|
|
|
47
49
|
navigationStateRef.current = navigationState;
|
|
48
50
|
});
|
|
49
51
|
const jumpTo = React.useCallback(key => {
|
|
50
|
-
var _pagerRef$current;
|
|
51
|
-
|
|
52
52
|
const index = navigationStateRef.current.routes.findIndex(route => route.key === key);
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
|
|
54
|
+
if (animationEnabled) {
|
|
55
|
+
var _pagerRef$current;
|
|
56
|
+
|
|
57
|
+
(_pagerRef$current = pagerRef.current) === null || _pagerRef$current === void 0 ? void 0 : _pagerRef$current.setPage(index);
|
|
58
|
+
} else {
|
|
59
|
+
var _pagerRef$current2;
|
|
60
|
+
|
|
61
|
+
(_pagerRef$current2 = pagerRef.current) === null || _pagerRef$current2 === void 0 ? void 0 : _pagerRef$current2.setPageWithoutAnimation(index);
|
|
62
|
+
position.setValue(index);
|
|
63
|
+
}
|
|
64
|
+
}, [animationEnabled, position]);
|
|
55
65
|
React.useEffect(() => {
|
|
56
66
|
if (keyboardDismissMode === 'auto') {
|
|
57
67
|
_reactNative.Keyboard.dismiss();
|
|
58
68
|
}
|
|
59
69
|
|
|
60
70
|
if (indexRef.current !== index) {
|
|
61
|
-
|
|
71
|
+
if (animationEnabled) {
|
|
72
|
+
var _pagerRef$current3;
|
|
62
73
|
|
|
63
|
-
|
|
74
|
+
(_pagerRef$current3 = pagerRef.current) === null || _pagerRef$current3 === void 0 ? void 0 : _pagerRef$current3.setPage(index);
|
|
75
|
+
} else {
|
|
76
|
+
var _pagerRef$current4;
|
|
77
|
+
|
|
78
|
+
(_pagerRef$current4 = pagerRef.current) === null || _pagerRef$current4 === void 0 ? void 0 : _pagerRef$current4.setPageWithoutAnimation(index);
|
|
79
|
+
position.setValue(index);
|
|
80
|
+
}
|
|
64
81
|
}
|
|
65
|
-
}, [keyboardDismissMode, index]);
|
|
82
|
+
}, [keyboardDismissMode, index, animationEnabled, position]);
|
|
66
83
|
|
|
67
84
|
const onPageScrollStateChanged = state => {
|
|
68
85
|
const {
|
|
@@ -76,9 +93,10 @@ function PagerViewAdapter({
|
|
|
76
93
|
|
|
77
94
|
case 'dragging':
|
|
78
95
|
{
|
|
79
|
-
const subscription = offset.addListener(
|
|
80
|
-
|
|
81
|
-
|
|
96
|
+
const subscription = offset.addListener(_ref2 => {
|
|
97
|
+
let {
|
|
98
|
+
value
|
|
99
|
+
} = _ref2;
|
|
82
100
|
const next = index + (value > 0 ? Math.ceil(value) : Math.floor(value));
|
|
83
101
|
|
|
84
102
|
if (next !== index) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["AnimatedViewPager","Animated","createAnimatedComponent","ViewPager","PagerViewAdapter","keyboardDismissMode","swipeEnabled","navigationState","onIndexChange","onSwipeStart","onSwipeEnd","children","style","animationEnabled","rest","index","listenersRef","React","useRef","pagerRef","indexRef","navigationStateRef","position","useAnimatedValue","offset","useEffect","current","jumpTo","useCallback","key","routes","findIndex","route","setPage","setPageWithoutAnimation","setValue","Keyboard","dismiss","onPageScrollStateChanged","state","pageScrollState","nativeEvent","subscription","addListener","value","next","Math","ceil","floor","forEach","listener","removeListener","addEnterListener","push","indexOf","splice","add","render","styles","container","event","useNativeDriver","e","StyleSheet","create","flex"],"sources":["PagerViewAdapter.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Animated, Keyboard, StyleSheet } from 'react-native';\nimport ViewPager, {\n PageScrollStateChangedNativeEvent,\n} from 'react-native-pager-view';\nimport useAnimatedValue from './useAnimatedValue';\nimport type {\n NavigationState,\n Route,\n Listener,\n EventEmitterProps,\n PagerProps,\n} from './types';\n\nconst AnimatedViewPager = Animated.createAnimatedComponent(ViewPager);\n\ntype Props<T extends Route> = PagerProps & {\n onIndexChange: (index: number) => void;\n navigationState: NavigationState<T>;\n children: (\n props: EventEmitterProps & {\n // Animated value which represents the state of current index\n // It can include fractional digits as it represents the intermediate value\n position: Animated.AnimatedInterpolation;\n // Function to actually render the content of the pager\n // The parent component takes care of rendering\n render: (children: React.ReactNode) => React.ReactNode;\n // Callback to call when switching the tab\n // The tab switch animation is performed even if the index in state is unchanged\n jumpTo: (key: string) => void;\n }\n ) => React.ReactElement;\n};\n\nexport default function PagerViewAdapter<T extends Route>({\n keyboardDismissMode = 'auto',\n swipeEnabled = true,\n navigationState,\n onIndexChange,\n onSwipeStart,\n onSwipeEnd,\n children,\n style,\n animationEnabled,\n ...rest\n}: Props<T>) {\n const { index } = navigationState;\n\n const listenersRef = React.useRef<Listener[]>([]);\n\n const pagerRef = React.useRef<ViewPager>();\n const indexRef = React.useRef<number>(index);\n const navigationStateRef = React.useRef(navigationState);\n\n const position = useAnimatedValue(index);\n const offset = useAnimatedValue(0);\n\n React.useEffect(() => {\n navigationStateRef.current = navigationState;\n });\n\n const jumpTo = React.useCallback(\n (key: string) => {\n const index = navigationStateRef.current.routes.findIndex(\n (route: { key: string }) => route.key === key\n );\n\n if (animationEnabled) {\n pagerRef.current?.setPage(index);\n } else {\n pagerRef.current?.setPageWithoutAnimation(index);\n position.setValue(index);\n }\n },\n [animationEnabled, position]\n );\n\n React.useEffect(() => {\n if (keyboardDismissMode === 'auto') {\n Keyboard.dismiss();\n }\n\n if (indexRef.current !== index) {\n if (animationEnabled) {\n pagerRef.current?.setPage(index);\n } else {\n pagerRef.current?.setPageWithoutAnimation(index);\n position.setValue(index);\n }\n }\n }, [keyboardDismissMode, index, animationEnabled, position]);\n\n const onPageScrollStateChanged = (\n state: PageScrollStateChangedNativeEvent\n ) => {\n const { pageScrollState } = state.nativeEvent;\n\n switch (pageScrollState) {\n case 'idle':\n onSwipeEnd?.();\n return;\n case 'dragging': {\n const subscription = offset.addListener(({ value }) => {\n const next =\n index + (value > 0 ? Math.ceil(value) : Math.floor(value));\n\n if (next !== index) {\n listenersRef.current.forEach((listener) => listener(next));\n }\n\n offset.removeListener(subscription);\n });\n\n onSwipeStart?.();\n return;\n }\n }\n };\n\n const addEnterListener = React.useCallback((listener: Listener) => {\n listenersRef.current.push(listener);\n\n return () => {\n const index = listenersRef.current.indexOf(listener);\n\n if (index > -1) {\n listenersRef.current.splice(index, 1);\n }\n };\n }, []);\n\n return children({\n position: Animated.add(position, offset),\n addEnterListener,\n jumpTo,\n render: (children) => (\n <AnimatedViewPager\n {...rest}\n ref={pagerRef}\n style={[styles.container, style]}\n initialPage={index}\n keyboardDismissMode={\n keyboardDismissMode === 'auto' ? 'on-drag' : keyboardDismissMode\n }\n onPageScroll={Animated.event(\n [\n {\n nativeEvent: {\n position: position,\n offset: offset,\n },\n },\n ],\n { useNativeDriver: true }\n )}\n onPageSelected={(e) => {\n const index = e.nativeEvent.position;\n indexRef.current = index;\n onIndexChange(index);\n }}\n onPageScrollStateChanged={onPageScrollStateChanged}\n scrollEnabled={swipeEnabled}\n >\n {children}\n </AnimatedViewPager>\n ),\n });\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n});\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAGA;;;;;;;;;;AASA,MAAMA,iBAAiB,GAAGC,qBAAA,CAASC,uBAAT,CAAiCC,6BAAjC,CAA1B;;AAoBe,SAASC,gBAAT,OAWF;EAAA,IAX6C;IACxDC,mBAAmB,GAAG,MADkC;IAExDC,YAAY,GAAG,IAFyC;IAGxDC,eAHwD;IAIxDC,aAJwD;IAKxDC,YALwD;IAMxDC,UANwD;IAOxDC,QAPwD;IAQxDC,KARwD;IASxDC,gBATwD;IAUxD,GAAGC;EAVqD,CAW7C;EACX,MAAM;IAAEC;EAAF,IAAYR,eAAlB;EAEA,MAAMS,YAAY,GAAGC,KAAK,CAACC,MAAN,CAAyB,EAAzB,CAArB;EAEA,MAAMC,QAAQ,GAAGF,KAAK,CAACC,MAAN,EAAjB;EACA,MAAME,QAAQ,GAAGH,KAAK,CAACC,MAAN,CAAqBH,KAArB,CAAjB;EACA,MAAMM,kBAAkB,GAAGJ,KAAK,CAACC,MAAN,CAAaX,eAAb,CAA3B;EAEA,MAAMe,QAAQ,GAAG,IAAAC,yBAAA,EAAiBR,KAAj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B,MAAM,EAAG9C,QAAD,iBACN,oBAAC,iBAAD,eACMG,IADN;MAEE,GAAG,EAAEK,QAFP;MAGE,KAAK,EAAE,CAACuC,MAAM,CAACC,SAAR,EAAmB/C,KAAnB,CAHT;MAIE,WAAW,EAAEG,KAJf;MAKE,mBAAmB,EACjBV,mBAAmB,KAAK,MAAxB,GAAiC,SAAjC,GAA6CA,mBANjD;MAQE,YAAY,EAAEJ,qBAAA,CAAS2D,KAAT,CACZ,CACE;QACEnB,WAAW,EAAE;UACXnB,QAAQ,EAAEA,QADC;UAEXE,MAAM,EAAEA;QAFG;MADf,CADF,CADY,EASZ;QAAEqC,eAAe,EAAE;MAAnB,CATY,CARhB;MAmBE,cAAc,EAAGC,CAAD,IAAO;QACrB,MAAM/C,KAAK,GAAG+C,CAAC,CAACrB,WAAF,CAAcnB,QAA5B;QACAF,QAAQ,CAACM,OAAT,GAAmBX,KAAnB;QACAP,aAAa,CAACO,KAAD,CAAb;MACD,CAvBH;MAwBE,wBAAwB,EAAEuB,wBAxB5B;MAyBE,aAAa,EAAEhC;IAzBjB,IA2BGK,QA3BH;EALY,CAAD,CAAf;AAoCD;;AAED,MAAM+C,MAAM,GAAGK,uBAAA,CAAWC,MAAX,CAAkB;EAC/BL,SAAS,EAAE;IACTM,IAAI,EAAE;EADG;AADoB,CAAlB,CAAf"}
|
|
@@ -17,7 +17,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
17
17
|
|
|
18
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
19
|
|
|
20
|
-
function _extends() { _extends = Object.assign
|
|
20
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
21
21
|
|
|
22
22
|
const DEAD_ZONE = 12;
|
|
23
23
|
const DefaultTransitionSpec = {
|
|
@@ -28,17 +28,19 @@ const DefaultTransitionSpec = {
|
|
|
28
28
|
overshootClamping: true
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
function PanResponderAdapter({
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
function PanResponderAdapter(_ref) {
|
|
32
|
+
let {
|
|
33
|
+
layout,
|
|
34
|
+
keyboardDismissMode = 'auto',
|
|
35
|
+
swipeEnabled = true,
|
|
36
|
+
navigationState,
|
|
37
|
+
onIndexChange,
|
|
38
|
+
onSwipeStart,
|
|
39
|
+
onSwipeEnd,
|
|
40
|
+
children,
|
|
41
|
+
style,
|
|
42
|
+
animationEnabled = false
|
|
43
|
+
} = _ref;
|
|
42
44
|
const {
|
|
43
45
|
routes,
|
|
44
46
|
index
|
|
@@ -52,27 +54,36 @@ function PanResponderAdapter({
|
|
|
52
54
|
const pendingIndexRef = React.useRef();
|
|
53
55
|
const swipeVelocityThreshold = 0.15;
|
|
54
56
|
const swipeDistanceThreshold = layout.width / 1.75;
|
|
55
|
-
const jumpToIndex = React.useCallback(index
|
|
57
|
+
const jumpToIndex = React.useCallback(function (index) {
|
|
58
|
+
let animate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : animationEnabled;
|
|
56
59
|
const offset = -index * layoutRef.current.width;
|
|
57
60
|
const {
|
|
58
61
|
timing,
|
|
59
62
|
...transitionConfig
|
|
60
63
|
} = DefaultTransitionSpec;
|
|
61
64
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
65
|
+
if (animate) {
|
|
66
|
+
_reactNative.Animated.parallel([timing(panX, { ...transitionConfig,
|
|
67
|
+
toValue: offset,
|
|
68
|
+
useNativeDriver: false
|
|
69
|
+
})]).start(_ref2 => {
|
|
70
|
+
let {
|
|
71
|
+
finished
|
|
72
|
+
} = _ref2;
|
|
73
|
+
|
|
74
|
+
if (finished) {
|
|
75
|
+
onIndexChangeRef.current(index);
|
|
76
|
+
pendingIndexRef.current = undefined;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
pendingIndexRef.current = index;
|
|
81
|
+
} else {
|
|
82
|
+
panX.setValue(offset);
|
|
83
|
+
onIndexChangeRef.current(index);
|
|
84
|
+
pendingIndexRef.current = undefined;
|
|
85
|
+
}
|
|
86
|
+
}, [animationEnabled, panX]);
|
|
76
87
|
React.useEffect(() => {
|
|
77
88
|
navigationStateRef.current = navigationState;
|
|
78
89
|
layoutRef.current = layout;
|
|
@@ -122,7 +133,8 @@ function PanResponderAdapter({
|
|
|
122
133
|
const diffX = _reactNative.I18nManager.isRTL ? -gestureState.dx : gestureState.dx;
|
|
123
134
|
|
|
124
135
|
if ( // swiping left
|
|
125
|
-
diffX > 0 && index <= 0 ||
|
|
136
|
+
diffX > 0 && index <= 0 || // swiping right
|
|
137
|
+
diffX < 0 && index >= routes.length - 1) {
|
|
126
138
|
return;
|
|
127
139
|
}
|
|
128
140
|
|
|
@@ -154,7 +166,7 @@ function PanResponderAdapter({
|
|
|
154
166
|
nextIndex = currentIndex;
|
|
155
167
|
}
|
|
156
168
|
|
|
157
|
-
jumpToIndex(nextIndex);
|
|
169
|
+
jumpToIndex(nextIndex, true);
|
|
158
170
|
}; // TODO: use the listeners
|
|
159
171
|
|
|
160
172
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["PanResponderAdapter.tsx"],"names":["DEAD_ZONE","DefaultTransitionSpec","timing","Animated","spring","stiffness","damping","mass","overshootClamping","PanResponderAdapter","layout","keyboardDismissMode","swipeEnabled","navigationState","onIndexChange","onSwipeStart","onSwipeEnd","children","style","routes","index","panX","listenersRef","React","useRef","navigationStateRef","layoutRef","onIndexChangeRef","currentIndexRef","pendingIndexRef","swipeVelocityThreshold","swipeDistanceThreshold","width","jumpToIndex","useCallback","offset","current","transitionConfig","parallel","toValue","useNativeDriver","start","finished","undefined","useEffect","setValue","Keyboard","dismiss","isMovingHorizontally","_","gestureState","Math","abs","dx","dy","vx","vy","canMoveScreen","event","diffX","I18nManager","isRTL","length","startGesture","stopAnimation","setOffset","_value","respondToGesture","position","_offset","next","ceil","floor","forEach","listener","finishGesture","flattenOffset","currentIndex","nextIndex","round","min","max","isFinite","addEnterListener","push","indexOf","splice","jumpTo","key","findIndex","route","panResponder","PanResponder","create","onMoveShouldSetPanResponder","onMoveShouldSetPanResponderCapture","onPanResponderGrant","onPanResponderMove","onPanResponderTerminate","onPanResponderRelease","onPanResponderTerminationRequest","maxTranslate","translateX","multiply","interpolate","inputRange","outputRange","extrapolate","divide","Value","render","styles","sheet","transform","panHandlers","Children","map","child","i","focused","StyleSheet","absoluteFill","flex","flexDirection","alignItems"],"mappings":";;;;;;;AAAA;;AACA;;AAUA;;;;;;;;;;AA6BA,MAAMA,SAAS,GAAG,EAAlB;AAEA,MAAMC,qBAAqB,GAAG;AAC5BC,EAAAA,MAAM,EAAEC,sBAASC,MADW;AAE5BC,EAAAA,SAAS,EAAE,IAFiB;AAG5BC,EAA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B,CAHU;AAId+D,IAAAA,gBAJc;AAKdI,IAAAA,MALc;AAMduB,IAAAA,MAAM,EAAG7F,QAAD,iBACN,oBAAC,qBAAD,CAAU,IAAV;AACE,MAAA,KAAK,EAAE,CACL8F,MAAM,CAACC,KADF,EAELtG,MAAM,CAACsB,KAAP,GACI;AACEA,QAAAA,KAAK,EAAEb,MAAM,CAAC2C,MAAP,GAAgBpD,MAAM,CAACsB,KADhC;AAEEiF,QAAAA,SAAS,EAAE,CAAC;AAAEX,UAAAA;AAAF,SAAD;AAFb,OADJ,GAKI,IAPC,EAQLpF,KARK;AADT,OAWMyE,YAAY,CAACuB,WAXnB,GAaG3F,KAAK,CAAC4F,QAAN,CAAeC,GAAf,CAAmBnG,QAAnB,EAA6B,CAACoG,KAAD,EAAQC,CAAR,KAAc;AAC1C,YAAM5B,KAAK,GAAGvE,MAAM,CAACmG,CAAD,CAApB;AACA,YAAMC,OAAO,GAAGD,CAAC,KAAKlG,KAAtB;AAEA,0BACE,oBAAC,iBAAD;AACE,QAAA,GAAG,EAAEsE,KAAK,CAACF,GADb;AAEE,QAAA,KAAK,EACH9E,MAAM,CAACsB,KAAP,GACI;AAAEA,UAAAA,KAAK,EAAEtB,MAAM,CAACsB;AAAhB,SADJ,GAEIuF,OAAO,GACPC,wBAAWC,YADJ,GAEP;AAPR,SAUGF,OAAO,IAAI7G,MAAM,CAACsB,KAAlB,GAA0BqF,KAA1B,GAAkC,IAVrC,CADF;AAcD,KAlBA,CAbH;AAPY,GAAD,CAAf;AA0CD;;AAED,MAAMN,MAAM,GAAGS,wBAAW3B,MAAX,CAAkB;AAC/BmB,EAAAA,KAAK,EAAE;AACLU,IAAAA,IAAI,EAAE,CADD;AAELC,IAAAA,aAAa,EAAE,KAFV;AAGLC,IAAAA,UAAU,EAAE;AAHP;AADwB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport {\n Animated,\n PanResponder,\n Keyboard,\n StyleSheet,\n GestureResponderEvent,\n PanResponderGestureState,\n I18nManager,\n View,\n} from 'react-native';\nimport useAnimatedValue from './useAnimatedValue';\nimport type {\n NavigationState,\n Route,\n Layout,\n EventEmitterProps,\n PagerProps,\n Listener,\n} from './types';\n\ntype Props<T extends Route> = PagerProps & {\n layout: Layout;\n onIndexChange: (index: number) => void;\n navigationState: NavigationState<T>;\n children: (\n props: EventEmitterProps & {\n // Animated value which represents the state of current index\n // It can include fractional digits as it represents the intermediate value\n position: Animated.AnimatedInterpolation;\n // Function to actually render the content of the pager\n // The parent component takes care of rendering\n render: (children: React.ReactNode) => React.ReactNode;\n // Callback to call when switching the tab\n // The tab switch animation is performed even if the index in state is unchanged\n jumpTo: (key: string) => void;\n }\n ) => React.ReactElement;\n};\n\nconst DEAD_ZONE = 12;\n\nconst DefaultTransitionSpec = {\n timing: Animated.spring,\n stiffness: 1000,\n damping: 500,\n mass: 3,\n overshootClamping: true,\n};\n\nexport default function PanResponderAdapter<T extends Route>({\n layout,\n keyboardDismissMode = 'auto',\n swipeEnabled = true,\n navigationState,\n onIndexChange,\n onSwipeStart,\n onSwipeEnd,\n children,\n style,\n}: Props<T>) {\n const { routes, index } = navigationState;\n\n const panX = useAnimatedValue(0);\n\n const listenersRef = React.useRef<Listener[]>([]);\n\n const navigationStateRef = React.useRef(navigationState);\n const layoutRef = React.useRef(layout);\n const onIndexChangeRef = React.useRef(onIndexChange);\n\n const currentIndexRef = React.useRef(index);\n const pendingIndexRef = React.useRef<number>();\n\n const swipeVelocityThreshold = 0.15;\n const swipeDistanceThreshold = layout.width / 1.75;\n\n const jumpToIndex = React.useCallback(\n (index: number) => {\n const offset = -index * layoutRef.current.width;\n\n const { timing, ...transitionConfig } = DefaultTransitionSpec;\n\n Animated.parallel([\n timing(panX, {\n ...transitionConfig,\n toValue: offset,\n useNativeDriver: false,\n }),\n ]).start(({ finished }) => {\n if (finished) {\n onIndexChangeRef.current(index);\n pendingIndexRef.current = undefined;\n }\n });\n\n pendingIndexRef.current = index;\n },\n [panX]\n );\n\n React.useEffect(() => {\n navigationStateRef.current = navigationState;\n layoutRef.current = layout;\n onIndexChangeRef.current = onIndexChange;\n });\n\n React.useEffect(() => {\n const offset = -navigationStateRef.current.index * layout.width;\n\n panX.setValue(offset);\n }, [layout.width, panX]);\n\n React.useEffect(() => {\n if (keyboardDismissMode === 'auto') {\n Keyboard.dismiss();\n }\n\n if (layout.width && currentIndexRef.current !== index) {\n currentIndexRef.current = index;\n jumpToIndex(index);\n }\n }, [jumpToIndex, keyboardDismissMode, layout.width, index]);\n\n const isMovingHorizontally = (\n _: GestureResponderEvent,\n gestureState: PanResponderGestureState\n ) => {\n return (\n Math.abs(gestureState.dx) > Math.abs(gestureState.dy * 2) &&\n Math.abs(gestureState.vx) > Math.abs(gestureState.vy * 2)\n );\n };\n\n const canMoveScreen = (\n event: GestureResponderEvent,\n gestureState: PanResponderGestureState\n ) => {\n if (swipeEnabled === false) {\n return false;\n }\n\n const diffX = I18nManager.isRTL ? -gestureState.dx : gestureState.dx;\n\n return (\n isMovingHorizontally(event, gestureState) &&\n ((diffX >= DEAD_ZONE && currentIndexRef.current > 0) ||\n (diffX <= -DEAD_ZONE && currentIndexRef.current < routes.length - 1))\n );\n };\n\n const startGesture = () => {\n onSwipeStart?.();\n\n if (keyboardDismissMode === 'on-drag') {\n Keyboard.dismiss();\n }\n\n panX.stopAnimation();\n // @ts-expect-error: _value is private, but docs use it as well\n panX.setOffset(panX._value);\n };\n\n const respondToGesture = (\n _: GestureResponderEvent,\n gestureState: PanResponderGestureState\n ) => {\n const diffX = I18nManager.isRTL ? -gestureState.dx : gestureState.dx;\n\n if (\n // swiping left\n (diffX > 0 && index <= 0) ||\n // swiping right\n (diffX < 0 && index >= routes.length - 1)\n ) {\n return;\n }\n\n if (layout.width) {\n // @ts-expect-error: _offset is private, but docs use it as well\n const position = (panX._offset + diffX) / -layout.width;\n const next =\n position > index ? Math.ceil(position) : Math.floor(position);\n\n if (next !== index) {\n listenersRef.current.forEach((listener) => listener(next));\n }\n }\n\n panX.setValue(diffX);\n };\n\n const finishGesture = (\n _: GestureResponderEvent,\n gestureState: PanResponderGestureState\n ) => {\n panX.flattenOffset();\n\n onSwipeEnd?.();\n\n const currentIndex =\n typeof pendingIndexRef.current === 'number'\n ? pendingIndexRef.current\n : currentIndexRef.current;\n\n let nextIndex = currentIndex;\n\n if (\n Math.abs(gestureState.dx) > Math.abs(gestureState.dy) &&\n Math.abs(gestureState.vx) > Math.abs(gestureState.vy) &&\n (Math.abs(gestureState.dx) > swipeDistanceThreshold ||\n Math.abs(gestureState.vx) > swipeVelocityThreshold)\n ) {\n nextIndex = Math.round(\n Math.min(\n Math.max(\n 0,\n I18nManager.isRTL\n ? currentIndex + gestureState.dx / Math.abs(gestureState.dx)\n : currentIndex - gestureState.dx / Math.abs(gestureState.dx)\n ),\n routes.length - 1\n )\n );\n\n currentIndexRef.current = nextIndex;\n }\n\n if (!isFinite(nextIndex)) {\n nextIndex = currentIndex;\n }\n\n jumpToIndex(nextIndex);\n };\n\n // TODO: use the listeners\n const addEnterListener = React.useCallback((listener: Listener) => {\n listenersRef.current.push(listener);\n\n return () => {\n const index = listenersRef.current.indexOf(listener);\n\n if (index > -1) {\n listenersRef.current.splice(index, 1);\n }\n };\n }, []);\n\n const jumpTo = React.useCallback(\n (key: string) => {\n const index = navigationStateRef.current.routes.findIndex(\n (route: { key: string }) => route.key === key\n );\n\n jumpToIndex(index);\n },\n [jumpToIndex]\n );\n\n const panResponder = PanResponder.create({\n onMoveShouldSetPanResponder: canMoveScreen,\n onMoveShouldSetPanResponderCapture: canMoveScreen,\n onPanResponderGrant: startGesture,\n onPanResponderMove: respondToGesture,\n onPanResponderTerminate: finishGesture,\n onPanResponderRelease: finishGesture,\n onPanResponderTerminationRequest: () => true,\n });\n\n const maxTranslate = layout.width * (routes.length - 1);\n const translateX = Animated.multiply(\n panX.interpolate({\n inputRange: [-maxTranslate, 0],\n outputRange: [-maxTranslate, 0],\n extrapolate: 'clamp',\n }),\n I18nManager.isRTL ? -1 : 1\n );\n\n return children({\n position: layout.width\n ? Animated.divide(panX, -layout.width)\n : new Animated.Value(index),\n addEnterListener,\n jumpTo,\n render: (children) => (\n <Animated.View\n style={[\n styles.sheet,\n layout.width\n ? {\n width: routes.length * layout.width,\n transform: [{ translateX }],\n }\n : null,\n style,\n ]}\n {...panResponder.panHandlers}\n >\n {React.Children.map(children, (child, i) => {\n const route = routes[i];\n const focused = i === index;\n\n return (\n <View\n key={route.key}\n style={\n layout.width\n ? { width: layout.width }\n : focused\n ? StyleSheet.absoluteFill\n : null\n }\n >\n {focused || layout.width ? child : null}\n </View>\n );\n })}\n </Animated.View>\n ),\n });\n}\n\nconst styles = StyleSheet.create({\n sheet: {\n flex: 1,\n flexDirection: 'row',\n alignItems: 'stretch',\n },\n});\n"]}
|
|
1
|
+
{"version":3,"names":["DEAD_ZONE","DefaultTransitionSpec","timing","Animated","spring","stiffness","damping","mass","overshootClamping","PanResponderAdapter","layout","keyboardDismissMode","swipeEnabled","navigationState","onIndexChange","onSwipeStart","onSwipeEnd","children","style","animationEnabled","routes","index","panX","useAnimatedValue","listenersRef","React","useRef","navigationStateRef","layoutRef","onIndexChangeRef","currentIndexRef","pendingIndexRef","swipeVelocityThreshold","swipeDistanceThreshold","width","jumpToIndex","useCallback","animate","offset","current","transitionConfig","parallel","toValue","useNativeDriver","start","finished","undefined","setValue","useEffect","Keyboard","dismiss","isMovingHorizontally","_","gestureState","Math","abs","dx","dy","vx","vy","canMoveScreen","event","diffX","I18nManager","isRTL","length","startGesture","stopAnimation","setOffset","_value","respondToGesture","position","_offset","next","ceil","floor","forEach","listener","finishGesture","flattenOffset","currentIndex","nextIndex","round","min","max","isFinite","addEnterListener","push","indexOf","splice","jumpTo","key","findIndex","route","panResponder","PanResponder","create","onMoveShouldSetPanResponder","onMoveShouldSetPanResponderCapture","onPanResponderGrant","onPanResponderMove","onPanResponderTerminate","onPanResponderRelease","onPanResponderTerminationRequest","maxTranslate","translateX","multiply","interpolate","inputRange","outputRange","extrapolate","divide","Value","render","styles","sheet","transform","panHandlers","Children","map","child","i","focused","StyleSheet","absoluteFill","flex","flexDirection","alignItems"],"sources":["PanResponderAdapter.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n Animated,\n PanResponder,\n Keyboard,\n StyleSheet,\n GestureResponderEvent,\n PanResponderGestureState,\n I18nManager,\n View,\n} from 'react-native';\nimport useAnimatedValue from './useAnimatedValue';\nimport type {\n NavigationState,\n Route,\n Layout,\n EventEmitterProps,\n PagerProps,\n Listener,\n} from './types';\n\ntype Props<T extends Route> = PagerProps & {\n layout: Layout;\n onIndexChange: (index: number) => void;\n navigationState: NavigationState<T>;\n children: (\n props: EventEmitterProps & {\n // Animated value which represents the state of current index\n // It can include fractional digits as it represents the intermediate value\n position: Animated.AnimatedInterpolation;\n // Function to actually render the content of the pager\n // The parent component takes care of rendering\n render: (children: React.ReactNode) => React.ReactNode;\n // Callback to call when switching the tab\n // The tab switch animation is performed even if the index in state is unchanged\n jumpTo: (key: string) => void;\n }\n ) => React.ReactElement;\n};\n\nconst DEAD_ZONE = 12;\n\nconst DefaultTransitionSpec = {\n timing: Animated.spring,\n stiffness: 1000,\n damping: 500,\n mass: 3,\n overshootClamping: true,\n};\n\nexport default function PanResponderAdapter<T extends Route>({\n layout,\n keyboardDismissMode = 'auto',\n swipeEnabled = true,\n navigationState,\n onIndexChange,\n onSwipeStart,\n onSwipeEnd,\n children,\n style,\n animationEnabled = false,\n}: Props<T>) {\n const { routes, index } = navigationState;\n\n const panX = useAnimatedValue(0);\n\n const listenersRef = React.useRef<Listener[]>([]);\n\n const navigationStateRef = React.useRef(navigationState);\n const layoutRef = React.useRef(layout);\n const onIndexChangeRef = React.useRef(onIndexChange);\n\n const currentIndexRef = React.useRef(index);\n const pendingIndexRef = React.useRef<number>();\n\n const swipeVelocityThreshold = 0.15;\n const swipeDistanceThreshold = layout.width / 1.75;\n\n const jumpToIndex = React.useCallback(\n (index: number, animate = animationEnabled) => {\n const offset = -index * layoutRef.current.width;\n\n const { timing, ...transitionConfig } = DefaultTransitionSpec;\n\n if (animate) {\n Animated.parallel([\n timing(panX, {\n ...transitionConfig,\n toValue: offset,\n useNativeDriver: false,\n }),\n ]).start(({ finished }) => {\n if (finished) {\n onIndexChangeRef.current(index);\n pendingIndexRef.current = undefined;\n }\n });\n pendingIndexRef.current = index;\n } else {\n panX.setValue(offset);\n onIndexChangeRef.current(index);\n pendingIndexRef.current = undefined;\n }\n },\n [animationEnabled, panX]\n );\n\n React.useEffect(() => {\n navigationStateRef.current = navigationState;\n layoutRef.current = layout;\n onIndexChangeRef.current = onIndexChange;\n });\n\n React.useEffect(() => {\n const offset = -navigationStateRef.current.index * layout.width;\n\n panX.setValue(offset);\n }, [layout.width, panX]);\n\n React.useEffect(() => {\n if (keyboardDismissMode === 'auto') {\n Keyboard.dismiss();\n }\n\n if (layout.width && currentIndexRef.current !== index) {\n currentIndexRef.current = index;\n jumpToIndex(index);\n }\n }, [jumpToIndex, keyboardDismissMode, layout.width, index]);\n\n const isMovingHorizontally = (\n _: GestureResponderEvent,\n gestureState: PanResponderGestureState\n ) => {\n return (\n Math.abs(gestureState.dx) > Math.abs(gestureState.dy * 2) &&\n Math.abs(gestureState.vx) > Math.abs(gestureState.vy * 2)\n );\n };\n\n const canMoveScreen = (\n event: GestureResponderEvent,\n gestureState: PanResponderGestureState\n ) => {\n if (swipeEnabled === false) {\n return false;\n }\n\n const diffX = I18nManager.isRTL ? -gestureState.dx : gestureState.dx;\n\n return (\n isMovingHorizontally(event, gestureState) &&\n ((diffX >= DEAD_ZONE && currentIndexRef.current > 0) ||\n (diffX <= -DEAD_ZONE && currentIndexRef.current < routes.length - 1))\n );\n };\n\n const startGesture = () => {\n onSwipeStart?.();\n\n if (keyboardDismissMode === 'on-drag') {\n Keyboard.dismiss();\n }\n\n panX.stopAnimation();\n // @ts-expect-error: _value is private, but docs use it as well\n panX.setOffset(panX._value);\n };\n\n const respondToGesture = (\n _: GestureResponderEvent,\n gestureState: PanResponderGestureState\n ) => {\n const diffX = I18nManager.isRTL ? -gestureState.dx : gestureState.dx;\n\n if (\n // swiping left\n (diffX > 0 && index <= 0) ||\n // swiping right\n (diffX < 0 && index >= routes.length - 1)\n ) {\n return;\n }\n\n if (layout.width) {\n // @ts-expect-error: _offset is private, but docs use it as well\n const position = (panX._offset + diffX) / -layout.width;\n const next =\n position > index ? Math.ceil(position) : Math.floor(position);\n\n if (next !== index) {\n listenersRef.current.forEach((listener) => listener(next));\n }\n }\n\n panX.setValue(diffX);\n };\n\n const finishGesture = (\n _: GestureResponderEvent,\n gestureState: PanResponderGestureState\n ) => {\n panX.flattenOffset();\n\n onSwipeEnd?.();\n\n const currentIndex =\n typeof pendingIndexRef.current === 'number'\n ? pendingIndexRef.current\n : currentIndexRef.current;\n\n let nextIndex = currentIndex;\n\n if (\n Math.abs(gestureState.dx) > Math.abs(gestureState.dy) &&\n Math.abs(gestureState.vx) > Math.abs(gestureState.vy) &&\n (Math.abs(gestureState.dx) > swipeDistanceThreshold ||\n Math.abs(gestureState.vx) > swipeVelocityThreshold)\n ) {\n nextIndex = Math.round(\n Math.min(\n Math.max(\n 0,\n I18nManager.isRTL\n ? currentIndex + gestureState.dx / Math.abs(gestureState.dx)\n : currentIndex - gestureState.dx / Math.abs(gestureState.dx)\n ),\n routes.length - 1\n )\n );\n\n currentIndexRef.current = nextIndex;\n }\n\n if (!isFinite(nextIndex)) {\n nextIndex = currentIndex;\n }\n\n jumpToIndex(nextIndex, true);\n };\n\n // TODO: use the listeners\n const addEnterListener = React.useCallback((listener: Listener) => {\n listenersRef.current.push(listener);\n\n return () => {\n const index = listenersRef.current.indexOf(listener);\n\n if (index > -1) {\n listenersRef.current.splice(index, 1);\n }\n };\n }, []);\n\n const jumpTo = React.useCallback(\n (key: string) => {\n const index = navigationStateRef.current.routes.findIndex(\n (route: { key: string }) => route.key === key\n );\n\n jumpToIndex(index);\n },\n [jumpToIndex]\n );\n\n const panResponder = PanResponder.create({\n onMoveShouldSetPanResponder: canMoveScreen,\n onMoveShouldSetPanResponderCapture: canMoveScreen,\n onPanResponderGrant: startGesture,\n onPanResponderMove: respondToGesture,\n onPanResponderTerminate: finishGesture,\n onPanResponderRelease: finishGesture,\n onPanResponderTerminationRequest: () => true,\n });\n\n const maxTranslate = layout.width * (routes.length - 1);\n const translateX = Animated.multiply(\n panX.interpolate({\n inputRange: [-maxTranslate, 0],\n outputRange: [-maxTranslate, 0],\n extrapolate: 'clamp',\n }),\n I18nManager.isRTL ? -1 : 1\n );\n\n return children({\n position: layout.width\n ? Animated.divide(panX, -layout.width)\n : new Animated.Value(index),\n addEnterListener,\n jumpTo,\n render: (children) => (\n <Animated.View\n style={[\n styles.sheet,\n layout.width\n ? {\n width: routes.length * layout.width,\n transform: [{ translateX }],\n }\n : null,\n style,\n ]}\n {...panResponder.panHandlers}\n >\n {React.Children.map(children, (child, i) => {\n const route = routes[i];\n const focused = i === index;\n\n return (\n <View\n key={route.key}\n style={\n layout.width\n ? { width: layout.width }\n : focused\n ? StyleSheet.absoluteFill\n : null\n }\n >\n {focused || layout.width ? child : null}\n </View>\n );\n })}\n </Animated.View>\n ),\n });\n}\n\nconst styles = StyleSheet.create({\n sheet: {\n flex: 1,\n flexDirection: 'row',\n alignItems: 'stretch',\n },\n});\n"],"mappings":";;;;;;;AAAA;;AACA;;AAUA;;;;;;;;;;AA6BA,MAAMA,SAAS,GAAG,EAAlB;AAEA,MAAMC,qBAAqB,GAAG;EAC5BC,MAAM,EAAEC,qBAAA,CAASC,MADW;EAE5BC,SAAS,EAAE,IAFiB;EAG5BC,OAAO,EAAE,GAHmB;EAI5BC,IAAI,EAAE,CAJsB;EAK5BC,iBAAiB,EAAE;AALS,CAA9B;;AAQe,SAASC,mBAAT,OAWF;EAAA,IAXgD;IAC3DC,MAD2D;IAE3DC,mBAAmB,GAAG,MAFqC;IAG3DC,YAAY,GAAG,IAH4C;IAI3DC,eAJ2D;IAK3DC,aAL2D;IAM3DC,YAN2D;IAO3DC,UAP2D;IAQ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QAAF,CAAD;MAFb,CADJ,GAKI,IAPC,EAQLvF,KARK;IADT,GAWM4E,YAAY,CAACuB,WAXnB,GAaG5F,KAAK,CAAC6F,QAAN,CAAeC,GAAf,CAAmBtG,QAAnB,EAA6B,CAACuG,KAAD,EAAQC,CAAR,KAAc;MAC1C,MAAM5B,KAAK,GAAGzE,MAAM,CAACqG,CAAD,CAApB;MACA,MAAMC,OAAO,GAAGD,CAAC,KAAKpG,KAAtB;MAEA,oBACE,oBAAC,iBAAD;QACE,GAAG,EAAEwE,KAAK,CAACF,GADb;QAEE,KAAK,EACHjF,MAAM,CAACwB,KAAP,GACI;UAAEA,KAAK,EAAExB,MAAM,CAACwB;QAAhB,CADJ,GAEIwF,OAAO,GACPC,uBAAA,CAAWC,YADJ,GAEP;MAPR,GAUGF,OAAO,IAAIhH,MAAM,CAACwB,KAAlB,GAA0BsF,KAA1B,GAAkC,IAVrC,CADF;IAcD,CAlBA,CAbH;EAPY,CAAD,CAAf;AA0CD;;AAED,MAAMN,MAAM,GAAGS,uBAAA,CAAW3B,MAAX,CAAkB;EAC/BmB,KAAK,EAAE;IACLU,IAAI,EAAE,CADD;IAELC,aAAa,EAAE,KAFV;IAGLC,UAAU,EAAE;EAHP;AADwB,CAAlB,CAAf"}
|
|
@@ -13,7 +13,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
15
|
|
|
16
|
-
function _extends() { _extends = Object.assign
|
|
16
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
17
17
|
|
|
18
18
|
const ANDROID_VERSION_LOLLIPOP = 21;
|
|
19
19
|
const ANDROID_SUPPORTS_RIPPLE = _reactNative.Platform.OS === 'android' && _reactNative.Platform.Version >= ANDROID_VERSION_LOLLIPOP;
|
|
@@ -25,25 +25,29 @@ const ANDROID_SUPPORTS_RIPPLE = _reactNative.Platform.OS === 'android' && _react
|
|
|
25
25
|
* On other platforms, you can pass the props of TouchableOpacity.
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
function PlatformPressable({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
function PlatformPressable(_ref) {
|
|
29
|
+
let {
|
|
30
|
+
android_ripple,
|
|
31
|
+
pressColor = 'rgba(0, 0, 0, .32)',
|
|
32
|
+
pressOpacity,
|
|
33
|
+
style,
|
|
34
|
+
...rest
|
|
35
|
+
} = _ref;
|
|
35
36
|
return /*#__PURE__*/React.createElement(_reactNative.Pressable, _extends({
|
|
36
37
|
android_ripple: ANDROID_SUPPORTS_RIPPLE ? {
|
|
37
38
|
color: pressColor,
|
|
38
39
|
...android_ripple
|
|
39
40
|
} : undefined,
|
|
40
|
-
style:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
style: _ref2 => {
|
|
42
|
+
let {
|
|
43
|
+
pressed
|
|
44
|
+
} = _ref2;
|
|
45
|
+
return [{
|
|
46
|
+
opacity: pressed && !ANDROID_SUPPORTS_RIPPLE ? pressOpacity : 1
|
|
47
|
+
}, typeof style === 'function' ? style({
|
|
48
|
+
pressed
|
|
49
|
+
}) : style];
|
|
50
|
+
}
|
|
47
51
|
}, rest));
|
|
48
52
|
}
|
|
49
53
|
//# sourceMappingURL=PlatformPressable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["ANDROID_VERSION_LOLLIPOP","ANDROID_SUPPORTS_RIPPLE","Platform","OS","Version","PlatformPressable","android_ripple","pressColor","pressOpacity","style","rest","color","undefined","pressed","opacity"],"sources":["PlatformPressable.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Platform, Pressable, PressableProps } from 'react-native';\n\nexport type Props = PressableProps & {\n pressColor?: string;\n pressOpacity?: number;\n children: React.ReactNode;\n};\n\nconst ANDROID_VERSION_LOLLIPOP = 21;\nconst ANDROID_SUPPORTS_RIPPLE =\n Platform.OS === 'android' && Platform.Version >= ANDROID_VERSION_LOLLIPOP;\n\n/**\n * PlatformPressable provides an abstraction on top of TouchableNativeFeedback and\n * TouchableOpacity to handle platform differences.\n *\n * On Android, you can pass the props of TouchableNativeFeedback.\n * On other platforms, you can pass the props of TouchableOpacity.\n */\nexport default function PlatformPressable({\n android_ripple,\n pressColor = 'rgba(0, 0, 0, .32)',\n pressOpacity,\n style,\n ...rest\n}: Props) {\n return (\n <Pressable\n android_ripple={\n ANDROID_SUPPORTS_RIPPLE\n ? { color: pressColor, ...android_ripple }\n : undefined\n }\n style={({ pressed }) => [\n { opacity: pressed && !ANDROID_SUPPORTS_RIPPLE ? pressOpacity : 1 },\n typeof style === 'function' ? style({ pressed }) : style,\n ]}\n {...rest}\n />\n );\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;;;;;;;AAQA,MAAMA,wBAAwB,GAAG,EAAjC;AACA,MAAMC,uBAAuB,GAC3BC,qBAAA,CAASC,EAAT,KAAgB,SAAhB,IAA6BD,qBAAA,CAASE,OAAT,IAAoBJ,wBADnD;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AACe,SAASK,iBAAT,OAML;EAAA,IANgC;IACxCC,cADwC;IAExCC,UAAU,GAAG,oBAF2B;IAGxCC,YAHwC;IAIxCC,KAJwC;IAKxC,GAAGC;EALqC,CAMhC;EACR,oBACE,oBAAC,sBAAD;IACE,cAAc,EACZT,uBAAuB,GACnB;MAAEU,KAAK,EAAEJ,UAAT;MAAqB,GAAGD;IAAxB,CADmB,GAEnBM,SAJR;IAME,KAAK,EAAE;MAAA,IAAC;QAAEC;MAAF,CAAD;MAAA,OAAiB,CACtB;QAAEC,OAAO,EAAED,OAAO,IAAI,CAACZ,uBAAZ,GAAsCO,YAAtC,GAAqD;MAAhE,CADsB,EAEtB,OAAOC,KAAP,KAAiB,UAAjB,GAA8BA,KAAK,CAAC;QAAEI;MAAF,CAAD,CAAnC,GAAmDJ,KAF7B,CAAjB;IAAA;EANT,GAUMC,IAVN,EADF;AAcD"}
|
package/lib/commonjs/SceneMap.js
CHANGED
|
@@ -23,16 +23,19 @@ class SceneComponent extends React.PureComponent {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
function SceneMap(scenes) {
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
return _ref => {
|
|
27
|
+
let {
|
|
28
|
+
route,
|
|
29
|
+
jumpTo,
|
|
30
|
+
position
|
|
31
|
+
} = _ref;
|
|
32
|
+
return /*#__PURE__*/React.createElement(SceneComponent, {
|
|
33
|
+
key: route.key,
|
|
34
|
+
component: scenes[route.key],
|
|
35
|
+
route: route,
|
|
36
|
+
jumpTo: jumpTo,
|
|
37
|
+
position: position
|
|
38
|
+
});
|
|
39
|
+
};
|
|
37
40
|
}
|
|
38
41
|
//# sourceMappingURL=SceneMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["SceneComponent","React","PureComponent","render","component","rest","props","createElement","SceneMap","scenes","route","jumpTo","position","key"],"sources":["SceneMap.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { SceneRendererProps } from './types';\n\nclass SceneComponent<\n T extends { component: React.ComponentType<any> }\n> extends React.PureComponent<T> {\n render() {\n const { component, ...rest } = this.props;\n return React.createElement(component, rest);\n }\n}\n\nexport default function SceneMap<T extends any>(scenes: {\n [key: string]: React.ComponentType<T>;\n}) {\n return ({ route, jumpTo, position }: SceneRendererProps & { route: any }) => (\n <SceneComponent\n key={route.key}\n component={scenes[route.key]}\n route={route}\n jumpTo={jumpTo}\n position={position}\n />\n );\n}\n"],"mappings":";;;;;;;AAAA;;;;;;AAGA,MAAMA,cAAN,SAEUC,KAAK,CAACC,aAFhB,CAEiC;EAC/BC,MAAM,GAAG;IACP,MAAM;MAAEC,SAAF;MAAa,GAAGC;IAAhB,IAAyB,KAAKC,KAApC;IACA,oBAAOL,KAAK,CAACM,aAAN,CAAoBH,SAApB,EAA+BC,IAA/B,CAAP;EACD;;AAJ8B;;AAOlB,SAASG,QAAT,CAAiCC,MAAjC,EAEZ;EACD,OAAO;IAAA,IAAC;MAAEC,KAAF;MAASC,MAAT;MAAiBC;IAAjB,CAAD;IAAA,oBACL,oBAAC,cAAD;MACE,GAAG,EAAEF,KAAK,CAACG,GADb;MAEE,SAAS,EAAEJ,MAAM,CAACC,KAAK,CAACG,GAAP,CAFnB;MAGE,KAAK,EAAEH,KAHT;MAIE,MAAM,EAAEC,MAJV;MAKE,QAAQ,EAAEC;IALZ,EADK;EAAA,CAAP;AASD"}
|
|
@@ -16,8 +16,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
16
16
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
17
|
|
|
18
18
|
class SceneView extends React.Component {
|
|
19
|
-
constructor(
|
|
20
|
-
super(...
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
21
|
|
|
22
22
|
_defineProperty(this, "state", {
|
|
23
23
|
loading: Math.abs(this.props.navigationState.index - this.props.index) > this.props.lazyPreloadDistance
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["SceneView","React","Component","loading","Math","abs","props","navigationState","index","lazyPreloadDistance","value","setState","prevState","getDerivedStateFromProps","state","componentDidMount","lazy","unsubscribe","addEnterListener","handleEnter","timerHandler","setTimeout","componentDidUpdate","prevProps","componentWillUnmount","clearTimeout","undefined","render","layout","style","focused","styles","route","width","StyleSheet","absoluteFill","children","create","flex","overflow"],"sources":["SceneView.tsx"],"sourcesContent":["import * as React from 'react';\nimport { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';\nimport type {\n SceneRendererProps,\n EventEmitterProps,\n NavigationState,\n Route,\n} from './types';\n\ntype Props<T extends Route> = SceneRendererProps &\n EventEmitterProps & {\n navigationState: NavigationState<T>;\n lazy: boolean;\n lazyPreloadDistance: number;\n index: number;\n children: (props: { loading: boolean }) => React.ReactNode;\n style?: StyleProp<ViewStyle>;\n };\n\ntype State = {\n loading: boolean;\n};\n\nexport default class SceneView<T extends Route> extends React.Component<\n Props<T>,\n State\n> {\n static getDerivedStateFromProps(props: Props<Route>, state: State) {\n if (\n state.loading &&\n Math.abs(props.navigationState.index - props.index) <=\n props.lazyPreloadDistance\n ) {\n // Always render the route when it becomes focused\n return { loading: false };\n }\n\n return null;\n }\n\n state = {\n loading:\n Math.abs(this.props.navigationState.index - this.props.index) >\n this.props.lazyPreloadDistance,\n };\n\n componentDidMount() {\n if (this.props.lazy) {\n // If lazy mode is enabled, listen to when we enter screens\n this.unsubscribe = this.props.addEnterListener(this.handleEnter);\n } else if (this.state.loading) {\n // If lazy mode is not enabled, render the scene with a delay if not loaded already\n // This improves the initial startup time as the scene is no longer blocking\n this.timerHandler = setTimeout(\n () => this.setState({ loading: false }),\n 0\n );\n }\n }\n\n componentDidUpdate(prevProps: Props<T>, prevState: State) {\n if (\n this.props.lazy !== prevProps.lazy ||\n this.state.loading !== prevState.loading\n ) {\n // We only need the listener if the tab hasn't loaded yet and lazy is enabled\n if (this.props.lazy && this.state.loading) {\n this.unsubscribe?.();\n this.unsubscribe = this.props.addEnterListener(this.handleEnter);\n } else {\n this.unsubscribe?.();\n }\n }\n }\n\n componentWillUnmount() {\n this.unsubscribe?.();\n\n if (this.timerHandler) {\n clearTimeout(this.timerHandler);\n this.timerHandler = undefined;\n }\n }\n\n private timerHandler: NodeJS.Timeout | undefined;\n\n private unsubscribe: (() => void) | null = null;\n\n private handleEnter = (value: number) => {\n const { index } = this.props;\n\n // If we're entering the current route, we need to load it\n if (value === index) {\n this.setState((prevState) => {\n if (prevState.loading) {\n return { loading: false };\n }\n\n return null;\n });\n }\n };\n\n render() {\n const { navigationState, index, layout, style } = this.props;\n const { loading } = this.state;\n\n const focused = navigationState.index === index;\n\n return (\n <View\n accessibilityElementsHidden={!focused}\n importantForAccessibility={focused ? 'auto' : 'no-hide-descendants'}\n style={[\n styles.route,\n // If we don't have the layout yet, make the focused screen fill the container\n // This avoids delay before we are able to render pages side by side\n layout.width\n ? { width: layout.width }\n : focused\n ? StyleSheet.absoluteFill\n : null,\n style,\n ]}\n >\n {\n // Only render the route only if it's either focused or layout is available\n // When layout is not available, we must not render unfocused routes\n // so that the focused route can fill the screen\n focused || layout.width ? this.props.children({ loading }) : null\n }\n </View>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n route: {\n flex: 1,\n overflow: 'hidden',\n },\n});\n"],"mappings":";;;;;;;AAAA;;AACA;;;;;;;;AAsBe,MAAMA,SAAN,SAAyCC,KAAK,CAACC,SAA/C,CAGb;EAAA;IAAA;;IAAA,+BAcQ;MACNC,OAAO,EACLC,IAAI,CAACC,GAAL,CAAS,KAAKC,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