@react-navigation/stack 7.0.0-rc.20 → 7.0.0-rc.22

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@react-navigation/stack",
3
3
  "description": "Stack navigator component for iOS and Android with animated transitions and gestures",
4
- "version": "7.0.0-rc.20",
4
+ "version": "7.0.0-rc.22",
5
5
  "keywords": [
6
6
  "react-native-component",
7
7
  "react-component",
@@ -51,12 +51,12 @@
51
51
  "clean": "del lib"
52
52
  },
53
53
  "dependencies": {
54
- "@react-navigation/elements": "^2.0.0-rc.18",
54
+ "@react-navigation/elements": "^2.0.0-rc.20",
55
55
  "color": "^4.2.3"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@jest/globals": "^29.7.0",
59
- "@react-navigation/native": "^7.0.0-rc.16",
59
+ "@react-navigation/native": "^7.0.0-rc.18",
60
60
  "@testing-library/react-native": "^12.4.3",
61
61
  "@types/color": "^3.0.6",
62
62
  "@types/react": "~18.2.79",
@@ -66,11 +66,11 @@
66
66
  "react-native-builder-bob": "^0.29.0",
67
67
  "react-native-gesture-handler": "~2.16.1",
68
68
  "react-native-safe-area-context": "4.10.1",
69
- "react-native-screens": "3.31.1",
69
+ "react-native-screens": "3.32.0",
70
70
  "typescript": "^5.5.2"
71
71
  },
72
72
  "peerDependencies": {
73
- "@react-navigation/native": "^7.0.0-rc.16",
73
+ "@react-navigation/native": "^7.0.0-rc.18",
74
74
  "react": ">= 18.2.0",
75
75
  "react-native": ">= 0.72.0",
76
76
  "react-native-gesture-handler": ">= 2.0.0",
@@ -102,5 +102,5 @@
102
102
  ]
103
103
  ]
104
104
  },
105
- "gitHead": "70c4339ca48961378837d9ee6cf63a396e55892d"
105
+ "gitHead": "b32550a43d0e2b532cfe100d9cf17837184a636e"
106
106
  }
package/src/types.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  HeaderBackButton,
3
+ HeaderBackButtonDisplayMode,
3
4
  HeaderBackButtonProps,
4
5
  HeaderOptions,
5
6
  HeaderTitleProps,
@@ -180,23 +181,31 @@ export type StackHeaderOptions = Omit<
180
181
  /**
181
182
  * Title string used by the back button on iOS.
182
183
  * Defaults to the previous screen's title, or "Back" if there's not enough space.
183
- * Use `headerBackTitleVisible: false` to hide it.
184
+ * Use `headerBackButtonDisplayMode` to customize the behavior.
184
185
  */
185
186
  headerBackTitle?: string;
186
187
  /**
187
- * Whether the back button title should be visible or not.
188
+ * Title string used by the back button when `headerBackTitle` doesn't fit on the screen.
189
+ * Use `headerBackButtonDisplayMode` to customize the behavior.
188
190
  *
189
- * Defaults to `true` on iOS, `false on Android.
191
+ * Defaults to "Back".
190
192
  */
191
- headerBackTitleVisible?: boolean;
193
+ headerBackTruncatedTitle?: string;
192
194
  /**
193
- * Style object for the back title.
195
+ * How the back button displays icon and title.
196
+ *
197
+ * Supported values:
198
+ * - "default" - Displays one of the following depending on the available space: previous screen's title, truncated title (e.g. 'Back') or no title (only icon).
199
+ * - "generic" – Displays one of the following depending on the available space: truncated title (e.g. 'Back') or no title (only icon).
200
+ * - "minimal" – Always displays only the icon without a title.
201
+ *
202
+ * Defaults to "default" on iOS, and "minimal" on Android.
194
203
  */
195
- headerBackTitleStyle?: StyleProp<TextStyle>;
204
+ headerBackButtonDisplayMode?: HeaderBackButtonDisplayMode;
196
205
  /**
197
- * Title string used by the back button when `headerBackTitle` doesn't fit on the screen. `"Back"` by default.
206
+ * Style object for the back title.
198
207
  */
199
- headerTruncatedBackTitle?: string;
208
+ headerBackTitleStyle?: StyleProp<TextStyle>;
200
209
  /**
201
210
  * Function which returns a React Element to display custom image in header's back button.
202
211
  * It receives the `tintColor` in in the options object as an argument. object.
@@ -114,8 +114,8 @@ export function HeaderSegment(props: Props) {
114
114
  headerRight: right,
115
115
  headerBackImage,
116
116
  headerBackTitle,
117
- headerBackTitleVisible = Platform.OS === 'ios',
118
- headerTruncatedBackTitle,
117
+ headerBackButtonDisplayMode = Platform.OS === 'ios' ? 'default' : 'minimal',
118
+ headerBackTruncatedTitle,
119
119
  headerBackAccessibilityLabel,
120
120
  headerBackTestID,
121
121
  headerBackAllowFontScaling,
@@ -167,7 +167,7 @@ export function HeaderSegment(props: Props) {
167
167
  allowFontScaling: headerBackAllowFontScaling,
168
168
  onPress: onGoBack,
169
169
  label: headerBackTitle,
170
- truncatedLabel: headerTruncatedBackTitle,
170
+ truncatedLabel: headerBackTruncatedTitle,
171
171
  labelStyle: [leftLabelStyle, headerBackTitleStyle],
172
172
  onLabelLayout: handleLeftLabelLayout,
173
173
  screenLayout: layout,
@@ -195,11 +195,11 @@ export function HeaderSegment(props: Props) {
195
195
  layout={layout}
196
196
  headerTitle={headerTitle}
197
197
  headerLeft={headerLeft}
198
- headerLeftLabelVisible={headerBackTitleVisible}
199
198
  headerRight={headerRight}
200
199
  headerTitleContainerStyle={[titleStyle, headerTitleContainerStyle]}
201
200
  headerLeftContainerStyle={[leftButtonStyle, headerLeftContainerStyle]}
202
201
  headerRightContainerStyle={[rightButtonStyle, headerRightContainerStyle]}
202
+ headerBackButtonDisplayMode={headerBackButtonDisplayMode}
203
203
  headerBackgroundContainerStyle={[
204
204
  backgroundStyle,
205
205
  headerBackgroundContainerStyle,
@@ -293,7 +293,11 @@ function CardContainerInner({
293
293
  value={isParentHeaderShown || headerShown !== false}
294
294
  >
295
295
  <HeaderHeightContext.Provider
296
- value={headerShown ? headerHeight : parentHeaderHeight ?? 0}
296
+ value={
297
+ headerShown !== false
298
+ ? headerHeight
299
+ : parentHeaderHeight ?? 0
300
+ }
297
301
  >
298
302
  {scene.descriptor.render()}
299
303
  </HeaderHeightContext.Provider>