@momo-kits/foundation 0.169.18-beta.2 → 0.170.4
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/BottomSheet.parts.tsx +4 -4
- package/Application/BottomSheet.tsx +6 -16
- package/Application/Components/HeaderAnimated.tsx +33 -9
- package/Application/Components/HeaderExtendHeader.tsx +28 -18
- package/Application/Components/SearchHeader.tsx +7 -5
- package/Application/ModalIconButton.tsx +13 -15
- package/Application/ModalScreen.tsx +13 -4
- package/Application/__tests__/headerLayout.test.ts +113 -0
- package/Application/headerLayout.ts +114 -30
- package/Application/modalLayout.ts +43 -11
- package/Application/types.header.ts +7 -1
- package/Input/ErrorView.tsx +1 -1
- package/Input/InputMoneyView.tsx +6 -14
- package/Layout/Screen.tsx +13 -16
- package/Layout/Section.tsx +3 -14
- package/Layout/layoutMetrics.ts +2 -2
- package/Layout/screenContent.tsx +4 -10
- package/Layout/screenFooter.tsx +22 -267
- package/Layout/screenHeader.tsx +26 -31
- package/Layout/screenTypes.ts +4 -27
- package/Layout/styles.ts +0 -10
- package/Layout/types.ts +0 -12
- package/Layout/useHeaderBarOptions.ts +54 -0
- package/package.json +1 -1
- package/Layout/__tests__/screenFooter.test.ts +0 -142
package/Layout/screenFooter.tsx
CHANGED
|
@@ -1,308 +1,63 @@
|
|
|
1
|
-
import React, { ReactNode
|
|
2
|
-
import {
|
|
3
|
-
import { isFoldableWindow } from '../Application/modalLayout';
|
|
4
|
-
import { ApplicationContext, MiniAppContext } from '../Context';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
5
3
|
import { Spacing } from '../Consts';
|
|
6
|
-
import { ScreenLayout } from './layoutTypes';
|
|
7
|
-
import { ScreenFooterSeparator, ScreenFooterStyle } from './types';
|
|
8
4
|
import Section from './Section';
|
|
9
5
|
import styles from './styles';
|
|
10
6
|
|
|
11
|
-
// Foldable footer spec, shared with the Compose / SwiftUI kits
|
|
12
|
-
const FOOTER_MAX_WIDTH = 600;
|
|
13
|
-
const FOOTER_WIDE_MAX_WIDTH = 800;
|
|
14
|
-
const FOOTER_WIDE_WINDOW_MIN_WIDTH = 800;
|
|
15
|
-
const FOOTER_BORDER_WIDTH = 1;
|
|
16
|
-
|
|
17
|
-
type FooterKind = 'phone' | 'anchored' | 'sheet';
|
|
18
|
-
|
|
19
|
-
type HorizontalInsets = { left: number; right: number };
|
|
20
|
-
|
|
21
|
-
type FooterGeometry = {
|
|
22
|
-
kind: FooterKind;
|
|
23
|
-
/**
|
|
24
|
-
* Sheet width or anchored content area, both before the 12pt row margins.
|
|
25
|
-
*/
|
|
26
|
-
width: number;
|
|
27
|
-
/**
|
|
28
|
-
* Footer margins from the window edges: only the phone bar keeps clear of the
|
|
29
|
-
* iPhone Duo side column, the foldable bar and sheet are laid on the window.
|
|
30
|
-
*/
|
|
31
|
-
barMargin: HorizontalInsets;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
type DesignSystemContext = {
|
|
35
|
-
designSystemConfig?: {
|
|
36
|
-
config?: { footerStyle?: unknown; footerSeparator?: unknown };
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
type FooterGeometryInput = {
|
|
41
|
-
width: number;
|
|
42
|
-
height: number;
|
|
43
|
-
contentWidth: number;
|
|
44
|
-
insetLeft: number;
|
|
45
|
-
insetRight: number;
|
|
46
|
-
footerStyle: ScreenFooterStyle;
|
|
47
|
-
hasImageBackground: boolean;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
type FooterLayout = FooterGeometry & {
|
|
51
|
-
/**
|
|
52
|
-
* `true` for the anchored bar without an image background, which draws a separator.
|
|
53
|
-
*/
|
|
54
|
-
hasSeparator: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* `false` on a foldable with an image background, so the screen's image shows through.
|
|
57
|
-
*/
|
|
58
|
-
hasSurface: boolean;
|
|
59
|
-
/**
|
|
60
|
-
* Height the sheet overlaps the body by; 0 while the footer sits below the body.
|
|
61
|
-
*/
|
|
62
|
-
overlap: number;
|
|
63
|
-
handleLayout: (event: LayoutChangeEvent) => void;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
7
|
type ScreenFooterProps = {
|
|
67
8
|
footer: ReactNode;
|
|
68
9
|
marginFooter: boolean;
|
|
69
|
-
|
|
70
|
-
|
|
10
|
+
insetLeft: number;
|
|
11
|
+
insetRight: number;
|
|
12
|
+
hasContentInset: boolean;
|
|
71
13
|
isTab: boolean;
|
|
72
14
|
duoTabInset: number;
|
|
73
15
|
bottomInset: number;
|
|
16
|
+
surfaceColor: string;
|
|
74
17
|
};
|
|
75
18
|
|
|
76
|
-
const NO_INSETS: HorizontalInsets = { left: 0, right: 0 };
|
|
77
|
-
|
|
78
19
|
/**
|
|
79
|
-
*
|
|
20
|
+
* Screen footer on the surface color with a top shadow, padded above the home indicator,
|
|
21
|
+
* or above the floating tab bar on a tab screen.
|
|
80
22
|
*/
|
|
81
|
-
const
|
|
82
|
-
footerStyle?: ScreenFooterStyle,
|
|
83
|
-
configured?: unknown,
|
|
84
|
-
): ScreenFooterStyle => {
|
|
85
|
-
if ((footerStyle ?? configured) === 'sheet') {
|
|
86
|
-
return 'sheet';
|
|
87
|
-
}
|
|
88
|
-
return 'anchored';
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* The screen prop wins over the host's design system config; anything else is `border`.
|
|
93
|
-
*/
|
|
94
|
-
const getFooterSeparator = (
|
|
95
|
-
separator?: ScreenFooterSeparator,
|
|
96
|
-
configured?: unknown,
|
|
97
|
-
): ScreenFooterSeparator => {
|
|
98
|
-
if ((separator ?? configured) === 'shadow') {
|
|
99
|
-
return 'shadow';
|
|
100
|
-
}
|
|
101
|
-
return 'border';
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Footer kind, width and side insets for a window, pure so it can be tested without a
|
|
106
|
-
* device. Phones, iPhone Duo outer included, keep the shadowed bar.
|
|
107
|
-
*/
|
|
108
|
-
const getFooterGeometry = ({
|
|
109
|
-
width,
|
|
110
|
-
height,
|
|
111
|
-
contentWidth,
|
|
112
|
-
insetLeft,
|
|
113
|
-
insetRight,
|
|
114
|
-
footerStyle,
|
|
115
|
-
hasImageBackground,
|
|
116
|
-
}: FooterGeometryInput): FooterGeometry => {
|
|
117
|
-
const contentInsets = { left: insetLeft, right: insetRight };
|
|
118
|
-
if (!isFoldableWindow(width, height)) {
|
|
119
|
-
return {
|
|
120
|
-
kind: 'phone',
|
|
121
|
-
width: contentWidth,
|
|
122
|
-
barMargin: contentInsets,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
let maxWidth = FOOTER_MAX_WIDTH;
|
|
127
|
-
if (width >= FOOTER_WIDE_WINDOW_MIN_WIDTH) {
|
|
128
|
-
maxWidth = FOOTER_WIDE_MAX_WIDTH;
|
|
129
|
-
}
|
|
130
|
-
const footerWidth = Math.min(contentWidth - Spacing.M * 2, maxWidth);
|
|
131
|
-
// an image background spans the window, so it never sits in a sheet
|
|
132
|
-
if (footerStyle === 'sheet' && !hasImageBackground) {
|
|
133
|
-
// Figma centers the sheet on the window, side column included
|
|
134
|
-
return {
|
|
135
|
-
kind: 'sheet',
|
|
136
|
-
width: footerWidth,
|
|
137
|
-
barMargin: NO_INSETS,
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
// Figma centers the anchored content on the window too, side column included
|
|
141
|
-
return { kind: 'anchored', width: footerWidth, barMargin: NO_INSETS };
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Cap of the footer grid row: the foldable area minus the 12pt margins it keeps
|
|
146
|
-
* inside; `undefined` on a phone, where the row spans the content.
|
|
147
|
-
*/
|
|
148
|
-
const getFooterRowWidth = (
|
|
149
|
-
geometry: FooterGeometry,
|
|
150
|
-
hasMargin: boolean,
|
|
151
|
-
): number | undefined => {
|
|
152
|
-
if (geometry.kind === 'phone') {
|
|
153
|
-
return undefined;
|
|
154
|
-
}
|
|
155
|
-
let margin = 0;
|
|
156
|
-
if (hasMargin) {
|
|
157
|
-
margin = Spacing.M;
|
|
158
|
-
}
|
|
159
|
-
return geometry.width - margin * 2;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Top edge of the anchored bar: a 1pt border line or the phone footer shadow.
|
|
164
|
-
*/
|
|
165
|
-
const getSeparatorStyle = (
|
|
166
|
-
separator: ScreenFooterSeparator,
|
|
167
|
-
borderColor: string,
|
|
168
|
-
): StyleProp<ViewStyle> => {
|
|
169
|
-
if (separator === 'shadow') {
|
|
170
|
-
return styles.shadow;
|
|
171
|
-
}
|
|
172
|
-
return { borderTopWidth: FOOTER_BORDER_WIDTH, borderTopColor: borderColor };
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Footer layout for the screen layout. A sheet overlaps the body, so its measured
|
|
177
|
-
* height comes back as `overlap` for the body to pad its end by.
|
|
178
|
-
*/
|
|
179
|
-
const useFooterLayout = (
|
|
180
|
-
layout: ScreenLayout,
|
|
181
|
-
footerStyle?: ScreenFooterStyle,
|
|
182
|
-
hasImageBackground = false,
|
|
183
|
-
): FooterLayout => {
|
|
184
|
-
const context: DesignSystemContext | undefined = useContext(MiniAppContext);
|
|
185
|
-
const [height, setHeight] = useState(0);
|
|
186
|
-
const handleLayout = useCallback((event: LayoutChangeEvent) => {
|
|
187
|
-
setHeight(event.nativeEvent.layout.height);
|
|
188
|
-
}, []);
|
|
189
|
-
|
|
190
|
-
const configured = context?.designSystemConfig?.config?.footerStyle;
|
|
191
|
-
const geometry = getFooterGeometry({
|
|
192
|
-
width: layout.width,
|
|
193
|
-
height: layout.height,
|
|
194
|
-
contentWidth: layout.contentWidth,
|
|
195
|
-
insetLeft: layout.insetLeft,
|
|
196
|
-
insetRight: layout.insetRight,
|
|
197
|
-
footerStyle: getFooterStyle(footerStyle, configured),
|
|
198
|
-
hasImageBackground,
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
let overlap = 0;
|
|
202
|
-
if (geometry.kind === 'sheet') {
|
|
203
|
-
overlap = height;
|
|
204
|
-
}
|
|
205
|
-
return {
|
|
206
|
-
...geometry,
|
|
207
|
-
hasSeparator: geometry.kind === 'anchored' && !hasImageBackground,
|
|
208
|
-
hasSurface: geometry.kind === 'phone' || !hasImageBackground,
|
|
209
|
-
overlap,
|
|
210
|
-
handleLayout,
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Spacer at the end of the body so a sheet footer does not cover its last element.
|
|
216
|
-
*/
|
|
217
|
-
const renderFooterSpacer = (overlap: number) => {
|
|
218
|
-
if (!overlap) {
|
|
219
|
-
return null;
|
|
220
|
-
}
|
|
221
|
-
return <View style={{ height: overlap }} />;
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Screen footer on the surface color above the home indicator or the floating tab bar.
|
|
226
|
-
* Phones keep the top shadow; foldables cap the content under a window-wide bar with a
|
|
227
|
-
* top border or shadow (`anchored`) or in a sheet centered over the body (`sheet`).
|
|
228
|
-
*/
|
|
229
|
-
const ScreenFooter = ({
|
|
23
|
+
export const ScreenFooter = ({
|
|
230
24
|
footer,
|
|
231
25
|
marginFooter,
|
|
232
|
-
|
|
233
|
-
|
|
26
|
+
insetLeft,
|
|
27
|
+
insetRight,
|
|
28
|
+
hasContentInset,
|
|
234
29
|
isTab,
|
|
235
30
|
duoTabInset,
|
|
236
31
|
bottomInset,
|
|
32
|
+
surfaceColor,
|
|
237
33
|
}: ScreenFooterProps) => {
|
|
238
|
-
const { theme } = useContext(ApplicationContext);
|
|
239
|
-
const context: DesignSystemContext | undefined = useContext(MiniAppContext);
|
|
240
34
|
let bottomSpace = bottomInset;
|
|
241
35
|
if (isTab && duoTabInset) {
|
|
242
36
|
bottomSpace = duoTabInset;
|
|
243
37
|
}
|
|
244
38
|
|
|
245
|
-
const { kind, barMargin } = layout;
|
|
246
|
-
const hasBarMargin = barMargin.left > 0 || barMargin.right > 0;
|
|
247
|
-
|
|
248
|
-
// one view tree for every kind, so folding keeps the footer content's state
|
|
249
|
-
let containerStyle: StyleProp<ViewStyle> = [
|
|
250
|
-
hasBarMargin && styles.footerClip,
|
|
251
|
-
{ marginLeft: barMargin.left, marginRight: barMargin.right },
|
|
252
|
-
];
|
|
253
|
-
let surfaceStyle: StyleProp<ViewStyle> = styles.shadow;
|
|
254
|
-
if (kind === 'anchored') {
|
|
255
|
-
const configured = context?.designSystemConfig?.config?.footerSeparator;
|
|
256
|
-
const resolved = getFooterSeparator(separator, configured);
|
|
257
|
-
const separatorStyle = getSeparatorStyle(
|
|
258
|
-
resolved,
|
|
259
|
-
theme.colors.border.default,
|
|
260
|
-
);
|
|
261
|
-
surfaceStyle = [styles.footerBar, layout.hasSeparator && separatorStyle];
|
|
262
|
-
}
|
|
263
|
-
if (kind === 'sheet') {
|
|
264
|
-
containerStyle = [containerStyle, { marginTop: -layout.overlap }];
|
|
265
|
-
surfaceStyle = [styles.footerSheet, { width: layout.width }];
|
|
266
|
-
}
|
|
267
|
-
let surfaceColor: string | undefined;
|
|
268
|
-
if (layout.hasSurface) {
|
|
269
|
-
surfaceColor = theme.colors.background.surface;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
39
|
return (
|
|
273
40
|
<View
|
|
274
41
|
pointerEvents={'box-none'}
|
|
275
|
-
|
|
276
|
-
|
|
42
|
+
style={[
|
|
43
|
+
hasContentInset && styles.footerClip,
|
|
44
|
+
{
|
|
45
|
+
marginLeft: insetLeft,
|
|
46
|
+
marginRight: insetRight,
|
|
47
|
+
},
|
|
48
|
+
]}
|
|
277
49
|
>
|
|
278
50
|
<View
|
|
279
51
|
style={[
|
|
280
|
-
|
|
52
|
+
styles.shadow,
|
|
281
53
|
{
|
|
282
54
|
paddingBottom: bottomSpace + Spacing.S,
|
|
283
55
|
backgroundColor: surfaceColor,
|
|
284
56
|
},
|
|
285
57
|
]}
|
|
286
58
|
>
|
|
287
|
-
<Section
|
|
288
|
-
useMargin={marginFooter}
|
|
289
|
-
maxWidth={getFooterRowWidth(layout, marginFooter)}
|
|
290
|
-
>
|
|
291
|
-
{footer}
|
|
292
|
-
</Section>
|
|
59
|
+
<Section useMargin={marginFooter}>{footer}</Section>
|
|
293
60
|
</View>
|
|
294
61
|
</View>
|
|
295
62
|
);
|
|
296
63
|
};
|
|
297
|
-
|
|
298
|
-
export type { FooterLayout };
|
|
299
|
-
|
|
300
|
-
export {
|
|
301
|
-
ScreenFooter,
|
|
302
|
-
getFooterGeometry,
|
|
303
|
-
getFooterRowWidth,
|
|
304
|
-
getFooterSeparator,
|
|
305
|
-
getFooterStyle,
|
|
306
|
-
renderFooterSpacer,
|
|
307
|
-
useFooterLayout,
|
|
308
|
-
};
|
package/Layout/screenHeader.tsx
CHANGED
|
@@ -13,13 +13,9 @@ import {
|
|
|
13
13
|
SearchHeader,
|
|
14
14
|
} from '../Application';
|
|
15
15
|
import { DuoGlassBackground } from '../Application/Components/DuoGlassBackground';
|
|
16
|
-
import {
|
|
17
|
-
type HeaderContentLayout,
|
|
18
|
-
useHeaderFrameOptions,
|
|
19
|
-
useHeaderLayout,
|
|
20
|
-
} from '../Application/headerLayout';
|
|
16
|
+
import { type HeaderContentLayout } from '../Application/headerLayout';
|
|
21
17
|
import { getHeaderMargin } from './utils';
|
|
22
|
-
import {
|
|
18
|
+
import { useHeaderBarOptions } from './useHeaderBarOptions';
|
|
23
19
|
import { HeaderType } from './types';
|
|
24
20
|
|
|
25
21
|
type ScreenHeaderParams = {
|
|
@@ -34,18 +30,20 @@ type ScreenHeaderParams = {
|
|
|
34
30
|
useShadowHeader: boolean;
|
|
35
31
|
gradientColor?: string;
|
|
36
32
|
headerBackground?: string;
|
|
37
|
-
|
|
33
|
+
bannerBottom: number;
|
|
38
34
|
contentLayout?: HeaderContentLayout;
|
|
39
35
|
};
|
|
40
36
|
|
|
41
37
|
/**
|
|
42
38
|
* Transparent header for an `inputSearchProps` Screen: its title fades out over the
|
|
43
|
-
* first 50pt of scroll while the search collapses into the bar.
|
|
39
|
+
* first 50pt of scroll while the search collapses into the bar (`searchTitleOptions`).
|
|
44
40
|
*/
|
|
45
41
|
const getSearchTitleOptions = (
|
|
46
42
|
sharedValue: SharedValue<number>,
|
|
43
|
+
searchTitleOptions: StackNavigationOptions,
|
|
47
44
|
): StackNavigationOptions => {
|
|
48
45
|
return {
|
|
46
|
+
...searchTitleOptions,
|
|
49
47
|
headerShown: true,
|
|
50
48
|
headerTransparent: true,
|
|
51
49
|
headerBackground: () => null,
|
|
@@ -79,14 +77,14 @@ export const useScreenHeader = ({
|
|
|
79
77
|
useShadowHeader,
|
|
80
78
|
gradientColor,
|
|
81
79
|
headerBackground,
|
|
82
|
-
|
|
80
|
+
bannerBottom,
|
|
83
81
|
contentLayout,
|
|
84
82
|
}: ScreenHeaderParams) => {
|
|
85
83
|
const currentTint = useRef<string | undefined>(undefined);
|
|
86
84
|
const appliedHeaderMode = useRef<string | undefined>(undefined);
|
|
87
85
|
const searchHeaderParams = useRef<SearchHeaderProps | undefined>(undefined);
|
|
88
|
-
const
|
|
89
|
-
const
|
|
86
|
+
const headerBarOptions = useHeaderBarOptions(layout, contentLayout);
|
|
87
|
+
const { barOptions, searchTitleOptions, searchOptions } = headerBarOptions;
|
|
90
88
|
|
|
91
89
|
// keepTitle leaves a title the screen set itself when the same type is re-applied
|
|
92
90
|
const setHeaderType = useCallback(
|
|
@@ -115,7 +113,7 @@ export const useScreenHeader = ({
|
|
|
115
113
|
headerTitle: (props: any) => <HeaderTitle {...props} />,
|
|
116
114
|
};
|
|
117
115
|
if (inputSearchProps) {
|
|
118
|
-
options = getSearchTitleOptions(sharedValue);
|
|
116
|
+
options = getSearchTitleOptions(sharedValue, searchTitleOptions);
|
|
119
117
|
}
|
|
120
118
|
break;
|
|
121
119
|
|
|
@@ -149,7 +147,7 @@ export const useScreenHeader = ({
|
|
|
149
147
|
headerTitle: (props: any) => <HeaderTitle {...props} />,
|
|
150
148
|
};
|
|
151
149
|
if (inputSearchProps) {
|
|
152
|
-
options = getSearchTitleOptions(sharedValue);
|
|
150
|
+
options = getSearchTitleOptions(sharedValue, searchTitleOptions);
|
|
153
151
|
}
|
|
154
152
|
}
|
|
155
153
|
|
|
@@ -159,7 +157,7 @@ export const useScreenHeader = ({
|
|
|
159
157
|
|
|
160
158
|
navigation?.instance?.setOptions({
|
|
161
159
|
header: undefined,
|
|
162
|
-
...
|
|
160
|
+
...barOptions,
|
|
163
161
|
...options,
|
|
164
162
|
});
|
|
165
163
|
},
|
|
@@ -172,7 +170,8 @@ export const useScreenHeader = ({
|
|
|
172
170
|
useShadowHeader,
|
|
173
171
|
hasSideBar,
|
|
174
172
|
quickReturnOptions,
|
|
175
|
-
|
|
173
|
+
barOptions,
|
|
174
|
+
searchTitleOptions,
|
|
176
175
|
],
|
|
177
176
|
);
|
|
178
177
|
|
|
@@ -193,7 +192,7 @@ export const useScreenHeader = ({
|
|
|
193
192
|
return (
|
|
194
193
|
<DuoGlassBackground
|
|
195
194
|
animatedValue={sharedValue}
|
|
196
|
-
bannerBottom={
|
|
195
|
+
bannerBottom={bannerBottom}
|
|
197
196
|
/>
|
|
198
197
|
);
|
|
199
198
|
}
|
|
@@ -220,7 +219,7 @@ export const useScreenHeader = ({
|
|
|
220
219
|
};
|
|
221
220
|
}
|
|
222
221
|
|
|
223
|
-
navigation?.instance?.setOptions({ ...
|
|
222
|
+
navigation?.instance?.setOptions({ ...barOptions, ...options });
|
|
224
223
|
},
|
|
225
224
|
[
|
|
226
225
|
gradientColor,
|
|
@@ -229,24 +228,20 @@ export const useScreenHeader = ({
|
|
|
229
228
|
sharedValue,
|
|
230
229
|
useShadowHeader,
|
|
231
230
|
hasSideBar,
|
|
232
|
-
|
|
231
|
+
bannerBottom,
|
|
233
232
|
quickReturnOptions,
|
|
234
|
-
|
|
233
|
+
barOptions,
|
|
235
234
|
],
|
|
236
235
|
);
|
|
237
236
|
|
|
238
237
|
const setAnimatedSearch = useCallback(() => {
|
|
239
|
-
const options = getSearchTitleOptions(sharedValue);
|
|
240
|
-
navigation?.instance?.setOptions({
|
|
241
|
-
|
|
242
|
-
...frameOptions,
|
|
243
|
-
...options,
|
|
244
|
-
});
|
|
245
|
-
}, [navigation?.instance, sharedValue, frameOptions]);
|
|
238
|
+
const options = getSearchTitleOptions(sharedValue, searchTitleOptions);
|
|
239
|
+
navigation?.instance?.setOptions({ header: undefined, ...options });
|
|
240
|
+
}, [navigation?.instance, sharedValue, searchTitleOptions]);
|
|
246
241
|
|
|
247
|
-
// the search field spans the content
|
|
248
|
-
//
|
|
249
|
-
let searchWidth =
|
|
242
|
+
// the search field spans the content, clear of the side bar and status bar
|
|
243
|
+
// clusters; kept as numbers so the setter below stays stable
|
|
244
|
+
let searchWidth = layout.width - Spacing.M * 2;
|
|
250
245
|
let searchLeft = Spacing.M;
|
|
251
246
|
if (layout.sideBar) {
|
|
252
247
|
searchWidth = layout.contentWidth - Spacing.M * 2;
|
|
@@ -265,7 +260,7 @@ export const useScreenHeader = ({
|
|
|
265
260
|
(params: SearchHeaderProps) => {
|
|
266
261
|
searchHeaderParams.current = params;
|
|
267
262
|
const options: StackNavigationOptions = {
|
|
268
|
-
...
|
|
263
|
+
...searchOptions,
|
|
269
264
|
headerRight: undefined,
|
|
270
265
|
headerTitleContainerStyle: {
|
|
271
266
|
width: searchWidth,
|
|
@@ -291,7 +286,7 @@ export const useScreenHeader = ({
|
|
|
291
286
|
|
|
292
287
|
navigation?.instance?.setOptions(options);
|
|
293
288
|
},
|
|
294
|
-
[navigation?.instance, sharedValue,
|
|
289
|
+
[navigation?.instance, sharedValue, searchOptions, searchWidth, searchLeft],
|
|
295
290
|
);
|
|
296
291
|
|
|
297
292
|
useEffect(() => {
|
package/Layout/screenTypes.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
SearchHeaderProps,
|
|
8
8
|
} from '../Application/types';
|
|
9
9
|
import { FloatingButtonProps } from './FloatingButton';
|
|
10
|
-
import { HeaderType
|
|
10
|
+
import { HeaderType } from './types';
|
|
11
11
|
import { InputRef } from '../Input';
|
|
12
12
|
import type { HeaderContentLayout } from '../Application/headerLayout';
|
|
13
13
|
|
|
@@ -65,29 +65,6 @@ export interface ScreenProps extends ViewProps {
|
|
|
65
65
|
*/
|
|
66
66
|
marginFooter?: boolean;
|
|
67
67
|
|
|
68
|
-
/**
|
|
69
|
-
* Optional. Footer look on foldable inner displays and wide windows: `anchored`, a
|
|
70
|
-
* full-width bar with a top separator, or `sheet`, a centered sheet over the body. Content
|
|
71
|
-
* is capped at 600pt (800pt on windows from 800pt). Defaults to the host's design
|
|
72
|
-
* system config (`footerStyle`), else `anchored`. Phones keep the current footer.
|
|
73
|
-
*/
|
|
74
|
-
footerStyle?: ScreenFooterStyle;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Optional. Top edge of the `anchored` footer on foldables: `border`, a 1pt line, or
|
|
78
|
-
* `shadow`, the phone footer's shadow. Defaults to the host's design system config
|
|
79
|
-
* (`footerSeparator`), else `border`. Phones keep their shadow; an image background
|
|
80
|
-
* draws neither.
|
|
81
|
-
*/
|
|
82
|
-
footerSeparator?: ScreenFooterSeparator;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Optional. If `true`, the screen draws an image behind the footer: on foldables the
|
|
86
|
-
* footer drops its surface fill, sheet and top border so the image shows through.
|
|
87
|
-
* Defaults to `false`.
|
|
88
|
-
*/
|
|
89
|
-
footerHasImageBackground?: boolean;
|
|
90
|
-
|
|
91
68
|
/**
|
|
92
69
|
* Optional. Background color of the screen.
|
|
93
70
|
*/
|
|
@@ -106,9 +83,9 @@ export interface ScreenProps extends ViewProps {
|
|
|
106
83
|
headerRightWidth?: 0 | 84 | 124 | number;
|
|
107
84
|
|
|
108
85
|
/**
|
|
109
|
-
* Optional. `stretch` centers back, title
|
|
110
|
-
*
|
|
111
|
-
*
|
|
86
|
+
* Optional. `stretch` centers back, title and the right cluster of the header in a
|
|
87
|
+
* 600pt frame on wide windows (foldable inner display, tablet); the background,
|
|
88
|
+
* status bar and a search header stay full width. Defaults to `grid`.
|
|
112
89
|
*/
|
|
113
90
|
contentLayout?: HeaderContentLayout;
|
|
114
91
|
|
package/Layout/styles.ts
CHANGED
|
@@ -91,15 +91,6 @@ export default StyleSheet.create({
|
|
|
91
91
|
},
|
|
92
92
|
}),
|
|
93
93
|
},
|
|
94
|
-
footerBar: {
|
|
95
|
-
paddingTop: Spacing.S,
|
|
96
|
-
},
|
|
97
|
-
footerSheet: {
|
|
98
|
-
paddingTop: Spacing.S,
|
|
99
|
-
alignSelf: 'center',
|
|
100
|
-
borderTopLeftRadius: Radius.XL,
|
|
101
|
-
borderTopRightRadius: Radius.XL,
|
|
102
|
-
},
|
|
103
94
|
footerClip: {
|
|
104
95
|
marginTop: -Spacing.XL,
|
|
105
96
|
paddingTop: Spacing.XL,
|
|
@@ -107,6 +98,5 @@ export default StyleSheet.create({
|
|
|
107
98
|
},
|
|
108
99
|
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
109
100
|
expanded: { flex: 1 },
|
|
110
|
-
centered: { alignSelf: 'center' },
|
|
111
101
|
rowWrap: { flexDirection: 'row', flexWrap: 'wrap' },
|
|
112
102
|
});
|
package/Layout/types.ts
CHANGED
|
@@ -2,18 +2,6 @@ import { NavigationOptions, SearchHeaderProps } from '../Application/types';
|
|
|
2
2
|
|
|
3
3
|
export type HeaderType = 'default' | 'extended' | 'none';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Screen footer look on foldable inner displays and wide windows: `anchored` is a
|
|
7
|
-
* full-width bar with a top separator, `sheet` a centered sheet over the body.
|
|
8
|
-
*/
|
|
9
|
-
export type ScreenFooterStyle = 'anchored' | 'sheet';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Top edge of the anchored footer on foldables: a 1pt `border` line, or the phone
|
|
13
|
-
* footer's `shadow`.
|
|
14
|
-
*/
|
|
15
|
-
export type ScreenFooterSeparator = 'border' | 'shadow';
|
|
16
|
-
|
|
17
5
|
export type ScreenRef = {
|
|
18
6
|
/**
|
|
19
7
|
* Applies navigation options to the screen's header.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import type { StackNavigationOptions } from '@react-navigation/stack';
|
|
3
|
+
import {
|
|
4
|
+
getSearchHeaderHeight,
|
|
5
|
+
type HeaderContentLayout,
|
|
6
|
+
useHeaderFrameOptions,
|
|
7
|
+
} from '../Application/headerLayout';
|
|
8
|
+
import type { ScreenLayout } from './layoutTypes';
|
|
9
|
+
|
|
10
|
+
type HeaderBarOptions = {
|
|
11
|
+
barOptions: StackNavigationOptions;
|
|
12
|
+
searchTitleOptions: StackNavigationOptions;
|
|
13
|
+
searchOptions: StackNavigationOptions;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Header row options for the Screen setters: the plain bar and the taller title row
|
|
18
|
+
* above an `inputSearchProps` search, both in the `contentLayout` frame, and the
|
|
19
|
+
* search header row, which spans the window and leaves the frame.
|
|
20
|
+
*/
|
|
21
|
+
const useHeaderBarOptions = (
|
|
22
|
+
layout: ScreenLayout,
|
|
23
|
+
contentLayout?: HeaderContentLayout,
|
|
24
|
+
): HeaderBarOptions => {
|
|
25
|
+
const frameOptions = useHeaderFrameOptions(contentLayout);
|
|
26
|
+
// the search header fills the bar, so it keeps the bar-edge row with either layout
|
|
27
|
+
let searchLayout: HeaderContentLayout | undefined;
|
|
28
|
+
if (contentLayout) {
|
|
29
|
+
searchLayout = 'grid';
|
|
30
|
+
}
|
|
31
|
+
const edgeOptions = useHeaderFrameOptions(searchLayout);
|
|
32
|
+
const { headerHeight, headerStatusBarHeight } = layout;
|
|
33
|
+
const searchHeight = getSearchHeaderHeight(
|
|
34
|
+
headerHeight,
|
|
35
|
+
headerStatusBarHeight,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// the height is re-applied on every header type, so a former search row does not stay
|
|
39
|
+
const barOptions = useMemo((): StackNavigationOptions => {
|
|
40
|
+
return { ...frameOptions, headerStyle: { height: headerHeight } };
|
|
41
|
+
}, [frameOptions, headerHeight]);
|
|
42
|
+
|
|
43
|
+
const searchTitleOptions = useMemo((): StackNavigationOptions => {
|
|
44
|
+
return { ...frameOptions, headerStyle: { height: searchHeight } };
|
|
45
|
+
}, [frameOptions, searchHeight]);
|
|
46
|
+
|
|
47
|
+
const searchOptions = useMemo((): StackNavigationOptions => {
|
|
48
|
+
return { ...edgeOptions, headerStyle: { height: searchHeight } };
|
|
49
|
+
}, [edgeOptions, searchHeight]);
|
|
50
|
+
|
|
51
|
+
return { barOptions, searchTitleOptions, searchOptions };
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { useHeaderBarOptions };
|