@react-navigation/native 8.0.0-alpha.0 → 8.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.
- package/ReactNavigation.podspec +20 -0
- package/android/build.gradle +147 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/org/reactnavigation/MaterialSymbolModule.kt +100 -0
- package/android/src/main/java/org/reactnavigation/MaterialSymbolTypeface.kt +77 -0
- package/android/src/main/java/org/reactnavigation/MaterialSymbolView.kt +95 -0
- package/android/src/main/java/org/reactnavigation/MaterialSymbolViewManager.kt +49 -0
- package/android/src/main/java/org/reactnavigation/ReactNavigationPackage.kt +34 -0
- package/assets/fonts/MaterialSymbolsOutlined.codepoints +4102 -0
- package/assets/fonts/MaterialSymbolsOutlined_100.ttf +0 -0
- package/assets/fonts/MaterialSymbolsOutlined_200.ttf +0 -0
- package/assets/fonts/MaterialSymbolsOutlined_300.ttf +0 -0
- package/assets/fonts/MaterialSymbolsOutlined_400.ttf +0 -0
- package/assets/fonts/MaterialSymbolsOutlined_500.ttf +0 -0
- package/assets/fonts/MaterialSymbolsOutlined_600.ttf +0 -0
- package/assets/fonts/MaterialSymbolsOutlined_700.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded.codepoints +4102 -0
- package/assets/fonts/MaterialSymbolsRounded_100.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded_200.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded_300.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded_400.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded_500.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded_600.ttf +0 -0
- package/assets/fonts/MaterialSymbolsRounded_700.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp.codepoints +4102 -0
- package/assets/fonts/MaterialSymbolsSharp_100.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp_200.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp_300.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp_400.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp_500.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp_600.ttf +0 -0
- package/assets/fonts/MaterialSymbolsSharp_700.ttf +0 -0
- package/ios/ReactNavigationSFSymbolView.h +14 -0
- package/ios/ReactNavigationSFSymbolView.mm +79 -0
- package/ios/ReactNavigationSFSymbolView.swift +300 -0
- package/lib/module/NavigationContainer.js +7 -2
- package/lib/module/NavigationContainer.js.map +1 -1
- package/lib/module/createStaticNavigation.js +3 -6
- package/lib/module/createStaticNavigation.js.map +1 -1
- package/lib/module/index.js +4 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/native/MaterialSymbol.android.js +58 -0
- package/lib/module/native/MaterialSymbol.android.js.map +1 -0
- package/lib/module/native/MaterialSymbol.js +9 -0
- package/lib/module/native/MaterialSymbol.js.map +1 -0
- package/lib/module/native/MaterialSymbolData.js +2 -0
- package/lib/module/native/MaterialSymbolData.js.map +1 -0
- package/lib/module/native/MaterialSymbolViewNativeComponent.ts +23 -0
- package/lib/module/native/NativeMaterialSymbolModule.js +7 -0
- package/lib/module/native/NativeMaterialSymbolModule.js.map +1 -0
- package/lib/module/native/SFSymbol.ios.js +46 -0
- package/lib/module/native/SFSymbol.ios.js.map +1 -0
- package/lib/module/native/SFSymbol.js +6 -0
- package/lib/module/native/SFSymbol.js.map +1 -0
- package/lib/module/native/SFSymbolViewNativeComponent.ts +32 -0
- package/lib/module/native/constants.js +14 -0
- package/lib/module/native/constants.js.map +1 -0
- package/lib/module/native/types.js +4 -0
- package/lib/module/native/types.js.map +1 -0
- package/lib/module/theming/{DefaultTheme.js → LightTheme.js} +2 -2
- package/lib/module/theming/LightTheme.js.map +1 -0
- package/lib/module/theming/MaterialTheme.android.js +29 -0
- package/lib/module/theming/MaterialTheme.android.js.map +1 -0
- package/lib/module/theming/MaterialTheme.js +18 -0
- package/lib/module/theming/MaterialTheme.js.map +1 -0
- package/lib/module/useLinkBuilder.js +24 -5
- package/lib/module/useLinkBuilder.js.map +1 -1
- package/lib/module/useLinkTo.js +2 -4
- package/lib/module/useLinkTo.js.map +1 -1
- package/lib/module/useLinking.native.js +20 -3
- package/lib/module/useLinking.native.js.map +1 -1
- package/lib/typescript/src/NavigationContainer.d.ts +6 -1
- package/lib/typescript/src/NavigationContainer.d.ts.map +1 -1
- package/lib/typescript/src/createStaticNavigation.d.ts +3 -3
- package/lib/typescript/src/createStaticNavigation.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +4 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/native/MaterialSymbol.android.d.ts +8 -0
- package/lib/typescript/src/native/MaterialSymbol.android.d.ts.map +1 -0
- package/lib/typescript/src/native/MaterialSymbol.d.ts +8 -0
- package/lib/typescript/src/native/MaterialSymbol.d.ts.map +1 -0
- package/lib/typescript/src/native/MaterialSymbolData.d.ts +2 -0
- package/lib/typescript/src/native/MaterialSymbolData.d.ts.map +1 -0
- package/lib/typescript/src/native/MaterialSymbolViewNativeComponent.d.ts +11 -0
- package/lib/typescript/src/native/MaterialSymbolViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/native/NativeMaterialSymbolModule.d.ts +7 -0
- package/lib/typescript/src/native/NativeMaterialSymbolModule.d.ts.map +1 -0
- package/lib/typescript/src/native/SFSymbol.d.ts +5 -0
- package/lib/typescript/src/native/SFSymbol.d.ts.map +1 -0
- package/lib/typescript/src/native/SFSymbol.ios.d.ts +5 -0
- package/lib/typescript/src/native/SFSymbol.ios.d.ts.map +1 -0
- package/lib/typescript/src/native/SFSymbolViewNativeComponent.d.ts +23 -0
- package/lib/typescript/src/native/SFSymbolViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/native/constants.d.ts +12 -0
- package/lib/typescript/src/native/constants.d.ts.map +1 -0
- package/lib/typescript/src/native/types.d.ts +181 -0
- package/lib/typescript/src/native/types.d.ts.map +1 -0
- package/lib/typescript/src/theming/{DefaultTheme.d.ts → LightTheme.d.ts} +2 -2
- package/lib/typescript/src/theming/LightTheme.d.ts.map +1 -0
- package/lib/typescript/src/theming/MaterialTheme.android.d.ts +127 -0
- package/lib/typescript/src/theming/MaterialTheme.android.d.ts.map +1 -0
- package/lib/typescript/src/theming/MaterialTheme.d.ts +114 -0
- package/lib/typescript/src/theming/MaterialTheme.d.ts.map +1 -0
- package/lib/typescript/src/useLinkBuilder.d.ts +104 -6
- package/lib/typescript/src/useLinkBuilder.d.ts.map +1 -1
- package/lib/typescript/src/useLinking.native.d.ts.map +1 -1
- package/package.json +39 -4
- package/src/NavigationContainer.tsx +20 -3
- package/src/createStaticNavigation.tsx +8 -12
- package/src/index.tsx +7 -1
- package/src/native/MaterialSymbol.android.tsx +83 -0
- package/src/native/MaterialSymbol.tsx +17 -0
- package/src/native/MaterialSymbolData.tsx +4106 -0
- package/src/native/MaterialSymbolViewNativeComponent.ts +23 -0
- package/src/native/NativeMaterialSymbolModule.ts +19 -0
- package/src/native/SFSymbol.ios.tsx +53 -0
- package/src/native/SFSymbol.tsx +9 -0
- package/src/native/SFSymbolViewNativeComponent.ts +32 -0
- package/src/native/constants.tsx +11 -0
- package/src/native/types.tsx +218 -0
- package/src/theming/{DefaultTheme.tsx → LightTheme.tsx} +1 -1
- package/src/theming/MaterialTheme.android.tsx +30 -0
- package/src/theming/MaterialTheme.tsx +19 -0
- package/src/useLinkBuilder.tsx +26 -6
- package/src/useLinkTo.tsx +2 -2
- package/src/useLinking.native.tsx +38 -15
- package/lib/module/theming/DefaultTheme.js.map +0 -1
- package/lib/typescript/src/theming/DefaultTheme.d.ts.map +0 -1
|
@@ -6,7 +6,9 @@ import {
|
|
|
6
6
|
type InitialState,
|
|
7
7
|
type NavigationContainerProps,
|
|
8
8
|
type NavigationContainerRef,
|
|
9
|
+
type NavigationState,
|
|
9
10
|
type ParamListBase,
|
|
11
|
+
type PartialState,
|
|
10
12
|
type RootParamList,
|
|
11
13
|
ThemeProvider,
|
|
12
14
|
validatePathConfig,
|
|
@@ -16,7 +18,7 @@ import { I18nManager, Platform } from 'react-native';
|
|
|
16
18
|
|
|
17
19
|
import { LinkingContext } from './LinkingContext';
|
|
18
20
|
import { LocaleDirContext } from './LocaleDirContext';
|
|
19
|
-
import {
|
|
21
|
+
import { LightTheme } from './theming/LightTheme';
|
|
20
22
|
import type {
|
|
21
23
|
DocumentTitleOptions,
|
|
22
24
|
LinkingOptions,
|
|
@@ -31,7 +33,16 @@ import { type Thenable, useThenable } from './useThenable';
|
|
|
31
33
|
declare global {
|
|
32
34
|
var REACT_NAVIGATION_DEVTOOLS: WeakMap<
|
|
33
35
|
NavigationContainerRef<any>,
|
|
34
|
-
{
|
|
36
|
+
{
|
|
37
|
+
readonly linking: LinkingOptions<any>;
|
|
38
|
+
readonly listeners: Set<
|
|
39
|
+
(data: {
|
|
40
|
+
type: 'link';
|
|
41
|
+
url: string;
|
|
42
|
+
state: PartialState<NavigationState> | undefined;
|
|
43
|
+
}) => void
|
|
44
|
+
>;
|
|
45
|
+
}
|
|
35
46
|
>;
|
|
36
47
|
}
|
|
37
48
|
|
|
@@ -103,7 +114,7 @@ const RESTORE_STATE_ERROR =
|
|
|
103
114
|
function NavigationContainerInner(
|
|
104
115
|
{
|
|
105
116
|
direction = I18nManager.getConstants().isRTL ? 'rtl' : 'ltr',
|
|
106
|
-
theme =
|
|
117
|
+
theme = LightTheme,
|
|
107
118
|
linking,
|
|
108
119
|
persistor,
|
|
109
120
|
fallback = null,
|
|
@@ -150,10 +161,16 @@ function NavigationContainerInner(
|
|
|
150
161
|
// This will be used by the devtools
|
|
151
162
|
React.useEffect(() => {
|
|
152
163
|
if (refContainer.current) {
|
|
164
|
+
const previous = REACT_NAVIGATION_DEVTOOLS.get(refContainer.current);
|
|
165
|
+
const listeners = previous?.listeners ?? new Set();
|
|
166
|
+
|
|
153
167
|
REACT_NAVIGATION_DEVTOOLS.set(refContainer.current, {
|
|
154
168
|
get linking() {
|
|
155
169
|
return linkingConfig.options;
|
|
156
170
|
},
|
|
171
|
+
get listeners() {
|
|
172
|
+
return listeners;
|
|
173
|
+
},
|
|
157
174
|
});
|
|
158
175
|
}
|
|
159
176
|
});
|
|
@@ -20,10 +20,10 @@ type Props = Omit<
|
|
|
20
20
|
linking?: Omit<LinkingOptions<ParamListBase>, 'config' | 'enabled'> & {
|
|
21
21
|
/**
|
|
22
22
|
* Whether deep link handling should be enabled.
|
|
23
|
-
* Defaults to `
|
|
23
|
+
* Defaults to `auto`.
|
|
24
24
|
*
|
|
25
|
-
* When 'auto'
|
|
26
|
-
* The generated
|
|
25
|
+
* When set to 'auto', all leaf screens will get autogenerated paths.
|
|
26
|
+
* The generated paths will be kebab-case versions of the screen names.
|
|
27
27
|
* This can be overridden for specific screens by specifying `linking` for the screen.
|
|
28
28
|
*/
|
|
29
29
|
enabled?: 'auto' | true | false;
|
|
@@ -55,7 +55,7 @@ export function createStaticNavigation(tree: StaticNavigation<any, any, any>) {
|
|
|
55
55
|
const screens = createPathConfigForStaticNavigation(
|
|
56
56
|
tree,
|
|
57
57
|
{ initialRouteName: linking?.config?.initialRouteName },
|
|
58
|
-
linking?.enabled === 'auto'
|
|
58
|
+
linking?.enabled == null || linking.enabled === 'auto'
|
|
59
59
|
);
|
|
60
60
|
|
|
61
61
|
if (!screens) return;
|
|
@@ -72,14 +72,10 @@ export function createStaticNavigation(tree: StaticNavigation<any, any, any>) {
|
|
|
72
72
|
]);
|
|
73
73
|
|
|
74
74
|
const memoizedLinking = React.useMemo(() => {
|
|
75
|
-
if (!linking) {
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
75
|
const enabled =
|
|
80
|
-
|
|
81
|
-
?
|
|
82
|
-
:
|
|
76
|
+
linking?.enabled == null || linking.enabled === 'auto'
|
|
77
|
+
? true
|
|
78
|
+
: linking.enabled;
|
|
83
79
|
|
|
84
80
|
return {
|
|
85
81
|
...linking,
|
|
@@ -92,7 +88,7 @@ export function createStaticNavigation(tree: StaticNavigation<any, any, any>) {
|
|
|
92
88
|
throw new Error(
|
|
93
89
|
'Linking is enabled but no linking configuration was found for the screens.\n\n' +
|
|
94
90
|
'To solve this:\n' +
|
|
95
|
-
"- Specify a 'linking' property
|
|
91
|
+
"- Specify a 'linking' property in each of the screen configs that you want to link to.\n" +
|
|
96
92
|
"- Or set 'linking.enabled' to 'auto' to generate paths automatically.\n\n" +
|
|
97
93
|
'See usage guide: https://reactnavigation.org/docs/static-configuration#linking'
|
|
98
94
|
);
|
package/src/index.tsx
CHANGED
|
@@ -2,10 +2,16 @@ export { createStaticNavigation } from './createStaticNavigation';
|
|
|
2
2
|
export { Link } from './Link';
|
|
3
3
|
export { LinkingContext } from './LinkingContext';
|
|
4
4
|
export { LocaleDirContext } from './LocaleDirContext';
|
|
5
|
+
export {
|
|
6
|
+
MaterialSymbol,
|
|
7
|
+
type MaterialSymbolProps,
|
|
8
|
+
} from './native/MaterialSymbol';
|
|
9
|
+
export { SFSymbol, type SFSymbolProps } from './native/SFSymbol';
|
|
5
10
|
export { NavigationContainer } from './NavigationContainer';
|
|
6
11
|
export { ServerContainer } from './ServerContainer';
|
|
7
12
|
export { DarkTheme } from './theming/DarkTheme';
|
|
8
|
-
export { DefaultTheme } from './theming/
|
|
13
|
+
export { LightTheme as DefaultTheme } from './theming/LightTheme';
|
|
14
|
+
export { MaterialDarkTheme, MaterialLightTheme } from './theming/MaterialTheme';
|
|
9
15
|
export * from './types';
|
|
10
16
|
export { useLinkBuilder } from './useLinkBuilder';
|
|
11
17
|
export { type LinkProps, useLinkProps } from './useLinkProps';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ImageSourcePropType,
|
|
3
|
+
PixelRatio,
|
|
4
|
+
processColor,
|
|
5
|
+
type ViewProps,
|
|
6
|
+
} from 'react-native';
|
|
7
|
+
|
|
8
|
+
import { FONT_WEIGHTS } from './constants';
|
|
9
|
+
import MaterialSymbolViewNativeComponent from './MaterialSymbolViewNativeComponent';
|
|
10
|
+
import NativeMaterialSymbolModule from './NativeMaterialSymbolModule';
|
|
11
|
+
import type { MaterialSymbolOptions } from './types';
|
|
12
|
+
|
|
13
|
+
export type MaterialSymbolProps = MaterialSymbolOptions & ViewProps;
|
|
14
|
+
|
|
15
|
+
const imageSourceCache = new Map<string, ImageSourcePropType>();
|
|
16
|
+
|
|
17
|
+
export function MaterialSymbol({
|
|
18
|
+
name,
|
|
19
|
+
weight,
|
|
20
|
+
size = 24,
|
|
21
|
+
color,
|
|
22
|
+
style,
|
|
23
|
+
...rest
|
|
24
|
+
}: MaterialSymbolProps): React.ReactElement {
|
|
25
|
+
return (
|
|
26
|
+
<MaterialSymbolViewNativeComponent
|
|
27
|
+
name={name}
|
|
28
|
+
weight={typeof weight === 'string' ? FONT_WEIGHTS[weight] : (weight ?? 0)}
|
|
29
|
+
size={size}
|
|
30
|
+
color={color}
|
|
31
|
+
style={[
|
|
32
|
+
{
|
|
33
|
+
width: size,
|
|
34
|
+
height: size,
|
|
35
|
+
},
|
|
36
|
+
style,
|
|
37
|
+
]}
|
|
38
|
+
{...rest}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
MaterialSymbol.getImageSource = ({
|
|
44
|
+
name,
|
|
45
|
+
variant,
|
|
46
|
+
weight,
|
|
47
|
+
size = 24,
|
|
48
|
+
color = 'black',
|
|
49
|
+
}: MaterialSymbolOptions): ImageSourcePropType => {
|
|
50
|
+
const processedColor = processColor(color);
|
|
51
|
+
|
|
52
|
+
if (processedColor == null) {
|
|
53
|
+
throw new Error(`Invalid color value: ${String(color)}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const scale = PixelRatio.get();
|
|
57
|
+
|
|
58
|
+
const cacheKey = `${name}:${variant}:${weight}:${size}:${scale}:${JSON.stringify(processedColor)}`;
|
|
59
|
+
const cached = imageSourceCache.get(cacheKey);
|
|
60
|
+
|
|
61
|
+
if (cached !== undefined) {
|
|
62
|
+
return cached;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const uri = NativeMaterialSymbolModule.getImageSource(
|
|
66
|
+
name,
|
|
67
|
+
variant,
|
|
68
|
+
typeof weight === 'string' ? FONT_WEIGHTS[weight] : weight,
|
|
69
|
+
size,
|
|
70
|
+
{ value: processedColor }
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const source: ImageSourcePropType = {
|
|
74
|
+
uri,
|
|
75
|
+
scale,
|
|
76
|
+
width: size,
|
|
77
|
+
height: size,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
imageSourceCache.set(cacheKey, source);
|
|
81
|
+
|
|
82
|
+
return source;
|
|
83
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ImageSourcePropType, type ViewProps } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import type { MaterialSymbolOptions } from './types';
|
|
4
|
+
|
|
5
|
+
export type MaterialSymbolProps = MaterialSymbolOptions & ViewProps;
|
|
6
|
+
|
|
7
|
+
export function MaterialSymbol(_: MaterialSymbolProps): React.ReactElement {
|
|
8
|
+
throw new Error('MaterialSymbol is only supported on Android.');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
MaterialSymbol.getImageSource = (
|
|
12
|
+
_: MaterialSymbolOptions
|
|
13
|
+
): ImageSourcePropType => {
|
|
14
|
+
throw new Error(
|
|
15
|
+
'MaterialSymbol.getImageSource is only supported on Android.'
|
|
16
|
+
);
|
|
17
|
+
};
|