@react-navigation/elements 2.9.5 → 3.0.0-alpha.1
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/lib/module/Badge.js +2 -2
- package/lib/module/Badge.js.map +1 -1
- package/lib/module/BlurEffectBackground.js +59 -0
- package/lib/module/BlurEffectBackground.js.map +1 -0
- package/lib/module/Button.js +7 -6
- package/lib/module/Button.js.map +1 -1
- package/lib/module/Color.js +11 -0
- package/lib/module/Color.js.map +1 -0
- package/lib/module/Container.js +42 -0
- package/lib/module/Container.js.map +1 -0
- package/lib/module/Header/Header.js +156 -97
- package/lib/module/Header/Header.js.map +1 -1
- package/lib/module/Header/HeaderBackButton.js +130 -121
- package/lib/module/Header/HeaderBackButton.js.map +1 -1
- package/lib/module/Header/HeaderBackground.js +10 -17
- package/lib/module/Header/HeaderBackground.js.map +1 -1
- package/lib/module/Header/HeaderButton.js +6 -2
- package/lib/module/Header/HeaderButton.js.map +1 -1
- package/lib/module/Header/HeaderButtonBackground.js +34 -0
- package/lib/module/Header/HeaderButtonBackground.js.map +1 -0
- package/lib/module/Header/HeaderSearchBar.js +174 -123
- package/lib/module/Header/HeaderSearchBar.js.map +1 -1
- package/lib/module/Header/HeaderTitle.js.map +1 -1
- package/lib/module/Header/getDefaultHeaderHeight.js +22 -10
- package/lib/module/Header/getDefaultHeaderHeight.js.map +1 -1
- package/lib/module/Label/Label.js.map +1 -1
- package/lib/module/LiquidGlassView.ios.js +21 -0
- package/lib/module/LiquidGlassView.ios.js.map +1 -0
- package/lib/module/LiquidGlassView.js +13 -0
- package/lib/module/LiquidGlassView.js.map +1 -0
- package/lib/module/MissingIcon.js +1 -0
- package/lib/module/MissingIcon.js.map +1 -1
- package/lib/module/PlatformColor.js +9 -0
- package/lib/module/PlatformColor.js.map +1 -0
- package/lib/module/PlatformColor.native.js +4 -0
- package/lib/module/PlatformColor.native.js.map +1 -0
- package/lib/module/PlatformPressable.js.map +1 -1
- package/lib/module/Screen.js +29 -23
- package/lib/module/Screen.js.map +1 -1
- package/lib/module/assets/back-icon.ios.svg +4 -0
- package/lib/module/assets/back-icon@1x.ios.png +0 -0
- package/lib/module/assets/back-icon@2x.ios.png +0 -0
- package/lib/module/assets/back-icon@3x.ios.png +0 -0
- package/lib/module/assets/back-icon@4x.ios.png +0 -0
- package/lib/module/assets/search-icon-legacy.png +0 -0
- package/lib/module/assets/search-icon-legacy@1x.ios.png +0 -0
- package/lib/module/assets/search-icon-legacy@2x.ios.png +0 -0
- package/lib/module/assets/search-icon-legacy@3x.ios.png +0 -0
- package/lib/module/assets/search-icon-legacy@4x.ios.png +0 -0
- package/lib/module/assets/search-icon.ios.svg +4 -0
- package/lib/module/assets/search-icon@1x.ios.png +0 -0
- package/lib/module/assets/search-icon@2x.ios.png +0 -0
- package/lib/module/assets/search-icon@3x.ios.png +0 -0
- package/lib/module/assets/search-icon@4x.ios.png +0 -0
- package/lib/module/getBlurBackgroundColor.js +48 -0
- package/lib/module/getBlurBackgroundColor.js.map +1 -0
- package/lib/module/index.js +2 -8
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +10 -0
- package/lib/module/internal.js.map +1 -0
- package/lib/module/useFrameSize.js +4 -4
- package/lib/module/useFrameSize.js.map +1 -1
- package/lib/typescript/src/Badge.d.ts.map +1 -1
- package/lib/typescript/src/BlurEffectBackground.d.ts +16 -0
- package/lib/typescript/src/BlurEffectBackground.d.ts.map +1 -0
- package/lib/typescript/src/Button.d.ts +5 -4
- package/lib/typescript/src/Button.d.ts.map +1 -1
- package/lib/typescript/src/Color.d.ts +13 -0
- package/lib/typescript/src/Color.d.ts.map +1 -0
- package/lib/typescript/src/Container.d.ts +8 -0
- package/lib/typescript/src/Container.d.ts.map +1 -0
- package/lib/typescript/src/Header/Header.d.ts +1 -5
- package/lib/typescript/src/Header/Header.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderBackButton.d.ts +1 -1
- package/lib/typescript/src/Header/HeaderBackButton.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderBackground.d.ts +5 -3
- package/lib/typescript/src/Header/HeaderBackground.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderButton.d.ts +2 -0
- package/lib/typescript/src/Header/HeaderButton.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderButtonBackground.d.ts +7 -0
- package/lib/typescript/src/Header/HeaderButtonBackground.d.ts.map +1 -0
- package/lib/typescript/src/Header/HeaderSearchBar.d.ts +5 -2
- package/lib/typescript/src/Header/HeaderSearchBar.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderTitle.d.ts +2 -2
- package/lib/typescript/src/Header/HeaderTitle.d.ts.map +1 -1
- package/lib/typescript/src/Header/getDefaultHeaderHeight.d.ts +5 -2
- package/lib/typescript/src/Header/getDefaultHeaderHeight.d.ts.map +1 -1
- package/lib/typescript/src/Label/Label.d.ts +2 -2
- package/lib/typescript/src/Label/Label.d.ts.map +1 -1
- package/lib/typescript/src/LiquidGlassView.d.ts +9 -0
- package/lib/typescript/src/LiquidGlassView.d.ts.map +1 -0
- package/lib/typescript/src/LiquidGlassView.ios.d.ts +5 -0
- package/lib/typescript/src/LiquidGlassView.ios.d.ts.map +1 -0
- package/lib/typescript/src/MissingIcon.d.ts +2 -2
- package/lib/typescript/src/MissingIcon.d.ts.map +1 -1
- package/lib/typescript/src/PlatformColor.d.ts +7 -0
- package/lib/typescript/src/PlatformColor.d.ts.map +1 -0
- package/lib/typescript/src/PlatformColor.native.d.ts +2 -0
- package/lib/typescript/src/PlatformColor.native.d.ts.map +1 -0
- package/lib/typescript/src/PlatformPressable.d.ts +3 -3
- package/lib/typescript/src/PlatformPressable.d.ts.map +1 -1
- package/lib/typescript/src/Screen.d.ts.map +1 -1
- package/lib/typescript/src/getBlurBackgroundColor.d.ts +7 -0
- package/lib/typescript/src/getBlurBackgroundColor.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +0 -6
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/internal.d.ts +8 -0
- package/lib/typescript/src/internal.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +47 -31
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +19 -17
- package/src/Badge.tsx +3 -2
- package/src/BlurEffectBackground.tsx +90 -0
- package/src/Button.tsx +33 -21
- package/src/Color.tsx +21 -0
- package/src/Container.tsx +44 -0
- package/src/Header/Header.tsx +230 -156
- package/src/Header/HeaderBackButton.tsx +194 -168
- package/src/Header/HeaderBackground.tsx +17 -19
- package/src/Header/HeaderButton.tsx +7 -2
- package/src/Header/HeaderButtonBackground.tsx +35 -0
- package/src/Header/HeaderSearchBar.tsx +227 -129
- package/src/Header/HeaderTitle.tsx +2 -1
- package/src/Header/getDefaultHeaderHeight.tsx +29 -18
- package/src/Label/Label.tsx +2 -1
- package/src/LiquidGlassView.ios.tsx +39 -0
- package/src/LiquidGlassView.tsx +20 -0
- package/src/MissingIcon.tsx +12 -3
- package/src/PlatformColor.native.tsx +1 -0
- package/src/PlatformColor.tsx +8 -0
- package/src/PlatformPressable.tsx +2 -1
- package/src/Screen.tsx +24 -25
- package/src/assets/back-icon.ios.svg +4 -0
- package/src/assets/back-icon@1x.ios.png +0 -0
- package/src/assets/back-icon@2x.ios.png +0 -0
- package/src/assets/back-icon@3x.ios.png +0 -0
- package/src/assets/back-icon@4x.ios.png +0 -0
- package/src/assets/search-icon-legacy.png +0 -0
- package/src/assets/search-icon-legacy@1x.ios.png +0 -0
- package/src/assets/search-icon-legacy@2x.ios.png +0 -0
- package/src/assets/search-icon-legacy@3x.ios.png +0 -0
- package/src/assets/search-icon-legacy@4x.ios.png +0 -0
- package/src/assets/search-icon.ios.svg +4 -0
- package/src/assets/search-icon@1x.ios.png +0 -0
- package/src/assets/search-icon@2x.ios.png +0 -0
- package/src/assets/search-icon@3x.ios.png +0 -0
- package/src/assets/search-icon@4x.ios.png +0 -0
- package/src/getBlurBackgroundColor.tsx +68 -0
- package/src/index.tsx +2 -8
- package/src/internal.tsx +7 -0
- package/src/types.tsx +50 -32
- package/src/useFrameSize.tsx +4 -4
- package/lib/module/Background.js +0 -22
- package/lib/module/Background.js.map +0 -1
- package/lib/module/MaskedView.android.js +0 -4
- package/lib/module/MaskedView.android.js.map +0 -1
- package/lib/module/MaskedView.ios.js +0 -4
- package/lib/module/MaskedView.ios.js.map +0 -1
- package/lib/module/MaskedView.js +0 -12
- package/lib/module/MaskedView.js.map +0 -1
- package/lib/module/MaskedViewNative.js +0 -30
- package/lib/module/MaskedViewNative.js.map +0 -1
- package/lib/module/ResourceSavingView.js +0 -57
- package/lib/module/ResourceSavingView.js.map +0 -1
- package/lib/module/assets/back-icon-mask.png +0 -0
- package/lib/typescript/src/Background.d.ts +0 -9
- package/lib/typescript/src/Background.d.ts.map +0 -1
- package/lib/typescript/src/MaskedView.android.d.ts +0 -2
- package/lib/typescript/src/MaskedView.android.d.ts.map +0 -1
- package/lib/typescript/src/MaskedView.d.ts +0 -11
- package/lib/typescript/src/MaskedView.d.ts.map +0 -1
- package/lib/typescript/src/MaskedView.ios.d.ts +0 -2
- package/lib/typescript/src/MaskedView.ios.d.ts.map +0 -1
- package/lib/typescript/src/MaskedViewNative.d.ts +0 -11
- package/lib/typescript/src/MaskedViewNative.d.ts.map +0 -1
- package/lib/typescript/src/ResourceSavingView.d.ts +0 -10
- package/lib/typescript/src/ResourceSavingView.d.ts.map +0 -1
- package/src/Background.tsx +0 -24
- package/src/MaskedView.android.tsx +0 -1
- package/src/MaskedView.ios.tsx +0 -1
- package/src/MaskedView.tsx +0 -13
- package/src/MaskedViewNative.tsx +0 -33
- package/src/ResourceSavingView.tsx +0 -76
- package/src/assets/back-icon-mask.png +0 -0
package/src/Button.tsx
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type LinkProps,
|
|
3
|
+
type RootParamList,
|
|
3
4
|
useLinkProps,
|
|
4
5
|
useTheme,
|
|
5
6
|
} from '@react-navigation/native';
|
|
6
|
-
import Color from 'color';
|
|
7
7
|
import * as React from 'react';
|
|
8
|
-
import { Platform, StyleSheet } from 'react-native';
|
|
8
|
+
import { type ColorValue, Platform, StyleSheet } from 'react-native';
|
|
9
9
|
|
|
10
|
+
import { Color } from './Color';
|
|
10
11
|
import {
|
|
11
12
|
PlatformPressable,
|
|
12
13
|
type Props as PlatformPressableProps,
|
|
@@ -15,24 +16,28 @@ import { Text } from './Text';
|
|
|
15
16
|
|
|
16
17
|
type ButtonBaseProps = Omit<PlatformPressableProps, 'children'> & {
|
|
17
18
|
variant?: 'plain' | 'tinted' | 'filled';
|
|
18
|
-
color?:
|
|
19
|
+
color?: ColorValue;
|
|
19
20
|
children: string | string[];
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
type ButtonLinkProps<
|
|
23
|
-
|
|
23
|
+
type ButtonLinkProps<
|
|
24
|
+
ParamList extends {} = RootParamList,
|
|
25
|
+
RouteName extends keyof ParamList = keyof ParamList,
|
|
26
|
+
> = LinkProps<ParamList, RouteName> & Omit<ButtonBaseProps, 'onPress'>;
|
|
24
27
|
|
|
25
28
|
const BUTTON_RADIUS = 40;
|
|
26
29
|
|
|
27
|
-
export function Button<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
export function Button<
|
|
31
|
+
ParamList extends {} = RootParamList,
|
|
32
|
+
RouteName extends keyof ParamList = keyof ParamList,
|
|
33
|
+
>(props: ButtonLinkProps<ParamList, RouteName>): React.JSX.Element;
|
|
30
34
|
|
|
31
35
|
export function Button(props: ButtonBaseProps): React.JSX.Element;
|
|
32
36
|
|
|
33
|
-
export function Button<
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
export function Button<
|
|
38
|
+
ParamList extends {} = RootParamList,
|
|
39
|
+
RouteName extends keyof ParamList = keyof ParamList,
|
|
40
|
+
>(props: ButtonBaseProps | ButtonLinkProps<ParamList, RouteName>) {
|
|
36
41
|
if ('screen' in props || 'action' in props) {
|
|
37
42
|
// @ts-expect-error: This is already type-checked by the prop types
|
|
38
43
|
return <ButtonLink {...props} />;
|
|
@@ -41,13 +46,16 @@ export function Button<ParamList extends ReactNavigation.RootParamList>(
|
|
|
41
46
|
}
|
|
42
47
|
}
|
|
43
48
|
|
|
44
|
-
function ButtonLink<
|
|
49
|
+
function ButtonLink<
|
|
50
|
+
const ParamList extends {} = RootParamList,
|
|
51
|
+
const RouteName extends keyof ParamList = keyof ParamList,
|
|
52
|
+
>({
|
|
45
53
|
screen,
|
|
46
54
|
params,
|
|
47
55
|
action,
|
|
48
56
|
href,
|
|
49
57
|
...rest
|
|
50
|
-
}: ButtonLinkProps<ParamList>) {
|
|
58
|
+
}: ButtonLinkProps<ParamList, RouteName>) {
|
|
51
59
|
// @ts-expect-error: This is already type-checked by the prop types
|
|
52
60
|
const props = useLinkProps({ screen, params, action, href });
|
|
53
61
|
|
|
@@ -62,12 +70,12 @@ function ButtonBase({
|
|
|
62
70
|
children,
|
|
63
71
|
...rest
|
|
64
72
|
}: ButtonBaseProps) {
|
|
65
|
-
const { colors, fonts } = useTheme();
|
|
73
|
+
const { dark, colors, fonts } = useTheme();
|
|
66
74
|
|
|
67
75
|
const color = customColor ?? colors.primary;
|
|
68
76
|
|
|
69
|
-
let backgroundColor;
|
|
70
|
-
let textColor;
|
|
77
|
+
let backgroundColor: ColorValue;
|
|
78
|
+
let textColor: ColorValue;
|
|
71
79
|
|
|
72
80
|
switch (variant) {
|
|
73
81
|
case 'plain':
|
|
@@ -75,14 +83,16 @@ function ButtonBase({
|
|
|
75
83
|
textColor = color;
|
|
76
84
|
break;
|
|
77
85
|
case 'tinted':
|
|
78
|
-
backgroundColor =
|
|
86
|
+
backgroundColor =
|
|
87
|
+
Color(color)?.fade(0.85).string() ??
|
|
88
|
+
(dark ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.06)');
|
|
79
89
|
textColor = color;
|
|
80
90
|
break;
|
|
81
91
|
case 'filled':
|
|
82
92
|
backgroundColor = color;
|
|
83
|
-
textColor = Color(color)
|
|
93
|
+
textColor = Color(color)?.isDark()
|
|
84
94
|
? 'white'
|
|
85
|
-
: Color(color)
|
|
95
|
+
: (Color(color)?.darken(0.71).string() ?? '#fff');
|
|
86
96
|
break;
|
|
87
97
|
}
|
|
88
98
|
|
|
@@ -91,11 +101,13 @@ function ButtonBase({
|
|
|
91
101
|
{...rest}
|
|
92
102
|
android_ripple={{
|
|
93
103
|
radius: BUTTON_RADIUS,
|
|
94
|
-
color: Color(textColor)
|
|
104
|
+
color: Color(textColor)?.fade(0.85).string() ?? 'rgba(0, 0, 0, 0.1)',
|
|
95
105
|
...android_ripple,
|
|
96
106
|
}}
|
|
97
107
|
pressOpacity={Platform.OS === 'ios' ? undefined : 1}
|
|
98
|
-
hoverEffect={
|
|
108
|
+
hoverEffect={
|
|
109
|
+
typeof textColor === 'string' ? { color: textColor } : undefined
|
|
110
|
+
}
|
|
99
111
|
style={[{ backgroundColor }, styles.button, style]}
|
|
100
112
|
>
|
|
101
113
|
<Text style={[{ color: textColor }, fonts.regular, styles.text]}>
|
package/src/Color.tsx
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// eslint-disable-next-line no-restricted-imports
|
|
2
|
+
import OriginalColor from 'color';
|
|
3
|
+
import type { ColorValue } from 'react-native';
|
|
4
|
+
|
|
5
|
+
type ColorType = {
|
|
6
|
+
isLight(): boolean;
|
|
7
|
+
isDark(): boolean;
|
|
8
|
+
alpha(amount: number): ColorType;
|
|
9
|
+
alpha(): number;
|
|
10
|
+
fade(amount: number): ColorType;
|
|
11
|
+
darken(amount: number): ColorType;
|
|
12
|
+
string(): string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function Color(value: ColorValue): ColorType | undefined {
|
|
16
|
+
if (typeof value === 'string' && !value.startsWith('var(')) {
|
|
17
|
+
return OriginalColor(value);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Platform, View, type ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export type Props = {
|
|
4
|
+
inert?: boolean;
|
|
5
|
+
style?: React.CSSProperties & ViewStyle;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function Container({ inert, children, style }: Props) {
|
|
10
|
+
if (Platform.OS === 'web') {
|
|
11
|
+
return (
|
|
12
|
+
<div
|
|
13
|
+
inert={inert}
|
|
14
|
+
aria-hidden={inert}
|
|
15
|
+
style={{ ...DEFAULT_STYLE, ...style }}
|
|
16
|
+
>
|
|
17
|
+
{children}
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<View
|
|
24
|
+
aria-hidden={inert}
|
|
25
|
+
style={[{ pointerEvents: inert ? 'none' : 'box-none' }, style]}
|
|
26
|
+
collapsable={false}
|
|
27
|
+
>
|
|
28
|
+
{children}
|
|
29
|
+
</View>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const DEFAULT_STYLE = {
|
|
34
|
+
display: 'flex',
|
|
35
|
+
alignContent: 'flex-start',
|
|
36
|
+
alignItems: 'stretch',
|
|
37
|
+
boxSizing: 'border-box',
|
|
38
|
+
flexBasis: 'auto',
|
|
39
|
+
flexDirection: 'column',
|
|
40
|
+
flexShrink: 0,
|
|
41
|
+
minHeight: 0,
|
|
42
|
+
minWidth: 0,
|
|
43
|
+
position: 'relative',
|
|
44
|
+
} as const satisfies React.CSSProperties;
|