@react-navigation/native-stack 6.4.1 → 6.5.2
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/lib/commonjs/views/NativeStackView.native.js +17 -12
- package/lib/commonjs/views/NativeStackView.native.js.map +1 -1
- package/lib/module/views/NativeStackView.native.js +17 -12
- package/lib/module/views/NativeStackView.native.js.map +1 -1
- package/lib/typescript/src/types.d.ts +21 -1
- package/package.json +2 -2
- package/src/types.tsx +21 -1
- package/src/views/NativeStackView.native.tsx +45 -37
|
@@ -95,11 +95,13 @@ const SceneView = _ref2 => {
|
|
|
95
95
|
render
|
|
96
96
|
} = descriptor;
|
|
97
97
|
const {
|
|
98
|
+
animation,
|
|
99
|
+
animationTypeForReplace = 'push',
|
|
100
|
+
customAnimationOnGesture,
|
|
101
|
+
fullScreenGestureEnabled,
|
|
98
102
|
gestureEnabled,
|
|
99
103
|
header,
|
|
100
104
|
headerShown,
|
|
101
|
-
animationTypeForReplace = 'push',
|
|
102
|
-
animation,
|
|
103
105
|
orientation,
|
|
104
106
|
statusBarAnimation,
|
|
105
107
|
statusBarHidden,
|
|
@@ -133,6 +135,8 @@ const SceneView = _ref2 => {
|
|
|
133
135
|
key: route.key,
|
|
134
136
|
enabled: true,
|
|
135
137
|
style: _reactNative.StyleSheet.absoluteFill,
|
|
138
|
+
customAnimationOnSwipe: customAnimationOnGesture,
|
|
139
|
+
fullScreenSwipeEnabled: fullScreenGestureEnabled,
|
|
136
140
|
gestureEnabled: isAndroid ? // This prop enables handling of system back gestures on Android
|
|
137
141
|
// Since we handle them in JS side, we disable this
|
|
138
142
|
false : gestureEnabled,
|
|
@@ -146,16 +150,17 @@ const SceneView = _ref2 => {
|
|
|
146
150
|
onWillDisappear: onWillDisappear,
|
|
147
151
|
onAppear: onAppear,
|
|
148
152
|
onDisappear: onDisappear,
|
|
149
|
-
onDismissed: onDismissed
|
|
153
|
+
onDismissed: onDismissed,
|
|
154
|
+
isNativeStack: true
|
|
155
|
+
}, /*#__PURE__*/React.createElement(_native.NavigationContext.Provider, {
|
|
156
|
+
value: navigation
|
|
157
|
+
}, /*#__PURE__*/React.createElement(_native.NavigationRouteContext.Provider, {
|
|
158
|
+
value: route
|
|
150
159
|
}, /*#__PURE__*/React.createElement(_elements.HeaderShownContext.Provider, {
|
|
151
160
|
value: isParentHeaderShown || isHeaderInPush !== false
|
|
152
161
|
}, /*#__PURE__*/React.createElement(_elements.HeaderHeightContext.Provider, {
|
|
153
162
|
value: isHeaderInPush !== false ? headerHeight : parentHeaderHeight !== null && parentHeaderHeight !== void 0 ? parentHeaderHeight : 0
|
|
154
|
-
}, header !== undefined && headerShown !== false ? /*#__PURE__*/React.createElement(
|
|
155
|
-
value: navigation
|
|
156
|
-
}, /*#__PURE__*/React.createElement(_native.NavigationRouteContext.Provider, {
|
|
157
|
-
value: route
|
|
158
|
-
}, /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
163
|
+
}, header !== undefined && headerShown !== false ? /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
159
164
|
onLayout: e => {
|
|
160
165
|
setCustomHeaderHeight(e.nativeEvent.layout.height);
|
|
161
166
|
}
|
|
@@ -166,7 +171,7 @@ const SceneView = _ref2 => {
|
|
|
166
171
|
options,
|
|
167
172
|
route,
|
|
168
173
|
navigation
|
|
169
|
-
}))
|
|
174
|
+
})) : /*#__PURE__*/React.createElement(_HeaderConfig.default, _extends({}, options, {
|
|
170
175
|
route: route,
|
|
171
176
|
headerShown: isHeaderInPush,
|
|
172
177
|
headerHeight: headerHeight,
|
|
@@ -176,7 +181,7 @@ const SceneView = _ref2 => {
|
|
|
176
181
|
route: route,
|
|
177
182
|
presentation: presentation,
|
|
178
183
|
headerHeight: headerHeight
|
|
179
|
-
}, render()))));
|
|
184
|
+
}, render()))))));
|
|
180
185
|
};
|
|
181
186
|
|
|
182
187
|
function NativeStackViewInner(_ref3) {
|
|
@@ -235,8 +240,8 @@ function NativeStackViewInner(_ref3) {
|
|
|
235
240
|
target: route.key
|
|
236
241
|
});
|
|
237
242
|
},
|
|
238
|
-
onDismissed:
|
|
239
|
-
navigation.dispatch({ ..._native.StackActions.pop(),
|
|
243
|
+
onDismissed: event => {
|
|
244
|
+
navigation.dispatch({ ..._native.StackActions.pop(event.nativeEvent.dismissCount),
|
|
240
245
|
source: route.key,
|
|
241
246
|
target: state.key
|
|
242
247
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["NativeStackView.native.tsx"],"names":["isAndroid","Platform","OS","MaybeNestedStack","options","route","presentation","headerHeight","children","colors","header","headerShown","contentStyle","isHeaderInModal","undefined","headerShownPreviousRef","React","useRef","useEffect","current","name","content","styles","container","backgroundColor","background","StyleSheet","absoluteFill","SceneView","descriptor","previousDescriptor","index","onWillDisappear","onAppear","onDisappear","onDismissed","navigation","render","gestureEnabled","animationTypeForReplace","animation","orientation","statusBarAnimation","statusBarHidden","statusBarStyle","isHeaderInPush","insets","frame","isModal","isIPhone","isPad","isTVOS","isLandscape","width","height","topInset","top","isParentHeaderShown","useContext","HeaderShownContext","parentHeaderHeight","HeaderHeightContext","defaultHeaderHeight","customHeaderHeight","setCustomHeaderHeight","useState","key","e","nativeEvent","layout","back","title","NativeStackViewInner","state","descriptors","nextDismissedKey","setNextDismissedKey","dismissedRouteName","routes","find","message","console","error","map","previousKey","emit","type","data","closing","target","dispatch","StackActions","pop","source","NativeStackView","props","create","flex"],"mappings":";;;;;;;AAAA;;AAOA;;AASA;;AACA;;AACA;;AAIA;;AAKA;;AAQA;;AACA;;;;;;;;;;AAEA,MAAMA,SAAS,GAAGC,sBAASC,EAAT,KAAgB,SAAlC;;AAEA,MAAMC,gBAAgB,GAAG,QAYnB;AAAA,MAZoB;AACxBC,IAAAA,OADwB;AAExBC,IAAAA,KAFwB;AAGxBC,IAAAA,YAHwB;AAIxBC,IAAAA,YAJwB;AAKxBC,IAAAA;AALwB,GAYpB;AACJ,QAAM;AAAEC,IAAAA;AAAF,M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aderHeightContext,\n HeaderShownContext,\n SafeAreaProviderCompat,\n} from '@react-navigation/elements';\nimport {\n NavigationContext,\n NavigationRouteContext,\n ParamListBase,\n Route,\n StackActions,\n StackNavigationState,\n useTheme,\n} from '@react-navigation/native';\nimport * as React from 'react';\nimport { Platform, StyleSheet, View } from 'react-native';\nimport {\n useSafeAreaFrame,\n useSafeAreaInsets,\n} from 'react-native-safe-area-context';\nimport {\n Screen,\n ScreenStack,\n StackPresentationTypes,\n} from 'react-native-screens';\nimport warnOnce from 'warn-once';\n\nimport type {\n NativeStackDescriptor,\n NativeStackDescriptorMap,\n NativeStackNavigationHelpers,\n NativeStackNavigationOptions,\n} from '../types';\nimport DebugContainer from './DebugContainer';\nimport HeaderConfig from './HeaderConfig';\n\nconst isAndroid = Platform.OS === 'android';\n\nconst MaybeNestedStack = ({\n options,\n route,\n presentation,\n headerHeight,\n children,\n}: {\n options: NativeStackNavigationOptions;\n route: Route<string>;\n presentation: Exclude<StackPresentationTypes, 'push'> | 'card';\n headerHeight: number;\n children: React.ReactNode;\n}) => {\n const { colors } = useTheme();\n const { header, headerShown = true, contentStyle } = options;\n\n const isHeaderInModal = isAndroid\n ? false\n : presentation !== 'card' && headerShown === true && header === undefined;\n\n const headerShownPreviousRef = React.useRef(headerShown);\n\n React.useEffect(() => {\n warnOnce(\n !isAndroid &&\n presentation !== 'card' &&\n headerShownPreviousRef.current !== headerShown,\n `Dynamically changing 'headerShown' in modals will result in remounting the screen and losing all local state. See options for the screen '${route.name}'.`\n );\n\n headerShownPreviousRef.current = headerShown;\n }, [headerShown, presentation, route.name]);\n\n const content = (\n <DebugContainer\n style={[\n styles.container,\n presentation !== 'transparentModal' &&\n presentation !== 'containedTransparentModal' && {\n backgroundColor: colors.background,\n },\n contentStyle,\n ]}\n stackPresentation={presentation === 'card' ? 'push' : presentation}\n >\n {children}\n </DebugContainer>\n );\n\n if (isHeaderInModal) {\n return (\n <ScreenStack style={styles.container}>\n <Screen enabled style={StyleSheet.absoluteFill}>\n <HeaderConfig\n {...options}\n route={route}\n headerHeight={headerHeight}\n canGoBack\n />\n {content}\n </Screen>\n </ScreenStack>\n );\n }\n\n return content;\n};\n\ntype SceneViewProps = {\n index: number;\n descriptor: NativeStackDescriptor;\n previousDescriptor?: NativeStackDescriptor;\n onWillDisappear: () => void;\n onAppear: () => void;\n onDisappear: () => void;\n onDismissed: () => void;\n};\n\nconst SceneView = ({\n descriptor,\n previousDescriptor,\n index,\n onWillDisappear,\n onAppear,\n onDisappear,\n onDismissed,\n}: SceneViewProps) => {\n const { route, navigation, options, render } = descriptor;\n const {\n gestureEnabled,\n header,\n headerShown,\n animationTypeForReplace = 'push',\n animation,\n orientation,\n statusBarAnimation,\n statusBarHidden,\n statusBarStyle,\n } = options;\n\n let { presentation = 'card' } = options;\n\n if (index === 0) {\n // first screen should always be treated as `card`, it resolves problems with no header animation\n // for navigator with first screen as `modal` and the next as `card`\n presentation = 'card';\n }\n\n const isHeaderInPush = isAndroid\n ? headerShown\n : presentation === 'card' && headerShown !== false;\n\n const insets = useSafeAreaInsets();\n const frame = useSafeAreaFrame();\n\n // `modal` and `formSheet` presentations do not take whole screen, so should not take the inset.\n const isModal = presentation === 'modal' || presentation === 'formSheet';\n\n // Modals are fullscreen in landscape only on iPhone\n const isIPhone =\n Platform.OS === 'ios' && !(Platform.isPad && Platform.isTVOS);\n const isLandscape = frame.width > frame.height;\n\n const topInset = isModal || (isIPhone && isLandscape) ? 0 : insets.top;\n\n const isParentHeaderShown = React.useContext(HeaderShownContext);\n const parentHeaderHeight = React.useContext(HeaderHeightContext);\n\n const defaultHeaderHeight = getDefaultHeaderHeight(frame, isModal, topInset);\n\n const [customHeaderHeight, setCustomHeaderHeight] =\n React.useState(defaultHeaderHeight);\n\n const headerHeight = header ? customHeaderHeight : defaultHeaderHeight;\n\n return (\n <Screen\n key={route.key}\n enabled\n style={StyleSheet.absoluteFill}\n gestureEnabled={\n isAndroid\n ? // This prop enables handling of system back gestures on Android\n // Since we handle them in JS side, we disable this\n false\n : gestureEnabled\n }\n replaceAnimation={animationTypeForReplace}\n stackPresentation={presentation === 'card' ? 'push' : presentation}\n stackAnimation={animation}\n screenOrientation={orientation}\n statusBarAnimation={statusBarAnimation}\n statusBarHidden={statusBarHidden}\n statusBarStyle={statusBarStyle}\n onWillDisappear={onWillDisappear}\n onAppear={onAppear}\n onDisappear={onDisappear}\n onDismissed={onDismissed}\n >\n <HeaderShownContext.Provider\n value={isParentHeaderShown || isHeaderInPush !== false}\n >\n <HeaderHeightContext.Provider\n value={\n isHeaderInPush !== false ? headerHeight : parentHeaderHeight ?? 0\n }\n >\n {header !== undefined && headerShown !== false ? (\n <NavigationContext.Provider value={navigation}>\n <NavigationRouteContext.Provider value={route}>\n <View\n onLayout={(e) => {\n setCustomHeaderHeight(e.nativeEvent.layout.height);\n }}\n >\n {header({\n back: previousDescriptor\n ? {\n title: getHeaderTitle(\n previousDescriptor.options,\n previousDescriptor.route.name\n ),\n }\n : undefined,\n options,\n route,\n navigation,\n })}\n </View>\n </NavigationRouteContext.Provider>\n </NavigationContext.Provider>\n ) : (\n <HeaderConfig\n {...options}\n route={route}\n headerShown={isHeaderInPush}\n headerHeight={headerHeight}\n canGoBack={index !== 0}\n />\n )}\n <MaybeNestedStack\n options={options}\n route={route}\n presentation={presentation}\n headerHeight={headerHeight}\n >\n {render()}\n </MaybeNestedStack>\n </HeaderHeightContext.Provider>\n </HeaderShownContext.Provider>\n </Screen>\n );\n};\n\ntype Props = {\n state: StackNavigationState<ParamListBase>;\n navigation: NativeStackNavigationHelpers;\n descriptors: NativeStackDescriptorMap;\n};\n\nfunction NativeStackViewInner({ state, navigation, descriptors }: Props) {\n const [nextDismissedKey, setNextDismissedKey] = React.useState<string | null>(\n null\n );\n\n const dismissedRouteName = nextDismissedKey\n ? state.routes.find((route) => route.key === nextDismissedKey)?.name\n : null;\n\n React.useEffect(() => {\n if (dismissedRouteName) {\n const message =\n `The screen '${dismissedRouteName}' was removed natively but didn't get removed from JS state. ` +\n `This can happen if the action was prevented in a 'beforeRemove' listener, which is not fully supported in native-stack.\\n\\n` +\n `Consider using 'gestureEnabled: false' to prevent back gesture and use a custom back button with 'headerLeft' option to override the native behavior.`;\n\n console.error(message);\n }\n }, [dismissedRouteName]);\n\n return (\n <ScreenStack style={styles.container}>\n {state.routes.map((route, index) => {\n const descriptor = descriptors[route.key];\n const previousKey = state.routes[index - 1]?.key;\n const previousDescriptor = previousKey\n ? descriptors[previousKey]\n : undefined;\n\n return (\n <SceneView\n key={route.key}\n index={index}\n descriptor={descriptor}\n previousDescriptor={previousDescriptor}\n onWillDisappear={() => {\n navigation.emit({\n type: 'transitionStart',\n data: { closing: true },\n target: route.key,\n });\n }}\n onAppear={() => {\n navigation.emit({\n type: 'transitionEnd',\n data: { closing: false },\n target: route.key,\n });\n }}\n onDisappear={() => {\n navigation.emit({\n type: 'transitionEnd',\n data: { closing: true },\n target: route.key,\n });\n }}\n onDismissed={() => {\n navigation.dispatch({\n ...StackActions.pop(),\n source: route.key,\n target: state.key,\n });\n\n setNextDismissedKey(route.key);\n }}\n />\n );\n })}\n </ScreenStack>\n );\n}\n\nexport default function NativeStackView(props: Props) {\n return (\n <SafeAreaProviderCompat>\n <NativeStackViewInner {...props} />\n </SafeAreaProviderCompat>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["NativeStackView.native.tsx"],"names":["isAndroid","Platform","OS","MaybeNestedStack","options","route","presentation","headerHeight","children","colors","header","headerShown","contentStyle","isHeaderInModal","undefined","headerShownPreviousRef","React","useRef","useEffect","current","name","content","styles","container","backgroundColor","background","StyleSheet","absoluteFill","SceneView","descriptor","previousDescriptor","index","onWillDisappear","onAppear","onDisappear","onDismissed","navigation","render","animation","animationTypeForReplace","customAnimationOnGesture","fullScreenGestureEnabled","gestureEnabled","orientation","statusBarAnimation","statusBarHidden","statusBarStyle","isHeaderInPush","insets","frame","isModal","isIPhone","isPad","isTVOS","isLandscape","width","height","topInset","top","isParentHeaderShown","useContext","HeaderShownContext","parentHeaderHeight","HeaderHeightContext","defaultHeaderHeight","customHeaderHeight","setCustomHeaderHeight","useState","key","e","nativeEvent","layout","back","title","NativeStackViewInner","state","descriptors","nextDismissedKey","setNextDismissedKey","dismissedRouteName","routes","find","message","console","error","map","previousKey","emit","type","data","closing","target","event","dispatch","StackActions","pop","dismissCount","source","NativeStackView","props","create","flex"],"mappings":";;;;;;;AAAA;;AAOA;;AASA;;AACA;;AACA;;AAKA;;AAKA;;AAQA;;AACA;;;;;;;;;;AAEA,MAAMA,SAAS,GAAGC,sBAASC,EAAT,KAAgB,SAAlC;;AAEA,MAAMC,gBAAgB,GAAG,QAYnB;AAAA,MAZoB;AACxBC,IAAAA,OADwB;AAExBC,IAAAA,KAFwB;AAGxBC,IAAAA,YAHwB;AAIxBC,IAAAA,YAJwB;AAKxBC,IAAAA;AALwB,GAYpB;AACJ,QAAM;AAAEC,IAAAA;AAAF,MAAa,uBAAnB;AACA,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,WAAW,GAAG,IAAxB;AAA8BC,IAAAA;AAA9B,MAA+CR,OAArD;AAEA,QAAMS,eAAe,GAAGb,SAAS,GAC7B,KAD6B,GAE7BM,YAAY,KAAK,MAAjB,IAA2BK,WAAW,KAAK,IAA3C,IAAmDD,MAAM,KAAKI,SAFlE;AAIA,QAAMC,sBAAsB,GAAGC,KAAK,CAACC,MAAN,CAAaN,WAAb,CAA/B;AAEAK,EAAAA,KAAK,CAACE,SAAN,CAAgB,MAAM;AACpB,2BACE,CAAClB,SAAD,IACEM,YAAY,KAAK,MADnB,IAEES,sBAAsB,CAACI,OAAvB,KAAmCR,WAHvC,EAIG,6IAA4IN,KAAK,CAACe,IAAK,IAJ1J;AAOAL,IAAAA,sBAAsB,CAACI,OAAvB,GAAiCR,WAAjC;AACD,GATD,EASG,CAACA,WAAD,EAAcL,YAAd,EAA4BD,KAAK,CAACe,IAAlC,CATH;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EdC,UAAAA,IAAI,EAAE;AAAEC,YAAAA,OAAO,EAAE;AAAX,WAFQ;AAGdC,UAAAA,MAAM,EAAEtF,KAAK,CAAC+D;AAHA,SAAhB;AAKD,OAzBH;AA0BE,MAAA,WAAW,EAAGwB,KAAD,IAAW;AACtBxD,QAAAA,UAAU,CAACyD,QAAX,CAAoB,EAClB,GAAGC,qBAAaC,GAAb,CAAiBH,KAAK,CAACtB,WAAN,CAAkB0B,YAAnC,CADe;AAElBC,UAAAA,MAAM,EAAE5F,KAAK,CAAC+D,GAFI;AAGlBuB,UAAAA,MAAM,EAAEhB,KAAK,CAACP;AAHI,SAApB;AAMAU,QAAAA,mBAAmB,CAACzE,KAAK,CAAC+D,GAAP,CAAnB;AACD;AAlCH,MADF;AAsCD,GA7CA,CADH,CADF;AAkDD;;AAEc,SAAS8B,eAAT,CAAyBC,KAAzB,EAAuC;AACpD,sBACE,oBAAC,gCAAD,qBACE,oBAAC,oBAAD,EAA0BA,KAA1B,CADF,CADF;AAKD;;AAED,MAAM7E,MAAM,GAAGI,wBAAW0E,MAAX,CAAkB;AAC/B7E,EAAAA,SAAS,EAAE;AACT8E,IAAAA,IAAI,EAAE;AADG;AADoB,CAAlB,CAAf","sourcesContent":["import {\n getDefaultHeaderHeight,\n getHeaderTitle,\n HeaderHeightContext,\n HeaderShownContext,\n SafeAreaProviderCompat,\n} from '@react-navigation/elements';\nimport {\n NavigationContext,\n NavigationRouteContext,\n ParamListBase,\n Route,\n StackActions,\n StackNavigationState,\n useTheme,\n} from '@react-navigation/native';\nimport * as React from 'react';\nimport { Platform, StyleSheet, View } from 'react-native';\nimport {\n useSafeAreaFrame,\n useSafeAreaInsets,\n} from 'react-native-safe-area-context';\nimport type { ScreenProps } from 'react-native-screens';\nimport {\n Screen,\n ScreenStack,\n StackPresentationTypes,\n} from 'react-native-screens';\nimport warnOnce from 'warn-once';\n\nimport type {\n NativeStackDescriptor,\n NativeStackDescriptorMap,\n NativeStackNavigationHelpers,\n NativeStackNavigationOptions,\n} from '../types';\nimport DebugContainer from './DebugContainer';\nimport HeaderConfig from './HeaderConfig';\n\nconst isAndroid = Platform.OS === 'android';\n\nconst MaybeNestedStack = ({\n options,\n route,\n presentation,\n headerHeight,\n children,\n}: {\n options: NativeStackNavigationOptions;\n route: Route<string>;\n presentation: Exclude<StackPresentationTypes, 'push'> | 'card';\n headerHeight: number;\n children: React.ReactNode;\n}) => {\n const { colors } = useTheme();\n const { header, headerShown = true, contentStyle } = options;\n\n const isHeaderInModal = isAndroid\n ? false\n : presentation !== 'card' && headerShown === true && header === undefined;\n\n const headerShownPreviousRef = React.useRef(headerShown);\n\n React.useEffect(() => {\n warnOnce(\n !isAndroid &&\n presentation !== 'card' &&\n headerShownPreviousRef.current !== headerShown,\n `Dynamically changing 'headerShown' in modals will result in remounting the screen and losing all local state. See options for the screen '${route.name}'.`\n );\n\n headerShownPreviousRef.current = headerShown;\n }, [headerShown, presentation, route.name]);\n\n const content = (\n <DebugContainer\n style={[\n styles.container,\n presentation !== 'transparentModal' &&\n presentation !== 'containedTransparentModal' && {\n backgroundColor: colors.background,\n },\n contentStyle,\n ]}\n stackPresentation={presentation === 'card' ? 'push' : presentation}\n >\n {children}\n </DebugContainer>\n );\n\n if (isHeaderInModal) {\n return (\n <ScreenStack style={styles.container}>\n <Screen enabled style={StyleSheet.absoluteFill}>\n <HeaderConfig\n {...options}\n route={route}\n headerHeight={headerHeight}\n canGoBack\n />\n {content}\n </Screen>\n </ScreenStack>\n );\n }\n\n return content;\n};\n\ntype SceneViewProps = {\n index: number;\n descriptor: NativeStackDescriptor;\n previousDescriptor?: NativeStackDescriptor;\n onWillDisappear: () => void;\n onAppear: () => void;\n onDisappear: () => void;\n onDismissed: ScreenProps['onDismissed'];\n};\n\nconst SceneView = ({\n descriptor,\n previousDescriptor,\n index,\n onWillDisappear,\n onAppear,\n onDisappear,\n onDismissed,\n}: SceneViewProps) => {\n const { route, navigation, options, render } = descriptor;\n const {\n animation,\n animationTypeForReplace = 'push',\n customAnimationOnGesture,\n fullScreenGestureEnabled,\n gestureEnabled,\n header,\n headerShown,\n orientation,\n statusBarAnimation,\n statusBarHidden,\n statusBarStyle,\n } = options;\n\n let { presentation = 'card' } = options;\n\n if (index === 0) {\n // first screen should always be treated as `card`, it resolves problems with no header animation\n // for navigator with first screen as `modal` and the next as `card`\n presentation = 'card';\n }\n\n const isHeaderInPush = isAndroid\n ? headerShown\n : presentation === 'card' && headerShown !== false;\n\n const insets = useSafeAreaInsets();\n const frame = useSafeAreaFrame();\n\n // `modal` and `formSheet` presentations do not take whole screen, so should not take the inset.\n const isModal = presentation === 'modal' || presentation === 'formSheet';\n\n // Modals are fullscreen in landscape only on iPhone\n const isIPhone =\n Platform.OS === 'ios' && !(Platform.isPad && Platform.isTVOS);\n const isLandscape = frame.width > frame.height;\n\n const topInset = isModal || (isIPhone && isLandscape) ? 0 : insets.top;\n\n const isParentHeaderShown = React.useContext(HeaderShownContext);\n const parentHeaderHeight = React.useContext(HeaderHeightContext);\n\n const defaultHeaderHeight = getDefaultHeaderHeight(frame, isModal, topInset);\n\n const [customHeaderHeight, setCustomHeaderHeight] =\n React.useState(defaultHeaderHeight);\n\n const headerHeight = header ? customHeaderHeight : defaultHeaderHeight;\n\n return (\n <Screen\n key={route.key}\n enabled\n style={StyleSheet.absoluteFill}\n customAnimationOnSwipe={customAnimationOnGesture}\n fullScreenSwipeEnabled={fullScreenGestureEnabled}\n gestureEnabled={\n isAndroid\n ? // This prop enables handling of system back gestures on Android\n // Since we handle them in JS side, we disable this\n false\n : gestureEnabled\n }\n replaceAnimation={animationTypeForReplace}\n stackPresentation={presentation === 'card' ? 'push' : presentation}\n stackAnimation={animation}\n screenOrientation={orientation}\n statusBarAnimation={statusBarAnimation}\n statusBarHidden={statusBarHidden}\n statusBarStyle={statusBarStyle}\n onWillDisappear={onWillDisappear}\n onAppear={onAppear}\n onDisappear={onDisappear}\n onDismissed={onDismissed}\n isNativeStack\n >\n <NavigationContext.Provider value={navigation}>\n <NavigationRouteContext.Provider value={route}>\n <HeaderShownContext.Provider\n value={isParentHeaderShown || isHeaderInPush !== false}\n >\n <HeaderHeightContext.Provider\n value={\n isHeaderInPush !== false\n ? headerHeight\n : parentHeaderHeight ?? 0\n }\n >\n {header !== undefined && headerShown !== false ? (\n <View\n onLayout={(e) => {\n setCustomHeaderHeight(e.nativeEvent.layout.height);\n }}\n >\n {header({\n back: previousDescriptor\n ? {\n title: getHeaderTitle(\n previousDescriptor.options,\n previousDescriptor.route.name\n ),\n }\n : undefined,\n options,\n route,\n navigation,\n })}\n </View>\n ) : (\n <HeaderConfig\n {...options}\n route={route}\n headerShown={isHeaderInPush}\n headerHeight={headerHeight}\n canGoBack={index !== 0}\n />\n )}\n <MaybeNestedStack\n options={options}\n route={route}\n presentation={presentation}\n headerHeight={headerHeight}\n >\n {render()}\n </MaybeNestedStack>\n </HeaderHeightContext.Provider>\n </HeaderShownContext.Provider>\n </NavigationRouteContext.Provider>\n </NavigationContext.Provider>\n </Screen>\n );\n};\n\ntype Props = {\n state: StackNavigationState<ParamListBase>;\n navigation: NativeStackNavigationHelpers;\n descriptors: NativeStackDescriptorMap;\n};\n\nfunction NativeStackViewInner({ state, navigation, descriptors }: Props) {\n const [nextDismissedKey, setNextDismissedKey] = React.useState<string | null>(\n null\n );\n\n const dismissedRouteName = nextDismissedKey\n ? state.routes.find((route) => route.key === nextDismissedKey)?.name\n : null;\n\n React.useEffect(() => {\n if (dismissedRouteName) {\n const message =\n `The screen '${dismissedRouteName}' was removed natively but didn't get removed from JS state. ` +\n `This can happen if the action was prevented in a 'beforeRemove' listener, which is not fully supported in native-stack.\\n\\n` +\n `Consider using 'gestureEnabled: false' to prevent back gesture and use a custom back button with 'headerLeft' option to override the native behavior.`;\n\n console.error(message);\n }\n }, [dismissedRouteName]);\n\n return (\n <ScreenStack style={styles.container}>\n {state.routes.map((route, index) => {\n const descriptor = descriptors[route.key];\n const previousKey = state.routes[index - 1]?.key;\n const previousDescriptor = previousKey\n ? descriptors[previousKey]\n : undefined;\n\n return (\n <SceneView\n key={route.key}\n index={index}\n descriptor={descriptor}\n previousDescriptor={previousDescriptor}\n onWillDisappear={() => {\n navigation.emit({\n type: 'transitionStart',\n data: { closing: true },\n target: route.key,\n });\n }}\n onAppear={() => {\n navigation.emit({\n type: 'transitionEnd',\n data: { closing: false },\n target: route.key,\n });\n }}\n onDisappear={() => {\n navigation.emit({\n type: 'transitionEnd',\n data: { closing: true },\n target: route.key,\n });\n }}\n onDismissed={(event) => {\n navigation.dispatch({\n ...StackActions.pop(event.nativeEvent.dismissCount),\n source: route.key,\n target: state.key,\n });\n\n setNextDismissedKey(route.key);\n }}\n />\n );\n })}\n </ScreenStack>\n );\n}\n\nexport default function NativeStackView(props: Props) {\n return (\n <SafeAreaProviderCompat>\n <NativeStackViewInner {...props} />\n </SafeAreaProviderCompat>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n});\n"]}
|
|
@@ -73,11 +73,13 @@ const SceneView = _ref2 => {
|
|
|
73
73
|
render
|
|
74
74
|
} = descriptor;
|
|
75
75
|
const {
|
|
76
|
+
animation,
|
|
77
|
+
animationTypeForReplace = 'push',
|
|
78
|
+
customAnimationOnGesture,
|
|
79
|
+
fullScreenGestureEnabled,
|
|
76
80
|
gestureEnabled,
|
|
77
81
|
header,
|
|
78
82
|
headerShown,
|
|
79
|
-
animationTypeForReplace = 'push',
|
|
80
|
-
animation,
|
|
81
83
|
orientation,
|
|
82
84
|
statusBarAnimation,
|
|
83
85
|
statusBarHidden,
|
|
@@ -111,6 +113,8 @@ const SceneView = _ref2 => {
|
|
|
111
113
|
key: route.key,
|
|
112
114
|
enabled: true,
|
|
113
115
|
style: StyleSheet.absoluteFill,
|
|
116
|
+
customAnimationOnSwipe: customAnimationOnGesture,
|
|
117
|
+
fullScreenSwipeEnabled: fullScreenGestureEnabled,
|
|
114
118
|
gestureEnabled: isAndroid ? // This prop enables handling of system back gestures on Android
|
|
115
119
|
// Since we handle them in JS side, we disable this
|
|
116
120
|
false : gestureEnabled,
|
|
@@ -124,16 +128,17 @@ const SceneView = _ref2 => {
|
|
|
124
128
|
onWillDisappear: onWillDisappear,
|
|
125
129
|
onAppear: onAppear,
|
|
126
130
|
onDisappear: onDisappear,
|
|
127
|
-
onDismissed: onDismissed
|
|
131
|
+
onDismissed: onDismissed,
|
|
132
|
+
isNativeStack: true
|
|
133
|
+
}, /*#__PURE__*/React.createElement(NavigationContext.Provider, {
|
|
134
|
+
value: navigation
|
|
135
|
+
}, /*#__PURE__*/React.createElement(NavigationRouteContext.Provider, {
|
|
136
|
+
value: route
|
|
128
137
|
}, /*#__PURE__*/React.createElement(HeaderShownContext.Provider, {
|
|
129
138
|
value: isParentHeaderShown || isHeaderInPush !== false
|
|
130
139
|
}, /*#__PURE__*/React.createElement(HeaderHeightContext.Provider, {
|
|
131
140
|
value: isHeaderInPush !== false ? headerHeight : parentHeaderHeight !== null && parentHeaderHeight !== void 0 ? parentHeaderHeight : 0
|
|
132
|
-
}, header !== undefined && headerShown !== false ? /*#__PURE__*/React.createElement(
|
|
133
|
-
value: navigation
|
|
134
|
-
}, /*#__PURE__*/React.createElement(NavigationRouteContext.Provider, {
|
|
135
|
-
value: route
|
|
136
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
141
|
+
}, header !== undefined && headerShown !== false ? /*#__PURE__*/React.createElement(View, {
|
|
137
142
|
onLayout: e => {
|
|
138
143
|
setCustomHeaderHeight(e.nativeEvent.layout.height);
|
|
139
144
|
}
|
|
@@ -144,7 +149,7 @@ const SceneView = _ref2 => {
|
|
|
144
149
|
options,
|
|
145
150
|
route,
|
|
146
151
|
navigation
|
|
147
|
-
}))
|
|
152
|
+
})) : /*#__PURE__*/React.createElement(HeaderConfig, _extends({}, options, {
|
|
148
153
|
route: route,
|
|
149
154
|
headerShown: isHeaderInPush,
|
|
150
155
|
headerHeight: headerHeight,
|
|
@@ -154,7 +159,7 @@ const SceneView = _ref2 => {
|
|
|
154
159
|
route: route,
|
|
155
160
|
presentation: presentation,
|
|
156
161
|
headerHeight: headerHeight
|
|
157
|
-
}, render()))));
|
|
162
|
+
}, render()))))));
|
|
158
163
|
};
|
|
159
164
|
|
|
160
165
|
function NativeStackViewInner(_ref3) {
|
|
@@ -213,8 +218,8 @@ function NativeStackViewInner(_ref3) {
|
|
|
213
218
|
target: route.key
|
|
214
219
|
});
|
|
215
220
|
},
|
|
216
|
-
onDismissed:
|
|
217
|
-
navigation.dispatch({ ...StackActions.pop(),
|
|
221
|
+
onDismissed: event => {
|
|
222
|
+
navigation.dispatch({ ...StackActions.pop(event.nativeEvent.dismissCount),
|
|
218
223
|
source: route.key,
|
|
219
224
|
target: state.key
|
|
220
225
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["NativeStackView.native.tsx"],"names":["getDefaultHeaderHeight","getHeaderTitle","HeaderHeightContext","HeaderShownContext","SafeAreaProviderCompat","NavigationContext","NavigationRouteContext","StackActions","useTheme","React","Platform","StyleSheet","View","useSafeAreaFrame","useSafeAreaInsets","Screen","ScreenStack","warnOnce","DebugContainer","HeaderConfig","isAndroid","OS","MaybeNestedStack","options","route","presentation","headerHeight","children","colors","header","headerShown","contentStyle","isHeaderInModal","undefined","headerShownPreviousRef","useRef","useEffect","current","name","content","styles","container","backgroundColor","background","absoluteFill","SceneView","descriptor","previousDescriptor","index","onWillDisappear","onAppear","onDisappear","onDismissed","navigation","render","gestureEnabled","animationTypeForReplace","animation","orientation","statusBarAnimation","statusBarHidden","statusBarStyle","isHeaderInPush","insets","frame","isModal","isIPhone","isPad","isTVOS","isLandscape","width","height","topInset","top","isParentHeaderShown","useContext","parentHeaderHeight","defaultHeaderHeight","customHeaderHeight","setCustomHeaderHeight","useState","key","e","nativeEvent","layout","back","title","NativeStackViewInner","state","descriptors","nextDismissedKey","setNextDismissedKey","dismissedRouteName","routes","find","message","console","error","map","previousKey","emit","type","data","closing","target","dispatch","pop","source","NativeStackView","props","create","flex"],"mappings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CAAC+C,IAAX,CAAgB;AACdC,UAAAA,IAAI,EAAE,eADQ;AAEdC,UAAAA,IAAI,EAAE;AAAEC,YAAAA,OAAO,EAAE;AAAX,WAFQ;AAGdC,UAAAA,MAAM,EAAEhF,KAAK,CAACyD;AAHA,SAAhB;AAKD,OAzBH;AA0BE,MAAA,WAAW,EAAE,MAAM;AACjB5B,QAAAA,UAAU,CAACoD,QAAX,CAAoB,EAClB,GAAGlG,YAAY,CAACmG,GAAb,EADe;AAElBC,UAAAA,MAAM,EAAEnF,KAAK,CAACyD,GAFI;AAGlBuB,UAAAA,MAAM,EAAEhB,KAAK,CAACP;AAHI,SAApB;AAMAU,QAAAA,mBAAmB,CAACnE,KAAK,CAACyD,GAAP,CAAnB;AACD;AAlCH,MADF;AAsCD,GA7CA,CADH,CADF;AAkDD;;AAED,eAAe,SAAS2B,eAAT,CAAyBC,KAAzB,EAAuC;AACpD,sBACE,oBAAC,sBAAD,qBACE,oBAAC,oBAAD,EAA0BA,KAA1B,CADF,CADF;AAKD;AAED,MAAMrE,MAAM,GAAG7B,UAAU,CAACmG,MAAX,CAAkB;AAC/BrE,EAAAA,SAAS,EAAE;AACTsE,IAAAA,IAAI,EAAE;AADG;AADoB,CAAlB,CAAf","sourcesContent":["import {\n getDefaultHeaderHeight,\n getHeaderTitle,\n HeaderHeightContext,\n HeaderShownContext,\n SafeAreaProviderCompat,\n} from '@react-navigation/elements';\nimport {\n NavigationContext,\n NavigationRouteContext,\n ParamListBase,\n Route,\n StackActions,\n StackNavigationState,\n useTheme,\n} from '@react-navigation/native';\nimport * as React from 'react';\nimport { Platform, StyleSheet, View } from 'react-native';\nimport {\n useSafeAreaFrame,\n useSafeAreaInsets,\n} from 'react-native-safe-area-context';\nimport {\n Screen,\n ScreenStack,\n StackPresentationTypes,\n} from 'react-native-screens';\nimport warnOnce from 'warn-once';\n\nimport type {\n NativeStackDescriptor,\n NativeStackDescriptorMap,\n NativeStackNavigationHelpers,\n NativeStackNavigationOptions,\n} from '../types';\nimport DebugContainer from './DebugContainer';\nimport HeaderConfig from './HeaderConfig';\n\nconst isAndroid = Platform.OS === 'android';\n\nconst MaybeNestedStack = ({\n options,\n route,\n presentation,\n headerHeight,\n children,\n}: {\n options: NativeStackNavigationOptions;\n route: Route<string>;\n presentation: Exclude<StackPresentationTypes, 'push'> | 'card';\n headerHeight: number;\n children: React.ReactNode;\n}) => {\n const { colors } = useTheme();\n const { header, headerShown = true, contentStyle } = options;\n\n const isHeaderInModal = isAndroid\n ? false\n : presentation !== 'card' && headerShown === true && header === undefined;\n\n const headerShownPreviousRef = React.useRef(headerShown);\n\n React.useEffect(() => {\n warnOnce(\n !isAndroid &&\n presentation !== 'card' &&\n headerShownPreviousRef.current !== headerShown,\n `Dynamically changing 'headerShown' in modals will result in remounting the screen and losing all local state. See options for the screen '${route.name}'.`\n );\n\n headerShownPreviousRef.current = headerShown;\n }, [headerShown, presentation, route.name]);\n\n const content = (\n <DebugContainer\n style={[\n styles.container,\n presentation !== 'transparentModal' &&\n presentation !== 'containedTransparentModal' && {\n backgroundColor: colors.background,\n },\n contentStyle,\n ]}\n stackPresentation={presentation === 'card' ? 'push' : presentation}\n >\n {children}\n </DebugContainer>\n );\n\n if (isHeaderInModal) {\n return (\n <ScreenStack style={styles.container}>\n <Screen enabled style={StyleSheet.absoluteFill}>\n <HeaderConfig\n {...options}\n route={route}\n headerHeight={headerHeight}\n canGoBack\n />\n {content}\n </Screen>\n </ScreenStack>\n );\n }\n\n return content;\n};\n\ntype SceneViewProps = {\n index: number;\n descriptor: NativeStackDescriptor;\n previousDescriptor?: NativeStackDescriptor;\n onWillDisappear: () => void;\n onAppear: () => void;\n onDisappear: () => void;\n onDismissed: () => void;\n};\n\nconst SceneView = ({\n descriptor,\n previousDescriptor,\n index,\n onWillDisappear,\n onAppear,\n onDisappear,\n onDismissed,\n}: SceneViewProps) => {\n const { route, navigation, options, render } = descriptor;\n const {\n gestureEnabled,\n header,\n headerShown,\n animationTypeForReplace = 'push',\n animation,\n orientation,\n statusBarAnimation,\n statusBarHidden,\n statusBarStyle,\n } = options;\n\n let { presentation = 'card' } = options;\n\n if (index === 0) {\n // first screen should always be treated as `card`, it resolves problems with no header animation\n // for navigator with first screen as `modal` and the next as `card`\n presentation = 'card';\n }\n\n const isHeaderInPush = isAndroid\n ? headerShown\n : presentation === 'card' && headerShown !== false;\n\n const insets = useSafeAreaInsets();\n const frame = useSafeAreaFrame();\n\n // `modal` and `formSheet` presentations do not take whole screen, so should not take the inset.\n const isModal = presentation === 'modal' || presentation === 'formSheet';\n\n // Modals are fullscreen in landscape only on iPhone\n const isIPhone =\n Platform.OS === 'ios' && !(Platform.isPad && Platform.isTVOS);\n const isLandscape = frame.width > frame.height;\n\n const topInset = isModal || (isIPhone && isLandscape) ? 0 : insets.top;\n\n const isParentHeaderShown = React.useContext(HeaderShownContext);\n const parentHeaderHeight = React.useContext(HeaderHeightContext);\n\n const defaultHeaderHeight = getDefaultHeaderHeight(frame, isModal, topInset);\n\n const [customHeaderHeight, setCustomHeaderHeight] =\n React.useState(defaultHeaderHeight);\n\n const headerHeight = header ? customHeaderHeight : defaultHeaderHeight;\n\n return (\n <Screen\n key={route.key}\n enabled\n style={StyleSheet.absoluteFill}\n gestureEnabled={\n isAndroid\n ? // This prop enables handling of system back gestures on Android\n // Since we handle them in JS side, we disable this\n false\n : gestureEnabled\n }\n replaceAnimation={animationTypeForReplace}\n stackPresentation={presentation === 'card' ? 'push' : presentation}\n stackAnimation={animation}\n screenOrientation={orientation}\n statusBarAnimation={statusBarAnimation}\n statusBarHidden={statusBarHidden}\n statusBarStyle={statusBarStyle}\n onWillDisappear={onWillDisappear}\n onAppear={onAppear}\n onDisappear={onDisappear}\n onDismissed={onDismissed}\n >\n <HeaderShownContext.Provider\n value={isParentHeaderShown || isHeaderInPush !== false}\n >\n <HeaderHeightContext.Provider\n value={\n isHeaderInPush !== false ? headerHeight : parentHeaderHeight ?? 0\n }\n >\n {header !== undefined && headerShown !== false ? (\n <NavigationContext.Provider value={navigation}>\n <NavigationRouteContext.Provider value={route}>\n <View\n onLayout={(e) => {\n setCustomHeaderHeight(e.nativeEvent.layout.height);\n }}\n >\n {header({\n back: previousDescriptor\n ? {\n title: getHeaderTitle(\n previousDescriptor.options,\n previousDescriptor.route.name\n ),\n }\n : undefined,\n options,\n route,\n navigation,\n })}\n </View>\n </NavigationRouteContext.Provider>\n </NavigationContext.Provider>\n ) : (\n <HeaderConfig\n {...options}\n route={route}\n headerShown={isHeaderInPush}\n headerHeight={headerHeight}\n canGoBack={index !== 0}\n />\n )}\n <MaybeNestedStack\n options={options}\n route={route}\n presentation={presentation}\n headerHeight={headerHeight}\n >\n {render()}\n </MaybeNestedStack>\n </HeaderHeightContext.Provider>\n </HeaderShownContext.Provider>\n </Screen>\n );\n};\n\ntype Props = {\n state: StackNavigationState<ParamListBase>;\n navigation: NativeStackNavigationHelpers;\n descriptors: NativeStackDescriptorMap;\n};\n\nfunction NativeStackViewInner({ state, navigation, descriptors }: Props) {\n const [nextDismissedKey, setNextDismissedKey] = React.useState<string | null>(\n null\n );\n\n const dismissedRouteName = nextDismissedKey\n ? state.routes.find((route) => route.key === nextDismissedKey)?.name\n : null;\n\n React.useEffect(() => {\n if (dismissedRouteName) {\n const message =\n `The screen '${dismissedRouteName}' was removed natively but didn't get removed from JS state. ` +\n `This can happen if the action was prevented in a 'beforeRemove' listener, which is not fully supported in native-stack.\\n\\n` +\n `Consider using 'gestureEnabled: false' to prevent back gesture and use a custom back button with 'headerLeft' option to override the native behavior.`;\n\n console.error(message);\n }\n }, [dismissedRouteName]);\n\n return (\n <ScreenStack style={styles.container}>\n {state.routes.map((route, index) => {\n const descriptor = descriptors[route.key];\n const previousKey = state.routes[index - 1]?.key;\n const previousDescriptor = previousKey\n ? descriptors[previousKey]\n : undefined;\n\n return (\n <SceneView\n key={route.key}\n index={index}\n descriptor={descriptor}\n previousDescriptor={previousDescriptor}\n onWillDisappear={() => {\n navigation.emit({\n type: 'transitionStart',\n data: { closing: true },\n target: route.key,\n });\n }}\n onAppear={() => {\n navigation.emit({\n type: 'transitionEnd',\n data: { closing: false },\n target: route.key,\n });\n }}\n onDisappear={() => {\n navigation.emit({\n type: 'transitionEnd',\n data: { closing: true },\n target: route.key,\n });\n }}\n onDismissed={() => {\n navigation.dispatch({\n ...StackActions.pop(),\n source: route.key,\n target: state.key,\n });\n\n setNextDismissedKey(route.key);\n }}\n />\n );\n })}\n </ScreenStack>\n );\n}\n\nexport default function NativeStackView(props: Props) {\n return (\n <SafeAreaProviderCompat>\n <NativeStackViewInner {...props} />\n </SafeAreaProviderCompat>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["NativeStackView.native.tsx"],"names":["getDefaultHeaderHeight","getHeaderTitle","HeaderHeightContext","HeaderShownContext","SafeAreaProviderCompat","NavigationContext","NavigationRouteContext","StackActions","useTheme","React","Platform","StyleSheet","View","useSafeAreaFrame","useSafeAreaInsets","Screen","ScreenStack","warnOnce","DebugContainer","HeaderConfig","isAndroid","OS","MaybeNestedStack","options","route","presentation","headerHeight","children","colors","header","headerShown","contentStyle","isHeaderInModal","undefined","headerShownPreviousRef","useRef","useEffect","current","name","content","styles","container","backgroundColor","background","absoluteFill","SceneView","descriptor","previousDescriptor","index","onWillDisappear","onAppear","onDisappear","onDismissed","navigation","render","animation","animationTypeForReplace","customAnimationOnGesture","fullScreenGestureEnabled","gestureEnabled","orientation","statusBarAnimation","statusBarHidden","statusBarStyle","isHeaderInPush","insets","frame","isModal","isIPhone","isPad","isTVOS","isLandscape","width","height","topInset","top","isParentHeaderShown","useContext","parentHeaderHeight","defaultHeaderHeight","customHeaderHeight","setCustomHeaderHeight","useState","key","e","nativeEvent","layout","back","title","NativeStackViewInner","state","descriptors","nextDismissedKey","setNextDismissedKey","dismissedRouteName","routes","find","message","console","error","map","previousKey","emit","type","data","closing","target","event","dispatch","pop","dismissCount","source","NativeStackView","props","create","flex"],"mapp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OAAO,EAAE;AAAX,WAFQ;AAGdC,UAAAA,MAAM,EAAElF,KAAK,CAAC2D;AAHA,SAAhB;AAKD,OAlBH;AAmBE,MAAA,WAAW,EAAE,MAAM;AACjB9B,QAAAA,UAAU,CAACiD,IAAX,CAAgB;AACdC,UAAAA,IAAI,EAAE,eADQ;AAEdC,UAAAA,IAAI,EAAE;AAAEC,YAAAA,OAAO,EAAE;AAAX,WAFQ;AAGdC,UAAAA,MAAM,EAAElF,KAAK,CAAC2D;AAHA,SAAhB;AAKD,OAzBH;AA0BE,MAAA,WAAW,EAAGwB,KAAD,IAAW;AACtBtD,QAAAA,UAAU,CAACuD,QAAX,CAAoB,EAClB,GAAGrG,YAAY,CAACsG,GAAb,CAAiBF,KAAK,CAACtB,WAAN,CAAkByB,YAAnC,CADe;AAElBC,UAAAA,MAAM,EAAEvF,KAAK,CAAC2D,GAFI;AAGlBuB,UAAAA,MAAM,EAAEhB,KAAK,CAACP;AAHI,SAApB;AAMAU,QAAAA,mBAAmB,CAACrE,KAAK,CAAC2D,GAAP,CAAnB;AACD;AAlCH,MADF;AAsCD,GA7CA,CADH,CADF;AAkDD;;AAED,eAAe,SAAS6B,eAAT,CAAyBC,KAAzB,EAAuC;AACpD,sBACE,oBAAC,sBAAD,qBACE,oBAAC,oBAAD,EAA0BA,KAA1B,CADF,CADF;AAKD;AAED,MAAMzE,MAAM,GAAG7B,UAAU,CAACuG,MAAX,CAAkB;AAC/BzE,EAAAA,SAAS,EAAE;AACT0E,IAAAA,IAAI,EAAE;AADG;AADoB,CAAlB,CAAf","sourcesContent":["import {\n getDefaultHeaderHeight,\n getHeaderTitle,\n HeaderHeightContext,\n HeaderShownContext,\n SafeAreaProviderCompat,\n} from '@react-navigation/elements';\nimport {\n NavigationContext,\n NavigationRouteContext,\n ParamListBase,\n Route,\n StackActions,\n StackNavigationState,\n useTheme,\n} from '@react-navigation/native';\nimport * as React from 'react';\nimport { Platform, StyleSheet, View } from 'react-native';\nimport {\n useSafeAreaFrame,\n useSafeAreaInsets,\n} from 'react-native-safe-area-context';\nimport type { ScreenProps } from 'react-native-screens';\nimport {\n Screen,\n ScreenStack,\n StackPresentationTypes,\n} from 'react-native-screens';\nimport warnOnce from 'warn-once';\n\nimport type {\n NativeStackDescriptor,\n NativeStackDescriptorMap,\n NativeStackNavigationHelpers,\n NativeStackNavigationOptions,\n} from '../types';\nimport DebugContainer from './DebugContainer';\nimport HeaderConfig from './HeaderConfig';\n\nconst isAndroid = Platform.OS === 'android';\n\nconst MaybeNestedStack = ({\n options,\n route,\n presentation,\n headerHeight,\n children,\n}: {\n options: NativeStackNavigationOptions;\n route: Route<string>;\n presentation: Exclude<StackPresentationTypes, 'push'> | 'card';\n headerHeight: number;\n children: React.ReactNode;\n}) => {\n const { colors } = useTheme();\n const { header, headerShown = true, contentStyle } = options;\n\n const isHeaderInModal = isAndroid\n ? false\n : presentation !== 'card' && headerShown === true && header === undefined;\n\n const headerShownPreviousRef = React.useRef(headerShown);\n\n React.useEffect(() => {\n warnOnce(\n !isAndroid &&\n presentation !== 'card' &&\n headerShownPreviousRef.current !== headerShown,\n `Dynamically changing 'headerShown' in modals will result in remounting the screen and losing all local state. See options for the screen '${route.name}'.`\n );\n\n headerShownPreviousRef.current = headerShown;\n }, [headerShown, presentation, route.name]);\n\n const content = (\n <DebugContainer\n style={[\n styles.container,\n presentation !== 'transparentModal' &&\n presentation !== 'containedTransparentModal' && {\n backgroundColor: colors.background,\n },\n contentStyle,\n ]}\n stackPresentation={presentation === 'card' ? 'push' : presentation}\n >\n {children}\n </DebugContainer>\n );\n\n if (isHeaderInModal) {\n return (\n <ScreenStack style={styles.container}>\n <Screen enabled style={StyleSheet.absoluteFill}>\n <HeaderConfig\n {...options}\n route={route}\n headerHeight={headerHeight}\n canGoBack\n />\n {content}\n </Screen>\n </ScreenStack>\n );\n }\n\n return content;\n};\n\ntype SceneViewProps = {\n index: number;\n descriptor: NativeStackDescriptor;\n previousDescriptor?: NativeStackDescriptor;\n onWillDisappear: () => void;\n onAppear: () => void;\n onDisappear: () => void;\n onDismissed: ScreenProps['onDismissed'];\n};\n\nconst SceneView = ({\n descriptor,\n previousDescriptor,\n index,\n onWillDisappear,\n onAppear,\n onDisappear,\n onDismissed,\n}: SceneViewProps) => {\n const { route, navigation, options, render } = descriptor;\n const {\n animation,\n animationTypeForReplace = 'push',\n customAnimationOnGesture,\n fullScreenGestureEnabled,\n gestureEnabled,\n header,\n headerShown,\n orientation,\n statusBarAnimation,\n statusBarHidden,\n statusBarStyle,\n } = options;\n\n let { presentation = 'card' } = options;\n\n if (index === 0) {\n // first screen should always be treated as `card`, it resolves problems with no header animation\n // for navigator with first screen as `modal` and the next as `card`\n presentation = 'card';\n }\n\n const isHeaderInPush = isAndroid\n ? headerShown\n : presentation === 'card' && headerShown !== false;\n\n const insets = useSafeAreaInsets();\n const frame = useSafeAreaFrame();\n\n // `modal` and `formSheet` presentations do not take whole screen, so should not take the inset.\n const isModal = presentation === 'modal' || presentation === 'formSheet';\n\n // Modals are fullscreen in landscape only on iPhone\n const isIPhone =\n Platform.OS === 'ios' && !(Platform.isPad && Platform.isTVOS);\n const isLandscape = frame.width > frame.height;\n\n const topInset = isModal || (isIPhone && isLandscape) ? 0 : insets.top;\n\n const isParentHeaderShown = React.useContext(HeaderShownContext);\n const parentHeaderHeight = React.useContext(HeaderHeightContext);\n\n const defaultHeaderHeight = getDefaultHeaderHeight(frame, isModal, topInset);\n\n const [customHeaderHeight, setCustomHeaderHeight] =\n React.useState(defaultHeaderHeight);\n\n const headerHeight = header ? customHeaderHeight : defaultHeaderHeight;\n\n return (\n <Screen\n key={route.key}\n enabled\n style={StyleSheet.absoluteFill}\n customAnimationOnSwipe={customAnimationOnGesture}\n fullScreenSwipeEnabled={fullScreenGestureEnabled}\n gestureEnabled={\n isAndroid\n ? // This prop enables handling of system back gestures on Android\n // Since we handle them in JS side, we disable this\n false\n : gestureEnabled\n }\n replaceAnimation={animationTypeForReplace}\n stackPresentation={presentation === 'card' ? 'push' : presentation}\n stackAnimation={animation}\n screenOrientation={orientation}\n statusBarAnimation={statusBarAnimation}\n statusBarHidden={statusBarHidden}\n statusBarStyle={statusBarStyle}\n onWillDisappear={onWillDisappear}\n onAppear={onAppear}\n onDisappear={onDisappear}\n onDismissed={onDismissed}\n isNativeStack\n >\n <NavigationContext.Provider value={navigation}>\n <NavigationRouteContext.Provider value={route}>\n <HeaderShownContext.Provider\n value={isParentHeaderShown || isHeaderInPush !== false}\n >\n <HeaderHeightContext.Provider\n value={\n isHeaderInPush !== false\n ? headerHeight\n : parentHeaderHeight ?? 0\n }\n >\n {header !== undefined && headerShown !== false ? (\n <View\n onLayout={(e) => {\n setCustomHeaderHeight(e.nativeEvent.layout.height);\n }}\n >\n {header({\n back: previousDescriptor\n ? {\n title: getHeaderTitle(\n previousDescriptor.options,\n previousDescriptor.route.name\n ),\n }\n : undefined,\n options,\n route,\n navigation,\n })}\n </View>\n ) : (\n <HeaderConfig\n {...options}\n route={route}\n headerShown={isHeaderInPush}\n headerHeight={headerHeight}\n canGoBack={index !== 0}\n />\n )}\n <MaybeNestedStack\n options={options}\n route={route}\n presentation={presentation}\n headerHeight={headerHeight}\n >\n {render()}\n </MaybeNestedStack>\n </HeaderHeightContext.Provider>\n </HeaderShownContext.Provider>\n </NavigationRouteContext.Provider>\n </NavigationContext.Provider>\n </Screen>\n );\n};\n\ntype Props = {\n state: StackNavigationState<ParamListBase>;\n navigation: NativeStackNavigationHelpers;\n descriptors: NativeStackDescriptorMap;\n};\n\nfunction NativeStackViewInner({ state, navigation, descriptors }: Props) {\n const [nextDismissedKey, setNextDismissedKey] = React.useState<string | null>(\n null\n );\n\n const dismissedRouteName = nextDismissedKey\n ? state.routes.find((route) => route.key === nextDismissedKey)?.name\n : null;\n\n React.useEffect(() => {\n if (dismissedRouteName) {\n const message =\n `The screen '${dismissedRouteName}' was removed natively but didn't get removed from JS state. ` +\n `This can happen if the action was prevented in a 'beforeRemove' listener, which is not fully supported in native-stack.\\n\\n` +\n `Consider using 'gestureEnabled: false' to prevent back gesture and use a custom back button with 'headerLeft' option to override the native behavior.`;\n\n console.error(message);\n }\n }, [dismissedRouteName]);\n\n return (\n <ScreenStack style={styles.container}>\n {state.routes.map((route, index) => {\n const descriptor = descriptors[route.key];\n const previousKey = state.routes[index - 1]?.key;\n const previousDescriptor = previousKey\n ? descriptors[previousKey]\n : undefined;\n\n return (\n <SceneView\n key={route.key}\n index={index}\n descriptor={descriptor}\n previousDescriptor={previousDescriptor}\n onWillDisappear={() => {\n navigation.emit({\n type: 'transitionStart',\n data: { closing: true },\n target: route.key,\n });\n }}\n onAppear={() => {\n navigation.emit({\n type: 'transitionEnd',\n data: { closing: false },\n target: route.key,\n });\n }}\n onDisappear={() => {\n navigation.emit({\n type: 'transitionEnd',\n data: { closing: true },\n target: route.key,\n });\n }}\n onDismissed={(event) => {\n navigation.dispatch({\n ...StackActions.pop(event.nativeEvent.dismissCount),\n source: route.key,\n target: state.key,\n });\n\n setNextDismissedKey(route.key);\n }}\n />\n );\n })}\n </ScreenStack>\n );\n}\n\nexport default function NativeStackView(props: Props) {\n return (\n <SafeAreaProviderCompat>\n <NativeStackViewInner {...props} />\n </SafeAreaProviderCompat>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n});\n"]}
|
|
@@ -311,6 +311,24 @@ export declare type NativeStackNavigationOptions = {
|
|
|
311
311
|
* Style object for the scene content.
|
|
312
312
|
*/
|
|
313
313
|
contentStyle?: StyleProp<ViewStyle>;
|
|
314
|
+
/**
|
|
315
|
+
* Whether the gesture to dismiss should use animation provided to `animation` prop. Defaults to `false`.
|
|
316
|
+
*
|
|
317
|
+
* Doesn't affect the behavior of screens presented modally.
|
|
318
|
+
*
|
|
319
|
+
* @platform ios
|
|
320
|
+
*/
|
|
321
|
+
customAnimationOnGesture?: boolean;
|
|
322
|
+
/**
|
|
323
|
+
* Whether the gesture to dismiss should work on the whole screen. Using gesture to dismiss with this option results in the same
|
|
324
|
+
* transition animation as `simple_push`. This behavior can be changed by setting `customAnimationOnGesture` prop. Achieving the
|
|
325
|
+
* default iOS animation isn't possible due to platform limitations. Defaults to `false`.
|
|
326
|
+
*
|
|
327
|
+
* Doesn't affect the behavior of screens presented modally.
|
|
328
|
+
*
|
|
329
|
+
* @platform ios
|
|
330
|
+
*/
|
|
331
|
+
fullScreenGestureEnabled?: boolean;
|
|
314
332
|
/**
|
|
315
333
|
* Whether you can use gestures to dismiss this screen. Defaults to `true`.
|
|
316
334
|
*
|
|
@@ -335,7 +353,9 @@ export declare type NativeStackNavigationOptions = {
|
|
|
335
353
|
* Supported values:
|
|
336
354
|
* - "default": use the platform default animation
|
|
337
355
|
* - "fade": fade screen in or out
|
|
338
|
-
* - "flip": flip the screen, requires
|
|
356
|
+
* - "flip": flip the screen, requires presentation: "modal" (iOS only)
|
|
357
|
+
* - "simple_push": use the platform default animation, but without shadow and native header transition (iOS only)
|
|
358
|
+
* - "slide_from_bottom": slide in the new screen from bottom
|
|
339
359
|
* - "slide_from_right": slide in the new screen from right (Android only, uses default animation on iOS)
|
|
340
360
|
* - "slide_from_left": slide in the new screen from left (Android only, uses default animation on iOS)
|
|
341
361
|
* - "none": don't animate the screen
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-navigation/native-stack",
|
|
3
3
|
"description": "Native stack navigator using react-native-screens",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.5.2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native-component",
|
|
7
7
|
"react-component",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
]
|
|
77
77
|
]
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "701302672962195f18b41d6538484d7727cd1d61"
|
|
80
80
|
}
|
package/src/types.tsx
CHANGED
|
@@ -352,6 +352,24 @@ export type NativeStackNavigationOptions = {
|
|
|
352
352
|
* Style object for the scene content.
|
|
353
353
|
*/
|
|
354
354
|
contentStyle?: StyleProp<ViewStyle>;
|
|
355
|
+
/**
|
|
356
|
+
* Whether the gesture to dismiss should use animation provided to `animation` prop. Defaults to `false`.
|
|
357
|
+
*
|
|
358
|
+
* Doesn't affect the behavior of screens presented modally.
|
|
359
|
+
*
|
|
360
|
+
* @platform ios
|
|
361
|
+
*/
|
|
362
|
+
customAnimationOnGesture?: boolean;
|
|
363
|
+
/**
|
|
364
|
+
* Whether the gesture to dismiss should work on the whole screen. Using gesture to dismiss with this option results in the same
|
|
365
|
+
* transition animation as `simple_push`. This behavior can be changed by setting `customAnimationOnGesture` prop. Achieving the
|
|
366
|
+
* default iOS animation isn't possible due to platform limitations. Defaults to `false`.
|
|
367
|
+
*
|
|
368
|
+
* Doesn't affect the behavior of screens presented modally.
|
|
369
|
+
*
|
|
370
|
+
* @platform ios
|
|
371
|
+
*/
|
|
372
|
+
fullScreenGestureEnabled?: boolean;
|
|
355
373
|
/**
|
|
356
374
|
* Whether you can use gestures to dismiss this screen. Defaults to `true`.
|
|
357
375
|
*
|
|
@@ -376,7 +394,9 @@ export type NativeStackNavigationOptions = {
|
|
|
376
394
|
* Supported values:
|
|
377
395
|
* - "default": use the platform default animation
|
|
378
396
|
* - "fade": fade screen in or out
|
|
379
|
-
* - "flip": flip the screen, requires
|
|
397
|
+
* - "flip": flip the screen, requires presentation: "modal" (iOS only)
|
|
398
|
+
* - "simple_push": use the platform default animation, but without shadow and native header transition (iOS only)
|
|
399
|
+
* - "slide_from_bottom": slide in the new screen from bottom
|
|
380
400
|
* - "slide_from_right": slide in the new screen from right (Android only, uses default animation on iOS)
|
|
381
401
|
* - "slide_from_left": slide in the new screen from left (Android only, uses default animation on iOS)
|
|
382
402
|
* - "none": don't animate the screen
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
useSafeAreaFrame,
|
|
21
21
|
useSafeAreaInsets,
|
|
22
22
|
} from 'react-native-safe-area-context';
|
|
23
|
+
import type { ScreenProps } from 'react-native-screens';
|
|
23
24
|
import {
|
|
24
25
|
Screen,
|
|
25
26
|
ScreenStack,
|
|
@@ -113,7 +114,7 @@ type SceneViewProps = {
|
|
|
113
114
|
onWillDisappear: () => void;
|
|
114
115
|
onAppear: () => void;
|
|
115
116
|
onDisappear: () => void;
|
|
116
|
-
onDismissed:
|
|
117
|
+
onDismissed: ScreenProps['onDismissed'];
|
|
117
118
|
};
|
|
118
119
|
|
|
119
120
|
const SceneView = ({
|
|
@@ -127,11 +128,13 @@ const SceneView = ({
|
|
|
127
128
|
}: SceneViewProps) => {
|
|
128
129
|
const { route, navigation, options, render } = descriptor;
|
|
129
130
|
const {
|
|
131
|
+
animation,
|
|
132
|
+
animationTypeForReplace = 'push',
|
|
133
|
+
customAnimationOnGesture,
|
|
134
|
+
fullScreenGestureEnabled,
|
|
130
135
|
gestureEnabled,
|
|
131
136
|
header,
|
|
132
137
|
headerShown,
|
|
133
|
-
animationTypeForReplace = 'push',
|
|
134
|
-
animation,
|
|
135
138
|
orientation,
|
|
136
139
|
statusBarAnimation,
|
|
137
140
|
statusBarHidden,
|
|
@@ -178,6 +181,8 @@ const SceneView = ({
|
|
|
178
181
|
key={route.key}
|
|
179
182
|
enabled
|
|
180
183
|
style={StyleSheet.absoluteFill}
|
|
184
|
+
customAnimationOnSwipe={customAnimationOnGesture}
|
|
185
|
+
fullScreenSwipeEnabled={fullScreenGestureEnabled}
|
|
181
186
|
gestureEnabled={
|
|
182
187
|
isAndroid
|
|
183
188
|
? // This prop enables handling of system back gestures on Android
|
|
@@ -196,18 +201,21 @@ const SceneView = ({
|
|
|
196
201
|
onAppear={onAppear}
|
|
197
202
|
onDisappear={onDisappear}
|
|
198
203
|
onDismissed={onDismissed}
|
|
204
|
+
isNativeStack
|
|
199
205
|
>
|
|
200
|
-
<
|
|
201
|
-
value={
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
206
|
+
<NavigationContext.Provider value={navigation}>
|
|
207
|
+
<NavigationRouteContext.Provider value={route}>
|
|
208
|
+
<HeaderShownContext.Provider
|
|
209
|
+
value={isParentHeaderShown || isHeaderInPush !== false}
|
|
210
|
+
>
|
|
211
|
+
<HeaderHeightContext.Provider
|
|
212
|
+
value={
|
|
213
|
+
isHeaderInPush !== false
|
|
214
|
+
? headerHeight
|
|
215
|
+
: parentHeaderHeight ?? 0
|
|
216
|
+
}
|
|
217
|
+
>
|
|
218
|
+
{header !== undefined && headerShown !== false ? (
|
|
211
219
|
<View
|
|
212
220
|
onLayout={(e) => {
|
|
213
221
|
setCustomHeaderHeight(e.nativeEvent.layout.height);
|
|
@@ -227,27 +235,27 @@ const SceneView = ({
|
|
|
227
235
|
navigation,
|
|
228
236
|
})}
|
|
229
237
|
</View>
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
</
|
|
249
|
-
</
|
|
250
|
-
</
|
|
238
|
+
) : (
|
|
239
|
+
<HeaderConfig
|
|
240
|
+
{...options}
|
|
241
|
+
route={route}
|
|
242
|
+
headerShown={isHeaderInPush}
|
|
243
|
+
headerHeight={headerHeight}
|
|
244
|
+
canGoBack={index !== 0}
|
|
245
|
+
/>
|
|
246
|
+
)}
|
|
247
|
+
<MaybeNestedStack
|
|
248
|
+
options={options}
|
|
249
|
+
route={route}
|
|
250
|
+
presentation={presentation}
|
|
251
|
+
headerHeight={headerHeight}
|
|
252
|
+
>
|
|
253
|
+
{render()}
|
|
254
|
+
</MaybeNestedStack>
|
|
255
|
+
</HeaderHeightContext.Provider>
|
|
256
|
+
</HeaderShownContext.Provider>
|
|
257
|
+
</NavigationRouteContext.Provider>
|
|
258
|
+
</NavigationContext.Provider>
|
|
251
259
|
</Screen>
|
|
252
260
|
);
|
|
253
261
|
};
|
|
@@ -314,9 +322,9 @@ function NativeStackViewInner({ state, navigation, descriptors }: Props) {
|
|
|
314
322
|
target: route.key,
|
|
315
323
|
});
|
|
316
324
|
}}
|
|
317
|
-
onDismissed={() => {
|
|
325
|
+
onDismissed={(event) => {
|
|
318
326
|
navigation.dispatch({
|
|
319
|
-
...StackActions.pop(),
|
|
327
|
+
...StackActions.pop(event.nativeEvent.dismissCount),
|
|
320
328
|
source: route.key,
|
|
321
329
|
target: state.key,
|
|
322
330
|
});
|