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/lib/commonjs/TabView.js
CHANGED
|
@@ -21,25 +21,28 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
21
21
|
|
|
22
22
|
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; }
|
|
23
23
|
|
|
24
|
-
function _extends() { _extends = Object.assign
|
|
25
|
-
|
|
26
|
-
function TabView({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
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); }
|
|
25
|
+
|
|
26
|
+
function TabView(_ref) {
|
|
27
|
+
let {
|
|
28
|
+
onIndexChange,
|
|
29
|
+
navigationState,
|
|
30
|
+
renderScene,
|
|
31
|
+
initialLayout,
|
|
32
|
+
keyboardDismissMode = 'auto',
|
|
33
|
+
lazy = false,
|
|
34
|
+
lazyPreloadDistance = 0,
|
|
35
|
+
onSwipeStart,
|
|
36
|
+
onSwipeEnd,
|
|
37
|
+
renderLazyPlaceholder = () => null,
|
|
38
|
+
renderTabBar = props => /*#__PURE__*/React.createElement(_TabBar.default, props),
|
|
39
|
+
sceneContainerStyle,
|
|
40
|
+
pagerStyle,
|
|
41
|
+
style,
|
|
42
|
+
swipeEnabled = true,
|
|
43
|
+
tabBarPosition = 'top',
|
|
44
|
+
animationEnabled = true
|
|
45
|
+
} = _ref;
|
|
43
46
|
const [layout, setLayout] = React.useState({
|
|
44
47
|
width: 0,
|
|
45
48
|
height: 0,
|
|
@@ -79,13 +82,16 @@ function TabView({
|
|
|
79
82
|
swipeEnabled: swipeEnabled,
|
|
80
83
|
onSwipeStart: onSwipeStart,
|
|
81
84
|
onSwipeEnd: onSwipeEnd,
|
|
82
|
-
onIndexChange: jumpToIndex
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
onIndexChange: jumpToIndex,
|
|
86
|
+
animationEnabled: animationEnabled,
|
|
87
|
+
style: pagerStyle
|
|
88
|
+
}, _ref2 => {
|
|
89
|
+
let {
|
|
90
|
+
position,
|
|
91
|
+
render,
|
|
92
|
+
addEnterListener,
|
|
93
|
+
jumpTo
|
|
94
|
+
} = _ref2;
|
|
89
95
|
// All of the props here must not change between re-renders
|
|
90
96
|
// This is crucial to optimizing the routes with PureComponent
|
|
91
97
|
const sceneRendererProps = {
|
|
@@ -106,13 +112,16 @@ function TabView({
|
|
|
106
112
|
lazyPreloadDistance: lazyPreloadDistance,
|
|
107
113
|
navigationState: navigationState,
|
|
108
114
|
style: sceneContainerStyle
|
|
109
|
-
}),
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
}), _ref3 => {
|
|
116
|
+
let {
|
|
117
|
+
loading
|
|
118
|
+
} = _ref3;
|
|
119
|
+
return loading ? renderLazyPlaceholder({
|
|
120
|
+
route
|
|
121
|
+
}) : renderScene({ ...sceneRendererProps,
|
|
122
|
+
route
|
|
123
|
+
});
|
|
124
|
+
});
|
|
116
125
|
})), tabBarPosition === 'bottom' && renderTabBar({ ...sceneRendererProps,
|
|
117
126
|
navigationState
|
|
118
127
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["TabView","onIndexChange","navigationState","renderScene","initialLayout","keyboardDismissMode","lazy","lazyPreloadDistance","onSwipeStart","onSwipeEnd","renderLazyPlaceholder","renderTabBar","props","sceneContainerStyle","pagerStyle","style","swipeEnabled","tabBarPosition","animationEnabled","layout","setLayout","React","useState","width","height","jumpToIndex","index","handleLayout","e","nativeEvent","prevLayout","styles","pager","position","render","addEnterListener","jumpTo","sceneRendererProps","routes","map","route","i","key","loading","StyleSheet","create","flex","overflow"],"sources":["TabView.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n StyleSheet,\n View,\n StyleProp,\n ViewStyle,\n LayoutChangeEvent,\n} from 'react-native';\nimport TabBar from './TabBar';\nimport SceneView from './SceneView';\nimport Pager from './Pager';\nimport type {\n Layout,\n NavigationState,\n Route,\n SceneRendererProps,\n PagerProps,\n} from './types';\n\nexport type Props<T extends Route> = PagerProps & {\n onIndexChange: (index: number) => void;\n navigationState: NavigationState<T>;\n renderScene: (props: SceneRendererProps & { route: T }) => React.ReactNode;\n renderLazyPlaceholder?: (props: { route: T }) => React.ReactNode;\n renderTabBar?: (\n props: SceneRendererProps & { navigationState: NavigationState<T> }\n ) => React.ReactNode;\n tabBarPosition?: 'top' | 'bottom';\n initialLayout?: Partial<Layout>;\n lazy?: ((props: { route: T }) => boolean) | boolean;\n lazyPreloadDistance?: number;\n sceneContainerStyle?: StyleProp<ViewStyle>;\n pagerStyle?: StyleProp<ViewStyle>;\n style?: StyleProp<ViewStyle>;\n};\n\nexport default function TabView<T extends Route>({\n onIndexChange,\n navigationState,\n renderScene,\n initialLayout,\n keyboardDismissMode = 'auto',\n lazy = false,\n lazyPreloadDistance = 0,\n onSwipeStart,\n onSwipeEnd,\n renderLazyPlaceholder = () => null,\n renderTabBar = (props) => <TabBar {...props} />,\n sceneContainerStyle,\n pagerStyle,\n style,\n swipeEnabled = true,\n tabBarPosition = 'top',\n animationEnabled = true,\n}: Props<T>) {\n const [layout, setLayout] = React.useState({\n width: 0,\n height: 0,\n ...initialLayout,\n });\n\n const jumpToIndex = (index: number) => {\n if (index !== navigationState.index) {\n onIndexChange(index);\n }\n };\n\n const handleLayout = (e: LayoutChangeEvent) => {\n const { height, width } = e.nativeEvent.layout;\n\n setLayout((prevLayout) => {\n if (prevLayout.width === width && prevLayout.height === height) {\n return prevLayout;\n }\n\n return { height, width };\n });\n };\n\n return (\n <View onLayout={handleLayout} style={[styles.pager, style]}>\n <Pager\n layout={layout}\n navigationState={navigationState}\n keyboardDismissMode={keyboardDismissMode}\n swipeEnabled={swipeEnabled}\n onSwipeStart={onSwipeStart}\n onSwipeEnd={onSwipeEnd}\n onIndexChange={jumpToIndex}\n animationEnabled={animationEnabled}\n style={pagerStyle}\n >\n {({ position, render, addEnterListener, jumpTo }) => {\n // All of the props here must not change between re-renders\n // This is crucial to optimizing the routes with PureComponent\n const sceneRendererProps = {\n position,\n layout,\n jumpTo,\n };\n\n return (\n <React.Fragment>\n {tabBarPosition === 'top' &&\n renderTabBar({\n ...sceneRendererProps,\n navigationState,\n })}\n {render(\n navigationState.routes.map((route, i) => {\n return (\n <SceneView\n {...sceneRendererProps}\n addEnterListener={addEnterListener}\n key={route.key}\n index={i}\n lazy={typeof lazy === 'function' ? lazy({ route }) : lazy}\n lazyPreloadDistance={lazyPreloadDistance}\n navigationState={navigationState}\n style={sceneContainerStyle}\n >\n {({ loading }) =>\n loading\n ? renderLazyPlaceholder({ route })\n : renderScene({\n ...sceneRendererProps,\n route,\n })\n }\n </SceneView>\n );\n })\n )}\n {tabBarPosition === 'bottom' &&\n renderTabBar({\n ...sceneRendererProps,\n navigationState,\n })}\n </React.Fragment>\n );\n }}\n </Pager>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n pager: {\n flex: 1,\n overflow: 'hidden',\n },\n});\n"],"mappings":";;;;;;;AAAA;;AACA;;AAOA;;AACA;;AACA;;;;;;;;;;AA0Be,SAASA,OAAT,OAkBF;EAAA,IAlBoC;IAC/CC,aAD+C;IAE/CC,eAF+C;IAG/CC,WAH+C;IAI/CC,aAJ+C;IAK/CC,mBAAmB,GAAG,MALyB;IAM/CC,IAAI,GAAG,KANwC;IAO/CC,mBAAmB,GAAG,CAPyB;IAQ/CC,YAR+C;IAS/CC,UAT+C;IAU/CC,qBAAqB,GAAG,MAAM,IAViB;IAW/CC,YAAY,GAAIC,KAAD,iBAAW,oBAAC,eAAD,EAAYA,KAAZ,CAXqB;IAY/CC,mBAZ+C;IAa/CC,UAb+C;IAc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
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "SceneMap", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _SceneMap.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "TabBar", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function () {
|
|
15
|
-
return
|
|
15
|
+
return _TabBar.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "TabBarIndicator", {
|
|
@@ -27,10 +27,10 @@ Object.defineProperty(exports, "TabBarItem", {
|
|
|
27
27
|
return _TabBarItem.default;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
Object.defineProperty(exports, "
|
|
30
|
+
Object.defineProperty(exports, "TabView", {
|
|
31
31
|
enumerable: true,
|
|
32
32
|
get: function () {
|
|
33
|
-
return
|
|
33
|
+
return _TabView.default;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.tsx"],"sourcesContent":["export { default as TabBar } from './TabBar';\nexport type { Props as TabBarProps } from './TabBar';\n\nexport { default as TabView } from './TabView';\nexport type { Props as TabViewProps } from './TabView';\n\nexport { default as TabBarIndicator } from './TabBarIndicator';\nexport type { Props as TabBarIndicatorProps } from './TabBarIndicator';\n\nexport { default as TabBarItem } from './TabBarItem';\nexport type { Props as TabBarItemProps } from './TabBarItem';\n\nexport { default as SceneMap } from './SceneMap';\n\nexport type { Route, NavigationState, SceneRendererProps } from './types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAGA;;AAGA;;AAGA;;AAGA"}
|
package/lib/commonjs/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":[],"sources":["types.tsx"],"sourcesContent":["import type { Animated } from 'react-native';\nimport type { PagerViewProps } from 'react-native-pager-view';\n\nexport type Route = {\n key: string;\n icon?: string;\n title?: string;\n accessible?: boolean;\n accessibilityLabel?: string;\n testID?: string;\n};\n\nexport type Event = {\n defaultPrevented: boolean;\n preventDefault(): void;\n};\n\nexport type Scene<T extends Route> = {\n route: T;\n};\n\nexport type NavigationState<T extends Route> = {\n index: number;\n routes: T[];\n};\n\nexport type Layout = {\n width: number;\n height: number;\n};\n\nexport type Listener = (value: number) => void;\n\nexport type SceneRendererProps = {\n layout: Layout;\n position: Animated.AnimatedInterpolation;\n jumpTo: (key: string) => void;\n};\n\nexport type EventEmitterProps = {\n addEnterListener: (listener: Listener) => () => void;\n};\n\nexport type PagerProps = Omit<\n PagerViewProps,\n | 'initialPage'\n | 'scrollEnabled'\n | 'onPageScroll'\n | 'onPageSelected'\n | 'onPageScrollStateChanged'\n | 'keyboardDismissMode'\n | 'children'\n> & {\n keyboardDismissMode?: 'none' | 'on-drag' | 'auto';\n swipeEnabled?: boolean;\n animationEnabled?: boolean;\n onSwipeStart?: () => void;\n onSwipeEnd?: () => void;\n};\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["useAnimatedValue","initialValue","lazyRef","React","useRef","current","undefined","Animated","Value"],"sources":["useAnimatedValue.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Animated } from 'react-native';\n\nexport default function useAnimatedValue(initialValue: number) {\n const lazyRef = React.useRef<Animated.Value>();\n\n if (lazyRef.current === undefined) {\n lazyRef.current = new Animated.Value(initialValue);\n }\n\n return lazyRef.current as Animated.Value;\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;;;;;AAEe,SAASA,gBAAT,CAA0BC,YAA1B,EAAgD;EAC7D,MAAMC,OAAO,GAAGC,KAAK,CAACC,MAAN,EAAhB;;EAEA,IAAIF,OAAO,CAACG,OAAR,KAAoBC,SAAxB,EAAmC;IACjCJ,OAAO,CAACG,OAAR,GAAkB,IAAIE,qBAAA,CAASC,KAAb,CAAmBP,YAAnB,CAAlB;EACD;;EAED,OAAOC,OAAO,CAACG,OAAf;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["default"],"sources":["Pager.android.tsx"],"sourcesContent":["export { default } from './PagerViewAdapter';\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,oBAAxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["default"],"sources":["Pager.ios.tsx"],"sourcesContent":["export { default } from './PagerViewAdapter';\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,oBAAxB"}
|
package/lib/module/Pager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["default"],"sources":["Pager.tsx"],"sourcesContent":["export { default } from './PanResponderAdapter';\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,uBAAxB"}
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
1
|
+
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); }
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { Animated, Keyboard, StyleSheet } from 'react-native';
|
|
5
5
|
import ViewPager from 'react-native-pager-view';
|
|
6
6
|
import useAnimatedValue from './useAnimatedValue';
|
|
7
7
|
const AnimatedViewPager = Animated.createAnimatedComponent(ViewPager);
|
|
8
|
-
export default function PagerViewAdapter({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
export default function PagerViewAdapter(_ref) {
|
|
9
|
+
let {
|
|
10
|
+
keyboardDismissMode = 'auto',
|
|
11
|
+
swipeEnabled = true,
|
|
12
|
+
navigationState,
|
|
13
|
+
onIndexChange,
|
|
14
|
+
onSwipeStart,
|
|
15
|
+
onSwipeEnd,
|
|
16
|
+
children,
|
|
17
|
+
style,
|
|
18
|
+
animationEnabled,
|
|
19
|
+
...rest
|
|
20
|
+
} = _ref;
|
|
19
21
|
const {
|
|
20
22
|
index
|
|
21
23
|
} = navigationState;
|
|
@@ -29,22 +31,37 @@ export default function PagerViewAdapter({
|
|
|
29
31
|
navigationStateRef.current = navigationState;
|
|
30
32
|
});
|
|
31
33
|
const jumpTo = React.useCallback(key => {
|
|
32
|
-
var _pagerRef$current;
|
|
33
|
-
|
|
34
34
|
const index = navigationStateRef.current.routes.findIndex(route => route.key === key);
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
|
|
36
|
+
if (animationEnabled) {
|
|
37
|
+
var _pagerRef$current;
|
|
38
|
+
|
|
39
|
+
(_pagerRef$current = pagerRef.current) === null || _pagerRef$current === void 0 ? void 0 : _pagerRef$current.setPage(index);
|
|
40
|
+
} else {
|
|
41
|
+
var _pagerRef$current2;
|
|
42
|
+
|
|
43
|
+
(_pagerRef$current2 = pagerRef.current) === null || _pagerRef$current2 === void 0 ? void 0 : _pagerRef$current2.setPageWithoutAnimation(index);
|
|
44
|
+
position.setValue(index);
|
|
45
|
+
}
|
|
46
|
+
}, [animationEnabled, position]);
|
|
37
47
|
React.useEffect(() => {
|
|
38
48
|
if (keyboardDismissMode === 'auto') {
|
|
39
49
|
Keyboard.dismiss();
|
|
40
50
|
}
|
|
41
51
|
|
|
42
52
|
if (indexRef.current !== index) {
|
|
43
|
-
|
|
53
|
+
if (animationEnabled) {
|
|
54
|
+
var _pagerRef$current3;
|
|
44
55
|
|
|
45
|
-
|
|
56
|
+
(_pagerRef$current3 = pagerRef.current) === null || _pagerRef$current3 === void 0 ? void 0 : _pagerRef$current3.setPage(index);
|
|
57
|
+
} else {
|
|
58
|
+
var _pagerRef$current4;
|
|
59
|
+
|
|
60
|
+
(_pagerRef$current4 = pagerRef.current) === null || _pagerRef$current4 === void 0 ? void 0 : _pagerRef$current4.setPageWithoutAnimation(index);
|
|
61
|
+
position.setValue(index);
|
|
62
|
+
}
|
|
46
63
|
}
|
|
47
|
-
}, [keyboardDismissMode, index]);
|
|
64
|
+
}, [keyboardDismissMode, index, animationEnabled, position]);
|
|
48
65
|
|
|
49
66
|
const onPageScrollStateChanged = state => {
|
|
50
67
|
const {
|
|
@@ -58,9 +75,10 @@ export default function PagerViewAdapter({
|
|
|
58
75
|
|
|
59
76
|
case 'dragging':
|
|
60
77
|
{
|
|
61
|
-
const subscription = offset.addListener(
|
|
62
|
-
|
|
63
|
-
|
|
78
|
+
const subscription = offset.addListener(_ref2 => {
|
|
79
|
+
let {
|
|
80
|
+
value
|
|
81
|
+
} = _ref2;
|
|
64
82
|
const next = index + (value > 0 ? Math.ceil(value) : Math.floor(value));
|
|
65
83
|
|
|
66
84
|
if (next !== index) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["React","Animated","Keyboard","StyleSheet","ViewPager","useAnimatedValue","AnimatedViewPager","createAnimatedComponent","PagerViewAdapter","keyboardDismissMode","swipeEnabled","navigationState","onIndexChange","onSwipeStart","onSwipeEnd","children","style","animationEnabled","rest","index","listenersRef","useRef","pagerRef","indexRef","navigationStateRef","position","offset","useEffect","current","jumpTo","useCallback","key","routes","findIndex","route","setPage","setPageWithoutAnimation","setValue","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","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,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,QAAT,EAAmBC,QAAnB,EAA6BC,UAA7B,QAA+C,cAA/C;AACA,OAAOC,SAAP,MAEO,yBAFP;AAGA,OAAOC,gBAAP,MAA6B,oBAA7B;AASA,MAAMC,iBAAiB,GAAGL,QAAQ,CAACM,uBAAT,CAAiCH,SAAjC,CAA1B;AAoBA,eAAe,SAAS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AzBjB,IA2BGK,QA3BH;EALY,CAAD,CAAf;AAoCD;AAED,MAAM4C,MAAM,GAAGxD,UAAU,CAAC6D,MAAX,CAAkB;EAC/BJ,SAAS,EAAE;IACTK,IAAI,EAAE;EADG;AADoB,CAAlB,CAAf"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
1
|
+
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); }
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { Animated, PanResponder, Keyboard, StyleSheet, I18nManager, View } from 'react-native';
|
|
@@ -11,17 +11,19 @@ const DefaultTransitionSpec = {
|
|
|
11
11
|
mass: 3,
|
|
12
12
|
overshootClamping: true
|
|
13
13
|
};
|
|
14
|
-
export default function PanResponderAdapter({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
export default function PanResponderAdapter(_ref) {
|
|
15
|
+
let {
|
|
16
|
+
layout,
|
|
17
|
+
keyboardDismissMode = 'auto',
|
|
18
|
+
swipeEnabled = true,
|
|
19
|
+
navigationState,
|
|
20
|
+
onIndexChange,
|
|
21
|
+
onSwipeStart,
|
|
22
|
+
onSwipeEnd,
|
|
23
|
+
children,
|
|
24
|
+
style,
|
|
25
|
+
animationEnabled = false
|
|
26
|
+
} = _ref;
|
|
25
27
|
const {
|
|
26
28
|
routes,
|
|
27
29
|
index
|
|
@@ -35,25 +37,35 @@ export default function PanResponderAdapter({
|
|
|
35
37
|
const pendingIndexRef = React.useRef();
|
|
36
38
|
const swipeVelocityThreshold = 0.15;
|
|
37
39
|
const swipeDistanceThreshold = layout.width / 1.75;
|
|
38
|
-
const jumpToIndex = React.useCallback(index
|
|
40
|
+
const jumpToIndex = React.useCallback(function (index) {
|
|
41
|
+
let animate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : animationEnabled;
|
|
39
42
|
const offset = -index * layoutRef.current.width;
|
|
40
43
|
const {
|
|
41
44
|
timing,
|
|
42
45
|
...transitionConfig
|
|
43
46
|
} = DefaultTransitionSpec;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
|
|
48
|
+
if (animate) {
|
|
49
|
+
Animated.parallel([timing(panX, { ...transitionConfig,
|
|
50
|
+
toValue: offset,
|
|
51
|
+
useNativeDriver: false
|
|
52
|
+
})]).start(_ref2 => {
|
|
53
|
+
let {
|
|
54
|
+
finished
|
|
55
|
+
} = _ref2;
|
|
56
|
+
|
|
57
|
+
if (finished) {
|
|
58
|
+
onIndexChangeRef.current(index);
|
|
59
|
+
pendingIndexRef.current = undefined;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
pendingIndexRef.current = index;
|
|
63
|
+
} else {
|
|
64
|
+
panX.setValue(offset);
|
|
65
|
+
onIndexChangeRef.current(index);
|
|
66
|
+
pendingIndexRef.current = undefined;
|
|
67
|
+
}
|
|
68
|
+
}, [animationEnabled, panX]);
|
|
57
69
|
React.useEffect(() => {
|
|
58
70
|
navigationStateRef.current = navigationState;
|
|
59
71
|
layoutRef.current = layout;
|
|
@@ -103,7 +115,8 @@ export default function PanResponderAdapter({
|
|
|
103
115
|
const diffX = I18nManager.isRTL ? -gestureState.dx : gestureState.dx;
|
|
104
116
|
|
|
105
117
|
if ( // swiping left
|
|
106
|
-
diffX > 0 && index <= 0 ||
|
|
118
|
+
diffX > 0 && index <= 0 || // swiping right
|
|
119
|
+
diffX < 0 && index >= routes.length - 1) {
|
|
107
120
|
return;
|
|
108
121
|
}
|
|
109
122
|
|
|
@@ -135,7 +148,7 @@ export default function PanResponderAdapter({
|
|
|
135
148
|
nextIndex = currentIndex;
|
|
136
149
|
}
|
|
137
150
|
|
|
138
|
-
jumpToIndex(nextIndex);
|
|
151
|
+
jumpToIndex(nextIndex, true);
|
|
139
152
|
}; // TODO: use the listeners
|
|
140
153
|
|
|
141
154
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["PanResponderAdapter.tsx"],"names":["React","Animated","PanResponder","Keyboard","StyleSheet","I18nManager","View","useAnimatedValue","DEAD_ZONE","DefaultTransitionSpec","timing","spring","stiffness","damping","mass","overshootClamping","PanResponderAdapter","layout","keyboardDismissMode","swipeEnabled","navigationState","onIndexChange","onSwipeStart","onSwipeEnd","children","style","routes","index","panX","listenersRef","useRef","navigationStateRef","layoutRef","onIndexChangeRef","currentIndexRef","pendingIndexRef","swipeVelocityThreshold","swipeDistanceThreshold","width","jumpToIndex","useCallback","offset","current","transitionConfig","parallel","toValue","useNativeDriver","start","finished","undefined","useEffect","setValue","dismiss","isMovingHorizontally","_","gestureState","Math","abs","dx","dy","vx","vy","canMoveScreen","event","diffX","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","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","absoluteFill","flex","flexDirection","alignItems"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,QADF,EAEEC,YAFF,EAGEC,QAHF,EAIEC,UAJF,EAOEC,WAP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AVrC,CADF;AAcD,KAlBA,CAbH;AAPY,GAAD,CAAf;AA0CD;AAED,MAAMN,MAAM,GAAG9G,UAAU,CAAC4F,MAAX,CAAkB;AAC/BmB,EAAAA,KAAK,EAAE;AACLS,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":["React","Animated","PanResponder","Keyboard","StyleSheet","I18nManager","View","useAnimatedValue","DEAD_ZONE","DefaultTransitionSpec","timing","spring","stiffness","damping","mass","overshootClamping","PanResponderAdapter","layout","keyboardDismissMode","swipeEnabled","navigationState","onIndexChange","onSwipeStart","onSwipeEnd","children","style","animationEnabled","routes","index","panX","listenersRef","useRef","navigationStateRef","layoutRef","onIndexChangeRef","currentIndexRef","pendingIndexRef","swipeVelocityThreshold","swipeDistanceThreshold","width","jumpToIndex","useCallback","animate","offset","current","transitionConfig","parallel","toValue","useNativeDriver","start","finished","undefined","setValue","useEffect","dismiss","isMovingHorizontally","_","gestureState","Math","abs","dx","dy","vx","vy","canMoveScreen","event","diffX","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","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","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,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,QADF,EAEEC,YAFF,EAGEC,QAHF,EAI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LC,UAAU,EAAE;EAHP;AADwB,CAAlB,CAAf"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
1
|
+
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); }
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { Platform, Pressable } from 'react-native';
|
|
@@ -12,25 +12,29 @@ const ANDROID_SUPPORTS_RIPPLE = Platform.OS === 'android' && Platform.Version >=
|
|
|
12
12
|
* On other platforms, you can pass the props of TouchableOpacity.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
export default function PlatformPressable({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
export default function PlatformPressable(_ref) {
|
|
16
|
+
let {
|
|
17
|
+
android_ripple,
|
|
18
|
+
pressColor = 'rgba(0, 0, 0, .32)',
|
|
19
|
+
pressOpacity,
|
|
20
|
+
style,
|
|
21
|
+
...rest
|
|
22
|
+
} = _ref;
|
|
22
23
|
return /*#__PURE__*/React.createElement(Pressable, _extends({
|
|
23
24
|
android_ripple: ANDROID_SUPPORTS_RIPPLE ? {
|
|
24
25
|
color: pressColor,
|
|
25
26
|
...android_ripple
|
|
26
27
|
} : undefined,
|
|
27
|
-
style:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
style: _ref2 => {
|
|
29
|
+
let {
|
|
30
|
+
pressed
|
|
31
|
+
} = _ref2;
|
|
32
|
+
return [{
|
|
33
|
+
opacity: pressed && !ANDROID_SUPPORTS_RIPPLE ? pressOpacity : 1
|
|
34
|
+
}, typeof style === 'function' ? style({
|
|
35
|
+
pressed
|
|
36
|
+
}) : style];
|
|
37
|
+
}
|
|
34
38
|
}, rest));
|
|
35
39
|
}
|
|
36
40
|
//# sourceMappingURL=PlatformPressable.js.map
|