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