@amazon-devices/react-navigation__stack 8.0.9000000001 → 8.0.9000000002

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 (76) hide show
  1. package/kepler-compatibility.json +2 -1
  2. package/lib/module/index.js +0 -34
  3. package/lib/module/views/Stack/CardStack.js.map +1 -1
  4. package/lib/typescript/src/views/Stack/CardStack.d.ts.map +1 -1
  5. package/package.json +1 -1
  6. package/src/index.tsx +0 -56
  7. package/lib/module/TransitionConfigs/CardStyleInterpolators.js +0 -394
  8. package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js +0 -262
  9. package/lib/module/TransitionConfigs/TransitionPresets.js +0 -156
  10. package/lib/module/TransitionConfigs/TransitionSpecs.js +0 -124
  11. package/lib/module/navigators/createStackNavigator.js +0 -71
  12. package/lib/module/types.js +0 -4
  13. package/lib/module/utils/CardAnimationContext.js +0 -5
  14. package/lib/module/utils/GestureHandlerRefContext.js +0 -5
  15. package/lib/module/utils/ModalPresentationContext.js +0 -5
  16. package/lib/module/utils/conditional.js +0 -28
  17. package/lib/module/utils/findLastIndex.js +0 -11
  18. package/lib/module/utils/gestureActivationCriteria.js +0 -60
  19. package/lib/module/utils/getDistanceForDirection.js +0 -15
  20. package/lib/module/utils/getInvertedMultiplier.js +0 -15
  21. package/lib/module/utils/getModalRoutesKeys.js +0 -12
  22. package/lib/module/utils/getShadowStyle.js +0 -24
  23. package/lib/module/utils/throttle.js +0 -14
  24. package/lib/module/utils/useCardAnimation.js +0 -12
  25. package/lib/module/utils/useGestureHandlerRef.js +0 -12
  26. package/lib/module/utils/useKeyboardManager.js +0 -90
  27. package/lib/module/views/GestureHandler.android.js +0 -4
  28. package/lib/module/views/GestureHandler.ios.js +0 -4
  29. package/lib/module/views/GestureHandler.js +0 -21
  30. package/lib/module/views/GestureHandler.kepler.js +0 -4
  31. package/lib/module/views/GestureHandlerNative.js +0 -18
  32. package/lib/module/views/Header/Header.js +0 -56
  33. package/lib/module/views/Header/HeaderContainer.js +0 -128
  34. package/lib/module/views/Header/HeaderSegment.js +0 -142
  35. package/lib/module/views/Screens.js +0 -42
  36. package/lib/module/views/Stack/Card.js +0 -433
  37. package/lib/module/views/Stack/CardA11yWrapper.js +0 -43
  38. package/lib/module/views/Stack/CardContainer.js +0 -276
  39. package/lib/module/views/Stack/CardContent.js +0 -74
  40. package/lib/module/views/Stack/CardStack.js +0 -498
  41. package/lib/module/views/Stack/StackView.js +0 -339
  42. package/src/TransitionConfigs/CardStyleInterpolators.tsx +0 -460
  43. package/src/TransitionConfigs/HeaderStyleInterpolators.tsx +0 -286
  44. package/src/TransitionConfigs/TransitionPresets.tsx +0 -182
  45. package/src/TransitionConfigs/TransitionSpecs.tsx +0 -124
  46. package/src/navigators/createStackNavigator.tsx +0 -120
  47. package/src/types.tsx +0 -639
  48. package/src/utils/CardAnimationContext.tsx +0 -7
  49. package/src/utils/GestureHandlerRefContext.tsx +0 -5
  50. package/src/utils/ModalPresentationContext.tsx +0 -3
  51. package/src/utils/conditional.tsx +0 -33
  52. package/src/utils/findLastIndex.tsx +0 -9
  53. package/src/utils/gestureActivationCriteria.tsx +0 -70
  54. package/src/utils/getDistanceForDirection.tsx +0 -19
  55. package/src/utils/getInvertedMultiplier.tsx +0 -17
  56. package/src/utils/getModalRoutesKeys.ts +0 -21
  57. package/src/utils/getShadowStyle.tsx +0 -37
  58. package/src/utils/throttle.tsx +0 -16
  59. package/src/utils/useCardAnimation.tsx +0 -15
  60. package/src/utils/useGestureHandlerRef.tsx +0 -15
  61. package/src/utils/useKeyboardManager.tsx +0 -103
  62. package/src/views/GestureHandler.android.tsx +0 -1
  63. package/src/views/GestureHandler.ios.tsx +0 -1
  64. package/src/views/GestureHandler.kepler.tsx +0 -1
  65. package/src/views/GestureHandler.tsx +0 -23
  66. package/src/views/GestureHandlerNative.tsx +0 -23
  67. package/src/views/Header/Header.tsx +0 -73
  68. package/src/views/Header/HeaderContainer.tsx +0 -191
  69. package/src/views/Header/HeaderSegment.tsx +0 -203
  70. package/src/views/Screens.tsx +0 -45
  71. package/src/views/Stack/Card.tsx +0 -646
  72. package/src/views/Stack/CardA11yWrapper.tsx +0 -67
  73. package/src/views/Stack/CardContainer.tsx +0 -339
  74. package/src/views/Stack/CardContent.tsx +0 -92
  75. package/src/views/Stack/CardStack.tsx +0 -849
  76. package/src/views/Stack/StackView.tsx +0 -485
@@ -1,60 +0,0 @@
1
- "use strict";
2
-
3
- import { getInvertedMultiplier } from "./getInvertedMultiplier.js";
4
-
5
- /**
6
- * The distance of touch start from the edge of the screen where the gesture will be recognized
7
- */
8
- const GESTURE_RESPONSE_DISTANCE_HORIZONTAL = 50;
9
- const GESTURE_RESPONSE_DISTANCE_VERTICAL = 135;
10
- export const gestureActivationCriteria = ({
11
- direction,
12
- gestureDirection,
13
- gestureResponseDistance,
14
- layout
15
- }) => {
16
- const enableTrackpadTwoFingerGesture = true;
17
- const distance = gestureResponseDistance !== undefined ? gestureResponseDistance : gestureDirection === 'vertical' || gestureDirection === 'vertical-inverted' ? GESTURE_RESPONSE_DISTANCE_VERTICAL : GESTURE_RESPONSE_DISTANCE_HORIZONTAL;
18
- if (gestureDirection === 'vertical') {
19
- return {
20
- maxDeltaX: 15,
21
- minOffsetY: 5,
22
- hitSlop: {
23
- bottom: -layout.height + distance
24
- },
25
- enableTrackpadTwoFingerGesture
26
- };
27
- } else if (gestureDirection === 'vertical-inverted') {
28
- return {
29
- maxDeltaX: 15,
30
- minOffsetY: -5,
31
- hitSlop: {
32
- top: -layout.height + distance
33
- },
34
- enableTrackpadTwoFingerGesture
35
- };
36
- } else {
37
- const hitSlop = -layout.width + distance;
38
- const invertedMultiplier = getInvertedMultiplier(gestureDirection, direction === 'rtl');
39
- if (invertedMultiplier === 1) {
40
- return {
41
- minOffsetX: 5,
42
- maxDeltaY: 20,
43
- hitSlop: {
44
- right: hitSlop
45
- },
46
- enableTrackpadTwoFingerGesture
47
- };
48
- } else {
49
- return {
50
- minOffsetX: -5,
51
- maxDeltaY: 20,
52
- hitSlop: {
53
- left: hitSlop
54
- },
55
- enableTrackpadTwoFingerGesture
56
- };
57
- }
58
- }
59
- };
60
- //# sourceMappingURL=gestureActivationCriteria.js.map
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- import { getInvertedMultiplier } from "./getInvertedMultiplier.js";
4
- export function getDistanceForDirection(layout, gestureDirection, isRTL) {
5
- const multiplier = getInvertedMultiplier(gestureDirection, isRTL);
6
- switch (gestureDirection) {
7
- case 'vertical':
8
- case 'vertical-inverted':
9
- return layout.height * multiplier;
10
- case 'horizontal':
11
- case 'horizontal-inverted':
12
- return layout.width * multiplier;
13
- }
14
- }
15
- //# sourceMappingURL=getDistanceForDirection.js.map
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- export function getInvertedMultiplier(gestureDirection, isRTL) {
4
- switch (gestureDirection) {
5
- case 'vertical':
6
- return 1;
7
- case 'vertical-inverted':
8
- return -1;
9
- case 'horizontal':
10
- return isRTL ? -1 : 1;
11
- case 'horizontal-inverted':
12
- return isRTL ? 1 : -1;
13
- }
14
- }
15
- //# sourceMappingURL=getInvertedMultiplier.js.map
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- export const getModalRouteKeys = (routes, descriptors) => routes.reduce((acc, route) => {
4
- const {
5
- presentation
6
- } = descriptors[route.key]?.options ?? {};
7
- if (acc.length && !presentation || presentation === 'modal' || presentation === 'transparentModal') {
8
- acc.push(route.key);
9
- }
10
- return acc;
11
- }, []);
12
- //# sourceMappingURL=getModalRoutesKeys.js.map
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- import Color from 'color';
4
- import { Platform } from 'react-native';
5
- export function getShadowStyle({
6
- offset,
7
- radius,
8
- opacity,
9
- color = '#000'
10
- }) {
11
- const result = Platform.select({
12
- web: {
13
- boxShadow: `${offset.width}px ${offset.height}px ${radius}px ${Color(color).alpha(opacity).toString()}`
14
- },
15
- default: {
16
- shadowOffset: offset,
17
- shadowRadius: radius,
18
- shadowColor: color,
19
- shadowOpacity: opacity
20
- }
21
- });
22
- return result;
23
- }
24
- //# sourceMappingURL=getShadowStyle.js.map
@@ -1,14 +0,0 @@
1
- "use strict";
2
-
3
- export function throttle(func, duration) {
4
- let timeout;
5
- return function (...args) {
6
- if (timeout == null) {
7
- func.apply(this, args);
8
- timeout = setTimeout(() => {
9
- timeout = undefined;
10
- }, duration);
11
- }
12
- };
13
- }
14
- //# sourceMappingURL=throttle.js.map
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- import * as React from 'react';
4
- import { CardAnimationContext } from "./CardAnimationContext.js";
5
- export function useCardAnimation() {
6
- const animation = React.useContext(CardAnimationContext);
7
- if (animation === undefined) {
8
- throw new Error("Couldn't find values for card animation. Are you inside a screen in Stack?");
9
- }
10
- return animation;
11
- }
12
- //# sourceMappingURL=useCardAnimation.js.map
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- import * as React from 'react';
4
- import { GestureHandlerRefContext } from "./GestureHandlerRefContext.js";
5
- export function useGestureHandlerRef() {
6
- const ref = React.useContext(GestureHandlerRefContext);
7
- if (ref === undefined) {
8
- throw new Error("Couldn't find a ref for gesture handler. Are you inside a screen in Stack?");
9
- }
10
- return ref;
11
- }
12
- //# sourceMappingURL=useGestureHandlerRef.js.map
@@ -1,90 +0,0 @@
1
- "use strict";
2
-
3
- import * as React from 'react';
4
- import { Keyboard, TextInput } from 'react-native';
5
- export function useKeyboardManager(isEnabled) {
6
- // Numeric id of the previously focused text input
7
- // When a gesture didn't change the tab, we can restore the focused input with this
8
- const previouslyFocusedTextInputRef = React.useRef(undefined);
9
- const startTimestampRef = React.useRef(0);
10
- const keyboardTimeoutRef = React.useRef(undefined);
11
- const clearKeyboardTimeout = React.useCallback(() => {
12
- if (keyboardTimeoutRef.current !== undefined) {
13
- clearTimeout(keyboardTimeoutRef.current);
14
- keyboardTimeoutRef.current = undefined;
15
- }
16
- }, []);
17
- const onPageChangeStart = React.useCallback(() => {
18
- if (!isEnabled()) {
19
- return;
20
- }
21
- clearKeyboardTimeout();
22
- const input = TextInput.State.currentlyFocusedInput();
23
-
24
- // When a page change begins, blur the currently focused input
25
- input?.blur();
26
-
27
- // Store the id of this input so we can refocus it if change was cancelled
28
- previouslyFocusedTextInputRef.current = input;
29
-
30
- // Store timestamp for touch start
31
- startTimestampRef.current = Date.now();
32
- }, [clearKeyboardTimeout, isEnabled]);
33
- const onPageChangeConfirm = React.useCallback(force => {
34
- if (!isEnabled()) {
35
- return;
36
- }
37
- clearKeyboardTimeout();
38
- if (force) {
39
- // Always dismiss input, even if we don't have a ref to it
40
- // We might not have the ref if onPageChangeStart was never called
41
- // This can happen if page change was not from a gesture
42
- Keyboard.dismiss();
43
- } else {
44
- const input = previouslyFocusedTextInputRef.current;
45
-
46
- // Dismiss the keyboard only if an input was a focused before
47
- // This makes sure we don't dismiss input on going back and focusing an input
48
- input?.blur();
49
- }
50
-
51
- // Cleanup the ID on successful page change
52
- previouslyFocusedTextInputRef.current = undefined;
53
- }, [clearKeyboardTimeout, isEnabled]);
54
- const onPageChangeCancel = React.useCallback(() => {
55
- if (!isEnabled()) {
56
- return;
57
- }
58
- clearKeyboardTimeout();
59
-
60
- // The page didn't change, we should restore the focus of text input
61
- const input = previouslyFocusedTextInputRef.current;
62
- if (input) {
63
- // If the interaction was super short we should make sure keyboard won't hide again.
64
-
65
- // Too fast input refocus will result only in keyboard flashing on screen and hiding right away.
66
- // During first ~100ms keyboard will be dismissed no matter what,
67
- // so we have to make sure it won't interrupt input refocus logic.
68
- // That's why when the interaction is shorter than 100ms we add delay so it won't hide once again.
69
- // Subtracting timestamps makes us sure the delay is executed only when needed.
70
- if (Date.now() - startTimestampRef.current < 100) {
71
- keyboardTimeoutRef.current = setTimeout(() => {
72
- input?.focus();
73
- previouslyFocusedTextInputRef.current = undefined;
74
- }, 100);
75
- } else {
76
- input?.focus();
77
- previouslyFocusedTextInputRef.current = undefined;
78
- }
79
- }
80
- }, [clearKeyboardTimeout, isEnabled]);
81
- React.useEffect(() => {
82
- return () => clearKeyboardTimeout();
83
- }, [clearKeyboardTimeout]);
84
- return {
85
- onPageChangeStart,
86
- onPageChangeConfirm,
87
- onPageChangeCancel
88
- };
89
- }
90
- //# sourceMappingURL=useKeyboardManager.js.map
@@ -1,4 +0,0 @@
1
- "use strict";
2
-
3
- export * from "./GestureHandlerNative.js";
4
- //# sourceMappingURL=GestureHandler.android.js.map
@@ -1,4 +0,0 @@
1
- "use strict";
2
-
3
- export * from "./GestureHandlerNative.js";
4
- //# sourceMappingURL=GestureHandler.ios.js.map
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- import * as React from 'react';
4
- import { View } from 'react-native';
5
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
6
- const Dummy = ({
7
- children
8
- }) => /*#__PURE__*/_jsx(_Fragment, {
9
- children: children
10
- });
11
- export const PanGestureHandler = Dummy;
12
- export const GestureHandlerRootView = View;
13
- export const GestureState = {
14
- UNDETERMINED: 0,
15
- FAILED: 1,
16
- BEGAN: 2,
17
- CANCELLED: 3,
18
- ACTIVE: 4,
19
- END: 5
20
- };
21
- //# sourceMappingURL=GestureHandler.js.map
@@ -1,4 +0,0 @@
1
- "use strict";
2
-
3
- export * from "./GestureHandlerNative.js";
4
- //# sourceMappingURL=GestureHandler.kepler.js.map
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- import * as React from 'react';
4
- import { PanGestureHandler as PanGestureHandlerNative } from '@amazon-devices/react-native-gesture-handler';
5
- import { GestureHandlerRefContext } from "../utils/GestureHandlerRefContext.js";
6
- import { jsx as _jsx } from "react/jsx-runtime";
7
- export function PanGestureHandler(props) {
8
- const gestureRef = React.useRef(null);
9
- return /*#__PURE__*/_jsx(GestureHandlerRefContext.Provider, {
10
- value: gestureRef,
11
- children: /*#__PURE__*/_jsx(PanGestureHandlerNative, {
12
- ...props,
13
- ref: gestureRef
14
- })
15
- });
16
- }
17
- export { GestureHandlerRootView, State as GestureState } from '@amazon-devices/react-native-gesture-handler';
18
- //# sourceMappingURL=GestureHandlerNative.js.map
@@ -1,56 +0,0 @@
1
- "use strict";
2
-
3
- import { getHeaderTitle, HeaderShownContext } from '@amazon-devices/react-navigation__elements';
4
- import { StackActions } from '@amazon-devices/react-navigation__native';
5
- import * as React from 'react';
6
- import { useSafeAreaInsets } from '@amazon-devices/react-native-safe-area-context';
7
- import { ModalPresentationContext } from "../../utils/ModalPresentationContext.js";
8
- import { throttle } from "../../utils/throttle.js";
9
- import { HeaderSegment } from "./HeaderSegment.js";
10
- import { jsx as _jsx } from "react/jsx-runtime";
11
- export const Header = /*#__PURE__*/React.memo(function Header({
12
- back,
13
- layout,
14
- progress,
15
- options,
16
- route,
17
- navigation,
18
- styleInterpolator
19
- }) {
20
- const insets = useSafeAreaInsets();
21
- let previousTitle;
22
-
23
- // The label for the left back button shows the title of the previous screen
24
- // If a custom label is specified, we use it, otherwise use previous screen's title
25
- if (options.headerBackTitle !== undefined) {
26
- previousTitle = options.headerBackTitle;
27
- } else if (back) {
28
- previousTitle = back.title;
29
- }
30
-
31
- // eslint-disable-next-line react-hooks/exhaustive-deps
32
- const goBack = React.useCallback(throttle(() => {
33
- if (navigation.isFocused() && navigation.canGoBack()) {
34
- navigation.dispatch({
35
- ...StackActions.pop(),
36
- source: route.key
37
- });
38
- }
39
- }, 50), [navigation, route.key]);
40
- const isModal = React.useContext(ModalPresentationContext);
41
- const isParentHeaderShown = React.useContext(HeaderShownContext);
42
- const statusBarHeight = options.headerStatusBarHeight !== undefined ? options.headerStatusBarHeight : isModal || isParentHeaderShown ? 0 : insets.top;
43
- return /*#__PURE__*/_jsx(HeaderSegment, {
44
- ...options,
45
- title: getHeaderTitle(options, route.name),
46
- progress: progress,
47
- layout: layout,
48
- modal: isModal,
49
- headerBackTitle: options.headerBackTitle !== undefined ? options.headerBackTitle : previousTitle,
50
- headerStatusBarHeight: statusBarHeight,
51
- onGoBack: back ? goBack : undefined,
52
- backHref: back ? back.href : undefined,
53
- styleInterpolator: styleInterpolator
54
- });
55
- });
56
- //# sourceMappingURL=Header.js.map
@@ -1,128 +0,0 @@
1
- "use strict";
2
-
3
- import { getHeaderTitle, HeaderBackContext } from '@amazon-devices/react-navigation__elements';
4
- import { NavigationContext, NavigationRouteContext, useLinkBuilder } from '@amazon-devices/react-navigation__native';
5
- import * as React from 'react';
6
- import { StyleSheet, View } from 'react-native';
7
- import { forNoAnimation, forSlideLeft, forSlideRight, forSlideUp } from "../../TransitionConfigs/HeaderStyleInterpolators.js";
8
- import { Header } from "./Header.js";
9
- import { jsx as _jsx } from "react/jsx-runtime";
10
- export function HeaderContainer({
11
- mode,
12
- scenes,
13
- layout,
14
- getPreviousScene,
15
- getFocusedRoute,
16
- onContentHeightChange,
17
- style
18
- }) {
19
- const focusedRoute = getFocusedRoute();
20
- const parentHeaderBack = React.useContext(HeaderBackContext);
21
- const {
22
- buildHref
23
- } = useLinkBuilder();
24
- return /*#__PURE__*/_jsx(View, {
25
- pointerEvents: "box-none",
26
- style: style,
27
- children: scenes.slice(-2).map((scene, i, self) => {
28
- if (mode === 'screen' && i !== self.length - 1 || !scene) {
29
- return null;
30
- }
31
- const {
32
- header,
33
- headerMode,
34
- headerShown = true,
35
- headerTransparent,
36
- headerStyleInterpolator
37
- } = scene.descriptor.options;
38
- if (headerMode !== mode || !headerShown) {
39
- return null;
40
- }
41
- const isFocused = focusedRoute.key === scene.descriptor.route.key;
42
- const previousScene = getPreviousScene({
43
- route: scene.descriptor.route
44
- });
45
- let headerBack = parentHeaderBack;
46
- if (previousScene) {
47
- const {
48
- options,
49
- route
50
- } = previousScene.descriptor;
51
- headerBack = previousScene ? {
52
- title: getHeaderTitle(options, route.name),
53
- href: buildHref(route.name, route.params)
54
- } : parentHeaderBack;
55
- }
56
-
57
- // If the screen is next to a headerless screen, we need to make the header appear static
58
- // This makes the header look like it's moving with the screen
59
- const previousDescriptor = self[i - 1]?.descriptor;
60
- const nextDescriptor = self[i + 1]?.descriptor;
61
- const {
62
- headerShown: previousHeaderShown = true,
63
- headerMode: previousHeaderMode
64
- } = previousDescriptor?.options || {};
65
-
66
- // If any of the next screens don't have a header or header is part of the screen
67
- // Then we need to move this header offscreen so that it doesn't cover it
68
- const nextHeaderlessScene = self.slice(i + 1).find(scene => {
69
- const {
70
- headerShown: currentHeaderShown = true,
71
- headerMode: currentHeaderMode
72
- } = scene?.descriptor.options || {};
73
- return currentHeaderShown === false || currentHeaderMode === 'screen';
74
- });
75
- const {
76
- gestureDirection: nextHeaderlessGestureDirection
77
- } = nextHeaderlessScene?.descriptor.options || {};
78
- const isHeaderStatic = (previousHeaderShown === false || previousHeaderMode === 'screen') &&
79
- // We still need to animate when coming back from next scene
80
- // A hacky way to check this is if the next scene exists
81
- !nextDescriptor || nextHeaderlessScene;
82
- const props = {
83
- layout,
84
- back: headerBack,
85
- progress: scene.progress,
86
- options: scene.descriptor.options,
87
- route: scene.descriptor.route,
88
- navigation: scene.descriptor.navigation,
89
- styleInterpolator: mode === 'float' ? isHeaderStatic ? nextHeaderlessGestureDirection === 'vertical' || nextHeaderlessGestureDirection === 'vertical-inverted' ? forSlideUp : nextHeaderlessGestureDirection === 'horizontal-inverted' ? forSlideRight : forSlideLeft : headerStyleInterpolator : forNoAnimation
90
- };
91
- return /*#__PURE__*/_jsx(NavigationContext.Provider, {
92
- value: scene.descriptor.navigation,
93
- children: /*#__PURE__*/_jsx(NavigationRouteContext.Provider, {
94
- value: scene.descriptor.route,
95
- children: /*#__PURE__*/_jsx(View, {
96
- onLayout: onContentHeightChange ? e => {
97
- const {
98
- height
99
- } = e.nativeEvent.layout;
100
- onContentHeightChange({
101
- route: scene.descriptor.route,
102
- height
103
- });
104
- } : undefined,
105
- pointerEvents: isFocused ? 'box-none' : 'none',
106
- "aria-hidden": !isFocused,
107
- style:
108
- // Avoid positioning the focused header absolutely
109
- // Otherwise accessibility tools don't seem to be able to find it
110
- mode === 'float' && !isFocused || headerTransparent ? styles.header : null,
111
- children: header !== undefined ? header(props) : /*#__PURE__*/_jsx(Header, {
112
- ...props
113
- })
114
- })
115
- })
116
- }, scene.descriptor.route.key);
117
- })
118
- });
119
- }
120
- const styles = StyleSheet.create({
121
- header: {
122
- position: 'absolute',
123
- top: 0,
124
- start: 0,
125
- end: 0
126
- }
127
- });
128
- //# sourceMappingURL=HeaderContainer.js.map
@@ -1,142 +0,0 @@
1
- "use strict";
2
-
3
- import { getDefaultHeaderHeight, Header, HeaderBackButton, HeaderTitle } from '@amazon-devices/react-navigation__elements';
4
- import { useLocale } from '@amazon-devices/react-navigation__native';
5
- import * as React from 'react';
6
- import { Platform, StyleSheet } from 'react-native';
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- export function HeaderSegment(props) {
9
- const {
10
- direction
11
- } = useLocale();
12
- const [leftLabelLayout, setLeftLabelLayout] = React.useState(undefined);
13
- const [titleLayout, setTitleLayout] = React.useState(undefined);
14
- const handleTitleLayout = e => {
15
- const {
16
- height,
17
- width
18
- } = e.nativeEvent.layout;
19
- setTitleLayout(titleLayout => {
20
- if (titleLayout && height === titleLayout.height && width === titleLayout.width) {
21
- return titleLayout;
22
- }
23
- return {
24
- height,
25
- width
26
- };
27
- });
28
- };
29
- const handleLeftLabelLayout = e => {
30
- const {
31
- height,
32
- width
33
- } = e.nativeEvent.layout;
34
- if (leftLabelLayout && height === leftLabelLayout.height && width === leftLabelLayout.width) {
35
- return;
36
- }
37
- setLeftLabelLayout({
38
- height,
39
- width
40
- });
41
- };
42
- const {
43
- progress,
44
- layout,
45
- modal,
46
- onGoBack,
47
- backHref,
48
- headerTitle: title,
49
- headerLeft: left = onGoBack ? props => /*#__PURE__*/_jsx(HeaderBackButton, {
50
- ...props
51
- }) : undefined,
52
- headerRight: right,
53
- headerBackImage,
54
- headerBackTitle,
55
- headerBackButtonDisplayMode = Platform.OS === 'ios' ? 'default' : 'minimal',
56
- headerBackTruncatedTitle,
57
- headerBackAccessibilityLabel,
58
- headerBackTestID,
59
- headerBackAllowFontScaling,
60
- headerBackTitleStyle,
61
- headerTitleContainerStyle,
62
- headerLeftContainerStyle,
63
- headerRightContainerStyle,
64
- headerBackgroundContainerStyle,
65
- headerStyle: customHeaderStyle,
66
- headerStatusBarHeight,
67
- styleInterpolator,
68
- ...rest
69
- } = props;
70
- const defaultHeight = getDefaultHeaderHeight(layout, modal, headerStatusBarHeight);
71
- const {
72
- height = defaultHeight
73
- } = StyleSheet.flatten(customHeaderStyle || {});
74
- const headerHeight = typeof height === 'number' ? height : defaultHeight;
75
- const {
76
- titleStyle,
77
- leftButtonStyle,
78
- leftLabelStyle,
79
- rightButtonStyle,
80
- backgroundStyle
81
- } = React.useMemo(() => styleInterpolator({
82
- current: {
83
- progress: progress.current
84
- },
85
- next: progress.next && {
86
- progress: progress.next
87
- },
88
- direction,
89
- layouts: {
90
- header: {
91
- height: headerHeight,
92
- width: layout.width
93
- },
94
- screen: layout,
95
- title: titleLayout,
96
- leftLabel: leftLabelLayout
97
- }
98
- }), [styleInterpolator, progress, direction, headerHeight, layout, titleLayout, leftLabelLayout]);
99
- const headerLeft = left ? props => left({
100
- ...props,
101
- href: backHref,
102
- backImage: headerBackImage,
103
- accessibilityLabel: headerBackAccessibilityLabel,
104
- testID: headerBackTestID,
105
- allowFontScaling: headerBackAllowFontScaling,
106
- onPress: onGoBack,
107
- label: headerBackTitle,
108
- truncatedLabel: headerBackTruncatedTitle,
109
- labelStyle: [leftLabelStyle, headerBackTitleStyle],
110
- onLabelLayout: handleLeftLabelLayout,
111
- screenLayout: layout,
112
- titleLayout,
113
- canGoBack: Boolean(onGoBack)
114
- }) : undefined;
115
- const headerRight = right ? props => right({
116
- ...props,
117
- canGoBack: Boolean(onGoBack)
118
- }) : undefined;
119
- const headerTitle = typeof title !== 'function' ? props => /*#__PURE__*/_jsx(HeaderTitle, {
120
- ...props,
121
- onLayout: handleTitleLayout
122
- }) : props => title({
123
- ...props,
124
- onLayout: handleTitleLayout
125
- });
126
- return /*#__PURE__*/_jsx(Header, {
127
- modal: modal,
128
- layout: layout,
129
- headerTitle: headerTitle,
130
- headerLeft: headerLeft,
131
- headerRight: headerRight,
132
- headerTitleContainerStyle: [titleStyle, headerTitleContainerStyle],
133
- headerLeftContainerStyle: [leftButtonStyle, headerLeftContainerStyle],
134
- headerRightContainerStyle: [rightButtonStyle, headerRightContainerStyle],
135
- headerBackButtonDisplayMode: headerBackButtonDisplayMode,
136
- headerBackgroundContainerStyle: [backgroundStyle, headerBackgroundContainerStyle],
137
- headerStyle: customHeaderStyle,
138
- headerStatusBarHeight: headerStatusBarHeight,
139
- ...rest
140
- });
141
- }
142
- //# sourceMappingURL=HeaderSegment.js.map