@react-navigation/elements 3.0.0-alpha.4 → 3.0.0-alpha.41

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 (212) hide show
  1. package/lib/module/ActivityView.js +90 -0
  2. package/lib/module/ActivityView.js.map +1 -0
  3. package/lib/module/ActivityView.native.js +67 -0
  4. package/lib/module/ActivityView.native.js.map +1 -0
  5. package/lib/module/Badge.js +5 -4
  6. package/lib/module/Badge.js.map +1 -1
  7. package/lib/module/BlurEffectBackground.js +3 -3
  8. package/lib/module/BlurEffectBackground.js.map +1 -1
  9. package/lib/module/Button.js +96 -14
  10. package/lib/module/Button.js.map +1 -1
  11. package/lib/module/Color.js +565 -4
  12. package/lib/module/Color.js.map +1 -1
  13. package/lib/module/Container.js +11 -1
  14. package/lib/module/Container.js.map +1 -1
  15. package/lib/module/Header/Header.js +29 -17
  16. package/lib/module/Header/Header.js.map +1 -1
  17. package/lib/module/Header/HeaderBackButton.js +27 -13
  18. package/lib/module/Header/HeaderBackButton.js.map +1 -1
  19. package/lib/module/Header/HeaderButton.js +4 -5
  20. package/lib/module/Header/HeaderButton.js.map +1 -1
  21. package/lib/module/Header/HeaderButtonBackground.js +1 -2
  22. package/lib/module/Header/HeaderButtonBackground.js.map +1 -1
  23. package/lib/module/Header/HeaderIcon.js +14 -17
  24. package/lib/module/Header/HeaderIcon.js.map +1 -1
  25. package/lib/module/Header/HeaderSearchBar.js +35 -25
  26. package/lib/module/Header/HeaderSearchBar.js.map +1 -1
  27. package/lib/module/Header/getHeaderTitle.js.map +1 -1
  28. package/lib/module/Header/useHeaderHeight.js +1 -1
  29. package/lib/module/Header/useHeaderHeight.js.map +1 -1
  30. package/lib/module/Label/getLabel.js.map +1 -1
  31. package/lib/module/LiquidGlassView.ios.js +1 -2
  32. package/lib/module/LiquidGlassView.ios.js.map +1 -1
  33. package/lib/module/LiquidGlassView.js +0 -4
  34. package/lib/module/LiquidGlassView.js.map +1 -1
  35. package/lib/module/PlatformColor.js +1 -0
  36. package/lib/module/PlatformColor.js.map +1 -1
  37. package/lib/module/PlatformColor.native.js +1 -1
  38. package/lib/module/PlatformColor.native.js.map +1 -1
  39. package/lib/module/PlatformIcon.js +46 -0
  40. package/lib/module/PlatformIcon.js.map +1 -0
  41. package/lib/module/PlatformPressable.js +56 -14
  42. package/lib/module/PlatformPressable.js.map +1 -1
  43. package/lib/module/SafeAreaProviderCompat.js +1 -1
  44. package/lib/module/SafeAreaProviderCompat.js.map +1 -1
  45. package/lib/module/Screen.js +31 -18
  46. package/lib/module/Screen.js.map +1 -1
  47. package/lib/module/index.js +2 -7
  48. package/lib/module/index.js.map +1 -1
  49. package/lib/module/internal.js +1 -1
  50. package/lib/module/internal.js.map +1 -1
  51. package/lib/module/useFrameSize.js +6 -2
  52. package/lib/module/useFrameSize.js.map +1 -1
  53. package/lib/typescript/src/ActivityView.d.ts +31 -0
  54. package/lib/typescript/src/ActivityView.d.ts.map +1 -0
  55. package/lib/typescript/src/ActivityView.native.d.ts +3 -0
  56. package/lib/typescript/src/ActivityView.native.d.ts.map +1 -0
  57. package/lib/typescript/src/Badge.d.ts +6 -5
  58. package/lib/typescript/src/Badge.d.ts.map +1 -1
  59. package/lib/typescript/src/BlurEffectBackground.d.ts +2 -2
  60. package/lib/typescript/src/BlurEffectBackground.d.ts.map +1 -1
  61. package/lib/typescript/src/Button.d.ts +54 -6
  62. package/lib/typescript/src/Button.d.ts.map +1 -1
  63. package/lib/typescript/src/Color.d.ts +4 -4
  64. package/lib/typescript/src/Color.d.ts.map +1 -1
  65. package/lib/typescript/src/Container.d.ts +7 -4
  66. package/lib/typescript/src/Container.d.ts.map +1 -1
  67. package/lib/typescript/src/Header/Header.d.ts +5 -4
  68. package/lib/typescript/src/Header/Header.d.ts.map +1 -1
  69. package/lib/typescript/src/Header/HeaderBackButton.d.ts +3 -2
  70. package/lib/typescript/src/Header/HeaderBackButton.d.ts.map +1 -1
  71. package/lib/typescript/src/Header/HeaderBackground.d.ts +5 -5
  72. package/lib/typescript/src/Header/HeaderBackground.d.ts.map +1 -1
  73. package/lib/typescript/src/Header/HeaderButton.d.ts +7 -2
  74. package/lib/typescript/src/Header/HeaderButton.d.ts.map +1 -1
  75. package/lib/typescript/src/Header/HeaderButtonBackground.d.ts +1 -1
  76. package/lib/typescript/src/Header/HeaderButtonBackground.d.ts.map +1 -1
  77. package/lib/typescript/src/Header/HeaderIcon.d.ts +9 -4
  78. package/lib/typescript/src/Header/HeaderIcon.d.ts.map +1 -1
  79. package/lib/typescript/src/Header/HeaderSearchBar.d.ts +10 -7
  80. package/lib/typescript/src/Header/HeaderSearchBar.d.ts.map +1 -1
  81. package/lib/typescript/src/Header/HeaderTitle.d.ts +4 -4
  82. package/lib/typescript/src/Header/HeaderTitle.d.ts.map +1 -1
  83. package/lib/typescript/src/Header/getHeaderTitle.d.ts +2 -2
  84. package/lib/typescript/src/Header/getHeaderTitle.d.ts.map +1 -1
  85. package/lib/typescript/src/Label/Label.d.ts +1 -1
  86. package/lib/typescript/src/Label/Label.d.ts.map +1 -1
  87. package/lib/typescript/src/Label/getLabel.d.ts +2 -2
  88. package/lib/typescript/src/Label/getLabel.d.ts.map +1 -1
  89. package/lib/typescript/src/LiquidGlassView.d.ts +7 -5
  90. package/lib/typescript/src/LiquidGlassView.d.ts.map +1 -1
  91. package/lib/typescript/src/LiquidGlassView.ios.d.ts +4 -2
  92. package/lib/typescript/src/LiquidGlassView.ios.d.ts.map +1 -1
  93. package/lib/typescript/src/MissingIcon.d.ts +1 -1
  94. package/lib/typescript/src/MissingIcon.d.ts.map +1 -1
  95. package/lib/typescript/src/PlatformColor.d.ts +1 -0
  96. package/lib/typescript/src/PlatformColor.d.ts.map +1 -1
  97. package/lib/typescript/src/PlatformColor.native.d.ts +1 -1
  98. package/lib/typescript/src/PlatformColor.native.d.ts.map +1 -1
  99. package/lib/typescript/src/PlatformIcon.d.ts +10 -0
  100. package/lib/typescript/src/PlatformIcon.d.ts.map +1 -0
  101. package/lib/typescript/src/PlatformPressable.d.ts +12 -15
  102. package/lib/typescript/src/PlatformPressable.d.ts.map +1 -1
  103. package/lib/typescript/src/SafeAreaProviderCompat.d.ts +1 -1
  104. package/lib/typescript/src/SafeAreaProviderCompat.d.ts.map +1 -1
  105. package/lib/typescript/src/Screen.d.ts +7 -7
  106. package/lib/typescript/src/Screen.d.ts.map +1 -1
  107. package/lib/typescript/src/Text.d.ts +1 -1
  108. package/lib/typescript/src/Text.d.ts.map +1 -1
  109. package/lib/typescript/src/index.d.ts +21 -21
  110. package/lib/typescript/src/index.d.ts.map +1 -1
  111. package/lib/typescript/src/internal.d.ts +6 -6
  112. package/lib/typescript/src/internal.d.ts.map +1 -1
  113. package/lib/typescript/src/types.d.ts +120 -70
  114. package/lib/typescript/src/types.d.ts.map +1 -1
  115. package/lib/typescript/src/useFrameSize.d.ts +1 -1
  116. package/lib/typescript/src/useFrameSize.d.ts.map +1 -1
  117. package/package.json +23 -22
  118. package/src/ActivityView.native.tsx +90 -0
  119. package/src/ActivityView.tsx +129 -0
  120. package/src/Badge.tsx +10 -8
  121. package/src/BlurEffectBackground.tsx +3 -3
  122. package/src/Button.tsx +173 -28
  123. package/src/Color.tsx +755 -8
  124. package/src/Container.tsx +20 -4
  125. package/src/Header/Header.tsx +46 -26
  126. package/src/Header/HeaderBackButton.tsx +31 -17
  127. package/src/Header/HeaderBackground.tsx +3 -3
  128. package/src/Header/HeaderButton.tsx +16 -18
  129. package/src/Header/HeaderButtonBackground.tsx +1 -4
  130. package/src/Header/HeaderIcon.tsx +27 -13
  131. package/src/Header/HeaderSearchBar.tsx +52 -44
  132. package/src/Header/HeaderTitle.tsx +3 -3
  133. package/src/Header/getHeaderTitle.tsx +4 -1
  134. package/src/Header/useHeaderHeight.tsx +1 -1
  135. package/src/Label/getLabel.tsx +1 -1
  136. package/src/LiquidGlassView.ios.tsx +14 -9
  137. package/src/LiquidGlassView.tsx +15 -11
  138. package/src/PlatformColor.native.tsx +1 -1
  139. package/src/PlatformColor.tsx +4 -0
  140. package/src/PlatformIcon.tsx +66 -0
  141. package/src/PlatformPressable.tsx +99 -41
  142. package/src/SafeAreaProviderCompat.tsx +1 -1
  143. package/src/Screen.tsx +40 -27
  144. package/src/index.tsx +2 -16
  145. package/src/internal.tsx +1 -1
  146. package/src/types.tsx +153 -76
  147. package/src/useFrameSize.tsx +9 -2
  148. package/lib/module/Lazy.js +0 -42
  149. package/lib/module/Lazy.js.map +0 -1
  150. package/lib/module/assets/back-icon.ios.svg +0 -4
  151. package/lib/module/assets/back-icon@1x.android.png +0 -0
  152. package/lib/module/assets/back-icon@1x.ios.png +0 -0
  153. package/lib/module/assets/back-icon@2x.android.png +0 -0
  154. package/lib/module/assets/back-icon@2x.ios.png +0 -0
  155. package/lib/module/assets/back-icon@3x.android.png +0 -0
  156. package/lib/module/assets/back-icon@3x.ios.png +0 -0
  157. package/lib/module/assets/back-icon@4x.android.png +0 -0
  158. package/lib/module/assets/back-icon@4x.ios.png +0 -0
  159. package/lib/module/assets/clear-icon@1x.png +0 -0
  160. package/lib/module/assets/clear-icon@2x.png +0 -0
  161. package/lib/module/assets/clear-icon@3x.png +0 -0
  162. package/lib/module/assets/clear-icon@4x.png +0 -0
  163. package/lib/module/assets/close-icon@1x.png +0 -0
  164. package/lib/module/assets/close-icon@2x.png +0 -0
  165. package/lib/module/assets/close-icon@3x.png +0 -0
  166. package/lib/module/assets/close-icon@4x.png +0 -0
  167. package/lib/module/assets/search-icon-legacy@1x.ios.png +0 -0
  168. package/lib/module/assets/search-icon-legacy@2x.ios.png +0 -0
  169. package/lib/module/assets/search-icon-legacy@3x.ios.png +0 -0
  170. package/lib/module/assets/search-icon-legacy@4x.ios.png +0 -0
  171. package/lib/module/assets/search-icon.ios.svg +0 -4
  172. package/lib/module/assets/search-icon@1x.android.png +0 -0
  173. package/lib/module/assets/search-icon@1x.ios.png +0 -0
  174. package/lib/module/assets/search-icon@2x.android.png +0 -0
  175. package/lib/module/assets/search-icon@2x.ios.png +0 -0
  176. package/lib/module/assets/search-icon@3x.android.png +0 -0
  177. package/lib/module/assets/search-icon@3x.ios.png +0 -0
  178. package/lib/module/assets/search-icon@4x.android.png +0 -0
  179. package/lib/module/assets/search-icon@4x.ios.png +0 -0
  180. package/lib/typescript/src/Lazy.d.ts +0 -31
  181. package/lib/typescript/src/Lazy.d.ts.map +0 -1
  182. package/src/Lazy.tsx +0 -59
  183. package/src/assets/back-icon.ios.svg +0 -4
  184. package/src/assets/back-icon@1x.android.png +0 -0
  185. package/src/assets/back-icon@1x.ios.png +0 -0
  186. package/src/assets/back-icon@2x.android.png +0 -0
  187. package/src/assets/back-icon@2x.ios.png +0 -0
  188. package/src/assets/back-icon@3x.android.png +0 -0
  189. package/src/assets/back-icon@3x.ios.png +0 -0
  190. package/src/assets/back-icon@4x.android.png +0 -0
  191. package/src/assets/back-icon@4x.ios.png +0 -0
  192. package/src/assets/clear-icon@1x.png +0 -0
  193. package/src/assets/clear-icon@2x.png +0 -0
  194. package/src/assets/clear-icon@3x.png +0 -0
  195. package/src/assets/clear-icon@4x.png +0 -0
  196. package/src/assets/close-icon@1x.png +0 -0
  197. package/src/assets/close-icon@2x.png +0 -0
  198. package/src/assets/close-icon@3x.png +0 -0
  199. package/src/assets/close-icon@4x.png +0 -0
  200. package/src/assets/search-icon-legacy@1x.ios.png +0 -0
  201. package/src/assets/search-icon-legacy@2x.ios.png +0 -0
  202. package/src/assets/search-icon-legacy@3x.ios.png +0 -0
  203. package/src/assets/search-icon-legacy@4x.ios.png +0 -0
  204. package/src/assets/search-icon.ios.svg +0 -4
  205. package/src/assets/search-icon@1x.android.png +0 -0
  206. package/src/assets/search-icon@1x.ios.png +0 -0
  207. package/src/assets/search-icon@2x.android.png +0 -0
  208. package/src/assets/search-icon@2x.ios.png +0 -0
  209. package/src/assets/search-icon@3x.android.png +0 -0
  210. package/src/assets/search-icon@3x.ios.png +0 -0
  211. package/src/assets/search-icon@4x.android.png +0 -0
  212. package/src/assets/search-icon@4x.ios.png +0 -0
@@ -1,20 +1,24 @@
1
+ import type {
2
+ LiquidGlassContainerViewProps,
3
+ LiquidGlassViewProps,
4
+ } from '@callstack/liquid-glass';
1
5
  import { Animated, View } from 'react-native';
2
6
 
3
- type CallstackLiquidGlass = typeof import('@callstack/liquid-glass');
7
+ type AnimatedLiquidGlassViewProps =
8
+ Animated.AnimatedProps<LiquidGlassViewProps>;
4
9
 
5
- export const LiquidGlassView: CallstackLiquidGlass['LiquidGlassView'] = View;
10
+ type AnimatedLiquidGlassContainerViewProps =
11
+ Animated.AnimatedProps<LiquidGlassContainerViewProps>;
6
12
 
7
- export const LiquidGlassContainerView: CallstackLiquidGlass['LiquidGlassContainerView'] =
13
+ export const LiquidGlassView: React.ComponentType<LiquidGlassViewProps> = View;
14
+
15
+ export const LiquidGlassContainerView: React.ComponentType<LiquidGlassContainerViewProps> =
8
16
  View;
9
17
 
10
- // @ts-expect-error: this is fine
11
- export const AnimatedLiquidGlassView: Animated.AnimatedComponent<
12
- typeof LiquidGlassView
13
- > = Animated.View;
18
+ export const AnimatedLiquidGlassView: React.ComponentType<AnimatedLiquidGlassViewProps> =
19
+ Animated.View;
14
20
 
15
- // @ts-expect-error: this is fine
16
- export const AnimatedLiquidGlassContainerView: Animated.AnimatedComponent<
17
- typeof LiquidGlassContainerView
18
- > = Animated.View;
21
+ export const AnimatedLiquidGlassContainerView: React.ComponentType<AnimatedLiquidGlassContainerViewProps> =
22
+ Animated.View;
19
23
 
20
24
  export const isLiquidGlassSupported = false;
@@ -1 +1 @@
1
- export { PlatformColor } from 'react-native';
1
+ export { DynamicColorIOS, PlatformColor } from 'react-native';
@@ -6,3 +6,7 @@
6
6
  export const PlatformColor:
7
7
  | typeof import('react-native').PlatformColor
8
8
  | undefined = undefined;
9
+
10
+ export const DynamicColorIOS:
11
+ | typeof import('react-native').DynamicColorIOS
12
+ | undefined = undefined;
@@ -0,0 +1,66 @@
1
+ import { MaterialSymbol, SFSymbol } from '@react-navigation/native';
2
+ import {
3
+ type ColorValue,
4
+ Image,
5
+ type ImageStyle,
6
+ type StyleProp,
7
+ } from 'react-native';
8
+
9
+ import type { Icon } from './types';
10
+
11
+ export type PlatformIconProps = {
12
+ icon: Icon;
13
+ size: number;
14
+ color?: ColorValue | undefined;
15
+ style?: StyleProp<ImageStyle> | undefined;
16
+ };
17
+
18
+ export function PlatformIcon({
19
+ icon,
20
+ color,
21
+ size,
22
+ style,
23
+ ...rest
24
+ }: PlatformIconProps) {
25
+ switch (icon.type) {
26
+ case 'sfSymbol':
27
+ return (
28
+ <SFSymbol
29
+ name={icon.name}
30
+ color={color}
31
+ size={size}
32
+ style={style}
33
+ {...rest}
34
+ />
35
+ );
36
+ case 'materialSymbol':
37
+ return (
38
+ <MaterialSymbol
39
+ name={icon.name}
40
+ variant={icon.variant}
41
+ weight={icon.weight}
42
+ size={size}
43
+ color={color}
44
+ style={style}
45
+ {...rest}
46
+ />
47
+ );
48
+ case 'image':
49
+ return (
50
+ <Image
51
+ source={icon.source}
52
+ resizeMode="contain"
53
+ fadeDuration={0}
54
+ tintColor={icon.tinted === false ? undefined : color}
55
+ style={[
56
+ {
57
+ width: size,
58
+ height: size,
59
+ },
60
+ style,
61
+ ]}
62
+ {...rest}
63
+ />
64
+ );
65
+ }
66
+ }
@@ -1,4 +1,4 @@
1
- import { useTheme } from '@react-navigation/native';
1
+ import { IsFocusedContext, useTheme } from '@react-navigation/native';
2
2
  import * as React from 'react';
3
3
  import {
4
4
  Animated,
@@ -19,15 +19,20 @@ type HoverEffectProps = {
19
19
  };
20
20
 
21
21
  export type Props = Omit<PressableProps, 'style' | 'onPress'> & {
22
- href?: string;
23
- pressColor?: ColorValue;
24
- pressOpacity?: number;
25
- hoverEffect?: HoverEffectProps;
26
- style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
27
- onPress?: (
28
- e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent
29
- ) => void;
22
+ href?: string | undefined;
23
+ pressColor?: ColorValue | undefined;
24
+ pressOpacity?: number | undefined;
25
+ hoverEffect?: HoverEffectProps | undefined;
26
+ style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>> | undefined;
27
+ onPress?:
28
+ | ((
29
+ e:
30
+ | React.MouseEvent<HTMLAnchorElement, MouseEvent>
31
+ | GestureResponderEvent
32
+ ) => void)
33
+ | undefined;
30
34
  children: React.ReactNode;
35
+ ref?: React.Ref<React.ComponentRef<typeof AnimatedPressable>> | undefined;
31
36
  };
32
37
 
33
38
  const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
@@ -41,22 +46,20 @@ const useNativeDriver = Platform.OS !== 'web';
41
46
  /**
42
47
  * PlatformPressable provides an abstraction on top of Pressable to handle platform differences.
43
48
  */
44
- function PlatformPressableInternal(
45
- {
46
- disabled,
47
- onPress,
48
- onPressIn,
49
- onPressOut,
50
- android_ripple,
51
- pressColor,
52
- pressOpacity = 0.3,
53
- hoverEffect,
54
- style,
55
- children,
56
- ...rest
57
- }: Props,
58
- ref: React.Ref<React.ComponentRef<typeof AnimatedPressable>>
59
- ) {
49
+ export function PlatformPressable({
50
+ disabled,
51
+ onPress,
52
+ onPressIn,
53
+ onPressOut,
54
+ android_ripple,
55
+ pressColor,
56
+ pressOpacity = 0.3,
57
+ hoverEffect,
58
+ style,
59
+ children,
60
+ ref,
61
+ ...rest
62
+ }: Props) {
60
63
  const { dark } = useTheme();
61
64
  const [opacity] = React.useState(() => new Animated.Value(1));
62
65
 
@@ -76,7 +79,7 @@ function PlatformPressableInternal(
76
79
  const handlePress = (
77
80
  e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent
78
81
  ) => {
79
- if (Platform.OS === 'web' && rest.href !== null) {
82
+ if (Platform.OS === 'web' && rest.href != null) {
80
83
  // ignore clicks with modifier keys
81
84
  const hasModifierKey =
82
85
  ('metaKey' in e && e.metaKey) ||
@@ -91,7 +94,7 @@ function PlatformPressableInternal(
91
94
  // let browser handle "target=_blank" etc.
92
95
  const isSelfTarget =
93
96
  e.currentTarget && 'target' in e.currentTarget
94
- ? [undefined, null, '', 'self'].includes(e.currentTarget.target)
97
+ ? [undefined, null, '', '_self'].includes(e.currentTarget.target)
95
98
  : true;
96
99
 
97
100
  if (!hasModifierKey && isLeftClick && isSelfTarget) {
@@ -115,10 +118,69 @@ function PlatformPressableInternal(
115
118
  onPressOut?.(e);
116
119
  };
117
120
 
121
+ const elementRef = React.useRef<HTMLElement | null>(null);
122
+
123
+ const handleRef = React.useCallback(
124
+ (node: React.ComponentRef<typeof AnimatedPressable> | null) => {
125
+ elementRef.current =
126
+ Platform.OS === 'web' &&
127
+ typeof HTMLElement !== 'undefined' &&
128
+ node instanceof HTMLElement
129
+ ? node
130
+ : null;
131
+
132
+ if (typeof ref === 'function') {
133
+ return ref(node);
134
+ } else if (ref != null) {
135
+ ref.current = node;
136
+ }
137
+ },
138
+ [ref]
139
+ );
140
+
141
+ // React Native Web doesn't correctly handle ref cleanup functions
142
+ // So we use a `useEffect` for the listeners instead of the ref callback
143
+ React.useEffect(() => {
144
+ const element = elementRef.current;
145
+
146
+ if (rest.href == null || element == null || !disabled) {
147
+ return;
148
+ }
149
+
150
+ // On web, a disabled button prevents our onPress from being called
151
+ // But the link is still clickable, and will perform a full page navigation
152
+ // So we manually prevent the default behavior of the link when disabled
153
+ // The `href` is still set so regular link semantics are preserved
154
+ const preventNavigation = (event: Event) => {
155
+ event.preventDefault();
156
+ event.stopPropagation();
157
+ };
158
+
159
+ element.addEventListener('click', preventNavigation, true);
160
+ element.addEventListener('auxclick', preventNavigation, true);
161
+
162
+ return () => {
163
+ element.removeEventListener('click', preventNavigation, true);
164
+ element.removeEventListener('auxclick', preventNavigation, true);
165
+ };
166
+ }, [disabled, rest.href]);
167
+
168
+ let focusable: boolean | undefined;
169
+
170
+ if (disabled) {
171
+ focusable = false;
172
+ } else if (Platform.isTV) {
173
+ // On `react-native-tvos`, the focus engine doesn't respect `aria-hidden` on screens
174
+ // So we hide them from TV focus engine for unfocused screens
175
+ focusable = React.use(IsFocusedContext);
176
+ }
177
+
118
178
  return (
119
179
  <AnimatedPressable
120
- ref={ref}
180
+ ref={handleRef}
121
181
  accessible
182
+ disabled={disabled}
183
+ focusable={focusable}
122
184
  role={Platform.OS === 'web' && rest.href != null ? 'link' : 'button'}
123
185
  onPress={disabled ? undefined : handlePress}
124
186
  onPressIn={disabled ? undefined : handlePressIn}
@@ -156,10 +218,6 @@ function PlatformPressableInternal(
156
218
  );
157
219
  }
158
220
 
159
- export const PlatformPressable = React.forwardRef(PlatformPressableInternal);
160
-
161
- PlatformPressable.displayName = 'PlatformPressable';
162
-
163
221
  const css = String.raw;
164
222
 
165
223
  const CLASS_NAME = `__react-navigation_elements_Pressable_hover`;
@@ -196,20 +254,20 @@ const HoverEffect = ({
196
254
  return null;
197
255
  }
198
256
 
257
+ const style: React.CSSProperties & {
258
+ [key: `--${string}`]: string | number;
259
+ } = {
260
+ '--overlay-color': color,
261
+ '--overlay-hover-opacity': hoverOpacity,
262
+ '--overlay-active-opacity': activeOpacity,
263
+ };
264
+
199
265
  return (
200
266
  <>
201
267
  <style href={CLASS_NAME} precedence="elements">
202
268
  {CSS_TEXT}
203
269
  </style>
204
- <div
205
- className={CLASS_NAME}
206
- style={{
207
- // @ts-expect-error: CSS variables are not typed
208
- '--overlay-color': color,
209
- '--overlay-hover-opacity': hoverOpacity,
210
- '--overlay-active-opacity': activeOpacity,
211
- }}
212
- />
270
+ <div className={CLASS_NAME} style={style} />
213
271
  </>
214
272
  );
215
273
  };
@@ -34,7 +34,7 @@ const initialMetrics =
34
34
  : initialWindowMetrics;
35
35
 
36
36
  export function SafeAreaProviderCompat({ children, style }: Props) {
37
- const insets = React.useContext(SafeAreaInsetsContext);
37
+ const insets = React.use(SafeAreaInsetsContext);
38
38
 
39
39
  return (
40
40
  <FrameSizeProvider
package/src/Screen.tsx CHANGED
@@ -6,15 +6,10 @@ import {
6
6
  useTheme,
7
7
  } from '@react-navigation/native';
8
8
  import * as React from 'react';
9
- import {
10
- Animated,
11
- type StyleProp,
12
- StyleSheet,
13
- View,
14
- type ViewStyle,
15
- } from 'react-native';
9
+ import { StyleSheet, View } from 'react-native';
16
10
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
17
11
 
12
+ import { Container, type Props as ContainerProps } from './Container';
18
13
  import { getDefaultHeaderHeight } from './Header/getDefaultHeaderHeight';
19
14
  import { HeaderHeightContext } from './Header/HeaderHeightContext';
20
15
  import { HeaderShownContext } from './Header/HeaderShownContext';
@@ -22,14 +17,14 @@ import { useFrameSize } from './useFrameSize';
22
17
 
23
18
  type Props = {
24
19
  focused: boolean;
25
- modal?: boolean;
20
+ modal?: boolean | undefined;
26
21
  navigation: NavigationProp<ParamListBase>;
27
22
  route: RouteProp<ParamListBase>;
28
23
  header: React.ReactNode;
29
- headerShown?: boolean;
30
- headerStatusBarHeight?: number;
31
- headerTransparent?: boolean;
32
- style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
24
+ headerShown?: boolean | undefined;
25
+ headerStatusBarHeight?: number | undefined;
26
+ headerTransparent?: boolean | undefined;
27
+ style?: ContainerProps['style'] | undefined;
33
28
  children: React.ReactNode;
34
29
  };
35
30
 
@@ -37,8 +32,8 @@ export function Screen(props: Props) {
37
32
  const insets = useSafeAreaInsets();
38
33
  const { colors } = useTheme();
39
34
 
40
- const isParentHeaderShown = React.useContext(HeaderShownContext);
41
- const parentHeaderHeight = React.useContext(HeaderHeightContext);
35
+ const isParentHeaderShown = React.use(HeaderShownContext);
36
+ const parentHeaderHeight = React.use(HeaderHeightContext);
42
37
 
43
38
  const {
44
39
  focused,
@@ -72,25 +67,43 @@ export function Screen(props: Props) {
72
67
  }, [route.name]);
73
68
 
74
69
  return (
75
- <Animated.View
76
- aria-hidden={!focused}
77
- style={[styles.container, { backgroundColor: colors.background }, style]}
70
+ <Container
71
+ inert={!focused}
72
+ style={{
73
+ ...styles.container,
74
+ backgroundColor: colors.background,
75
+ ...style,
76
+ }}
78
77
  // On Fabric we need to disable collapsing for the background to ensure
79
78
  // that we won't render unnecessary views due to the view flattening.
80
- collapsable={false}
79
+ // Container sets `collapsable` to `false` internally
80
+ // This comment is left to make sure refactors don't remove it by mistake
81
81
  >
82
82
  {headerShown ? (
83
83
  <NavigationProvider navigation={navigation} route={route}>
84
84
  <View
85
- ref={headerRef}
86
- onLayout={(e) => {
87
- const { height } = e.nativeEvent.layout;
88
-
89
- setHeaderHeight(height);
90
- }}
91
- style={[styles.header, headerTransparent ? styles.absolute : null]}
85
+ style={[
86
+ styles.header,
87
+ headerTransparent
88
+ ? [
89
+ styles.absolute,
90
+ // Specify an explicit min height for Android screen readers
91
+ { minHeight: headerHeight },
92
+ ]
93
+ : null,
94
+ ]}
92
95
  >
93
- {header}
96
+ <View
97
+ ref={headerRef}
98
+ onLayout={(e) => {
99
+ const { height } = e.nativeEvent.layout;
100
+
101
+ setHeaderHeight(height);
102
+ }}
103
+ style={{ pointerEvents: 'box-none' }}
104
+ >
105
+ {header}
106
+ </View>
94
107
  </View>
95
108
  </NavigationProvider>
96
109
  ) : null}
@@ -105,7 +118,7 @@ export function Screen(props: Props) {
105
118
  </HeaderHeightContext.Provider>
106
119
  </HeaderShownContext.Provider>
107
120
  </View>
108
- </Animated.View>
121
+ </Container>
109
122
  );
110
123
  }
111
124
 
package/src/index.tsx CHANGED
@@ -1,9 +1,3 @@
1
- import backIcon from './assets/back-icon.png';
2
- import clearIcon from './assets/clear-icon.png';
3
- import closeIcon from './assets/close-icon.png';
4
- import searchIcon from './assets/search-icon.png';
5
- import searchIconLegacy from './assets/search-icon-legacy.png';
6
-
7
1
  export { Badge } from './Badge';
8
2
  export { Button } from './Button';
9
3
  export { getDefaultSidebarWidth } from './getDefaultSidebarWidth';
@@ -20,16 +14,8 @@ export { HeaderTitle } from './Header/HeaderTitle';
20
14
  export { useHeaderHeight } from './Header/useHeaderHeight';
21
15
  export { getLabel } from './Label/getLabel';
22
16
  export { Label } from './Label/Label';
17
+ export { PlatformIcon } from './PlatformIcon';
23
18
  export { PlatformPressable } from './PlatformPressable';
24
19
  export { Text } from './Text';
25
- export { useFrameSize } from './useFrameSize';
26
-
27
- export const Assets = [
28
- backIcon,
29
- searchIcon,
30
- searchIconLegacy,
31
- closeIcon,
32
- clearIcon,
33
- ];
34
-
35
20
  export * from './types';
21
+ export { useFrameSize } from './useFrameSize';
package/src/internal.tsx CHANGED
@@ -1,6 +1,6 @@
1
+ export { ActivityView } from './ActivityView';
1
2
  export { Color } from './Color';
2
3
  export { Container, type Props as ContainerProps } from './Container';
3
- export { Lazy } from './Lazy';
4
4
  export { isLiquidGlassSupported } from './LiquidGlassView';
5
5
  export { MissingIcon } from './MissingIcon';
6
6
  export { SafeAreaProviderCompat } from './SafeAreaProviderCompat';