@react-navigation/elements 3.0.0-alpha.1 → 3.0.0-alpha.10

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 (108) hide show
  1. package/lib/module/Badge.js +1 -1
  2. package/lib/module/Badge.js.map +1 -1
  3. package/lib/module/Button.js +1 -1
  4. package/lib/module/Button.js.map +1 -1
  5. package/lib/module/Color.js +95 -0
  6. package/lib/module/Color.js.map +1 -1
  7. package/lib/module/Header/Header.js +15 -2
  8. package/lib/module/Header/Header.js.map +1 -1
  9. package/lib/module/Header/HeaderBackButton.js +27 -13
  10. package/lib/module/Header/HeaderBackButton.js.map +1 -1
  11. package/lib/module/Header/HeaderIcon.js +29 -10
  12. package/lib/module/Header/HeaderIcon.js.map +1 -1
  13. package/lib/module/Header/HeaderSearchBar.js +28 -21
  14. package/lib/module/Header/HeaderSearchBar.js.map +1 -1
  15. package/lib/module/PlatformColor.js +1 -0
  16. package/lib/module/PlatformColor.js.map +1 -1
  17. package/lib/module/PlatformColor.native.js +1 -1
  18. package/lib/module/PlatformColor.native.js.map +1 -1
  19. package/lib/module/index.js +1 -7
  20. package/lib/module/index.js.map +1 -1
  21. package/lib/typescript/src/Color.d.ts +4 -3
  22. package/lib/typescript/src/Color.d.ts.map +1 -1
  23. package/lib/typescript/src/Header/Header.d.ts.map +1 -1
  24. package/lib/typescript/src/Header/HeaderBackButton.d.ts +1 -1
  25. package/lib/typescript/src/Header/HeaderBackButton.d.ts.map +1 -1
  26. package/lib/typescript/src/Header/HeaderIcon.d.ts +8 -4
  27. package/lib/typescript/src/Header/HeaderIcon.d.ts.map +1 -1
  28. package/lib/typescript/src/Header/HeaderSearchBar.d.ts.map +1 -1
  29. package/lib/typescript/src/PlatformColor.d.ts +1 -0
  30. package/lib/typescript/src/PlatformColor.d.ts.map +1 -1
  31. package/lib/typescript/src/PlatformColor.native.d.ts +1 -1
  32. package/lib/typescript/src/PlatformColor.native.d.ts.map +1 -1
  33. package/lib/typescript/src/index.d.ts +1 -2
  34. package/lib/typescript/src/index.d.ts.map +1 -1
  35. package/lib/typescript/src/types.d.ts +26 -5
  36. package/lib/typescript/src/types.d.ts.map +1 -1
  37. package/package.json +5 -5
  38. package/src/Badge.tsx +1 -1
  39. package/src/Button.tsx +1 -3
  40. package/src/Color.tsx +133 -3
  41. package/src/Header/Header.tsx +17 -1
  42. package/src/Header/HeaderBackButton.tsx +28 -14
  43. package/src/Header/HeaderIcon.tsx +49 -9
  44. package/src/Header/HeaderSearchBar.tsx +27 -18
  45. package/src/PlatformColor.native.tsx +1 -1
  46. package/src/PlatformColor.tsx +4 -0
  47. package/src/index.tsx +1 -16
  48. package/src/types.tsx +33 -2
  49. package/lib/module/assets/back-icon.ios.svg +0 -4
  50. package/lib/module/assets/back-icon@1x.android.png +0 -0
  51. package/lib/module/assets/back-icon@1x.ios.png +0 -0
  52. package/lib/module/assets/back-icon@2x.android.png +0 -0
  53. package/lib/module/assets/back-icon@2x.ios.png +0 -0
  54. package/lib/module/assets/back-icon@3x.android.png +0 -0
  55. package/lib/module/assets/back-icon@3x.ios.png +0 -0
  56. package/lib/module/assets/back-icon@4x.android.png +0 -0
  57. package/lib/module/assets/back-icon@4x.ios.png +0 -0
  58. package/lib/module/assets/clear-icon@1x.png +0 -0
  59. package/lib/module/assets/clear-icon@2x.png +0 -0
  60. package/lib/module/assets/clear-icon@3x.png +0 -0
  61. package/lib/module/assets/clear-icon@4x.png +0 -0
  62. package/lib/module/assets/close-icon@1x.png +0 -0
  63. package/lib/module/assets/close-icon@2x.png +0 -0
  64. package/lib/module/assets/close-icon@3x.png +0 -0
  65. package/lib/module/assets/close-icon@4x.png +0 -0
  66. package/lib/module/assets/search-icon-legacy@1x.ios.png +0 -0
  67. package/lib/module/assets/search-icon-legacy@2x.ios.png +0 -0
  68. package/lib/module/assets/search-icon-legacy@3x.ios.png +0 -0
  69. package/lib/module/assets/search-icon-legacy@4x.ios.png +0 -0
  70. package/lib/module/assets/search-icon.ios.svg +0 -4
  71. package/lib/module/assets/search-icon@1x.android.png +0 -0
  72. package/lib/module/assets/search-icon@1x.ios.png +0 -0
  73. package/lib/module/assets/search-icon@2x.android.png +0 -0
  74. package/lib/module/assets/search-icon@2x.ios.png +0 -0
  75. package/lib/module/assets/search-icon@3x.android.png +0 -0
  76. package/lib/module/assets/search-icon@3x.ios.png +0 -0
  77. package/lib/module/assets/search-icon@4x.android.png +0 -0
  78. package/lib/module/assets/search-icon@4x.ios.png +0 -0
  79. package/src/assets/back-icon.ios.svg +0 -4
  80. package/src/assets/back-icon@1x.android.png +0 -0
  81. package/src/assets/back-icon@1x.ios.png +0 -0
  82. package/src/assets/back-icon@2x.android.png +0 -0
  83. package/src/assets/back-icon@2x.ios.png +0 -0
  84. package/src/assets/back-icon@3x.android.png +0 -0
  85. package/src/assets/back-icon@3x.ios.png +0 -0
  86. package/src/assets/back-icon@4x.android.png +0 -0
  87. package/src/assets/back-icon@4x.ios.png +0 -0
  88. package/src/assets/clear-icon@1x.png +0 -0
  89. package/src/assets/clear-icon@2x.png +0 -0
  90. package/src/assets/clear-icon@3x.png +0 -0
  91. package/src/assets/clear-icon@4x.png +0 -0
  92. package/src/assets/close-icon@1x.png +0 -0
  93. package/src/assets/close-icon@2x.png +0 -0
  94. package/src/assets/close-icon@3x.png +0 -0
  95. package/src/assets/close-icon@4x.png +0 -0
  96. package/src/assets/search-icon-legacy@1x.ios.png +0 -0
  97. package/src/assets/search-icon-legacy@2x.ios.png +0 -0
  98. package/src/assets/search-icon-legacy@3x.ios.png +0 -0
  99. package/src/assets/search-icon-legacy@4x.ios.png +0 -0
  100. package/src/assets/search-icon.ios.svg +0 -4
  101. package/src/assets/search-icon@1x.android.png +0 -0
  102. package/src/assets/search-icon@1x.ios.png +0 -0
  103. package/src/assets/search-icon@2x.android.png +0 -0
  104. package/src/assets/search-icon@2x.ios.png +0 -0
  105. package/src/assets/search-icon@3x.android.png +0 -0
  106. package/src/assets/search-icon@3x.ios.png +0 -0
  107. package/src/assets/search-icon@4x.android.png +0 -0
  108. package/src/assets/search-icon@4x.ios.png +0 -0
@@ -1,24 +1,64 @@
1
- import { useLocale, useTheme } from '@react-navigation/native';
2
- import { Image, type ImageProps, Platform, StyleSheet } from 'react-native';
1
+ import { MaterialSymbol, SFSymbol, useLocale } from '@react-navigation/native';
2
+ import {
3
+ type ColorValue,
4
+ Image,
5
+ type ImageProps,
6
+ Platform,
7
+ StyleSheet,
8
+ } from 'react-native';
3
9
 
4
- export function HeaderIcon({ source, style, ...rest }: ImageProps) {
5
- const { colors } = useTheme();
10
+ import type { HeaderIcon as HeaderIconType } from '../types';
11
+
12
+ type Props = Omit<ImageProps, 'source'> & {
13
+ icon: HeaderIconType;
14
+ color: ColorValue;
15
+ };
16
+
17
+ export function HeaderIcon({ icon, color, style, ...rest }: Props) {
6
18
  const { direction } = useLocale();
7
19
 
20
+ const iconStyle = [styles.icon, direction === 'rtl' && styles.flip, style];
21
+
22
+ if (icon.type === 'sfSymbol') {
23
+ return (
24
+ <SFSymbol
25
+ name={icon.name}
26
+ color={color}
27
+ size={ICON_SIZE}
28
+ style={iconStyle}
29
+ {...rest}
30
+ />
31
+ );
32
+ }
33
+
34
+ if (icon.type === 'materialSymbol') {
35
+ return (
36
+ <MaterialSymbol
37
+ name={icon.name}
38
+ variant={icon.variant}
39
+ weight={icon.weight}
40
+ color={color}
41
+ size={ICON_SIZE}
42
+ style={iconStyle}
43
+ {...rest}
44
+ />
45
+ );
46
+ }
47
+
8
48
  return (
9
49
  <Image
10
- source={source}
50
+ source={icon.source}
11
51
  resizeMode="contain"
12
52
  fadeDuration={0}
13
- tintColor={colors.text}
14
- style={[styles.icon, direction === 'rtl' && styles.flip, style]}
53
+ tintColor={color}
54
+ style={iconStyle}
15
55
  {...rest}
16
56
  />
17
57
  );
18
58
  }
19
59
 
20
- export const ICON_SIZE = Platform.OS === 'ios' ? 21 : 24;
21
- export const ICON_MARGIN = Platform.OS === 'ios' ? 8 : 3;
60
+ const ICON_SIZE = Platform.OS === 'ios' ? 21 : 24;
61
+ const ICON_MARGIN = Platform.OS === 'ios' ? 8 : 3;
22
62
 
23
63
  const styles = StyleSheet.create({
24
64
  icon: {
@@ -1,10 +1,9 @@
1
- import { useNavigation, useTheme } from '@react-navigation/native';
1
+ import { SFSymbol, useNavigation, useTheme } from '@react-navigation/native';
2
2
  import * as React from 'react';
3
3
  import {
4
4
  Animated,
5
5
  BackHandler,
6
6
  type ColorValue,
7
- Image,
8
7
  type NativeEventSubscription,
9
8
  Platform,
10
9
  type StyleProp,
@@ -14,10 +13,7 @@ import {
14
13
  type ViewStyle,
15
14
  } from 'react-native';
16
15
 
17
- import clearIcon from '../assets/clear-icon.png';
18
16
  import closeIcon from '../assets/close-icon.png';
19
- import searchIcon from '../assets/search-icon.png';
20
- import searchIconLegacy from '../assets/search-icon-legacy.png';
21
17
  import { Color } from '../Color';
22
18
  import {
23
19
  AnimatedLiquidGlassContainerView,
@@ -210,9 +206,10 @@ function HeaderSearchBarInternal(
210
206
  ) : null}
211
207
  <HeaderButtonBackground style={styles.searchbarContainer}>
212
208
  {Platform.OS === 'ios' ? (
213
- <HeaderIcon
214
- source={isLiquidGlassSupported ? searchIcon : searchIconLegacy}
215
- tintColor={textColor}
209
+ <SFSymbol
210
+ name="magnifyingglass"
211
+ size={SEARCH_ICON_SIZE}
212
+ color={textColor}
216
213
  style={[
217
214
  styles.inputSearchIconIos,
218
215
  !isLiquidGlassSupported && styles.inputSearchIconIosLegacy,
@@ -263,10 +260,10 @@ function HeaderSearchBarInternal(
263
260
  !isLiquidGlassSupported && styles.clearButtonIosLegacy,
264
261
  ]}
265
262
  >
266
- <Image
267
- source={clearIcon}
268
- resizeMode="contain"
269
- tintColor={textColor}
263
+ <SFSymbol
264
+ name="xmark.circle.fill"
265
+ size={CLEAR_ICON_SIZE}
266
+ color={textColor}
270
267
  style={styles.clearIconIos}
271
268
  />
272
269
  </PlatformPressable>
@@ -278,7 +275,19 @@ function HeaderSearchBarInternal(
278
275
  onPress={onClear}
279
276
  style={[styles.closeButton, { opacity: clearVisibleAnim }]}
280
277
  >
281
- <HeaderIcon source={closeIcon} tintColor={textColor} />
278
+ <HeaderIcon
279
+ icon={Platform.select({
280
+ android: {
281
+ type: 'materialSymbol',
282
+ name: 'close',
283
+ },
284
+ default: {
285
+ type: 'image',
286
+ source: closeIcon,
287
+ },
288
+ })}
289
+ color={textColor}
290
+ />
282
291
  </HeaderButton>
283
292
  ) : null}
284
293
  {Platform.OS === 'ios' ? (
@@ -288,7 +297,7 @@ function HeaderSearchBarInternal(
288
297
  accessibilityLabel={cancelButtonText}
289
298
  onPress={cancelSearch}
290
299
  >
291
- <HeaderIcon source={closeIcon} tintColor={textColor} />
300
+ <SFSymbol name="xmark" color={textColor} />
292
301
  </HeaderButton>
293
302
  </HeaderButtonBackground>
294
303
  ) : (
@@ -332,14 +341,14 @@ const styles = StyleSheet.create({
332
341
  },
333
342
  inputSearchIconIos: {
334
343
  position: 'absolute',
335
- opacity: 0.5,
336
- top: SEARCHBAR_ICON_SPACING,
337
- left: SEARCHBAR_ICON_SPACING,
344
+ top: '50%',
345
+ left: BUTTON_SPACING + SEARCHBAR_ICON_SPACING / 2,
346
+ marginTop: -SEARCH_ICON_SIZE / 2,
338
347
  height: SEARCH_ICON_SIZE,
339
348
  width: SEARCH_ICON_SIZE,
340
349
  },
341
350
  inputSearchIconIosLegacy: {
342
- top: SEARCHBAR_LEGACY_VERTICAL_OFFSET_IOS,
351
+ top: SEARCHBAR_ICON_SPACING,
343
352
  },
344
353
  backButton: {
345
354
  alignSelf: 'center',
@@ -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;
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';
@@ -22,14 +16,5 @@ export { getLabel } from './Label/getLabel';
22
16
  export { Label } from './Label/Label';
23
17
  export { PlatformPressable } from './PlatformPressable';
24
18
  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
19
  export * from './types';
20
+ export { useFrameSize } from './useFrameSize';
package/src/types.tsx CHANGED
@@ -1,6 +1,12 @@
1
+ import type {
2
+ MaterialSymbolProps,
3
+ SFSymbolProps,
4
+ } from '@react-navigation/native';
5
+ import * as React from 'react';
1
6
  import type {
2
7
  Animated,
3
8
  ColorValue,
9
+ ImageSourcePropType,
4
10
  LayoutChangeEvent,
5
11
  StyleProp,
6
12
  TextInputProps,
@@ -325,11 +331,36 @@ export type HeaderButtonProps = {
325
331
  children: React.ReactNode;
326
332
  };
327
333
 
334
+ export type HeaderIcon =
335
+ | {
336
+ type: 'image';
337
+ source: ImageSourcePropType;
338
+ }
339
+ | {
340
+ type: 'sfSymbol';
341
+ name: SFSymbolProps['name'];
342
+ }
343
+ | ({
344
+ type: 'materialSymbol';
345
+ } & Pick<MaterialSymbolProps, 'name' | 'variant' | 'weight'>);
346
+
328
347
  export type HeaderBackButtonProps = Omit<HeaderButtonProps, 'children'> & {
329
348
  /**
330
- * Function which returns a React Element to display custom image in header's back button.
349
+ * Icon to display for the back button.
350
+ *
351
+ * Supported types:
352
+ * - image: custom image source
353
+ * - sfSymbol: SF Symbol icon (iOS only)
354
+ * - materialSymbol: material symbol icon (Android only)
355
+ * - React Node: function that returns a React Element
356
+ *
357
+ * Defaults to back icon image for the platform
358
+ * - A chevron on iOS
359
+ * - An arrow on Android
331
360
  */
332
- backImage?: (props: { tintColor: ColorValue }) => React.ReactNode;
361
+ icon?:
362
+ | HeaderIcon
363
+ | ((props: { tintColor: ColorValue | undefined }) => React.ReactNode);
333
364
  /**
334
365
  * Label text for the button. Usually the title of the previous screen.
335
366
  * By default, this is only shown on iOS.
@@ -1,4 +0,0 @@
1
- <svg viewBox="0 0 12 21" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <path d="M10.527 1.485L1.584 10.5L10.559 19.542" stroke="#0c0000" stroke-width="2.5" stroke-linecap="round"
3
- stroke-linejoin="round" />
4
- </svg>
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,4 +0,0 @@
1
- <svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <circle cx="9.75" cy="9.75" r="8" stroke="#000" stroke-width="2" />
3
- <path d="M15.5 15.5L22 22" stroke="#000" stroke-width="2" stroke-linecap="round" />
4
- </svg>
@@ -1,4 +0,0 @@
1
- <svg viewBox="0 0 12 21" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <path d="M10.527 1.485L1.584 10.5L10.559 19.542" stroke="#0c0000" stroke-width="2.5" stroke-linecap="round"
3
- stroke-linejoin="round" />
4
- </svg>
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,4 +0,0 @@
1
- <svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <circle cx="9.75" cy="9.75" r="8" stroke="#000" stroke-width="2" />
3
- <path d="M15.5 15.5L22 22" stroke="#000" stroke-width="2" stroke-linecap="round" />
4
- </svg>
Binary file
Binary file
Binary file
Binary file