@react-navigation/native-stack 7.0.0-rc.21 → 7.0.0-rc.23
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/HeaderConfig.js +12 -2
- package/lib/commonjs/views/HeaderConfig.js.map +1 -1
- package/lib/commonjs/views/NativeStackView.native.js +1 -1
- package/lib/commonjs/views/NativeStackView.native.js.map +1 -1
- package/lib/module/views/HeaderConfig.js +12 -2
- package/lib/module/views/HeaderConfig.js.map +1 -1
- package/lib/module/views/NativeStackView.native.js +1 -1
- package/lib/module/views/NativeStackView.native.js.map +1 -1
- package/lib/typescript/commonjs/src/types.d.ts +20 -9
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/views/HeaderConfig.d.ts +1 -1
- package/lib/typescript/commonjs/src/views/HeaderConfig.d.ts.map +1 -1
- package/lib/typescript/commonjs/tsconfig.build.tsbuildinfo +1 -1
- package/lib/typescript/module/src/types.d.ts +20 -9
- package/lib/typescript/module/src/types.d.ts.map +1 -1
- package/lib/typescript/module/src/views/HeaderConfig.d.ts +1 -1
- package/lib/typescript/module/src/views/HeaderConfig.d.ts.map +1 -1
- package/lib/typescript/module/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/types.tsx +20 -9
- package/src/views/HeaderConfig.tsx +23 -2
- package/src/views/NativeStackView.native.tsx +1 -1
package/src/types.tsx
CHANGED
|
@@ -148,21 +148,13 @@ export type NativeStackNavigationOptions = {
|
|
|
148
148
|
/**
|
|
149
149
|
* Title string used by the back button on iOS.
|
|
150
150
|
* Defaults to the previous scene's title, or "Back" if there's not enough space.
|
|
151
|
-
* Use `
|
|
151
|
+
* Use `headerBackButtonDisplayMode: "minimal"` to hide it.
|
|
152
152
|
*
|
|
153
153
|
* Only supported on iOS.
|
|
154
154
|
*
|
|
155
155
|
* @platform ios
|
|
156
156
|
*/
|
|
157
157
|
headerBackTitle?: string;
|
|
158
|
-
/**
|
|
159
|
-
* Whether the back button title should be visible or not.
|
|
160
|
-
*
|
|
161
|
-
* Only supported on iOS.
|
|
162
|
-
*
|
|
163
|
-
* @platform ios
|
|
164
|
-
*/
|
|
165
|
-
headerBackTitleVisible?: boolean;
|
|
166
158
|
/**
|
|
167
159
|
* Style object for header back title. Supported properties:
|
|
168
160
|
* - fontFamily
|
|
@@ -342,6 +334,25 @@ export type NativeStackNavigationOptions = {
|
|
|
342
334
|
* @platform ios
|
|
343
335
|
*/
|
|
344
336
|
headerBackButtonMenuEnabled?: boolean;
|
|
337
|
+
/**
|
|
338
|
+
* How the back button displays icon and title.
|
|
339
|
+
*
|
|
340
|
+
* Supported values:
|
|
341
|
+
* - "default" - Displays one of the following depending on the available space: previous screen's title, generic title (e.g. 'Back') or no title (only icon).
|
|
342
|
+
* - "generic" – Displays one of the following depending on the available space: generic title (e.g. 'Back') or no title (only icon).
|
|
343
|
+
* - "minimal" – Always displays only the icon without a title.
|
|
344
|
+
*
|
|
345
|
+
* The "generic" mode is not supported when:
|
|
346
|
+
* - The iOS version is lower than 14
|
|
347
|
+
* - Custom back title is set
|
|
348
|
+
* - Custom back title style is set
|
|
349
|
+
* - Back button menu is disabled
|
|
350
|
+
*
|
|
351
|
+
* In such cases, the "default" mode will be used instead.
|
|
352
|
+
*
|
|
353
|
+
* @platform ios
|
|
354
|
+
*/
|
|
355
|
+
headerBackButtonDisplayMode?: ScreenStackHeaderConfigProps['backButtonDisplayMode'];
|
|
345
356
|
/**
|
|
346
357
|
* Whether the home indicator should prefer to stay hidden on this screen. Defaults to `false`.
|
|
347
358
|
*
|
|
@@ -24,10 +24,10 @@ type Props = NativeStackNavigationOptions & {
|
|
|
24
24
|
|
|
25
25
|
export function HeaderConfig({
|
|
26
26
|
headerBackImageSource,
|
|
27
|
+
headerBackButtonDisplayMode,
|
|
27
28
|
headerBackButtonMenuEnabled,
|
|
28
29
|
headerBackTitle,
|
|
29
30
|
headerBackTitleStyle,
|
|
30
|
-
headerBackTitleVisible = true,
|
|
31
31
|
headerBackVisible,
|
|
32
32
|
headerShadowVisible,
|
|
33
33
|
headerLargeStyle,
|
|
@@ -176,12 +176,33 @@ export function HeaderConfig({
|
|
|
176
176
|
Platform.OS === 'ios' &&
|
|
177
177
|
headerTransparent !== false);
|
|
178
178
|
|
|
179
|
+
const isBackButtonDisplayModeAvailable =
|
|
180
|
+
// On iOS 14+
|
|
181
|
+
Platform.OS === 'ios' &&
|
|
182
|
+
parseInt(Platform.Version, 10) >= 14 &&
|
|
183
|
+
// Doesn't have custom back title
|
|
184
|
+
headerBackTitle == null &&
|
|
185
|
+
// Doesn't have custom styling
|
|
186
|
+
backTitleFontFamily == null &&
|
|
187
|
+
backTitleFontSize == null &&
|
|
188
|
+
// Back button menu is not disabled
|
|
189
|
+
headerBackButtonMenuEnabled !== false;
|
|
190
|
+
|
|
179
191
|
return (
|
|
180
192
|
<ScreenStackHeaderConfig
|
|
181
193
|
backButtonInCustomView={backButtonInCustomView}
|
|
182
194
|
backgroundColor={headerBackgroundColor}
|
|
183
195
|
backTitle={headerBackTitle}
|
|
184
|
-
backTitleVisible={
|
|
196
|
+
backTitleVisible={
|
|
197
|
+
isBackButtonDisplayModeAvailable
|
|
198
|
+
? undefined
|
|
199
|
+
: headerBackButtonDisplayMode !== 'minimal'
|
|
200
|
+
}
|
|
201
|
+
backButtonDisplayMode={
|
|
202
|
+
isBackButtonDisplayModeAvailable
|
|
203
|
+
? headerBackButtonDisplayMode
|
|
204
|
+
: undefined
|
|
205
|
+
}
|
|
185
206
|
backTitleFontFamily={backTitleFontFamily}
|
|
186
207
|
backTitleFontSize={backTitleFontSize}
|
|
187
208
|
blurEffect={headerBlurEffect}
|
|
@@ -343,6 +343,7 @@ const SceneView = ({
|
|
|
343
343
|
homeIndicatorHidden={autoHideHomeIndicator}
|
|
344
344
|
hideKeyboardOnSwipe={keyboardHandlingEnabled}
|
|
345
345
|
navigationBarColor={navigationBarColor}
|
|
346
|
+
navigationBarTranslucent={navigationBarTranslucent}
|
|
346
347
|
navigationBarHidden={navigationBarHidden}
|
|
347
348
|
replaceAnimation={animationTypeForReplace}
|
|
348
349
|
stackPresentation={presentation === 'card' ? 'push' : presentation}
|
|
@@ -425,7 +426,6 @@ const SceneView = ({
|
|
|
425
426
|
// So we keep any props that need it at the end
|
|
426
427
|
// Otherwise invalid props may not be caught by TypeScript
|
|
427
428
|
// @ts-expect-error Props available in newer versions of `react-native-screens`
|
|
428
|
-
navigationBarTranslucent={navigationBarTranslucent}
|
|
429
429
|
fullScreenSwipeShadowEnabled={fullScreenGestureShadowEnabled} // 3.33.0 onwards
|
|
430
430
|
>
|
|
431
431
|
<NavigationContext.Provider value={navigation}>
|