react-native-tab-view 3.1.1 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -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 +17 -15
- package/lib/commonjs/PagerViewAdapter.js.map +1 -1
- package/lib/commonjs/PanResponderAdapter.js +20 -16
- 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 +40 -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 +17 -15
- package/lib/module/PagerViewAdapter.js.map +1 -1
- package/lib/module/PanResponderAdapter.js +20 -16
- 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 +39 -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/TabBar.d.ts +3 -1
- package/lib/typescript/TabBarIndicator.d.ts +1 -0
- package/lib/typescript/TabView.d.ts +2 -1
- package/package.json +19 -18
- package/src/TabBar.tsx +75 -31
- package/src/TabBarIndicator.tsx +14 -5
- package/src/TabView.tsx +3 -0
package/lib/commonjs/TabView.js
CHANGED
|
@@ -21,25 +21,27 @@ 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
|
+
} = _ref;
|
|
43
45
|
const [layout, setLayout] = React.useState({
|
|
44
46
|
width: 0,
|
|
45
47
|
height: 0,
|
|
@@ -79,13 +81,15 @@ function TabView({
|
|
|
79
81
|
swipeEnabled: swipeEnabled,
|
|
80
82
|
onSwipeStart: onSwipeStart,
|
|
81
83
|
onSwipeEnd: onSwipeEnd,
|
|
82
|
-
onIndexChange: jumpToIndex
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
onIndexChange: jumpToIndex,
|
|
85
|
+
style: pagerStyle
|
|
86
|
+
}, _ref2 => {
|
|
87
|
+
let {
|
|
88
|
+
position,
|
|
89
|
+
render,
|
|
90
|
+
addEnterListener,
|
|
91
|
+
jumpTo
|
|
92
|
+
} = _ref2;
|
|
89
93
|
// All of the props here must not change between re-renders
|
|
90
94
|
// This is crucial to optimizing the routes with PureComponent
|
|
91
95
|
const sceneRendererProps = {
|
|
@@ -106,13 +110,16 @@ function TabView({
|
|
|
106
110
|
lazyPreloadDistance: lazyPreloadDistance,
|
|
107
111
|
navigationState: navigationState,
|
|
108
112
|
style: sceneContainerStyle
|
|
109
|
-
}),
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
}), _ref3 => {
|
|
114
|
+
let {
|
|
115
|
+
loading
|
|
116
|
+
} = _ref3;
|
|
117
|
+
return loading ? renderLazyPlaceholder({
|
|
118
|
+
route
|
|
119
|
+
}) : renderScene({ ...sceneRendererProps,
|
|
120
|
+
route
|
|
121
|
+
});
|
|
122
|
+
});
|
|
116
123
|
})), tabBarPosition === 'bottom' && renderTabBar({ ...sceneRendererProps,
|
|
117
124
|
navigationState
|
|
118
125
|
}));
|
|
@@ -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","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}: 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 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,OAiBF;EAAA,IAjBoC;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/CC,KAd+C;IAe/CC,YAAY,GAAG,IAfgC;IAgB/CC,cAAc,GAAG;EAhB8B,CAiBpC;EACX,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsBC,KAAK,CAACC,QAAN,CAAe;IACzCC,KAAK,EAAE,CADkC;IAEzCC,MAAM,EAAE,CAFiC;IAGzC,GAAGnB;EAHsC,CAAf,CAA5B;;EAMA,MAAMoB,WAAW,GAAIC,KAAD,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,kBAAD,eACMJ,kBADN;QAEE,gBAAgB,EAAEF,gBAFpB;QAGE,GAAG,EAAEK,KAAK,CAACE,GAHb;QAIE,KAAK,EAAED,CAJT;QAKE,IAAI,EAAE,OAAOlC,IAAP,KAAgB,UAAhB,GAA6BA,IAAI,CAAC;UAAEiC;QAAF,CAAD,CAAjC,GAA+CjC,IALvD;QAME,mBAAmB,EAAEC,mBANvB;QAOE,eAAe,EAAEL,eAPnB;QAQE,KAAK,EAAEW;MART,IAUG;QAAA,IAAC;UAAE6B;QAAF,CAAD;QAAA,OACCA,OAAO,GACHhC,qBAAqB,CAAC;UAAE6B;QAAF,CAAD,CADlB,GAEHpC,WAAW,CAAC,EACV,GAAGiC,kBADO;UAEVG;QAFU,CAAD,CAHhB;MAAA,CAVH,CADF;IAqBD,CAtBD,CADK,CANT,EA+BGtB,cAAc,KAAK,QAAnB,IACCN,YAAY,CAAC,EACX,GAAGyB,kBADQ;MAEXlC;IAFW,CAAD,CAhChB,CADF;EAuCD,CA1DH,CADF,CADF;AAgED;;AAED,MAAM4B,MAAM,GAAGa,uBAAA,CAAWC,MAAX,CAAkB;EAC/Bb,KAAK,EAAE;IACLc,IAAI,EAAE,CADD;IAELC,QAAQ,EAAE;EAFL;AADwB,CAAlB,CAAf"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
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 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,22 @@
|
|
|
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
|
+
...rest
|
|
19
|
+
} = _ref;
|
|
19
20
|
const {
|
|
20
21
|
index
|
|
21
22
|
} = navigationState;
|
|
@@ -58,9 +59,10 @@ export default function PagerViewAdapter({
|
|
|
58
59
|
|
|
59
60
|
case 'dragging':
|
|
60
61
|
{
|
|
61
|
-
const subscription = offset.addListener(
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
const subscription = offset.addListener(_ref2 => {
|
|
63
|
+
let {
|
|
64
|
+
value
|
|
65
|
+
} = _ref2;
|
|
64
66
|
const next = index + (value > 0 ? Math.ceil(value) : Math.floor(value));
|
|
65
67
|
|
|
66
68
|
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","rest","index","listenersRef","useRef","pagerRef","indexRef","navigationStateRef","position","offset","useEffect","current","jumpTo","useCallback","key","routes","findIndex","route","setPage","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 ...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((key: string) => {\n const index = navigationStateRef.current.routes.findIndex(\n (route: { key: string }) => route.key === key\n );\n\n pagerRef.current?.setPage(index);\n }, []);\n\n React.useEffect(() => {\n if (keyboardDismissMode === 'auto') {\n Keyboard.dismiss();\n }\n\n if (indexRef.current !== index) {\n pagerRef.current?.setPage(index);\n }\n }, [keyboardDismissMode, index]);\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,SAASI,gBAAT,OAUF;EAAA,IAV6C;IACxDC,mBAAmB,GAAG,MADkC;IAExDC,YAAY,GAAG,IAFyC;IAGxDC,eAHwD;IAIxDC,aAJwD;IAKxDC,YALwD;IAMxDC,UANwD;IAOxDC,QAPwD;IAQxDC,KARwD;IASxD,GAAGC;EATqD,CAU7C;EACX,MAAM;IAAEC;EAAF,IAAYP,eAAlB;EAEA,MAAMQ,YAAY,GAAGnB,KAAK,CAACoB,MAAN,CAAyB,EAAzB,CAArB;EAEA,MAAMC,QAAQ,GAAGrB,KAAK,CAACoB,MAAN,EAAjB;EACA,MAAME,QAAQ,GAAGtB,KAAK,CAACoB,MAAN,CAAqBF,KAArB,CAAjB;EACA,MAAMK,kBAAkB,GAAGvB,KAAK,CAACoB,MAAN,CAAaT,eAAb,CAA3B;EAEA,MAAMa,QAAQ,GAAGnB,gBAAgB,CAACa,KAAD,CAAjC;EACA,MAAMO,MAAM,GAAGpB,gBAAgB,CAAC,CAAD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,IAAO;QACrB,MAAM1C,KAAK,GAAG0C,CAAC,CAACrB,WAAF,CAAcf,QAA5B;QACAF,QAAQ,CAACK,OAAT,GAAmBT,KAAnB;QACAN,aAAa,CAACM,KAAD,CAAb;MACD,CAvBH;MAwBE,wBAAwB,EAAEkB,wBAxB5B;MAyBE,aAAa,EAAE1B;IAzBjB,IA2BGK,QA3BH;EALY,CAAD,CAAf;AAoCD;AAED,MAAMyC,MAAM,GAAGrD,UAAU,CAAC0D,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,18 @@ 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
|
+
} = _ref;
|
|
25
26
|
const {
|
|
26
27
|
routes,
|
|
27
28
|
index
|
|
@@ -44,9 +45,11 @@ export default function PanResponderAdapter({
|
|
|
44
45
|
Animated.parallel([timing(panX, { ...transitionConfig,
|
|
45
46
|
toValue: offset,
|
|
46
47
|
useNativeDriver: false
|
|
47
|
-
})]).start(
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
})]).start(_ref2 => {
|
|
49
|
+
let {
|
|
50
|
+
finished
|
|
51
|
+
} = _ref2;
|
|
52
|
+
|
|
50
53
|
if (finished) {
|
|
51
54
|
onIndexChangeRef.current(index);
|
|
52
55
|
pendingIndexRef.current = undefined;
|
|
@@ -103,7 +106,8 @@ export default function PanResponderAdapter({
|
|
|
103
106
|
const diffX = I18nManager.isRTL ? -gestureState.dx : gestureState.dx;
|
|
104
107
|
|
|
105
108
|
if ( // swiping left
|
|
106
|
-
diffX > 0 && index <= 0 ||
|
|
109
|
+
diffX > 0 && index <= 0 || // swiping right
|
|
110
|
+
diffX < 0 && index >= routes.length - 1) {
|
|
107
111
|
return;
|
|
108
112
|
}
|
|
109
113
|
|
|
@@ -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,WAPF,EAQEC,IARF,QASO,cATP;AAUA,OAAOC,gBAAP,MAA6B,oBAA7B;AA6BA,MAAMC,SAAS,GAAG,EAAlB;AAEA,MAAMC,qBAAqB,GAAG;AAC5BC,EAAAA,MAAM,EAAET,QAAQ,CAACU,MADW;AAE5BC,EAAAA,SAAS,EAAE,IAFiB;AAG5BC,EAAAA,OAAO,EAAE,GAHmB;AAI5BC,EAAAA,IAAI,EAAE,CAJsB;AAK5BC,EAAAA,iBAAiB,EAAE;AALS,CAA9B;AAQA,eAAe,SAASC,mBAAT,CAA8C;AAC3DC,EAAAA,MAD2D;AAE3DC,EAAAA,mBAAmB,GAAG,MAFqC;AAG3DC,EAAAA,YAAY,GAAG,IAH4C;AAI3DC,EAAAA,eAJ2D;AAK3DC,EAAAA,aAL2D;AAM3DC,EAAAA,YAN2D;AAO3DC,EAAAA,UAP2D;AAQ3DC,EAAAA,QAR2D;AAS3DC,EAAAA;AAT2D,CAA9C,EAUF;AACX,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAAoBP,eAA1B;AAEA,QAAMQ,IAAI,GAAGrB,gBAAgB,CAAC,CAAD,CAA7B;AAEA,QAAMsB,YAAY,GAAG7B,KAAK,CAAC8B,MAAN,CAAyB,EAAzB,CAArB;AAEA,QAAMC,kBAAkB,GAAG/B,KAA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QC,CAAR,KAAc;AAC1C,YAAM3B,KAAK,GAAGpE,MAAM,CAAC+F,CAAD,CAApB;AACA,YAAMC,OAAO,GAAGD,CAAC,KAAK9F,KAAtB;AAEA,0BACE,oBAAC,IAAD;AACE,QAAA,GAAG,EAAEmE,KAAK,CAACF,GADb;AAEE,QAAA,KAAK,EACH3E,MAAM,CAACqB,KAAP,GACI;AAAEA,UAAAA,KAAK,EAAErB,MAAM,CAACqB;AAAhB,SADJ,GAEIoF,OAAO,GACPtH,UAAU,CAACuH,YADJ,GAEP;AAPR,SAUGD,OAAO,IAAIzG,MAAM,CAACqB,KAAlB,GAA0BkF,KAA1B,GAAkC,IAVrC,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","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"],"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}: 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"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,QADF,EAEEC,YAFF,EAGEC,QAHF,EAIEC,UAJF,EAOEC,WAPF,EAQEC,IARF,QASO,cATP;AAUA,OAAOC,gBAAP,MAA6B,oBAA7B;AA6BA,MAAMC,SAAS,GAAG,EAAlB;AAEA,MAAMC,qBAAqB,GAAG;EAC5BC,MAAM,EAAET,QAAQ,CAACU,MADW;EAE5BC,SAAS,EAAE,IAFiB;EAG5BC,OAAO,EAAE,GAHmB;EAI5BC,IAAI,EAAE,CAJsB;EAK5BC,iBAAiB,EAAE;AALS,CAA9B;AAQA,eAAe,SAASC,mBAAT,OAUF;EAAA,IAVgD;IAC3DC,MAD2D;IAE3DC,mBAAmB,GAAG,MAFqC;IAG3DC,YAAY,GAAG,IAH4C;IAI3DC,eAJ2D;IAK3DC,aAL2D;IAM3DC,YAN2D;IAO3DC,UAP2D;IAQ3DC,QAR2D;IAS3DC;EAT2D,CAUhD;EACX,MAAM;IAAEC,MAAF;IAAUC;EAAV,IAAoBP,eAA1B;EAEA,MAAMQ,IAAI,GAAGrB,gBAAgB,CAAC,CAAD,CAA7B;EAEA,MAAMsB,YAAY,GAAG7B,KAAK,CAAC8B,MAAN,CAAyB,EAAzB,CAArB;EAEA,MAAMC,kBAAkB,GAAG/B,KAAK,CAAC8B,MAAN,CAAaV,eAAb,CAA3B;EACA,MAAMY,SAAS,GAAGhC,KAAK,CAAC8B,MAAN,CAAab,MAAb,CAAlB;EACA,MAAMgB,gBAAgB,GAAGjC,KAAK,CAAC8B,MAAN,CAAaT,aAAb,CAAzB;EAEA,MAAMa,eAAe,GAAGlC,KAAK,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;IAGLC,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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["React","Platform","Pressable","ANDROID_VERSION_LOLLIPOP","ANDROID_SUPPORTS_RIPPLE","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,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoD,cAApD;AAQA,MAAMC,wBAAwB,GAAG,EAAjC;AACA,MAAMC,uBAAuB,GAC3BH,QAAQ,CAACI,EAAT,KAAgB,SAAhB,IAA6BJ,QAAQ,CAACK,OAAT,IAAoBH,wBADnD;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASI,iBAAT,OAML;EAAA,IANgC;IACxCC,cADwC;IAExCC,UAAU,GAAG,oBAF2B;IAGxCC,YAHwC;IAIxCC,KAJwC;IAKxC,GAAGC;EALqC,CAMhC;EACR,oBACE,oBAAC,SAAD;IACE,cAAc,EACZR,uBAAuB,GACnB;MAAES,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,CAACX,uBAAZ,GAAsCM,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/module/SceneMap.js
CHANGED
|
@@ -12,16 +12,19 @@ class SceneComponent extends React.PureComponent {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export default function SceneMap(scenes) {
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
return _ref => {
|
|
16
|
+
let {
|
|
17
|
+
route,
|
|
18
|
+
jumpTo,
|
|
19
|
+
position
|
|
20
|
+
} = _ref;
|
|
21
|
+
return /*#__PURE__*/React.createElement(SceneComponent, {
|
|
22
|
+
key: route.key,
|
|
23
|
+
component: scenes[route.key],
|
|
24
|
+
route: route,
|
|
25
|
+
jumpTo: jumpTo,
|
|
26
|
+
position: position
|
|
27
|
+
});
|
|
28
|
+
};
|
|
26
29
|
}
|
|
27
30
|
//# sourceMappingURL=SceneMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["React","SceneComponent","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,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;;AAGA,MAAMC,cAAN,SAEUD,KAAK,CAACE,aAFhB,CAEiC;EAC/BC,MAAM,GAAG;IACP,MAAM;MAAEC,SAAF;MAAa,GAAGC;IAAhB,IAAyB,KAAKC,KAApC;IACA,oBAAON,KAAK,CAACO,aAAN,CAAoBH,SAApB,EAA+BC,IAA/B,CAAP;EACD;;AAJ8B;;AAOjC,eAAe,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"}
|
package/lib/module/SceneView.js
CHANGED
|
@@ -3,8 +3,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { View, StyleSheet } from 'react-native';
|
|
5
5
|
export default class SceneView extends React.Component {
|
|
6
|
-
constructor(
|
|
7
|
-
super(...
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
8
|
|
|
9
9
|
_defineProperty(this, "state", {
|
|
10
10
|
loading: Math.abs(this.props.navigationState.index - this.props.index) > this.props.lazyPreloadDistance
|