@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.
- package/lib/module/ActivityView.js +90 -0
- package/lib/module/ActivityView.js.map +1 -0
- package/lib/module/ActivityView.native.js +67 -0
- package/lib/module/ActivityView.native.js.map +1 -0
- package/lib/module/Badge.js +5 -4
- package/lib/module/Badge.js.map +1 -1
- package/lib/module/BlurEffectBackground.js +3 -3
- package/lib/module/BlurEffectBackground.js.map +1 -1
- package/lib/module/Button.js +96 -14
- package/lib/module/Button.js.map +1 -1
- package/lib/module/Color.js +565 -4
- package/lib/module/Color.js.map +1 -1
- package/lib/module/Container.js +11 -1
- package/lib/module/Container.js.map +1 -1
- package/lib/module/Header/Header.js +29 -17
- package/lib/module/Header/Header.js.map +1 -1
- package/lib/module/Header/HeaderBackButton.js +27 -13
- package/lib/module/Header/HeaderBackButton.js.map +1 -1
- package/lib/module/Header/HeaderButton.js +4 -5
- package/lib/module/Header/HeaderButton.js.map +1 -1
- package/lib/module/Header/HeaderButtonBackground.js +1 -2
- package/lib/module/Header/HeaderButtonBackground.js.map +1 -1
- package/lib/module/Header/HeaderIcon.js +14 -17
- package/lib/module/Header/HeaderIcon.js.map +1 -1
- package/lib/module/Header/HeaderSearchBar.js +35 -25
- package/lib/module/Header/HeaderSearchBar.js.map +1 -1
- package/lib/module/Header/getHeaderTitle.js.map +1 -1
- package/lib/module/Header/useHeaderHeight.js +1 -1
- package/lib/module/Header/useHeaderHeight.js.map +1 -1
- package/lib/module/Label/getLabel.js.map +1 -1
- package/lib/module/LiquidGlassView.ios.js +1 -2
- package/lib/module/LiquidGlassView.ios.js.map +1 -1
- package/lib/module/LiquidGlassView.js +0 -4
- package/lib/module/LiquidGlassView.js.map +1 -1
- package/lib/module/PlatformColor.js +1 -0
- package/lib/module/PlatformColor.js.map +1 -1
- package/lib/module/PlatformColor.native.js +1 -1
- package/lib/module/PlatformColor.native.js.map +1 -1
- package/lib/module/PlatformIcon.js +46 -0
- package/lib/module/PlatformIcon.js.map +1 -0
- package/lib/module/PlatformPressable.js +56 -14
- package/lib/module/PlatformPressable.js.map +1 -1
- package/lib/module/SafeAreaProviderCompat.js +1 -1
- package/lib/module/SafeAreaProviderCompat.js.map +1 -1
- package/lib/module/Screen.js +31 -18
- package/lib/module/Screen.js.map +1 -1
- package/lib/module/index.js +2 -7
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +1 -1
- package/lib/module/internal.js.map +1 -1
- package/lib/module/useFrameSize.js +6 -2
- package/lib/module/useFrameSize.js.map +1 -1
- package/lib/typescript/src/ActivityView.d.ts +31 -0
- package/lib/typescript/src/ActivityView.d.ts.map +1 -0
- package/lib/typescript/src/ActivityView.native.d.ts +3 -0
- package/lib/typescript/src/ActivityView.native.d.ts.map +1 -0
- package/lib/typescript/src/Badge.d.ts +6 -5
- package/lib/typescript/src/Badge.d.ts.map +1 -1
- package/lib/typescript/src/BlurEffectBackground.d.ts +2 -2
- package/lib/typescript/src/BlurEffectBackground.d.ts.map +1 -1
- package/lib/typescript/src/Button.d.ts +54 -6
- package/lib/typescript/src/Button.d.ts.map +1 -1
- package/lib/typescript/src/Color.d.ts +4 -4
- package/lib/typescript/src/Color.d.ts.map +1 -1
- package/lib/typescript/src/Container.d.ts +7 -4
- package/lib/typescript/src/Container.d.ts.map +1 -1
- package/lib/typescript/src/Header/Header.d.ts +5 -4
- package/lib/typescript/src/Header/Header.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderBackButton.d.ts +3 -2
- package/lib/typescript/src/Header/HeaderBackButton.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderBackground.d.ts +5 -5
- package/lib/typescript/src/Header/HeaderBackground.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderButton.d.ts +7 -2
- package/lib/typescript/src/Header/HeaderButton.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderButtonBackground.d.ts +1 -1
- package/lib/typescript/src/Header/HeaderButtonBackground.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderIcon.d.ts +9 -4
- package/lib/typescript/src/Header/HeaderIcon.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderSearchBar.d.ts +10 -7
- package/lib/typescript/src/Header/HeaderSearchBar.d.ts.map +1 -1
- package/lib/typescript/src/Header/HeaderTitle.d.ts +4 -4
- package/lib/typescript/src/Header/HeaderTitle.d.ts.map +1 -1
- package/lib/typescript/src/Header/getHeaderTitle.d.ts +2 -2
- package/lib/typescript/src/Header/getHeaderTitle.d.ts.map +1 -1
- package/lib/typescript/src/Label/Label.d.ts +1 -1
- package/lib/typescript/src/Label/Label.d.ts.map +1 -1
- package/lib/typescript/src/Label/getLabel.d.ts +2 -2
- package/lib/typescript/src/Label/getLabel.d.ts.map +1 -1
- package/lib/typescript/src/LiquidGlassView.d.ts +7 -5
- package/lib/typescript/src/LiquidGlassView.d.ts.map +1 -1
- package/lib/typescript/src/LiquidGlassView.ios.d.ts +4 -2
- package/lib/typescript/src/LiquidGlassView.ios.d.ts.map +1 -1
- package/lib/typescript/src/MissingIcon.d.ts +1 -1
- package/lib/typescript/src/MissingIcon.d.ts.map +1 -1
- package/lib/typescript/src/PlatformColor.d.ts +1 -0
- package/lib/typescript/src/PlatformColor.d.ts.map +1 -1
- package/lib/typescript/src/PlatformColor.native.d.ts +1 -1
- package/lib/typescript/src/PlatformColor.native.d.ts.map +1 -1
- package/lib/typescript/src/PlatformIcon.d.ts +10 -0
- package/lib/typescript/src/PlatformIcon.d.ts.map +1 -0
- package/lib/typescript/src/PlatformPressable.d.ts +12 -15
- package/lib/typescript/src/PlatformPressable.d.ts.map +1 -1
- package/lib/typescript/src/SafeAreaProviderCompat.d.ts +1 -1
- package/lib/typescript/src/SafeAreaProviderCompat.d.ts.map +1 -1
- package/lib/typescript/src/Screen.d.ts +7 -7
- package/lib/typescript/src/Screen.d.ts.map +1 -1
- package/lib/typescript/src/Text.d.ts +1 -1
- package/lib/typescript/src/Text.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +21 -21
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/internal.d.ts +6 -6
- package/lib/typescript/src/internal.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +120 -70
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/useFrameSize.d.ts +1 -1
- package/lib/typescript/src/useFrameSize.d.ts.map +1 -1
- package/package.json +23 -22
- package/src/ActivityView.native.tsx +90 -0
- package/src/ActivityView.tsx +129 -0
- package/src/Badge.tsx +10 -8
- package/src/BlurEffectBackground.tsx +3 -3
- package/src/Button.tsx +173 -28
- package/src/Color.tsx +755 -8
- package/src/Container.tsx +20 -4
- package/src/Header/Header.tsx +46 -26
- package/src/Header/HeaderBackButton.tsx +31 -17
- package/src/Header/HeaderBackground.tsx +3 -3
- package/src/Header/HeaderButton.tsx +16 -18
- package/src/Header/HeaderButtonBackground.tsx +1 -4
- package/src/Header/HeaderIcon.tsx +27 -13
- package/src/Header/HeaderSearchBar.tsx +52 -44
- package/src/Header/HeaderTitle.tsx +3 -3
- package/src/Header/getHeaderTitle.tsx +4 -1
- package/src/Header/useHeaderHeight.tsx +1 -1
- package/src/Label/getLabel.tsx +1 -1
- package/src/LiquidGlassView.ios.tsx +14 -9
- package/src/LiquidGlassView.tsx +15 -11
- package/src/PlatformColor.native.tsx +1 -1
- package/src/PlatformColor.tsx +4 -0
- package/src/PlatformIcon.tsx +66 -0
- package/src/PlatformPressable.tsx +99 -41
- package/src/SafeAreaProviderCompat.tsx +1 -1
- package/src/Screen.tsx +40 -27
- package/src/index.tsx +2 -16
- package/src/internal.tsx +1 -1
- package/src/types.tsx +153 -76
- package/src/useFrameSize.tsx +9 -2
- package/lib/module/Lazy.js +0 -42
- package/lib/module/Lazy.js.map +0 -1
- package/lib/module/assets/back-icon.ios.svg +0 -4
- package/lib/module/assets/back-icon@1x.android.png +0 -0
- package/lib/module/assets/back-icon@1x.ios.png +0 -0
- package/lib/module/assets/back-icon@2x.android.png +0 -0
- package/lib/module/assets/back-icon@2x.ios.png +0 -0
- package/lib/module/assets/back-icon@3x.android.png +0 -0
- package/lib/module/assets/back-icon@3x.ios.png +0 -0
- package/lib/module/assets/back-icon@4x.android.png +0 -0
- package/lib/module/assets/back-icon@4x.ios.png +0 -0
- package/lib/module/assets/clear-icon@1x.png +0 -0
- package/lib/module/assets/clear-icon@2x.png +0 -0
- package/lib/module/assets/clear-icon@3x.png +0 -0
- package/lib/module/assets/clear-icon@4x.png +0 -0
- package/lib/module/assets/close-icon@1x.png +0 -0
- package/lib/module/assets/close-icon@2x.png +0 -0
- package/lib/module/assets/close-icon@3x.png +0 -0
- package/lib/module/assets/close-icon@4x.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 +0 -4
- package/lib/module/assets/search-icon@1x.android.png +0 -0
- package/lib/module/assets/search-icon@1x.ios.png +0 -0
- package/lib/module/assets/search-icon@2x.android.png +0 -0
- package/lib/module/assets/search-icon@2x.ios.png +0 -0
- package/lib/module/assets/search-icon@3x.android.png +0 -0
- package/lib/module/assets/search-icon@3x.ios.png +0 -0
- package/lib/module/assets/search-icon@4x.android.png +0 -0
- package/lib/module/assets/search-icon@4x.ios.png +0 -0
- package/lib/typescript/src/Lazy.d.ts +0 -31
- package/lib/typescript/src/Lazy.d.ts.map +0 -1
- package/src/Lazy.tsx +0 -59
- package/src/assets/back-icon.ios.svg +0 -4
- package/src/assets/back-icon@1x.android.png +0 -0
- package/src/assets/back-icon@1x.ios.png +0 -0
- package/src/assets/back-icon@2x.android.png +0 -0
- package/src/assets/back-icon@2x.ios.png +0 -0
- package/src/assets/back-icon@3x.android.png +0 -0
- package/src/assets/back-icon@3x.ios.png +0 -0
- package/src/assets/back-icon@4x.android.png +0 -0
- package/src/assets/back-icon@4x.ios.png +0 -0
- package/src/assets/clear-icon@1x.png +0 -0
- package/src/assets/clear-icon@2x.png +0 -0
- package/src/assets/clear-icon@3x.png +0 -0
- package/src/assets/clear-icon@4x.png +0 -0
- package/src/assets/close-icon@1x.png +0 -0
- package/src/assets/close-icon@2x.png +0 -0
- package/src/assets/close-icon@3x.png +0 -0
- package/src/assets/close-icon@4x.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 +0 -4
- package/src/assets/search-icon@1x.android.png +0 -0
- package/src/assets/search-icon@1x.ios.png +0 -0
- package/src/assets/search-icon@2x.android.png +0 -0
- package/src/assets/search-icon@2x.ios.png +0 -0
- package/src/assets/search-icon@3x.android.png +0 -0
- package/src/assets/search-icon@3x.ios.png +0 -0
- package/src/assets/search-icon@4x.android.png +0 -0
- package/src/assets/search-icon@4x.ios.png +0 -0
package/src/Container.tsx
CHANGED
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
import { Platform, View, type ViewStyle } from 'react-native';
|
|
2
2
|
|
|
3
3
|
export type Props = {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
ref?: React.Ref<HTMLDivElement | View> | undefined;
|
|
5
|
+
inert?: boolean | undefined;
|
|
6
|
+
style?:
|
|
7
|
+
| (ViewStyle &
|
|
8
|
+
Omit<React.CSSProperties, 'backgroundColor'> & {
|
|
9
|
+
backgroundColor?: ViewStyle['backgroundColor'] | undefined;
|
|
10
|
+
})
|
|
11
|
+
| undefined;
|
|
6
12
|
children: React.ReactNode;
|
|
7
13
|
};
|
|
8
14
|
|
|
9
|
-
export function Container({ inert, children, style }: Props) {
|
|
15
|
+
export function Container({ ref, inert, children, style }: Props) {
|
|
10
16
|
if (Platform.OS === 'web') {
|
|
17
|
+
const { backgroundColor, ...rest } = style ?? {};
|
|
18
|
+
|
|
11
19
|
return (
|
|
12
20
|
<div
|
|
21
|
+
ref={ref as React.Ref<HTMLDivElement> | undefined}
|
|
13
22
|
inert={inert}
|
|
14
23
|
aria-hidden={inert}
|
|
15
|
-
style={{
|
|
24
|
+
style={{
|
|
25
|
+
...DEFAULT_STYLE,
|
|
26
|
+
...rest,
|
|
27
|
+
backgroundColor:
|
|
28
|
+
// In practice we only get string on web instead of OpaqueValue
|
|
29
|
+
typeof backgroundColor === 'string' ? backgroundColor : undefined,
|
|
30
|
+
}}
|
|
16
31
|
>
|
|
17
32
|
{children}
|
|
18
33
|
</div>
|
|
@@ -21,6 +36,7 @@ export function Container({ inert, children, style }: Props) {
|
|
|
21
36
|
|
|
22
37
|
return (
|
|
23
38
|
<View
|
|
39
|
+
ref={ref as React.Ref<View> | undefined}
|
|
24
40
|
aria-hidden={inert}
|
|
25
41
|
style={[{ pointerEvents: inert ? 'none' : 'box-none' }, style]}
|
|
26
42
|
collapsable={false}
|
package/src/Header/Header.tsx
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
UNSTABLE_CornerInset,
|
|
3
|
+
useNavigation,
|
|
4
|
+
useTheme,
|
|
5
|
+
} from '@react-navigation/native';
|
|
2
6
|
import * as React from 'react';
|
|
3
7
|
import {
|
|
4
8
|
Animated,
|
|
@@ -30,20 +34,22 @@ type Props = HeaderOptions & {
|
|
|
30
34
|
/**
|
|
31
35
|
* Options for the back button.
|
|
32
36
|
*/
|
|
33
|
-
back?:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
back?:
|
|
38
|
+
| {
|
|
39
|
+
/**
|
|
40
|
+
* Title of the previous screen.
|
|
41
|
+
*/
|
|
42
|
+
title: string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* The `href` to use for the anchor tag on web
|
|
45
|
+
*/
|
|
46
|
+
href: string | undefined;
|
|
47
|
+
}
|
|
48
|
+
| undefined;
|
|
43
49
|
/**
|
|
44
50
|
* Whether the header is in a modal
|
|
45
51
|
*/
|
|
46
|
-
modal?: boolean;
|
|
52
|
+
modal?: boolean | undefined;
|
|
47
53
|
/**
|
|
48
54
|
* Title text for the header.
|
|
49
55
|
*/
|
|
@@ -79,7 +85,7 @@ export function Header(props: Props) {
|
|
|
79
85
|
const { colors } = useTheme();
|
|
80
86
|
|
|
81
87
|
const navigation = useNavigation();
|
|
82
|
-
const isParentHeaderShown = React.
|
|
88
|
+
const isParentHeaderShown = React.use(HeaderShownContext);
|
|
83
89
|
|
|
84
90
|
const [searchBarVisible, setSearchBarVisible] = React.useState(false);
|
|
85
91
|
|
|
@@ -231,12 +237,9 @@ export function Header(props: Props) {
|
|
|
231
237
|
// Setting a property to undefined triggers default style
|
|
232
238
|
// So we need to filter them out
|
|
233
239
|
// Users can use `null` instead
|
|
234
|
-
for (const styleProp
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
// @ts-expect-error don't need to care about index signature for deletion
|
|
238
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
239
|
-
delete safeStyles[styleProp];
|
|
240
|
+
for (const [styleProp, value] of Object.entries(safeStyles)) {
|
|
241
|
+
if (value === undefined) {
|
|
242
|
+
Reflect.deleteProperty(safeStyles, styleProp);
|
|
240
243
|
}
|
|
241
244
|
}
|
|
242
245
|
|
|
@@ -321,21 +324,21 @@ export function Header(props: Props) {
|
|
|
321
324
|
return;
|
|
322
325
|
}
|
|
323
326
|
|
|
324
|
-
Animated.timing(searchBarVisibleAnim, {
|
|
327
|
+
const animation = Animated.timing(searchBarVisibleAnim, {
|
|
325
328
|
toValue: searchBarVisible ? 1 : 0,
|
|
326
329
|
duration: 150,
|
|
327
330
|
useNativeDriver,
|
|
328
331
|
easing: Easing.in(Easing.linear),
|
|
329
|
-
})
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
animation.start(({ finished }) => {
|
|
330
335
|
if (finished) {
|
|
331
336
|
setSearchBarRendered(searchBarVisible);
|
|
332
337
|
searchBarVisibleRef.current = searchBarVisible;
|
|
333
338
|
}
|
|
334
339
|
});
|
|
335
340
|
|
|
336
|
-
return () =>
|
|
337
|
-
searchBarVisibleAnim.stopAnimation();
|
|
338
|
-
};
|
|
341
|
+
return () => animation.stop();
|
|
339
342
|
}, [searchBarVisible, searchBarVisibleAnim]);
|
|
340
343
|
|
|
341
344
|
const headerOpacity = searchBarVisibleAnim.interpolate({
|
|
@@ -402,6 +405,7 @@ export function Header(props: Props) {
|
|
|
402
405
|
},
|
|
403
406
|
]}
|
|
404
407
|
>
|
|
408
|
+
<UNSTABLE_CornerInset direction="horizontal" edge="left" />
|
|
405
409
|
<View
|
|
406
410
|
style={[
|
|
407
411
|
styles.start,
|
|
@@ -458,7 +462,23 @@ export function Header(props: Props) {
|
|
|
458
462
|
headerSearchBarOptions?.onOpen?.();
|
|
459
463
|
}}
|
|
460
464
|
>
|
|
461
|
-
<HeaderIcon
|
|
465
|
+
<HeaderIcon
|
|
466
|
+
icon={Platform.select({
|
|
467
|
+
android: {
|
|
468
|
+
type: 'materialSymbol',
|
|
469
|
+
name: 'search',
|
|
470
|
+
},
|
|
471
|
+
ios: {
|
|
472
|
+
type: 'sfSymbol',
|
|
473
|
+
name: 'magnifyingglass',
|
|
474
|
+
},
|
|
475
|
+
default: {
|
|
476
|
+
type: 'image',
|
|
477
|
+
source: searchIcon,
|
|
478
|
+
},
|
|
479
|
+
})}
|
|
480
|
+
color={iconTintColor}
|
|
481
|
+
/>
|
|
462
482
|
</HeaderButton>
|
|
463
483
|
) : null}
|
|
464
484
|
</HeaderButtonBackground>
|
|
@@ -540,7 +560,7 @@ const styles = StyleSheet.create({
|
|
|
540
560
|
maxWidth: '50%',
|
|
541
561
|
},
|
|
542
562
|
background: {
|
|
543
|
-
...StyleSheet.
|
|
563
|
+
...StyleSheet.absoluteFill,
|
|
544
564
|
pointerEvents: 'box-none',
|
|
545
565
|
},
|
|
546
566
|
});
|
|
@@ -12,11 +12,12 @@ import {
|
|
|
12
12
|
View,
|
|
13
13
|
} from 'react-native';
|
|
14
14
|
|
|
15
|
-
import
|
|
15
|
+
import backIconImage from '../assets/back-icon.png';
|
|
16
16
|
import { isLiquidGlassSupported } from '../LiquidGlassView';
|
|
17
17
|
import type {
|
|
18
18
|
HeaderBackButtonDisplayMode,
|
|
19
19
|
HeaderBackButtonProps,
|
|
20
|
+
Icon,
|
|
20
21
|
} from '../types';
|
|
21
22
|
import { BUTTON_SIZE, HeaderButton } from './HeaderButton';
|
|
22
23
|
import { HeaderIcon } from './HeaderIcon';
|
|
@@ -24,7 +25,7 @@ import { HeaderIcon } from './HeaderIcon';
|
|
|
24
25
|
export function HeaderBackButton({
|
|
25
26
|
disabled,
|
|
26
27
|
allowFontScaling,
|
|
27
|
-
|
|
28
|
+
icon,
|
|
28
29
|
label,
|
|
29
30
|
labelStyle,
|
|
30
31
|
displayMode = 'minimal',
|
|
@@ -48,17 +49,30 @@ export function HeaderBackButton({
|
|
|
48
49
|
const isMinimal = displayMode === 'minimal' || measuredMinimal;
|
|
49
50
|
|
|
50
51
|
const renderBackImage = () => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<HeaderIcon
|
|
56
|
-
source={backIcon}
|
|
57
|
-
tintColor={tintColor ?? colors.text}
|
|
58
|
-
style={styles.icon}
|
|
59
|
-
/>
|
|
60
|
-
);
|
|
52
|
+
const color = tintColor ?? colors.text;
|
|
53
|
+
|
|
54
|
+
if (typeof icon === 'function') {
|
|
55
|
+
return icon({ tintColor: color });
|
|
61
56
|
}
|
|
57
|
+
|
|
58
|
+
const backIcon =
|
|
59
|
+
icon ??
|
|
60
|
+
Platform.select<Icon>({
|
|
61
|
+
ios: {
|
|
62
|
+
type: 'sfSymbol',
|
|
63
|
+
name: 'chevron.left',
|
|
64
|
+
},
|
|
65
|
+
android: {
|
|
66
|
+
type: 'materialSymbol',
|
|
67
|
+
name: 'arrow_back',
|
|
68
|
+
},
|
|
69
|
+
default: {
|
|
70
|
+
type: 'image',
|
|
71
|
+
source: backIconImage,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
return <HeaderIcon icon={backIcon} color={color} style={styles.icon} />;
|
|
62
76
|
};
|
|
63
77
|
|
|
64
78
|
const handlePress = () => {
|
|
@@ -105,11 +119,11 @@ function HeaderBackLabel({
|
|
|
105
119
|
truncatedLabel,
|
|
106
120
|
onMeasureMinimal,
|
|
107
121
|
}: {
|
|
108
|
-
allowFontScaling?: boolean;
|
|
122
|
+
allowFontScaling?: boolean | undefined;
|
|
109
123
|
displayMode: HeaderBackButtonDisplayMode;
|
|
110
124
|
label: string | undefined;
|
|
111
|
-
labelStyle?: Animated.WithAnimatedValue<StyleProp<TextStyle
|
|
112
|
-
tintColor?: ColorValue;
|
|
125
|
+
labelStyle?: Animated.WithAnimatedValue<StyleProp<TextStyle>> | undefined;
|
|
126
|
+
tintColor?: ColorValue | undefined;
|
|
113
127
|
truncatedLabel: string | undefined;
|
|
114
128
|
onMeasureMinimal: () => void;
|
|
115
129
|
}) {
|
|
@@ -231,8 +245,8 @@ function HeaderBackLabel({
|
|
|
231
245
|
// iOS uses a smaller chevron, Android uses a larger arrow
|
|
232
246
|
const ICON_WIDTH = Platform.OS === 'ios' ? 13 : 24;
|
|
233
247
|
const ICON_SPACING_START = isLiquidGlassSupported
|
|
234
|
-
?
|
|
235
|
-
:
|
|
248
|
+
? 15 // Standard distance of chevron from left edge in liquid glass
|
|
249
|
+
: 2; // Otherwise icon is aligned to the start of the button
|
|
236
250
|
|
|
237
251
|
// Standard distance between chevron and label
|
|
238
252
|
const ICON_LABEL_SPACING = 9;
|
|
@@ -12,9 +12,9 @@ import { BlurEffectBackground } from '../BlurEffectBackground';
|
|
|
12
12
|
import { type BlurEffectType } from '../getBlurBackgroundColor';
|
|
13
13
|
|
|
14
14
|
type Props = Omit<ViewProps, 'style'> & {
|
|
15
|
-
blurEffect?: BlurEffectType | 'none';
|
|
16
|
-
style?: StyleProp<ViewStyle
|
|
17
|
-
children?: React.ReactNode;
|
|
15
|
+
blurEffect?: BlurEffectType | 'none' | undefined;
|
|
16
|
+
style?: StyleProp<ViewStyle> | undefined;
|
|
17
|
+
children?: React.ReactNode | undefined;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export function HeaderBackground({
|
|
@@ -4,20 +4,22 @@ import { Platform, StyleSheet } from 'react-native';
|
|
|
4
4
|
import { PlatformPressable } from '../PlatformPressable';
|
|
5
5
|
import type { HeaderButtonProps } from '../types';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
type Props = HeaderButtonProps & {
|
|
8
|
+
ref?: React.Ref<React.ComponentRef<typeof PlatformPressable>> | undefined;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function HeaderButton({
|
|
12
|
+
disabled,
|
|
13
|
+
onPress,
|
|
14
|
+
pressColor,
|
|
15
|
+
pressOpacity,
|
|
16
|
+
accessibilityLabel,
|
|
17
|
+
testID,
|
|
18
|
+
style,
|
|
19
|
+
href,
|
|
20
|
+
children,
|
|
21
|
+
ref,
|
|
22
|
+
}: Props) {
|
|
21
23
|
return (
|
|
22
24
|
<PlatformPressable
|
|
23
25
|
ref={ref}
|
|
@@ -40,10 +42,6 @@ function HeaderButtonInternal(
|
|
|
40
42
|
);
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
export const HeaderButton = React.forwardRef(HeaderButtonInternal);
|
|
44
|
-
|
|
45
|
-
HeaderButton.displayName = 'HeaderButton';
|
|
46
|
-
|
|
47
45
|
export const BUTTON_SIZE = Platform.OS === 'ios' ? 44 : 48;
|
|
48
46
|
export const BUTTON_SPACING = Platform.OS === 'ios' ? 10 : 8;
|
|
49
47
|
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { Animated, StyleSheet } from 'react-native';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { AnimatedLiquidGlassView } from '../LiquidGlassView';
|
|
4
4
|
import { BUTTON_SIZE } from './HeaderButton';
|
|
5
5
|
|
|
6
6
|
type Props = React.ComponentProps<typeof Animated.View> & {
|
|
7
7
|
plain?: boolean;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
const AnimatedLiquidGlassView =
|
|
11
|
-
Animated.createAnimatedComponent(LiquidGlassView);
|
|
12
|
-
|
|
13
10
|
export function HeaderButtonBackground({ plain, style, ...rest }: Props) {
|
|
14
11
|
if (plain) {
|
|
15
12
|
return <Animated.View style={[styles.container, style]} {...rest} />;
|
|
@@ -1,24 +1,38 @@
|
|
|
1
|
-
import { useLocale
|
|
2
|
-
import {
|
|
1
|
+
import { useLocale } from '@react-navigation/native';
|
|
2
|
+
import {
|
|
3
|
+
type ColorValue,
|
|
4
|
+
type ImageStyle,
|
|
5
|
+
Platform,
|
|
6
|
+
type StyleProp,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
} from 'react-native';
|
|
3
9
|
|
|
4
|
-
|
|
5
|
-
|
|
10
|
+
import { PlatformIcon } from '../PlatformIcon';
|
|
11
|
+
import type { Icon } from '../types';
|
|
12
|
+
|
|
13
|
+
type Props = {
|
|
14
|
+
icon: Icon;
|
|
15
|
+
color: ColorValue;
|
|
16
|
+
style?: StyleProp<ImageStyle> | undefined;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function HeaderIcon({ icon, color, style }: Props) {
|
|
6
20
|
const { direction } = useLocale();
|
|
7
21
|
|
|
22
|
+
const iconStyle = [styles.icon, direction === 'rtl' && styles.flip, style];
|
|
23
|
+
|
|
8
24
|
return (
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
style={[styles.icon, direction === 'rtl' && styles.flip, style]}
|
|
15
|
-
{...rest}
|
|
25
|
+
<PlatformIcon
|
|
26
|
+
icon={icon}
|
|
27
|
+
color={color}
|
|
28
|
+
size={ICON_SIZE}
|
|
29
|
+
style={iconStyle}
|
|
16
30
|
/>
|
|
17
31
|
);
|
|
18
32
|
}
|
|
19
33
|
|
|
20
|
-
|
|
21
|
-
|
|
34
|
+
const ICON_SIZE = Platform.OS === 'ios' ? 21 : 24;
|
|
35
|
+
const ICON_MARGIN = Platform.OS === 'ios' ? 8 : 3;
|
|
22
36
|
|
|
23
37
|
const styles = StyleSheet.create({
|
|
24
38
|
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,
|
|
@@ -34,11 +30,12 @@ import { HeaderIcon } from './HeaderIcon';
|
|
|
34
30
|
type Props = Omit<HeaderSearchBarOptions, 'ref'> & {
|
|
35
31
|
visible: boolean;
|
|
36
32
|
onClose: () => void;
|
|
37
|
-
tintColor?: ColorValue;
|
|
38
|
-
pressColor?: ColorValue;
|
|
39
|
-
pressOpacity?: number;
|
|
33
|
+
tintColor?: ColorValue | undefined;
|
|
34
|
+
pressColor?: ColorValue | undefined;
|
|
35
|
+
pressOpacity?: number | undefined;
|
|
40
36
|
statusBarHeight: number;
|
|
41
|
-
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle
|
|
37
|
+
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>> | undefined;
|
|
38
|
+
ref?: React.Ref<HeaderSearchBarRef> | undefined;
|
|
42
39
|
};
|
|
43
40
|
|
|
44
41
|
const INPUT_TYPE_TO_MODE = {
|
|
@@ -50,26 +47,24 @@ const INPUT_TYPE_TO_MODE = {
|
|
|
50
47
|
|
|
51
48
|
const useNativeDriver = Platform.OS !== 'web';
|
|
52
49
|
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
ref: React.ForwardedRef<HeaderSearchBarRef>
|
|
72
|
-
) {
|
|
50
|
+
export function HeaderSearchBar({
|
|
51
|
+
visible,
|
|
52
|
+
inputType,
|
|
53
|
+
autoFocus = true,
|
|
54
|
+
autoCapitalize,
|
|
55
|
+
placeholder = 'Search',
|
|
56
|
+
enterKeyHint = 'search',
|
|
57
|
+
cancelButtonText = 'Cancel',
|
|
58
|
+
onChange,
|
|
59
|
+
onClose,
|
|
60
|
+
tintColor,
|
|
61
|
+
pressColor,
|
|
62
|
+
pressOpacity,
|
|
63
|
+
statusBarHeight,
|
|
64
|
+
style,
|
|
65
|
+
ref,
|
|
66
|
+
...rest
|
|
67
|
+
}: Props) {
|
|
73
68
|
const navigation = useNavigation();
|
|
74
69
|
const { dark, colors, fonts } = useTheme();
|
|
75
70
|
const [value, setValue] = React.useState('');
|
|
@@ -131,8 +126,10 @@ function HeaderSearchBarInternal(
|
|
|
131
126
|
if (Platform.OS === 'web') {
|
|
132
127
|
document?.body?.addEventListener?.('keyup', onKeyup);
|
|
133
128
|
} else {
|
|
129
|
+
// eslint-disable-next-line @eslint-react/web-api/no-leaked-event-listener
|
|
134
130
|
backHandlerSubscription = BackHandler.addEventListener(
|
|
135
131
|
'hardwareBackPress',
|
|
132
|
+
// eslint-disable-next-line @eslint-react/web-api/no-leaked-event-listener
|
|
136
133
|
() => {
|
|
137
134
|
cancelSearch();
|
|
138
135
|
return true;
|
|
@@ -210,9 +207,10 @@ function HeaderSearchBarInternal(
|
|
|
210
207
|
) : null}
|
|
211
208
|
<HeaderButtonBackground style={styles.searchbarContainer}>
|
|
212
209
|
{Platform.OS === 'ios' ? (
|
|
213
|
-
<
|
|
214
|
-
|
|
215
|
-
|
|
210
|
+
<SFSymbol
|
|
211
|
+
name="magnifyingglass"
|
|
212
|
+
size={SEARCH_ICON_SIZE}
|
|
213
|
+
color={textColor}
|
|
216
214
|
style={[
|
|
217
215
|
styles.inputSearchIconIos,
|
|
218
216
|
!isLiquidGlassSupported && styles.inputSearchIconIosLegacy,
|
|
@@ -263,10 +261,10 @@ function HeaderSearchBarInternal(
|
|
|
263
261
|
!isLiquidGlassSupported && styles.clearButtonIosLegacy,
|
|
264
262
|
]}
|
|
265
263
|
>
|
|
266
|
-
<
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
264
|
+
<SFSymbol
|
|
265
|
+
name="xmark.circle.fill"
|
|
266
|
+
size={CLEAR_ICON_SIZE}
|
|
267
|
+
color={textColor}
|
|
270
268
|
style={styles.clearIconIos}
|
|
271
269
|
/>
|
|
272
270
|
</PlatformPressable>
|
|
@@ -278,7 +276,19 @@ function HeaderSearchBarInternal(
|
|
|
278
276
|
onPress={onClear}
|
|
279
277
|
style={[styles.closeButton, { opacity: clearVisibleAnim }]}
|
|
280
278
|
>
|
|
281
|
-
<HeaderIcon
|
|
279
|
+
<HeaderIcon
|
|
280
|
+
icon={Platform.select({
|
|
281
|
+
android: {
|
|
282
|
+
type: 'materialSymbol',
|
|
283
|
+
name: 'close',
|
|
284
|
+
},
|
|
285
|
+
default: {
|
|
286
|
+
type: 'image',
|
|
287
|
+
source: closeIcon,
|
|
288
|
+
},
|
|
289
|
+
})}
|
|
290
|
+
color={textColor}
|
|
291
|
+
/>
|
|
282
292
|
</HeaderButton>
|
|
283
293
|
) : null}
|
|
284
294
|
{Platform.OS === 'ios' ? (
|
|
@@ -288,7 +298,7 @@ function HeaderSearchBarInternal(
|
|
|
288
298
|
accessibilityLabel={cancelButtonText}
|
|
289
299
|
onPress={cancelSearch}
|
|
290
300
|
>
|
|
291
|
-
<
|
|
301
|
+
<SFSymbol name="xmark" color={textColor} />
|
|
292
302
|
</HeaderButton>
|
|
293
303
|
</HeaderButtonBackground>
|
|
294
304
|
) : (
|
|
@@ -332,14 +342,14 @@ const styles = StyleSheet.create({
|
|
|
332
342
|
},
|
|
333
343
|
inputSearchIconIos: {
|
|
334
344
|
position: 'absolute',
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
345
|
+
top: '50%',
|
|
346
|
+
left: BUTTON_SPACING + SEARCHBAR_ICON_SPACING / 2,
|
|
347
|
+
marginTop: -SEARCH_ICON_SIZE / 2,
|
|
338
348
|
height: SEARCH_ICON_SIZE,
|
|
339
349
|
width: SEARCH_ICON_SIZE,
|
|
340
350
|
},
|
|
341
351
|
inputSearchIconIosLegacy: {
|
|
342
|
-
top:
|
|
352
|
+
top: SEARCHBAR_ICON_SPACING,
|
|
343
353
|
},
|
|
344
354
|
backButton: {
|
|
345
355
|
alignSelf: 'center',
|
|
@@ -417,5 +427,3 @@ const styles = StyleSheet.create({
|
|
|
417
427
|
}),
|
|
418
428
|
},
|
|
419
429
|
});
|
|
420
|
-
|
|
421
|
-
export const HeaderSearchBar = React.forwardRef(HeaderSearchBarInternal);
|
|
@@ -10,9 +10,9 @@ import {
|
|
|
10
10
|
} from 'react-native';
|
|
11
11
|
|
|
12
12
|
type Props = Omit<TextProps, 'style'> & {
|
|
13
|
-
tintColor?: ColorValue;
|
|
14
|
-
children?: string;
|
|
15
|
-
style?: Animated.WithAnimatedValue<StyleProp<TextStyle
|
|
13
|
+
tintColor?: ColorValue | undefined;
|
|
14
|
+
children?: string | undefined;
|
|
15
|
+
style?: Animated.WithAnimatedValue<StyleProp<TextStyle>> | undefined;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
export function HeaderTitle({ tintColor, style, ...rest }: Props) {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { HeaderOptions } from '../types';
|
|
2
2
|
|
|
3
3
|
export function getHeaderTitle(
|
|
4
|
-
options: {
|
|
4
|
+
options: {
|
|
5
|
+
title?: string | undefined;
|
|
6
|
+
headerTitle?: HeaderOptions['headerTitle'];
|
|
7
|
+
},
|
|
5
8
|
fallback: string
|
|
6
9
|
): string {
|
|
7
10
|
return typeof options.headerTitle === 'string'
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { HeaderHeightContext } from './HeaderHeightContext';
|
|
4
4
|
|
|
5
5
|
export function useHeaderHeight() {
|
|
6
|
-
const height = React.
|
|
6
|
+
const height = React.use(HeaderHeightContext);
|
|
7
7
|
|
|
8
8
|
if (height === undefined) {
|
|
9
9
|
throw new Error(
|
package/src/Label/getLabel.tsx
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
LiquidGlassContainerViewProps,
|
|
3
|
+
LiquidGlassViewProps,
|
|
4
|
+
} from '@callstack/liquid-glass';
|
|
1
5
|
import { Animated, View } from 'react-native';
|
|
2
6
|
|
|
3
|
-
type
|
|
7
|
+
type AnimatedLiquidGlassViewProps =
|
|
8
|
+
Animated.AnimatedProps<LiquidGlassViewProps>;
|
|
9
|
+
|
|
10
|
+
type AnimatedLiquidGlassContainerViewProps =
|
|
11
|
+
Animated.AnimatedProps<LiquidGlassContainerViewProps>;
|
|
4
12
|
|
|
5
13
|
let isLiquidGlassSupported: boolean,
|
|
6
|
-
LiquidGlassView:
|
|
7
|
-
LiquidGlassContainerView:
|
|
8
|
-
AnimatedLiquidGlassView:
|
|
9
|
-
AnimatedLiquidGlassContainerView:
|
|
10
|
-
typeof LiquidGlassContainerView
|
|
11
|
-
>;
|
|
14
|
+
LiquidGlassView: React.ComponentType<LiquidGlassViewProps>,
|
|
15
|
+
LiquidGlassContainerView: React.ComponentType<LiquidGlassContainerViewProps>,
|
|
16
|
+
AnimatedLiquidGlassView: React.ComponentType<AnimatedLiquidGlassViewProps>,
|
|
17
|
+
AnimatedLiquidGlassContainerView: React.ComponentType<AnimatedLiquidGlassContainerViewProps>;
|
|
12
18
|
|
|
13
19
|
try {
|
|
14
20
|
// Add try/catch to support usage even if it's not installed, since it's optional.
|
|
@@ -24,9 +30,8 @@ try {
|
|
|
24
30
|
} catch (e) {
|
|
25
31
|
isLiquidGlassSupported = false;
|
|
26
32
|
LiquidGlassView = View;
|
|
27
|
-
|
|
33
|
+
LiquidGlassContainerView = View;
|
|
28
34
|
AnimatedLiquidGlassView = Animated.View;
|
|
29
|
-
// @ts-expect-error: this is fine
|
|
30
35
|
AnimatedLiquidGlassContainerView = Animated.View;
|
|
31
36
|
}
|
|
32
37
|
|