@momo-kits/foundation 0.169.7-beta.7 → 0.169.7-beta.9
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/Application/Components/HeaderAnimated.tsx +13 -37
- package/Application/Components/HeaderBackground.tsx +3 -16
- package/Application/Components/HeaderExtendHeader.tsx +28 -41
- package/Application/Components/HeaderLeft.tsx +18 -4
- package/Application/Components/HeaderRight.styles.ts +13 -15
- package/Application/Components/HeaderTitle.shared.ts +11 -10
- package/Application/Components/HeaderToolkitAction.tsx +37 -12
- package/Application/Components/NavigationButton.tsx +6 -9
- package/Application/Components/SearchHeader.tsx +7 -20
- package/Application/StackScreen.tsx +0 -9
- package/Application/index.ts +1 -11
- package/Application/navigationOptions.tsx +15 -6
- package/Application/types.header.ts +2 -7
- package/Application/types.ts +0 -7
- package/Input/InputSearch.tsx +2 -18
- package/Input/index.tsx +1 -7
- package/Layout/Card.tsx +10 -10
- package/Layout/Item.tsx +2 -2
- package/Layout/Screen.tsx +0 -3
- package/Layout/Section.tsx +8 -9
- package/Layout/constants.ts +19 -0
- package/Layout/screenHeader.tsx +52 -55
- package/Layout/screenTypes.ts +2 -10
- package/Layout/types.ts +37 -1
- package/Layout/useGridSystem.ts +49 -0
- package/Layout/utils.ts +0 -8
- package/package.json +1 -1
- package/Application/headerLayout.ts +0 -158
|
@@ -8,7 +8,6 @@ import { SwipeBackHaptic } from './Components/SwipeBackHaptic';
|
|
|
8
8
|
import { useAppState } from './hooks';
|
|
9
9
|
import { createScreenTracking } from './StackScreen.tracking';
|
|
10
10
|
import { TooltipPortalHost, TooltipPortalProvider } from './TooltipPortal';
|
|
11
|
-
import { useHeaderFrameOptions } from './headerLayout';
|
|
12
11
|
|
|
13
12
|
const runAfterInteractions = InteractionManager.runAfterInteractions;
|
|
14
13
|
|
|
@@ -52,7 +51,6 @@ const StackScreen: React.FC<any> = props => {
|
|
|
52
51
|
const navigation = useRef(new Navigation(props.navigation, context)).current;
|
|
53
52
|
const heightHeader = useHeaderHeight();
|
|
54
53
|
const { isBackgroundToForeground } = useAppState();
|
|
55
|
-
const headerFrameOptions = useHeaderFrameOptions(options?.contentLayout);
|
|
56
54
|
|
|
57
55
|
const data = {
|
|
58
56
|
...initialParams,
|
|
@@ -71,13 +69,6 @@ const StackScreen: React.FC<any> = props => {
|
|
|
71
69
|
}
|
|
72
70
|
}, [navigation, options]);
|
|
73
71
|
|
|
74
|
-
// re-applied on fold, unfold and rotation, apart from the other options
|
|
75
|
-
useLayoutEffect(() => {
|
|
76
|
-
if (headerFrameOptions) {
|
|
77
|
-
navigation.instance.setOptions(headerFrameOptions);
|
|
78
|
-
}
|
|
79
|
-
}, [navigation, headerFrameOptions]);
|
|
80
|
-
|
|
81
72
|
useEffect(() => {
|
|
82
73
|
let focusScreen: any;
|
|
83
74
|
let onFocusApp: any;
|
package/Application/index.ts
CHANGED
|
@@ -26,13 +26,6 @@ import {
|
|
|
26
26
|
type ModalLayout,
|
|
27
27
|
type ModalRect,
|
|
28
28
|
} from './modalLayout';
|
|
29
|
-
import {
|
|
30
|
-
HeaderBarMetrics,
|
|
31
|
-
getHeaderLayout,
|
|
32
|
-
useHeaderLayout,
|
|
33
|
-
type HeaderContentLayout,
|
|
34
|
-
type HeaderLayout,
|
|
35
|
-
} from './headerLayout';
|
|
36
29
|
|
|
37
30
|
export {
|
|
38
31
|
NavigationContainer,
|
|
@@ -48,9 +41,6 @@ export {
|
|
|
48
41
|
useTooltipPortal,
|
|
49
42
|
getModalLayout,
|
|
50
43
|
useModalLayout,
|
|
51
|
-
HeaderBarMetrics,
|
|
52
|
-
getHeaderLayout,
|
|
53
|
-
useHeaderLayout,
|
|
54
44
|
};
|
|
55
45
|
|
|
56
|
-
export type { ModalLayout, ModalRect
|
|
46
|
+
export type { ModalLayout, ModalRect };
|
|
@@ -8,12 +8,11 @@ import {
|
|
|
8
8
|
TransitionPresets,
|
|
9
9
|
} from '@react-navigation/stack';
|
|
10
10
|
import type { SharedValue } from 'react-native-reanimated';
|
|
11
|
-
import { Colors } from '../Consts';
|
|
11
|
+
import { Colors, Spacing } from '../Consts';
|
|
12
12
|
import { HeaderBackground } from './Components/HeaderBackground';
|
|
13
13
|
import { HeaderLeft } from './Components/HeaderLeft';
|
|
14
14
|
import { HeaderRight } from './Components/HeaderRight';
|
|
15
15
|
import { HeaderTitle, TitleCustom } from './Components/HeaderTitle';
|
|
16
|
-
import { HeaderBarMetrics, TITLE_CONTAINER_RESET } from './headerLayout';
|
|
17
16
|
import type { HeaderTitleProps, NavigationOptions } from './types';
|
|
18
17
|
|
|
19
18
|
const CARD_SHADOW_OPACITY = 0.3;
|
|
@@ -56,8 +55,13 @@ const getStackOptions = (): StackNavigationOptions => {
|
|
|
56
55
|
headerTitleAlign: 'left',
|
|
57
56
|
headerTitle: props => <HeaderTitle {...props} />,
|
|
58
57
|
headerTitleContainerStyle: {
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
marginLeft: 0,
|
|
59
|
+
marginEnd: 0,
|
|
60
|
+
marginStart: 0,
|
|
61
|
+
marginHorizontal: 0,
|
|
62
|
+
marginVertical: 0,
|
|
63
|
+
margin: 0,
|
|
64
|
+
left: Spacing.S,
|
|
61
65
|
},
|
|
62
66
|
headerBackground: (props: any) => <HeaderBackground {...props} />,
|
|
63
67
|
headerLeft: (props: any) => <HeaderLeft {...props} floating />,
|
|
@@ -168,8 +172,13 @@ const getOptions = (
|
|
|
168
172
|
if (params.hiddenBack) {
|
|
169
173
|
headerLeft = null;
|
|
170
174
|
options.headerTitleContainerStyle = {
|
|
171
|
-
|
|
172
|
-
|
|
175
|
+
marginLeft: 0,
|
|
176
|
+
marginEnd: 0,
|
|
177
|
+
marginStart: 0,
|
|
178
|
+
marginHorizontal: 0,
|
|
179
|
+
marginVertical: 0,
|
|
180
|
+
margin: 0,
|
|
181
|
+
left: Spacing.M,
|
|
173
182
|
};
|
|
174
183
|
}
|
|
175
184
|
options = {
|
|
@@ -98,11 +98,6 @@ export interface HeaderAnimatedProps extends ViewProps {
|
|
|
98
98
|
image: string;
|
|
99
99
|
useScale?: boolean;
|
|
100
100
|
aspectRatio?: '16/9' | '3/2' | '1/1';
|
|
101
|
-
/**
|
|
102
|
-
* Optional. On wide windows the image keeps its phone width, centered; this
|
|
103
|
-
* color fills the sides and fades to transparent downward. No fill when unset.
|
|
104
|
-
*/
|
|
105
|
-
bannerBackgroundColor?: string;
|
|
106
101
|
}
|
|
107
102
|
|
|
108
103
|
export type AnimatedHeader = {
|
|
@@ -114,8 +109,8 @@ export type AnimatedHeader = {
|
|
|
114
109
|
export interface SearchHeaderProps extends InputSearchProps {
|
|
115
110
|
ref?: React.RefObject<InputRef>;
|
|
116
111
|
animatedValue?: Animated.Value | SharedValue<number>;
|
|
117
|
-
headerRightWidth?: 0 |
|
|
118
|
-
leftPosition?: 12 |
|
|
112
|
+
headerRightWidth?: 0 | 74 | 110 | number;
|
|
113
|
+
leftPosition?: 12 | 48 | number;
|
|
119
114
|
renderButtons?: () => ReactNode;
|
|
120
115
|
hiddenBack?: boolean;
|
|
121
116
|
}
|
package/Application/types.ts
CHANGED
|
@@ -9,7 +9,6 @@ import type {
|
|
|
9
9
|
OnBoarding,
|
|
10
10
|
} from './types.header';
|
|
11
11
|
import type { LocalizeProps, Theme } from './types.theme';
|
|
12
|
-
import type { HeaderContentLayout } from './headerLayout';
|
|
13
12
|
|
|
14
13
|
export * from './types.theme';
|
|
15
14
|
export * from './types.header';
|
|
@@ -129,10 +128,4 @@ export interface NavigationOptions
|
|
|
129
128
|
hiddenBack?: boolean;
|
|
130
129
|
headerTitle?: HeaderTitleProps | string;
|
|
131
130
|
headerRight?: OnBoarding | HeaderRightToolkit | any;
|
|
132
|
-
/**
|
|
133
|
-
* Optional. `stretch` centers back, title and the right cluster in a 600pt
|
|
134
|
-
* frame on wide windows (foldable inner display, tablet); the background stays
|
|
135
|
-
* full width. Defaults to `grid`, the header row at the window edges.
|
|
136
|
-
*/
|
|
137
|
-
contentLayout?: HeaderContentLayout;
|
|
138
131
|
}
|
package/Input/InputSearch.tsx
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
View,
|
|
14
14
|
} from 'react-native';
|
|
15
15
|
import { useComponentId } from '../Application';
|
|
16
|
-
import { HeaderBarMetrics } from '../Application/headerLayout';
|
|
17
16
|
import {
|
|
18
17
|
ApplicationContext,
|
|
19
18
|
ComponentContext,
|
|
@@ -27,8 +26,6 @@ import styles from './styles';
|
|
|
27
26
|
import { Styles } from '../Consts';
|
|
28
27
|
import SystemTextInput from './SystemTextInput';
|
|
29
28
|
|
|
30
|
-
const SEARCH_ICON_SIZE = 24;
|
|
31
|
-
|
|
32
29
|
/**
|
|
33
30
|
* Search field with search icon, clear icon, optional trailing icon and a
|
|
34
31
|
* cancel button; with `typingData` it shows an animated placeholder instead.
|
|
@@ -52,7 +49,6 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
|
|
|
52
49
|
backgroundColor,
|
|
53
50
|
onPress,
|
|
54
51
|
typingData,
|
|
55
|
-
size = 'default',
|
|
56
52
|
...props
|
|
57
53
|
},
|
|
58
54
|
ref,
|
|
@@ -63,13 +59,6 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
|
|
|
63
59
|
const searchFontFamily = exportFontFamily('regular');
|
|
64
60
|
|
|
65
61
|
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
66
|
-
const isHeaderSize = size === 'header';
|
|
67
|
-
const inputHeightStyle = isHeaderSize && {
|
|
68
|
-
height: HeaderBarMetrics.searchHeight,
|
|
69
|
-
};
|
|
70
|
-
const searchIconSize = isHeaderSize
|
|
71
|
-
? HeaderBarMetrics.iconSize
|
|
72
|
-
: SEARCH_ICON_SIZE;
|
|
73
62
|
|
|
74
63
|
const [focused, setFocused] = useState(false);
|
|
75
64
|
const [internalText, setInternalText] = useState(defaultValue || '');
|
|
@@ -125,11 +114,7 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
|
|
|
125
114
|
if (typingData && typingData?.length > 0) {
|
|
126
115
|
return (
|
|
127
116
|
<TouchableOpacity
|
|
128
|
-
style={[
|
|
129
|
-
styles.searchInput,
|
|
130
|
-
styles.searchInputTyping,
|
|
131
|
-
inputHeightStyle,
|
|
132
|
-
]}
|
|
117
|
+
style={[styles.searchInput, styles.searchInputTyping]}
|
|
133
118
|
onPress={onPress}
|
|
134
119
|
activeOpacity={onPress ? 0.6 : 1}
|
|
135
120
|
>
|
|
@@ -147,7 +132,6 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
|
|
|
147
132
|
ref={inputRef}
|
|
148
133
|
style={[
|
|
149
134
|
styles.searchInput,
|
|
150
|
-
inputHeightStyle,
|
|
151
135
|
{
|
|
152
136
|
fontSize: scaledFontSize,
|
|
153
137
|
color: theme.colors.text.default,
|
|
@@ -241,7 +225,7 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
|
|
|
241
225
|
>
|
|
242
226
|
<Icon
|
|
243
227
|
source={'navigation_search'}
|
|
244
|
-
size={
|
|
228
|
+
size={24}
|
|
245
229
|
color={theme.colors.text.hint}
|
|
246
230
|
/>
|
|
247
231
|
{renderInputView()}
|
package/Input/index.tsx
CHANGED
|
@@ -194,12 +194,6 @@ export interface InputSearchProps extends TextInputProps {
|
|
|
194
194
|
*/
|
|
195
195
|
typingData?: string[];
|
|
196
196
|
|
|
197
|
-
/**
|
|
198
|
-
* Optional. `header` is the 32pt field with a 20pt search icon that sits in the
|
|
199
|
-
* navigation header. Defaults to `default`, the 36pt field for content.
|
|
200
|
-
*/
|
|
201
|
-
size?: 'default' | 'header';
|
|
202
|
-
|
|
203
197
|
/**
|
|
204
198
|
* Optional. Called when the field is pressed while showing `typingData`.
|
|
205
199
|
*/
|
|
@@ -373,4 +367,4 @@ export {
|
|
|
373
367
|
InputPhoneNumber,
|
|
374
368
|
};
|
|
375
369
|
|
|
376
|
-
export {
|
|
370
|
+
export {checkValidPhoneNumber};
|
package/Layout/Card.tsx
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
2
|
import { View, ViewProps } from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import { GRID_GUTTER, GRID_MARGIN } from './constants';
|
|
4
|
+
import { useGridSystem } from './useGridSystem';
|
|
4
5
|
import { GridContextProps } from './types';
|
|
5
6
|
import { GridContext } from './index';
|
|
6
7
|
import { Image } from '../Image';
|
|
7
8
|
import { ApplicationContext } from '../Context';
|
|
8
9
|
import styles from './styles';
|
|
9
|
-
import { Radius, Shadow
|
|
10
|
+
import { Radius, Shadow } from '../Consts';
|
|
10
11
|
|
|
11
12
|
export interface CardProps extends ViewProps {
|
|
12
13
|
/**
|
|
@@ -21,7 +22,7 @@ export interface CardProps extends ViewProps {
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
|
-
* Surface card across the
|
|
25
|
+
* Surface card across the grid width minus 12pt margins, with its own grid for child
|
|
25
26
|
* Items; optional background image and light shadow.
|
|
26
27
|
*/
|
|
27
28
|
const Card: React.FC<CardProps> = ({
|
|
@@ -32,19 +33,18 @@ const Card: React.FC<CardProps> = ({
|
|
|
32
33
|
...props
|
|
33
34
|
}) => {
|
|
34
35
|
const { theme } = useContext(ApplicationContext);
|
|
35
|
-
const { numberOfColumns } = useGridSystem();
|
|
36
|
-
const { contentWidth } = useScreenLayout();
|
|
36
|
+
const { numberOfColumns, gridWidth, gridOffset } = useGridSystem();
|
|
37
37
|
|
|
38
|
-
const gutterSize =
|
|
39
|
-
const margin =
|
|
40
|
-
const widthSection =
|
|
38
|
+
const gutterSize = GRID_GUTTER;
|
|
39
|
+
const margin = GRID_MARGIN;
|
|
40
|
+
const widthSection = gridWidth - margin * 2;
|
|
41
41
|
const innerWidth = widthSection - margin * 2;
|
|
42
42
|
const columnsWidth = innerWidth - gutterSize * (numberOfColumns - 1);
|
|
43
43
|
const sizePerSpan = columnsWidth / numberOfColumns - 1 / numberOfColumns;
|
|
44
44
|
|
|
45
45
|
const gridContext: GridContextProps = {
|
|
46
46
|
numberOfColumns,
|
|
47
|
-
gutterSize:
|
|
47
|
+
gutterSize: GRID_GUTTER,
|
|
48
48
|
sizePerSpan,
|
|
49
49
|
getSizeSpan: span => {
|
|
50
50
|
return sizePerSpan * span + gutterSize * (span - 1);
|
|
@@ -63,7 +63,7 @@ const Card: React.FC<CardProps> = ({
|
|
|
63
63
|
styles.card,
|
|
64
64
|
{
|
|
65
65
|
width: widthSection,
|
|
66
|
-
marginHorizontal: margin,
|
|
66
|
+
marginHorizontal: gridOffset + margin,
|
|
67
67
|
gap: gutterSize,
|
|
68
68
|
},
|
|
69
69
|
!!backgroundImage && { backgroundColor: undefined },
|
package/Layout/Item.tsx
CHANGED
|
@@ -7,12 +7,12 @@ import { SpanNumber } from './types';
|
|
|
7
7
|
|
|
8
8
|
export interface ItemProps extends ViewProps {
|
|
9
9
|
/**
|
|
10
|
-
* Width in grid columns (1-12). Defaults to the full row.
|
|
10
|
+
* Width in grid columns (1-36, out of the grid's 12, 24 or 36). Defaults to the full row.
|
|
11
11
|
*/
|
|
12
12
|
widthSpan?: SpanNumber;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Optional. Height in grid spans (1-12). Unset keeps the content height.
|
|
15
|
+
* Optional. Height in grid spans (1-36, out of the grid's 12, 24 or 36). Unset keeps the content height.
|
|
16
16
|
*/
|
|
17
17
|
heightSpan?: SpanNumber;
|
|
18
18
|
}
|
package/Layout/Screen.tsx
CHANGED
|
@@ -67,7 +67,6 @@ const Screen = forwardRef(
|
|
|
67
67
|
headerBackground,
|
|
68
68
|
gradientColor,
|
|
69
69
|
trackingParams,
|
|
70
|
-
contentLayout,
|
|
71
70
|
}: ScreenProps,
|
|
72
71
|
ref: any,
|
|
73
72
|
) => {
|
|
@@ -145,7 +144,6 @@ const Screen = forwardRef(
|
|
|
145
144
|
gradientColor,
|
|
146
145
|
headerBackground,
|
|
147
146
|
layoutOffset,
|
|
148
|
-
contentLayout,
|
|
149
147
|
});
|
|
150
148
|
|
|
151
149
|
// mutates the content node so callers keep its methods plus the header setters
|
|
@@ -225,7 +223,6 @@ const Screen = forwardRef(
|
|
|
225
223
|
useShadowHeader={useShadowHeader}
|
|
226
224
|
gradientColor={gradientColor}
|
|
227
225
|
headerBackground={headerBackground}
|
|
228
|
-
contentLayout={contentLayout}
|
|
229
226
|
/>
|
|
230
227
|
);
|
|
231
228
|
};
|
package/Layout/Section.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View, ViewProps } from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import { GRID_GUTTER, GRID_MARGIN } from './constants';
|
|
4
|
+
import { useGridSystem } from './useGridSystem';
|
|
4
5
|
import { GridContextProps } from './types';
|
|
5
6
|
import { GridContext } from './index';
|
|
6
7
|
import styles from './styles';
|
|
7
8
|
import { Image } from '../Image';
|
|
8
|
-
import { Spacing } from '../Consts';
|
|
9
9
|
|
|
10
10
|
export interface SectionProps extends ViewProps {
|
|
11
11
|
/**
|
|
@@ -37,22 +37,21 @@ const Section: React.FC<SectionProps> = ({
|
|
|
37
37
|
style,
|
|
38
38
|
...props
|
|
39
39
|
}) => {
|
|
40
|
-
const { numberOfColumns } = useGridSystem();
|
|
41
|
-
const { contentWidth } = useScreenLayout();
|
|
40
|
+
const { numberOfColumns, gridWidth, gridOffset } = useGridSystem();
|
|
42
41
|
|
|
43
|
-
const gutterSize =
|
|
42
|
+
const gutterSize = GRID_GUTTER;
|
|
44
43
|
let margin = 0;
|
|
45
44
|
if (useMargin) {
|
|
46
|
-
margin =
|
|
45
|
+
margin = GRID_MARGIN;
|
|
47
46
|
}
|
|
48
|
-
const widthSection =
|
|
47
|
+
const widthSection = gridWidth - margin * 2;
|
|
49
48
|
|
|
50
49
|
const columnsWidth = widthSection - gutterSize * (numberOfColumns - 1);
|
|
51
50
|
const sizePerSpan = columnsWidth / numberOfColumns - 1 / numberOfColumns;
|
|
52
51
|
|
|
53
52
|
const gridContext: GridContextProps = {
|
|
54
53
|
numberOfColumns,
|
|
55
|
-
gutterSize:
|
|
54
|
+
gutterSize: GRID_GUTTER,
|
|
56
55
|
sizePerSpan,
|
|
57
56
|
getSizeSpan: span => {
|
|
58
57
|
return span * sizePerSpan + gutterSize * (span - 1);
|
|
@@ -70,7 +69,7 @@ const Section: React.FC<SectionProps> = ({
|
|
|
70
69
|
styles.rowWrap,
|
|
71
70
|
{
|
|
72
71
|
width: widthSection,
|
|
73
|
-
marginHorizontal: margin,
|
|
72
|
+
marginHorizontal: gridOffset + margin,
|
|
74
73
|
gap: gutterSize,
|
|
75
74
|
},
|
|
76
75
|
]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const GRID_MARGIN = 12;
|
|
2
|
+
const GRID_GUTTER = 12;
|
|
3
|
+
const GRID_PHONE_MAX_WIDTH = 600;
|
|
4
|
+
const GRID_TABLET_MIN_WIDTH = 800;
|
|
5
|
+
const GRID_DESKTOP_MIN_WIDTH = 1100;
|
|
6
|
+
const GRID_PHONE_COLUMNS = 12;
|
|
7
|
+
const GRID_TABLET_COLUMNS = 24;
|
|
8
|
+
const GRID_DESKTOP_COLUMNS = 36;
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
GRID_DESKTOP_COLUMNS,
|
|
12
|
+
GRID_DESKTOP_MIN_WIDTH,
|
|
13
|
+
GRID_GUTTER,
|
|
14
|
+
GRID_MARGIN,
|
|
15
|
+
GRID_PHONE_COLUMNS,
|
|
16
|
+
GRID_PHONE_MAX_WIDTH,
|
|
17
|
+
GRID_TABLET_COLUMNS,
|
|
18
|
+
GRID_TABLET_MIN_WIDTH,
|
|
19
|
+
};
|
package/Layout/screenHeader.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef } from 'react';
|
|
2
2
|
import { StatusBar, StatusBarStyle } from 'react-native';
|
|
3
3
|
import { StackNavigationOptions } from '@react-navigation/stack';
|
|
4
|
-
import type { SharedValue } from 'react-native-reanimated';
|
|
5
4
|
import Navigation from '../Application/Navigation';
|
|
6
5
|
import { AnimatedHeader, SearchHeaderProps } from '../Application/types';
|
|
7
6
|
import { exportHeaderTitle } from '../Application/navigationOptions';
|
|
@@ -13,11 +12,6 @@ import {
|
|
|
13
12
|
SearchHeader,
|
|
14
13
|
} from '../Application';
|
|
15
14
|
import { DuoGlassBackground } from '../Application/Components/DuoGlassBackground';
|
|
16
|
-
import {
|
|
17
|
-
type HeaderContentLayout,
|
|
18
|
-
useHeaderFrameOptions,
|
|
19
|
-
useHeaderLayout,
|
|
20
|
-
} from '../Application/headerLayout';
|
|
21
15
|
import { getHeaderMargin } from './utils';
|
|
22
16
|
import { ANIMATED_BANNER_HEIGHT } from './screenTypes';
|
|
23
17
|
import { HeaderType } from './types';
|
|
@@ -35,31 +29,6 @@ type ScreenHeaderParams = {
|
|
|
35
29
|
gradientColor?: string;
|
|
36
30
|
headerBackground?: string;
|
|
37
31
|
layoutOffset: number;
|
|
38
|
-
contentLayout?: HeaderContentLayout;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Transparent header for an `inputSearchProps` Screen: its title fades out over the
|
|
43
|
-
* first 50pt of scroll while the search collapses into the bar.
|
|
44
|
-
*/
|
|
45
|
-
const getSearchTitleOptions = (
|
|
46
|
-
sharedValue: SharedValue<number>,
|
|
47
|
-
): StackNavigationOptions => {
|
|
48
|
-
return {
|
|
49
|
-
headerShown: true,
|
|
50
|
-
headerTransparent: true,
|
|
51
|
-
headerBackground: () => null,
|
|
52
|
-
headerTitle: (props: any) => (
|
|
53
|
-
<HeaderTitle
|
|
54
|
-
{...props}
|
|
55
|
-
interpolate={{
|
|
56
|
-
inputRange: [0, 50],
|
|
57
|
-
outputRange: [1, 0],
|
|
58
|
-
}}
|
|
59
|
-
animatedValue={sharedValue}
|
|
60
|
-
/>
|
|
61
|
-
),
|
|
62
|
-
};
|
|
63
32
|
};
|
|
64
33
|
|
|
65
34
|
/**
|
|
@@ -79,12 +48,9 @@ export const useScreenHeader = ({
|
|
|
79
48
|
gradientColor,
|
|
80
49
|
headerBackground,
|
|
81
50
|
layoutOffset,
|
|
82
|
-
contentLayout,
|
|
83
51
|
}: ScreenHeaderParams) => {
|
|
84
52
|
const currentTint = useRef<string | undefined>(undefined);
|
|
85
53
|
const appliedHeaderMode = useRef<string | undefined>(undefined);
|
|
86
|
-
const headerLayout = useHeaderLayout(contentLayout);
|
|
87
|
-
const frameOptions = useHeaderFrameOptions(contentLayout);
|
|
88
54
|
|
|
89
55
|
// keepTitle leaves a title the screen set itself when the same type is re-applied
|
|
90
56
|
const setHeaderType = useCallback(
|
|
@@ -113,7 +79,21 @@ export const useScreenHeader = ({
|
|
|
113
79
|
headerTitle: (props: any) => <HeaderTitle {...props} />,
|
|
114
80
|
};
|
|
115
81
|
if (inputSearchProps) {
|
|
116
|
-
options =
|
|
82
|
+
options = {
|
|
83
|
+
headerShown: true,
|
|
84
|
+
headerTransparent: true,
|
|
85
|
+
headerBackground: () => null,
|
|
86
|
+
headerTitle: (props: any) => (
|
|
87
|
+
<HeaderTitle
|
|
88
|
+
{...props}
|
|
89
|
+
interpolate={{
|
|
90
|
+
inputRange: [0, 50],
|
|
91
|
+
outputRange: [1, 0],
|
|
92
|
+
}}
|
|
93
|
+
animatedValue={sharedValue}
|
|
94
|
+
/>
|
|
95
|
+
),
|
|
96
|
+
};
|
|
117
97
|
}
|
|
118
98
|
break;
|
|
119
99
|
|
|
@@ -147,7 +127,21 @@ export const useScreenHeader = ({
|
|
|
147
127
|
headerTitle: (props: any) => <HeaderTitle {...props} />,
|
|
148
128
|
};
|
|
149
129
|
if (inputSearchProps) {
|
|
150
|
-
options =
|
|
130
|
+
options = {
|
|
131
|
+
headerShown: true,
|
|
132
|
+
headerTransparent: true,
|
|
133
|
+
headerBackground: () => null,
|
|
134
|
+
headerTitle: (props: any) => (
|
|
135
|
+
<HeaderTitle
|
|
136
|
+
{...props}
|
|
137
|
+
interpolate={{
|
|
138
|
+
inputRange: [0, 50],
|
|
139
|
+
outputRange: [1, 0],
|
|
140
|
+
}}
|
|
141
|
+
animatedValue={sharedValue}
|
|
142
|
+
/>
|
|
143
|
+
),
|
|
144
|
+
};
|
|
151
145
|
}
|
|
152
146
|
}
|
|
153
147
|
|
|
@@ -155,11 +149,7 @@ export const useScreenHeader = ({
|
|
|
155
149
|
delete options.headerTitle;
|
|
156
150
|
}
|
|
157
151
|
|
|
158
|
-
navigation?.instance?.setOptions({
|
|
159
|
-
header: undefined,
|
|
160
|
-
...frameOptions,
|
|
161
|
-
...options,
|
|
162
|
-
});
|
|
152
|
+
navigation?.instance?.setOptions({ header: undefined, ...options });
|
|
163
153
|
},
|
|
164
154
|
[
|
|
165
155
|
gradientColor,
|
|
@@ -170,7 +160,6 @@ export const useScreenHeader = ({
|
|
|
170
160
|
useShadowHeader,
|
|
171
161
|
hasSideBar,
|
|
172
162
|
quickReturnOptions,
|
|
173
|
-
frameOptions,
|
|
174
163
|
],
|
|
175
164
|
);
|
|
176
165
|
|
|
@@ -218,7 +207,7 @@ export const useScreenHeader = ({
|
|
|
218
207
|
};
|
|
219
208
|
}
|
|
220
209
|
|
|
221
|
-
navigation?.instance?.setOptions(
|
|
210
|
+
navigation?.instance?.setOptions(options);
|
|
222
211
|
},
|
|
223
212
|
[
|
|
224
213
|
gradientColor,
|
|
@@ -229,23 +218,32 @@ export const useScreenHeader = ({
|
|
|
229
218
|
hasSideBar,
|
|
230
219
|
layoutOffset,
|
|
231
220
|
quickReturnOptions,
|
|
232
|
-
frameOptions,
|
|
233
221
|
],
|
|
234
222
|
);
|
|
235
223
|
|
|
236
224
|
const setAnimatedSearch = useCallback(() => {
|
|
237
|
-
const options =
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
225
|
+
const options: StackNavigationOptions = {
|
|
226
|
+
headerShown: true,
|
|
227
|
+
headerTransparent: true,
|
|
228
|
+
headerBackground: () => null,
|
|
229
|
+
headerTitle: (props: any) => (
|
|
230
|
+
<HeaderTitle
|
|
231
|
+
{...props}
|
|
232
|
+
interpolate={{
|
|
233
|
+
inputRange: [0, 50],
|
|
234
|
+
outputRange: [1, 0],
|
|
235
|
+
}}
|
|
236
|
+
animatedValue={sharedValue}
|
|
237
|
+
/>
|
|
238
|
+
),
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
navigation?.instance?.setOptions({ header: undefined, ...options });
|
|
242
|
+
}, [navigation?.instance, sharedValue]);
|
|
244
243
|
|
|
245
|
-
// the search field spans the content
|
|
246
|
-
// and status bar clusters
|
|
244
|
+
// the search field spans the content, clear of the side bar and status bar clusters
|
|
247
245
|
const setSearchHeader = (params: SearchHeaderProps) => {
|
|
248
|
-
let searchWidth =
|
|
246
|
+
let searchWidth = layout.width - 24;
|
|
249
247
|
let searchLeft = Spacing.M;
|
|
250
248
|
if (layout.sideBar) {
|
|
251
249
|
searchWidth = layout.contentWidth - Spacing.M * 2;
|
|
@@ -256,7 +254,6 @@ export const useScreenHeader = ({
|
|
|
256
254
|
searchWidth -= clearance.left + clearance.right;
|
|
257
255
|
}
|
|
258
256
|
const options: StackNavigationOptions = {
|
|
259
|
-
...frameOptions,
|
|
260
257
|
headerRight: undefined,
|
|
261
258
|
headerTitleContainerStyle: {
|
|
262
259
|
width: searchWidth,
|
package/Layout/screenTypes.ts
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
import { FloatingButtonProps } from './FloatingButton';
|
|
10
10
|
import { HeaderType } from './types';
|
|
11
11
|
import { InputRef } from '../Input';
|
|
12
|
-
import type { HeaderContentLayout } from '../Application/headerLayout';
|
|
13
12
|
|
|
14
13
|
export const ANIMATED_BANNER_HEIGHT = 210;
|
|
15
14
|
|
|
@@ -78,17 +77,10 @@ export interface ScreenProps extends ViewProps {
|
|
|
78
77
|
layoutOffset?: -8 | -24 | -56 | number;
|
|
79
78
|
|
|
80
79
|
/**
|
|
81
|
-
* Optional. Width of the right header. Defaults to the toolkit width (
|
|
80
|
+
* Optional. Width of the right header. Defaults to the toolkit width (73), or 0 when
|
|
82
81
|
* iPhone Duo floats the toolkit into its side bar.
|
|
83
82
|
*/
|
|
84
|
-
headerRightWidth?: 0 |
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Optional. `stretch` centers back, title or search and the right cluster of the
|
|
88
|
-
* header in a 600pt frame on wide windows (foldable inner display, tablet); the
|
|
89
|
-
* background and status bar stay full width. Defaults to `grid`.
|
|
90
|
-
*/
|
|
91
|
-
contentLayout?: HeaderContentLayout;
|
|
83
|
+
headerRightWidth?: 0 | 73 | 110 | number;
|
|
92
84
|
|
|
93
85
|
/**
|
|
94
86
|
* Optional. Props for the floating action button.
|
package/Layout/types.ts
CHANGED
|
@@ -13,7 +13,43 @@ export type ScreenRef = {
|
|
|
13
13
|
*/
|
|
14
14
|
setSearchHeader: (params: SearchHeaderProps) => void;
|
|
15
15
|
};
|
|
16
|
-
export type SpanNumber =
|
|
16
|
+
export type SpanNumber =
|
|
17
|
+
| 1
|
|
18
|
+
| 2
|
|
19
|
+
| 3
|
|
20
|
+
| 4
|
|
21
|
+
| 5
|
|
22
|
+
| 6
|
|
23
|
+
| 7
|
|
24
|
+
| 8
|
|
25
|
+
| 9
|
|
26
|
+
| 10
|
|
27
|
+
| 11
|
|
28
|
+
| 12
|
|
29
|
+
| 13
|
|
30
|
+
| 14
|
|
31
|
+
| 15
|
|
32
|
+
| 16
|
|
33
|
+
| 17
|
|
34
|
+
| 18
|
|
35
|
+
| 19
|
|
36
|
+
| 20
|
|
37
|
+
| 21
|
|
38
|
+
| 22
|
|
39
|
+
| 23
|
|
40
|
+
| 24
|
|
41
|
+
| 25
|
|
42
|
+
| 26
|
|
43
|
+
| 27
|
|
44
|
+
| 28
|
|
45
|
+
| 29
|
|
46
|
+
| 30
|
|
47
|
+
| 31
|
|
48
|
+
| 32
|
|
49
|
+
| 33
|
|
50
|
+
| 34
|
|
51
|
+
| 35
|
|
52
|
+
| 36;
|
|
17
53
|
|
|
18
54
|
export type GridContextProps = {
|
|
19
55
|
/**
|