@react-navigation/stack 7.6.16 → 8.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/TransitionConfigs/HeaderStyleInterpolators.js +44 -52
- package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js.map +1 -1
- package/lib/module/TransitionConfigs/TransitionPresets.js +4 -4
- package/lib/module/TransitionConfigs/TransitionPresets.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/navigators/createStackNavigator.js +7 -6
- package/lib/module/navigators/createStackNavigator.js.map +1 -1
- package/lib/module/utils/getShadowStyle.js +3 -5
- package/lib/module/utils/getShadowStyle.js.map +1 -1
- package/lib/module/views/Header/Header.js +0 -2
- package/lib/module/views/Header/Header.js.map +1 -1
- package/lib/module/views/Header/HeaderContainer.js +27 -28
- package/lib/module/views/Header/HeaderContainer.js.map +1 -1
- package/lib/module/views/Header/HeaderSegment.js +14 -51
- package/lib/module/views/Header/HeaderSegment.js.map +1 -1
- package/lib/module/views/Stack/Card.js +12 -30
- package/lib/module/views/Stack/Card.js.map +1 -1
- package/lib/module/views/Stack/CardA11yWrapper.js +1 -1
- package/lib/module/views/Stack/CardA11yWrapper.js.map +1 -1
- package/lib/module/views/Stack/CardContainer.js +0 -1
- package/lib/module/views/Stack/CardContainer.js.map +1 -1
- package/lib/module/views/Stack/CardContent.js +3 -2
- package/lib/module/views/Stack/CardContent.js.map +1 -1
- package/lib/module/views/Stack/CardStack.js +23 -19
- package/lib/module/views/Stack/CardStack.js.map +1 -1
- package/lib/module/views/Stack/StackView.js +2 -1
- package/lib/module/views/Stack/StackView.js.map +1 -1
- package/lib/typescript/src/TransitionConfigs/HeaderStyleInterpolators.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/navigators/createStackNavigator.d.ts +10 -6
- package/lib/typescript/src/navigators/createStackNavigator.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +12 -28
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/getShadowStyle.d.ts +1 -2
- package/lib/typescript/src/utils/getShadowStyle.d.ts.map +1 -1
- package/lib/typescript/src/views/Header/Header.d.ts.map +1 -1
- package/lib/typescript/src/views/Header/HeaderContainer.d.ts +2 -3
- package/lib/typescript/src/views/Header/HeaderContainer.d.ts.map +1 -1
- package/lib/typescript/src/views/Header/HeaderSegment.d.ts +1 -2
- package/lib/typescript/src/views/Header/HeaderSegment.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/Card.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/CardContainer.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/CardContent.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/CardStack.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/StackView.d.ts +22 -2
- package/lib/typescript/src/views/Stack/StackView.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/TransitionConfigs/HeaderStyleInterpolators.tsx +43 -80
- package/src/TransitionConfigs/TransitionPresets.tsx +4 -4
- package/src/index.tsx +4 -1
- package/src/navigators/createStackNavigator.tsx +42 -25
- package/src/types.tsx +18 -33
- package/src/utils/getShadowStyle.tsx +3 -14
- package/src/views/Header/Header.tsx +0 -2
- package/src/views/Header/HeaderContainer.tsx +36 -37
- package/src/views/Header/HeaderSegment.tsx +27 -92
- package/src/views/Stack/Card.tsx +8 -33
- package/src/views/Stack/CardA11yWrapper.tsx +1 -1
- package/src/views/Stack/CardContainer.tsx +0 -1
- package/src/views/Stack/CardContent.tsx +5 -2
- package/src/views/Stack/CardStack.tsx +24 -21
- package/src/views/Stack/StackView.tsx +2 -4
- package/lib/module/views/Screens.js +0 -42
- package/lib/module/views/Screens.js.map +0 -1
- package/lib/typescript/src/views/Screens.d.ts +0 -15
- package/lib/typescript/src/views/Screens.d.ts.map +0 -1
- package/src/views/Screens.tsx +0 -45
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isLiquidGlassSupported } from '@react-navigation/elements/internal';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
2
3
|
|
|
3
4
|
import type {
|
|
4
5
|
StackHeaderInterpolatedStyle,
|
|
@@ -7,10 +8,6 @@ import type {
|
|
|
7
8
|
|
|
8
9
|
const { add, multiply } = Animated;
|
|
9
10
|
|
|
10
|
-
// Width of the screen in split layout on portrait mode on iPad Mini
|
|
11
|
-
// Keep in sync with HeaderBackButton.tsx
|
|
12
|
-
const IPAD_MINI_MEDIUM_WIDTH = 414;
|
|
13
|
-
|
|
14
11
|
/**
|
|
15
12
|
* Standard UIKit style animation for the header where the title fades into the back button label.
|
|
16
13
|
*/
|
|
@@ -20,29 +17,6 @@ export function forUIKit({
|
|
|
20
17
|
direction,
|
|
21
18
|
layouts,
|
|
22
19
|
}: StackHeaderInterpolationProps): StackHeaderInterpolatedStyle {
|
|
23
|
-
const defaultOffset = 100;
|
|
24
|
-
const leftSpacing =
|
|
25
|
-
27 +
|
|
26
|
-
(Platform.OS === 'ios' && layouts.screen.width >= IPAD_MINI_MEDIUM_WIDTH
|
|
27
|
-
? 5 // Additional padding on iPad specified in Header.tsx
|
|
28
|
-
: 0);
|
|
29
|
-
|
|
30
|
-
// The title and back button title should cross-fade to each other
|
|
31
|
-
// When screen is fully open, the title should be in center, and back title should be on left
|
|
32
|
-
// When screen is closing, the previous title will animate to back title's position
|
|
33
|
-
// And back title will animate to title's position
|
|
34
|
-
// We achieve this by calculating the offsets needed to translate title to back title's position and vice-versa
|
|
35
|
-
const leftLabelOffset = layouts.leftLabel
|
|
36
|
-
? (layouts.screen.width - layouts.leftLabel.width) / 2 - leftSpacing
|
|
37
|
-
: defaultOffset;
|
|
38
|
-
const titleLeftOffset = layouts.title
|
|
39
|
-
? (layouts.screen.width - layouts.title.width) / 2 - leftSpacing
|
|
40
|
-
: defaultOffset;
|
|
41
|
-
|
|
42
|
-
// When the current title is animating to right, it is centered in the right half of screen in middle of transition
|
|
43
|
-
// The back title also animates in from this position
|
|
44
|
-
const rightOffset = layouts.screen.width / 4;
|
|
45
|
-
|
|
46
20
|
const multiplier = direction === 'rtl' ? -1 : 1;
|
|
47
21
|
|
|
48
22
|
const progress = add(
|
|
@@ -60,61 +34,50 @@ export function forUIKit({
|
|
|
60
34
|
: 0
|
|
61
35
|
);
|
|
62
36
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
leftLabelStyle: {
|
|
71
|
-
transform: [
|
|
72
|
-
{
|
|
73
|
-
translateX: multiply(
|
|
74
|
-
multiplier,
|
|
75
|
-
progress.interpolate({
|
|
76
|
-
inputRange: [0, 1, 2],
|
|
77
|
-
outputRange: [leftLabelOffset, 0, -rightOffset],
|
|
78
|
-
})
|
|
79
|
-
),
|
|
80
|
-
},
|
|
37
|
+
if (isLiquidGlassSupported) {
|
|
38
|
+
const opacity = progress.interpolate({
|
|
39
|
+
inputRange: [0, 1, 2],
|
|
40
|
+
outputRange: [
|
|
41
|
+
// FIXME: Liquid glass views don't work properly with `opacity: 0`
|
|
42
|
+
// So we use a small value instead to workaround this issue.
|
|
43
|
+
0.1, 1, 1,
|
|
81
44
|
],
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const translateX = multiply(
|
|
48
|
+
multiplier,
|
|
49
|
+
progress.interpolate({
|
|
50
|
+
inputRange: [0, 1, 2],
|
|
51
|
+
outputRange: [layouts.screen.width, 0, -layouts.screen.width * 0.3],
|
|
52
|
+
})
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
leftButtonStyle: { opacity },
|
|
57
|
+
rightButtonStyle: { opacity },
|
|
58
|
+
titleStyle: {
|
|
59
|
+
transform: [{ translateX }],
|
|
60
|
+
},
|
|
61
|
+
backgroundStyle: {
|
|
62
|
+
transform: [{ translateX }],
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const opacity = progress.interpolate({
|
|
68
|
+
inputRange: [0, 1, 2],
|
|
69
|
+
outputRange: [0, 1, 0],
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
leftButtonStyle: { opacity },
|
|
74
|
+
rightButtonStyle: { opacity },
|
|
75
|
+
titleStyle: { opacity },
|
|
76
|
+
backgroundStyle: {
|
|
90
77
|
opacity: progress.interpolate({
|
|
91
|
-
inputRange: [0,
|
|
92
|
-
outputRange: [0,
|
|
78
|
+
inputRange: [0, 1, 1.9, 2],
|
|
79
|
+
outputRange: [0, 1, 1, 0],
|
|
93
80
|
}),
|
|
94
|
-
transform: [
|
|
95
|
-
{
|
|
96
|
-
translateX: multiply(
|
|
97
|
-
multiplier,
|
|
98
|
-
progress.interpolate({
|
|
99
|
-
inputRange: [0.5, 1, 2],
|
|
100
|
-
outputRange: [rightOffset, 0, -titleLeftOffset],
|
|
101
|
-
})
|
|
102
|
-
),
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
},
|
|
106
|
-
backgroundStyle: {
|
|
107
|
-
transform: [
|
|
108
|
-
{
|
|
109
|
-
translateX: multiply(
|
|
110
|
-
multiplier,
|
|
111
|
-
progress.interpolate({
|
|
112
|
-
inputRange: [0, 1, 2],
|
|
113
|
-
outputRange: [layouts.screen.width, 0, -layouts.screen.width],
|
|
114
|
-
})
|
|
115
|
-
),
|
|
116
|
-
},
|
|
117
|
-
],
|
|
118
81
|
},
|
|
119
82
|
};
|
|
120
83
|
}
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
forScaleFromCenterAndroid,
|
|
14
14
|
forVerticalIOS,
|
|
15
15
|
} from './CardStyleInterpolators';
|
|
16
|
-
import { forFade } from './HeaderStyleInterpolators';
|
|
16
|
+
import { forFade, forUIKit } from './HeaderStyleInterpolators';
|
|
17
17
|
import {
|
|
18
18
|
BottomSheetSlideInSpec,
|
|
19
19
|
BottomSheetSlideOutSpec,
|
|
@@ -38,7 +38,7 @@ export const SlideFromRightIOS: TransitionPreset = {
|
|
|
38
38
|
close: TransitionIOSSpec,
|
|
39
39
|
},
|
|
40
40
|
cardStyleInterpolator: forHorizontalIOS,
|
|
41
|
-
headerStyleInterpolator:
|
|
41
|
+
headerStyleInterpolator: forUIKit,
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -51,7 +51,7 @@ export const ModalSlideFromBottomIOS: TransitionPreset = {
|
|
|
51
51
|
close: TransitionIOSSpec,
|
|
52
52
|
},
|
|
53
53
|
cardStyleInterpolator: forVerticalIOS,
|
|
54
|
-
headerStyleInterpolator:
|
|
54
|
+
headerStyleInterpolator: forUIKit,
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
/**
|
|
@@ -64,7 +64,7 @@ export const ModalPresentationIOS: TransitionPreset = {
|
|
|
64
64
|
close: TransitionIOSSpec,
|
|
65
65
|
},
|
|
66
66
|
cardStyleInterpolator: forModalPresentationIOS,
|
|
67
|
-
headerStyleInterpolator:
|
|
67
|
+
headerStyleInterpolator: forUIKit,
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
/**
|
package/src/index.tsx
CHANGED
|
@@ -6,7 +6,10 @@ import * as TransitionSpecs from './TransitionConfigs/TransitionSpecs';
|
|
|
6
6
|
/**
|
|
7
7
|
* Navigators
|
|
8
8
|
*/
|
|
9
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
createStackNavigator,
|
|
11
|
+
createStackScreen,
|
|
12
|
+
} from './navigators/createStackNavigator';
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
* Views
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createNavigatorFactory,
|
|
3
3
|
type EventArg,
|
|
4
|
-
type NavigatorTypeBagBase,
|
|
5
4
|
type ParamListBase,
|
|
6
5
|
type StackActionHelpers,
|
|
7
6
|
StackActions,
|
|
@@ -9,6 +8,10 @@ import {
|
|
|
9
8
|
StackRouter,
|
|
10
9
|
type StackRouterOptions,
|
|
11
10
|
type StaticConfig,
|
|
11
|
+
type StaticParamList,
|
|
12
|
+
type StaticScreenConfig,
|
|
13
|
+
type StaticScreenConfigLinking,
|
|
14
|
+
type StaticScreenConfigScreen,
|
|
12
15
|
type TypedNavigator,
|
|
13
16
|
useLocale,
|
|
14
17
|
useNavigationBuilder,
|
|
@@ -24,15 +27,14 @@ import type {
|
|
|
24
27
|
import { StackView } from '../views/Stack/StackView';
|
|
25
28
|
|
|
26
29
|
function StackNavigator({
|
|
27
|
-
id,
|
|
28
30
|
initialRouteName,
|
|
29
|
-
|
|
31
|
+
routeNamesChangeBehavior,
|
|
30
32
|
children,
|
|
31
33
|
layout,
|
|
32
34
|
screenListeners,
|
|
33
35
|
screenOptions,
|
|
34
36
|
screenLayout,
|
|
35
|
-
|
|
37
|
+
router,
|
|
36
38
|
...rest
|
|
37
39
|
}: StackNavigatorProps) {
|
|
38
40
|
const { direction } = useLocale();
|
|
@@ -45,15 +47,14 @@ function StackNavigator({
|
|
|
45
47
|
StackNavigationOptions,
|
|
46
48
|
StackNavigationEventMap
|
|
47
49
|
>(StackRouter, {
|
|
48
|
-
id,
|
|
49
50
|
initialRouteName,
|
|
50
|
-
|
|
51
|
+
routeNamesChangeBehavior,
|
|
51
52
|
children,
|
|
52
53
|
layout,
|
|
53
54
|
screenListeners,
|
|
54
55
|
screenOptions,
|
|
55
56
|
screenLayout,
|
|
56
|
-
|
|
57
|
+
router,
|
|
57
58
|
});
|
|
58
59
|
|
|
59
60
|
React.useEffect(
|
|
@@ -96,25 +97,41 @@ function StackNavigator({
|
|
|
96
97
|
);
|
|
97
98
|
}
|
|
98
99
|
|
|
100
|
+
type StackTypeBag<ParamList extends {}> = {
|
|
101
|
+
ParamList: ParamList;
|
|
102
|
+
State: StackNavigationState<ParamList>;
|
|
103
|
+
ScreenOptions: StackNavigationOptions;
|
|
104
|
+
EventMap: StackNavigationEventMap;
|
|
105
|
+
NavigationList: {
|
|
106
|
+
[RouteName in keyof ParamList]: StackNavigationProp<ParamList, RouteName>;
|
|
107
|
+
};
|
|
108
|
+
Navigator: typeof StackNavigator;
|
|
109
|
+
};
|
|
110
|
+
|
|
99
111
|
export function createStackNavigator<
|
|
100
112
|
const ParamList extends ParamListBase,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
NavigationList: {
|
|
109
|
-
[RouteName in keyof ParamList]: StackNavigationProp<
|
|
110
|
-
ParamList,
|
|
111
|
-
RouteName,
|
|
112
|
-
NavigatorID
|
|
113
|
-
>;
|
|
114
|
-
};
|
|
115
|
-
Navigator: typeof StackNavigator;
|
|
116
|
-
},
|
|
117
|
-
const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>,
|
|
118
|
-
>(config?: Config): TypedNavigator<TypeBag, Config> {
|
|
113
|
+
>(): TypedNavigator<StackTypeBag<ParamList>, undefined>;
|
|
114
|
+
export function createStackNavigator<
|
|
115
|
+
const Config extends StaticConfig<StackTypeBag<ParamListBase>>,
|
|
116
|
+
>(
|
|
117
|
+
config: Config
|
|
118
|
+
): TypedNavigator<StackTypeBag<StaticParamList<{ config: Config }>>, Config>;
|
|
119
|
+
export function createStackNavigator(config?: unknown) {
|
|
119
120
|
return createNavigatorFactory(StackNavigator)(config);
|
|
120
121
|
}
|
|
122
|
+
|
|
123
|
+
export function createStackScreen<
|
|
124
|
+
const Linking extends StaticScreenConfigLinking,
|
|
125
|
+
const Screen extends StaticScreenConfigScreen,
|
|
126
|
+
>(
|
|
127
|
+
config: StaticScreenConfig<
|
|
128
|
+
Linking,
|
|
129
|
+
Screen,
|
|
130
|
+
StackNavigationState<ParamListBase>,
|
|
131
|
+
StackNavigationOptions,
|
|
132
|
+
StackNavigationEventMap,
|
|
133
|
+
StackNavigationProp<ParamListBase>
|
|
134
|
+
>
|
|
135
|
+
) {
|
|
136
|
+
return config;
|
|
137
|
+
}
|
package/src/types.tsx
CHANGED
|
@@ -20,7 +20,13 @@ import type {
|
|
|
20
20
|
Theme,
|
|
21
21
|
} from '@react-navigation/native';
|
|
22
22
|
import type * as React from 'react';
|
|
23
|
-
import type {
|
|
23
|
+
import type {
|
|
24
|
+
Animated,
|
|
25
|
+
ColorValue,
|
|
26
|
+
StyleProp,
|
|
27
|
+
TextStyle,
|
|
28
|
+
ViewStyle,
|
|
29
|
+
} from 'react-native';
|
|
24
30
|
|
|
25
31
|
export type StackNavigationEventMap = {
|
|
26
32
|
/**
|
|
@@ -54,31 +60,27 @@ export type StackNavigationHelpers = NavigationHelpers<
|
|
|
54
60
|
export type StackNavigationProp<
|
|
55
61
|
ParamList extends ParamListBase,
|
|
56
62
|
RouteName extends keyof ParamList = keyof ParamList,
|
|
57
|
-
NavigatorID extends string | undefined = undefined,
|
|
58
63
|
> = NavigationProp<
|
|
59
64
|
ParamList,
|
|
60
65
|
RouteName,
|
|
61
|
-
NavigatorID,
|
|
62
66
|
StackNavigationState<ParamList>,
|
|
63
67
|
StackNavigationOptions,
|
|
64
|
-
StackNavigationEventMap
|
|
65
|
-
>
|
|
66
|
-
|
|
68
|
+
StackNavigationEventMap,
|
|
69
|
+
StackActionHelpers<ParamList>
|
|
70
|
+
>;
|
|
67
71
|
|
|
68
72
|
export type StackScreenProps<
|
|
69
73
|
ParamList extends ParamListBase,
|
|
70
74
|
RouteName extends keyof ParamList = keyof ParamList,
|
|
71
|
-
NavigatorID extends string | undefined = undefined,
|
|
72
75
|
> = {
|
|
73
|
-
navigation: StackNavigationProp<ParamList, RouteName
|
|
76
|
+
navigation: StackNavigationProp<ParamList, RouteName>;
|
|
74
77
|
route: RouteProp<ParamList, RouteName>;
|
|
75
78
|
};
|
|
76
79
|
|
|
77
80
|
export type StackOptionsArgs<
|
|
78
81
|
ParamList extends ParamListBase,
|
|
79
82
|
RouteName extends keyof ParamList = keyof ParamList,
|
|
80
|
-
|
|
81
|
-
> = StackScreenProps<ParamList, RouteName, NavigatorID> & {
|
|
83
|
+
> = StackScreenProps<ParamList, RouteName> & {
|
|
82
84
|
theme: Theme;
|
|
83
85
|
};
|
|
84
86
|
|
|
@@ -217,10 +219,6 @@ export type StackHeaderOptions = Omit<
|
|
|
217
219
|
};
|
|
218
220
|
|
|
219
221
|
export type StackHeaderProps = {
|
|
220
|
-
/**
|
|
221
|
-
* Layout of the screen.
|
|
222
|
-
*/
|
|
223
|
-
layout: Layout;
|
|
224
222
|
/**
|
|
225
223
|
* Options for the back button.
|
|
226
224
|
*/
|
|
@@ -260,11 +258,11 @@ export type StackHeaderRightProps = {
|
|
|
260
258
|
/**
|
|
261
259
|
* Tint color for the header button.
|
|
262
260
|
*/
|
|
263
|
-
tintColor?:
|
|
261
|
+
tintColor?: ColorValue;
|
|
264
262
|
/**
|
|
265
263
|
* Color for material ripple (Android >= 5.0 only).
|
|
266
264
|
*/
|
|
267
|
-
pressColor?:
|
|
265
|
+
pressColor?: ColorValue;
|
|
268
266
|
/**
|
|
269
267
|
* Opacity when the button is pressed, used when ripple is not supported.
|
|
270
268
|
*/
|
|
@@ -561,38 +559,26 @@ export type StackHeaderInterpolationProps = {
|
|
|
561
559
|
* Layout of the whole screen.
|
|
562
560
|
*/
|
|
563
561
|
screen: Layout;
|
|
564
|
-
/**
|
|
565
|
-
* Layout of the title element.
|
|
566
|
-
*/
|
|
567
|
-
title?: Layout;
|
|
568
|
-
/**
|
|
569
|
-
* Layout of the back button label.
|
|
570
|
-
*/
|
|
571
|
-
leftLabel?: Layout;
|
|
572
562
|
};
|
|
573
563
|
};
|
|
574
564
|
|
|
575
565
|
export type StackHeaderInterpolatedStyle = {
|
|
576
|
-
/**
|
|
577
|
-
* Interpolated style for the label of the left button (back button label).
|
|
578
|
-
*/
|
|
579
|
-
leftLabelStyle?: any;
|
|
580
566
|
/**
|
|
581
567
|
* Interpolated style for the left button (usually the back button).
|
|
582
568
|
*/
|
|
583
|
-
leftButtonStyle?:
|
|
569
|
+
leftButtonStyle?: Animated.WithAnimatedValue<ViewStyle>;
|
|
584
570
|
/**
|
|
585
571
|
* Interpolated style for the right button.
|
|
586
572
|
*/
|
|
587
|
-
rightButtonStyle?:
|
|
573
|
+
rightButtonStyle?: Animated.WithAnimatedValue<ViewStyle>;
|
|
588
574
|
/**
|
|
589
575
|
* Interpolated style for the header title text.
|
|
590
576
|
*/
|
|
591
|
-
titleStyle?:
|
|
577
|
+
titleStyle?: Animated.WithAnimatedValue<TextStyle>;
|
|
592
578
|
/**
|
|
593
579
|
* Interpolated style for the header background.
|
|
594
580
|
*/
|
|
595
|
-
backgroundStyle?:
|
|
581
|
+
backgroundStyle?: Animated.WithAnimatedValue<ViewStyle>;
|
|
596
582
|
};
|
|
597
583
|
|
|
598
584
|
export type StackHeaderStyleInterpolator = (
|
|
@@ -629,7 +615,6 @@ export type TransitionPreset = {
|
|
|
629
615
|
|
|
630
616
|
export type StackNavigatorProps = DefaultNavigatorOptions<
|
|
631
617
|
ParamListBase,
|
|
632
|
-
string | undefined,
|
|
633
618
|
StackNavigationState<ParamListBase>,
|
|
634
619
|
StackNavigationOptions,
|
|
635
620
|
StackNavigationEventMap,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import Color from 'color';
|
|
2
1
|
import { Platform } from 'react-native';
|
|
3
2
|
|
|
4
3
|
type ShadowConfig = {
|
|
@@ -8,27 +7,17 @@ type ShadowConfig = {
|
|
|
8
7
|
};
|
|
9
8
|
radius: number;
|
|
10
9
|
opacity: number;
|
|
11
|
-
color?: string;
|
|
12
10
|
};
|
|
13
11
|
|
|
14
|
-
export function getShadowStyle({
|
|
15
|
-
offset,
|
|
16
|
-
radius,
|
|
17
|
-
opacity,
|
|
18
|
-
color = '#000',
|
|
19
|
-
}: ShadowConfig) {
|
|
12
|
+
export function getShadowStyle({ offset, radius, opacity }: ShadowConfig) {
|
|
20
13
|
const result = Platform.select({
|
|
21
14
|
web: {
|
|
22
|
-
boxShadow: `${offset.width}px ${offset.height}px ${radius}px ${
|
|
23
|
-
color
|
|
24
|
-
)
|
|
25
|
-
.alpha(opacity)
|
|
26
|
-
.toString()}`,
|
|
15
|
+
boxShadow: `${offset.width}px ${offset.height}px ${radius}px rgba(0, 0, 0, ${opacity})`,
|
|
27
16
|
},
|
|
28
17
|
default: {
|
|
29
18
|
shadowOffset: offset,
|
|
30
19
|
shadowRadius: radius,
|
|
31
|
-
shadowColor:
|
|
20
|
+
shadowColor: '#000',
|
|
32
21
|
shadowOpacity: opacity,
|
|
33
22
|
},
|
|
34
23
|
});
|
|
@@ -10,7 +10,6 @@ import { HeaderSegment } from './HeaderSegment';
|
|
|
10
10
|
|
|
11
11
|
export const Header = React.memo(function Header({
|
|
12
12
|
back,
|
|
13
|
-
layout,
|
|
14
13
|
progress,
|
|
15
14
|
options,
|
|
16
15
|
route,
|
|
@@ -57,7 +56,6 @@ export const Header = React.memo(function Header({
|
|
|
57
56
|
{...options}
|
|
58
57
|
title={getHeaderTitle(options, route.name)}
|
|
59
58
|
progress={progress}
|
|
60
|
-
layout={layout}
|
|
61
59
|
modal={isModal}
|
|
62
60
|
headerBackTitle={
|
|
63
61
|
options.headerBackTitle !== undefined
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { getHeaderTitle, HeaderBackContext } from '@react-navigation/elements';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
NavigationRouteContext,
|
|
3
|
+
NavigationProvider,
|
|
5
4
|
type ParamListBase,
|
|
6
5
|
type Route,
|
|
7
6
|
useLinkBuilder,
|
|
@@ -16,7 +15,6 @@ import {
|
|
|
16
15
|
forSlideUp,
|
|
17
16
|
} from '../../TransitionConfigs/HeaderStyleInterpolators';
|
|
18
17
|
import type {
|
|
19
|
-
Layout,
|
|
20
18
|
Scene,
|
|
21
19
|
StackHeaderMode,
|
|
22
20
|
StackHeaderProps,
|
|
@@ -26,7 +24,6 @@ import { Header } from './Header';
|
|
|
26
24
|
|
|
27
25
|
export type Props = {
|
|
28
26
|
mode: StackHeaderMode;
|
|
29
|
-
layout: Layout;
|
|
30
27
|
scenes: (Scene | undefined)[];
|
|
31
28
|
getPreviousScene: (props: { route: Route<string> }) => Scene | undefined;
|
|
32
29
|
getFocusedRoute: () => Route<string>;
|
|
@@ -40,7 +37,6 @@ export type Props = {
|
|
|
40
37
|
export function HeaderContainer({
|
|
41
38
|
mode,
|
|
42
39
|
scenes,
|
|
43
|
-
layout,
|
|
44
40
|
getPreviousScene,
|
|
45
41
|
getFocusedRoute,
|
|
46
42
|
onContentHeightChange,
|
|
@@ -51,7 +47,7 @@ export function HeaderContainer({
|
|
|
51
47
|
const { buildHref } = useLinkBuilder();
|
|
52
48
|
|
|
53
49
|
return (
|
|
54
|
-
<View
|
|
50
|
+
<View style={[styles.container, style]}>
|
|
55
51
|
{/* We render header only on two top-most headers as
|
|
56
52
|
a workaround for https://github.com/react-navigation/react-navigation/issues/12456.
|
|
57
53
|
If the header is persisted, it might be placed incorrectly when navigating back. */}
|
|
@@ -122,7 +118,6 @@ export function HeaderContainer({
|
|
|
122
118
|
nextHeaderlessScene;
|
|
123
119
|
|
|
124
120
|
const props: StackHeaderProps = {
|
|
125
|
-
layout,
|
|
126
121
|
back: headerBack,
|
|
127
122
|
progress: scene.progress,
|
|
128
123
|
options: scene.descriptor.options,
|
|
@@ -143,38 +138,39 @@ export function HeaderContainer({
|
|
|
143
138
|
};
|
|
144
139
|
|
|
145
140
|
return (
|
|
146
|
-
<
|
|
141
|
+
<NavigationProvider
|
|
147
142
|
key={scene.descriptor.route.key}
|
|
148
|
-
|
|
143
|
+
navigation={scene.descriptor.navigation}
|
|
144
|
+
route={scene.descriptor.route}
|
|
149
145
|
>
|
|
150
|
-
<
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
</
|
|
177
|
-
</
|
|
146
|
+
<View
|
|
147
|
+
onLayout={
|
|
148
|
+
onContentHeightChange
|
|
149
|
+
? (e) => {
|
|
150
|
+
const { height } = e.nativeEvent.layout;
|
|
151
|
+
|
|
152
|
+
onContentHeightChange({
|
|
153
|
+
route: scene.descriptor.route,
|
|
154
|
+
height,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
: undefined
|
|
158
|
+
}
|
|
159
|
+
aria-hidden={!isFocused}
|
|
160
|
+
style={[
|
|
161
|
+
// Avoid positioning the focused header absolutely
|
|
162
|
+
// Otherwise accessibility tools don't seem to be able to find it
|
|
163
|
+
(mode === 'float' && !isFocused) || headerTransparent
|
|
164
|
+
? styles.header
|
|
165
|
+
: null,
|
|
166
|
+
{
|
|
167
|
+
pointerEvents: isFocused ? 'box-none' : 'none',
|
|
168
|
+
},
|
|
169
|
+
]}
|
|
170
|
+
>
|
|
171
|
+
{header !== undefined ? header(props) : <Header {...props} />}
|
|
172
|
+
</View>
|
|
173
|
+
</NavigationProvider>
|
|
178
174
|
);
|
|
179
175
|
})}
|
|
180
176
|
</View>
|
|
@@ -182,6 +178,9 @@ export function HeaderContainer({
|
|
|
182
178
|
}
|
|
183
179
|
|
|
184
180
|
const styles = StyleSheet.create({
|
|
181
|
+
container: {
|
|
182
|
+
pointerEvents: 'box-none',
|
|
183
|
+
},
|
|
185
184
|
header: {
|
|
186
185
|
position: 'absolute',
|
|
187
186
|
top: 0,
|