@react-navigation/native-stack 7.0.0-alpha.0 → 7.0.0-alpha.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.
Files changed (68) hide show
  1. package/lib/commonjs/index.js +4 -5
  2. package/lib/commonjs/index.js.map +1 -1
  3. package/lib/commonjs/navigators/createNativeStackNavigator.js +5 -6
  4. package/lib/commonjs/navigators/createNativeStackNavigator.js.map +1 -1
  5. package/lib/commonjs/utils/useDismissedRouteError.js +2 -2
  6. package/lib/commonjs/utils/useDismissedRouteError.js.map +1 -1
  7. package/lib/commonjs/utils/useInvalidPreventRemoveError.js +1 -1
  8. package/lib/commonjs/utils/useInvalidPreventRemoveError.js.map +1 -1
  9. package/lib/commonjs/views/DebugContainer.js +2 -2
  10. package/lib/commonjs/views/DebugContainer.js.map +1 -1
  11. package/lib/commonjs/views/DebugContainer.native.js +4 -6
  12. package/lib/commonjs/views/DebugContainer.native.js.map +1 -1
  13. package/lib/commonjs/views/FontProcessor.js.map +1 -1
  14. package/lib/commonjs/views/FontProcessor.native.js.map +1 -1
  15. package/lib/commonjs/views/HeaderConfig.js +26 -13
  16. package/lib/commonjs/views/HeaderConfig.js.map +1 -1
  17. package/lib/commonjs/views/NativeStackView.js +1 -1
  18. package/lib/commonjs/views/NativeStackView.js.map +1 -1
  19. package/lib/commonjs/views/NativeStackView.native.js +10 -10
  20. package/lib/commonjs/views/NativeStackView.native.js.map +1 -1
  21. package/lib/module/index.js +2 -2
  22. package/lib/module/index.js.map +1 -1
  23. package/lib/module/navigators/createNativeStackNavigator.js +2 -2
  24. package/lib/module/navigators/createNativeStackNavigator.js.map +1 -1
  25. package/lib/module/utils/useDismissedRouteError.js +1 -1
  26. package/lib/module/utils/useDismissedRouteError.js.map +1 -1
  27. package/lib/module/utils/useInvalidPreventRemoveError.js +1 -1
  28. package/lib/module/utils/useInvalidPreventRemoveError.js.map +1 -1
  29. package/lib/module/views/DebugContainer.js +1 -1
  30. package/lib/module/views/DebugContainer.js.map +1 -1
  31. package/lib/module/views/DebugContainer.native.js +2 -4
  32. package/lib/module/views/DebugContainer.native.js.map +1 -1
  33. package/lib/module/views/FontProcessor.js.map +1 -1
  34. package/lib/module/views/FontProcessor.native.js.map +1 -1
  35. package/lib/module/views/HeaderConfig.js +26 -13
  36. package/lib/module/views/HeaderConfig.js.map +1 -1
  37. package/lib/module/views/NativeStackView.js +1 -1
  38. package/lib/module/views/NativeStackView.js.map +1 -1
  39. package/lib/module/views/NativeStackView.native.js +5 -5
  40. package/lib/module/views/NativeStackView.native.js.map +1 -1
  41. package/lib/typescript/src/index.d.ts +2 -2
  42. package/lib/typescript/src/index.d.ts.map +1 -1
  43. package/lib/typescript/src/navigators/createNativeStackNavigator.d.ts +2 -3
  44. package/lib/typescript/src/navigators/createNativeStackNavigator.d.ts.map +1 -1
  45. package/lib/typescript/src/utils/useDismissedRouteError.d.ts +1 -1
  46. package/lib/typescript/src/utils/useDismissedRouteError.d.ts.map +1 -1
  47. package/lib/typescript/src/utils/useInvalidPreventRemoveError.d.ts +1 -1
  48. package/lib/typescript/src/utils/useInvalidPreventRemoveError.d.ts.map +1 -1
  49. package/lib/typescript/src/views/DebugContainer.d.ts +1 -1
  50. package/lib/typescript/src/views/DebugContainer.d.ts.map +1 -1
  51. package/lib/typescript/src/views/DebugContainer.native.d.ts +2 -2
  52. package/lib/typescript/src/views/DebugContainer.native.d.ts.map +1 -1
  53. package/lib/typescript/src/views/HeaderConfig.d.ts +1 -2
  54. package/lib/typescript/src/views/HeaderConfig.d.ts.map +1 -1
  55. package/lib/typescript/src/views/NativeStackView.d.ts +1 -2
  56. package/lib/typescript/src/views/NativeStackView.d.ts.map +1 -1
  57. package/lib/typescript/src/views/NativeStackView.native.d.ts +1 -2
  58. package/lib/typescript/src/views/NativeStackView.native.d.ts.map +1 -1
  59. package/package.json +9 -9
  60. package/src/index.tsx +2 -2
  61. package/src/navigators/createNativeStackNavigator.tsx +2 -2
  62. package/src/utils/useDismissedRouteError.tsx +1 -1
  63. package/src/utils/useInvalidPreventRemoveError.tsx +1 -1
  64. package/src/views/DebugContainer.native.tsx +3 -6
  65. package/src/views/DebugContainer.tsx +1 -1
  66. package/src/views/HeaderConfig.tsx +47 -18
  67. package/src/views/NativeStackView.native.tsx +5 -5
  68. package/src/views/NativeStackView.tsx +1 -1
@@ -29,7 +29,7 @@ type Props = NativeStackNavigationOptions & {
29
29
  canGoBack: boolean;
30
30
  };
31
31
 
32
- export default function HeaderConfig({
32
+ export function HeaderConfig({
33
33
  headerHeight,
34
34
  headerBackImageSource,
35
35
  headerBackButtonMenuEnabled,
@@ -59,15 +59,22 @@ export default function HeaderConfig({
59
59
  title,
60
60
  canGoBack,
61
61
  }: Props): JSX.Element {
62
- const { colors } = useTheme();
62
+ const { colors, fonts } = useTheme();
63
63
  const tintColor =
64
64
  headerTintColor ?? (Platform.OS === 'ios' ? colors.primary : colors.text);
65
65
 
66
66
  const headerBackTitleStyleFlattened =
67
- StyleSheet.flatten(headerBackTitleStyle) || {};
67
+ StyleSheet.flatten([headerBackTitleStyle, fonts.regular]) || {};
68
68
  const headerLargeTitleStyleFlattened =
69
- StyleSheet.flatten(headerLargeTitleStyle) || {};
70
- const headerTitleStyleFlattened = StyleSheet.flatten(headerTitleStyle) || {};
69
+ StyleSheet.flatten([
70
+ headerLargeTitleStyle,
71
+ Platform.select({ ios: fonts.heavy, default: fonts.medium }),
72
+ ]) || {};
73
+ const headerTitleStyleFlattened =
74
+ StyleSheet.flatten([
75
+ headerTitleStyle,
76
+ Platform.select({ ios: fonts.bold, default: fonts.medium }),
77
+ ]) || {};
71
78
  const headerStyleFlattened = StyleSheet.flatten(headerStyle) || {};
72
79
  const headerLargeStyleFlattened = StyleSheet.flatten(headerLargeStyle) || {};
73
80
 
@@ -78,12 +85,33 @@ export default function HeaderConfig({
78
85
  headerTitleStyleFlattened.fontFamily,
79
86
  ]);
80
87
 
88
+ const backTitleFontSize =
89
+ 'fontSize' in headerBackTitleStyleFlattened
90
+ ? headerBackTitleStyleFlattened.fontSize
91
+ : undefined;
92
+
81
93
  const titleText = getHeaderTitle({ title, headerTitle }, route.name);
82
94
  const titleColor =
83
- headerTitleStyleFlattened.color ?? headerTintColor ?? colors.text;
84
- const titleFontSize = headerTitleStyleFlattened.fontSize;
95
+ 'color' in headerTitleStyleFlattened
96
+ ? headerTitleStyleFlattened.color
97
+ : headerTintColor ?? colors.text;
98
+ const titleFontSize =
99
+ 'fontSize' in headerTitleStyleFlattened
100
+ ? headerTitleStyleFlattened.fontSize
101
+ : undefined;
85
102
  const titleFontWeight = headerTitleStyleFlattened.fontWeight;
86
103
 
104
+ const largeTitleBackgroundColor = headerLargeStyleFlattened.backgroundColor;
105
+ const largeTitleColor =
106
+ 'color' in headerLargeTitleStyleFlattened
107
+ ? headerLargeTitleStyleFlattened.color
108
+ : undefined;
109
+ const largeTitleFontSize =
110
+ 'fontSize' in headerLargeTitleStyleFlattened
111
+ ? headerLargeTitleStyleFlattened.fontSize
112
+ : undefined;
113
+ const largeTitleFontWeight = headerLargeTitleStyleFlattened.fontWeight;
114
+
87
115
  const headerTitleStyleSupported: TextStyle = { color: titleColor };
88
116
 
89
117
  if (headerTitleStyleFlattened.fontFamily != null) {
@@ -98,6 +126,12 @@ export default function HeaderConfig({
98
126
  headerTitleStyleSupported.fontWeight = titleFontWeight;
99
127
  }
100
128
 
129
+ const headerBackgroundColor =
130
+ headerStyleFlattened.backgroundColor ??
131
+ (headerBackground != null || headerTransparent
132
+ ? 'transparent'
133
+ : colors.card);
134
+
101
135
  const headerLeftElement = headerLeft?.({
102
136
  tintColor,
103
137
  canGoBack,
@@ -162,15 +196,10 @@ export default function HeaderConfig({
162
196
  ) : null}
163
197
  <ScreenStackHeaderConfig
164
198
  backButtonInCustomView={backButtonInCustomView}
165
- backgroundColor={
166
- headerStyleFlattened.backgroundColor ??
167
- (headerBackground != null || headerTransparent
168
- ? 'transparent'
169
- : colors.card)
170
- }
199
+ backgroundColor={headerBackgroundColor}
171
200
  backTitle={headerBackTitleVisible ? headerBackTitle : ' '}
172
201
  backTitleFontFamily={backTitleFontFamily}
173
- backTitleFontSize={headerBackTitleStyleFlattened.fontSize}
202
+ backTitleFontSize={backTitleFontSize}
174
203
  blurEffect={headerBlurEffect}
175
204
  color={tintColor}
176
205
  direction={I18nManager.getConstants().isRTL ? 'rtl' : 'ltr'}
@@ -183,11 +212,11 @@ export default function HeaderConfig({
183
212
  (headerTransparent && headerShadowVisible !== true)
184
213
  }
185
214
  largeTitle={headerLargeTitle}
186
- largeTitleBackgroundColor={headerLargeStyleFlattened.backgroundColor}
187
- largeTitleColor={headerLargeTitleStyleFlattened.color}
215
+ largeTitleBackgroundColor={largeTitleBackgroundColor}
216
+ largeTitleColor={largeTitleColor}
188
217
  largeTitleFontFamily={largeTitleFontFamily}
189
- largeTitleFontSize={headerLargeTitleStyleFlattened.fontSize}
190
- largeTitleFontWeight={headerLargeTitleStyleFlattened.fontWeight}
218
+ largeTitleFontSize={largeTitleFontSize}
219
+ largeTitleFontWeight={largeTitleFontWeight}
191
220
  largeTitleHideShadow={headerLargeTitleShadowVisible === false}
192
221
  title={titleText}
193
222
  titleColor={titleColor}
@@ -36,10 +36,10 @@ import type {
36
36
  NativeStackNavigationHelpers,
37
37
  NativeStackNavigationOptions,
38
38
  } from '../types';
39
- import useDismissedRouteError from '../utils/useDismissedRouteError';
40
- import useInvalidPreventRemoveError from '../utils/useInvalidPreventRemoveError';
41
- import DebugContainer from './DebugContainer';
42
- import HeaderConfig from './HeaderConfig';
39
+ import { useDismissedRouteError } from '../utils/useDismissedRouteError';
40
+ import { useInvalidPreventRemoveError } from '../utils/useInvalidPreventRemoveError';
41
+ import { DebugContainer } from './DebugContainer';
42
+ import { HeaderConfig } from './HeaderConfig';
43
43
 
44
44
  const isAndroid = Platform.OS === 'android';
45
45
 
@@ -440,7 +440,7 @@ function NativeStackViewInner({ state, navigation, descriptors }: Props) {
440
440
  );
441
441
  }
442
442
 
443
- export default function NativeStackView(props: Props) {
443
+ export function NativeStackView(props: Props) {
444
444
  return (
445
445
  <SafeAreaProviderCompat>
446
446
  <NativeStackViewInner {...props} />
@@ -31,7 +31,7 @@ const TRANSPARENT_PRESENTATIONS = [
31
31
  'containedTransparentModal',
32
32
  ];
33
33
 
34
- export default function NativeStackView({ state, descriptors }: Props) {
34
+ export function NativeStackView({ state, descriptors }: Props) {
35
35
  const parentHeaderBack = React.useContext(HeaderBackContext);
36
36
 
37
37
  return (