@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
|
@@ -8,7 +8,7 @@ import { isIPhoneDuo } from './utils';
|
|
|
8
8
|
const POPUP_MAX_WIDTH = 450;
|
|
9
9
|
const POPUP_MIN_WIDTH = 280;
|
|
10
10
|
const POPUP_MAX_HEIGHT = 600;
|
|
11
|
-
const SHEET_MAX_WIDTH =
|
|
11
|
+
const SHEET_MAX_WIDTH = 653;
|
|
12
12
|
const SHEET_MIN_WIDTH = 296;
|
|
13
13
|
const SHEET_MIN_HEIGHT = 230;
|
|
14
14
|
const FOLDABLE_MIN_WIDTH = 600;
|
|
@@ -46,12 +46,6 @@ export type ModalLayout = {
|
|
|
46
46
|
maxHeight?: number;
|
|
47
47
|
margin: number;
|
|
48
48
|
radius: number;
|
|
49
|
-
/**
|
|
50
|
-
* Window x of the left edge of a `width` wide popup, `undefined` on phones.
|
|
51
|
-
* Centered on the window, but a margin clear of the iPhone Duo control
|
|
52
|
-
* column / system insets; half folded it is centered in the right half.
|
|
53
|
-
*/
|
|
54
|
-
x?: number;
|
|
55
49
|
};
|
|
56
50
|
|
|
57
51
|
sheet: {
|
|
@@ -59,12 +53,6 @@ export type ModalLayout = {
|
|
|
59
53
|
* `undefined` on phones, the sheet spans the window.
|
|
60
54
|
*/
|
|
61
55
|
width?: number;
|
|
62
|
-
/**
|
|
63
|
-
* Window x of the sheet's left edge, `undefined` on phones. Centered on the
|
|
64
|
-
* window, but kept a margin clear of the iPhone Duo control column / system
|
|
65
|
-
* insets; half folded it is centered in the right half.
|
|
66
|
-
*/
|
|
67
|
-
x?: number;
|
|
68
56
|
maxHeight?: number;
|
|
69
57
|
minHeight?: number;
|
|
70
58
|
margin: number;
|
|
@@ -91,22 +79,11 @@ const clamp = (value: number, min: number, max: number) => {
|
|
|
91
79
|
};
|
|
92
80
|
|
|
93
81
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* placement; centered in the placement when it does not fit with the margins.
|
|
82
|
+
* True when the window's short side reaches a foldable inner display (Galaxy Z Fold,
|
|
83
|
+
* Pixel Fold, iPhone Duo inner); short side, so a phone in landscape stays a phone.
|
|
97
84
|
*/
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
placement: ModalRect,
|
|
101
|
-
boxWidth: number,
|
|
102
|
-
margin: number,
|
|
103
|
-
) => {
|
|
104
|
-
const min = placement.x + margin;
|
|
105
|
-
const max = placement.x + placement.width - margin - boxWidth;
|
|
106
|
-
if (max < min) {
|
|
107
|
-
return placement.x + (placement.width - boxWidth) / 2;
|
|
108
|
-
}
|
|
109
|
-
return clamp(center - boxWidth / 2, min, max);
|
|
85
|
+
const isFoldableWindow = (width: number, height: number) => {
|
|
86
|
+
return Math.min(width, height) >= FOLDABLE_MIN_WIDTH;
|
|
110
87
|
};
|
|
111
88
|
|
|
112
89
|
/**
|
|
@@ -119,10 +96,9 @@ const getModalLayout = ({
|
|
|
119
96
|
isDuo,
|
|
120
97
|
hinge,
|
|
121
98
|
}: ModalLayoutInput): ModalLayout => {
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
const isDuoOuter = isDuo && shortSide < FOLDABLE_MIN_WIDTH;
|
|
99
|
+
const isWideWindow = isFoldableWindow(width, height);
|
|
100
|
+
const isFoldable = isDuo || isWideWindow;
|
|
101
|
+
const isDuoOuter = isDuo && !isWideWindow;
|
|
126
102
|
const hingeRight = hinge ? hinge.x + hinge.width : 0;
|
|
127
103
|
const hasHinge = !!hinge && hinge.x > 0;
|
|
128
104
|
const isHingeInWindow = hingeRight < width - insets.right;
|
|
@@ -161,20 +137,12 @@ const getModalLayout = ({
|
|
|
161
137
|
const sheetSpace = placement.width - sheetMargin * 2;
|
|
162
138
|
const sheetMinWidth = Math.min(SHEET_MIN_WIDTH, sheetSpace);
|
|
163
139
|
const sheetMaxHeight = height - insets.top - Spacing.M;
|
|
164
|
-
const sheetWidth = clamp(sheetSpace, sheetMinWidth, SHEET_MAX_WIDTH);
|
|
165
|
-
const popupWidth = clamp(popupSpace, popupMinWidth, POPUP_MAX_WIDTH);
|
|
166
|
-
// the window center; half folded, the right half's
|
|
167
|
-
let overlayCenter = width / 2;
|
|
168
|
-
if (isHalfFolded) {
|
|
169
|
-
overlayCenter = placement.x + placement.width / 2;
|
|
170
|
-
}
|
|
171
140
|
|
|
172
141
|
return {
|
|
173
142
|
isFoldable,
|
|
174
143
|
placement,
|
|
175
144
|
popup: {
|
|
176
|
-
width:
|
|
177
|
-
x: overlayX(overlayCenter, placement, popupWidth, popupMargin),
|
|
145
|
+
width: clamp(popupSpace, popupMinWidth, POPUP_MAX_WIDTH),
|
|
178
146
|
minWidth: popupMinWidth,
|
|
179
147
|
maxWidth: POPUP_MAX_WIDTH,
|
|
180
148
|
maxHeight: Math.min(POPUP_MAX_HEIGHT, placement.height - Spacing.XL * 2),
|
|
@@ -182,8 +150,7 @@ const getModalLayout = ({
|
|
|
182
150
|
radius: Radius.XL,
|
|
183
151
|
},
|
|
184
152
|
sheet: {
|
|
185
|
-
width:
|
|
186
|
-
x: overlayX(overlayCenter, placement, sheetWidth, sheetMargin),
|
|
153
|
+
width: clamp(sheetSpace, sheetMinWidth, SHEET_MAX_WIDTH),
|
|
187
154
|
maxHeight: sheetMaxHeight,
|
|
188
155
|
minHeight: Math.min(SHEET_MIN_HEIGHT, sheetMaxHeight),
|
|
189
156
|
margin: sheetMargin,
|
|
@@ -206,6 +173,7 @@ const useModalLayout = (): ModalLayout => {
|
|
|
206
173
|
|
|
207
174
|
export {
|
|
208
175
|
getModalLayout,
|
|
176
|
+
isFoldableWindow,
|
|
209
177
|
useModalLayout,
|
|
210
178
|
POPUP_MAX_WIDTH,
|
|
211
179
|
POPUP_MIN_WIDTH,
|
|
@@ -99,16 +99,10 @@ export interface HeaderAnimatedProps extends ViewProps {
|
|
|
99
99
|
useScale?: boolean;
|
|
100
100
|
aspectRatio?: '16/9' | '3/2' | '1/1';
|
|
101
101
|
/**
|
|
102
|
-
* Optional. On wide windows the image
|
|
102
|
+
* Optional. On wide windows the image keeps its phone width, centered; this
|
|
103
103
|
* color fills the sides and fades to transparent downward. No fill when unset.
|
|
104
|
-
* `bannerGradientColors` wins when both are set.
|
|
105
104
|
*/
|
|
106
105
|
bannerBackgroundColor?: string;
|
|
107
|
-
/**
|
|
108
|
-
* Optional. Side fill behind the centered banner on wide windows, from the top
|
|
109
|
-
* color to the bottom one: `[start, end]`. A single color fills solid.
|
|
110
|
-
*/
|
|
111
|
-
bannerGradientColors?: string[];
|
|
112
106
|
}
|
|
113
107
|
|
|
114
108
|
export type AnimatedHeader = {
|
package/Input/ErrorView.tsx
CHANGED
package/Input/InputMoneyView.tsx
CHANGED
|
@@ -53,8 +53,8 @@ type InputMoneyViewProps = Pick<
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
* Presentational body of InputMoney: bordered field, currency suffix (
|
|
57
|
-
*
|
|
56
|
+
* Presentational body of InputMoney: bordered field, currency suffix (kept
|
|
57
|
+
* after a placeholder that ends with it) and the clear/trailing icons.
|
|
58
58
|
*/
|
|
59
59
|
export const InputMoneyView = ({
|
|
60
60
|
size,
|
|
@@ -101,8 +101,13 @@ export const InputMoneyView = ({
|
|
|
101
101
|
fontSize: scaledFontSize,
|
|
102
102
|
fontFamily: inputFontFamily,
|
|
103
103
|
};
|
|
104
|
-
const
|
|
104
|
+
const hasCurrencyInPlaceholder = placeholder.endsWith(currency);
|
|
105
|
+
const shouldShowCurrency = !!displayValue || hasCurrencyInPlaceholder;
|
|
105
106
|
const shouldShowClearIcon = !!(showClearIcon && focused && displayValue);
|
|
107
|
+
let inputPlaceholder = placeholder;
|
|
108
|
+
if (hasCurrencyInPlaceholder) {
|
|
109
|
+
inputPlaceholder = placeholder.slice(0, -currency.length);
|
|
110
|
+
}
|
|
106
111
|
return (
|
|
107
112
|
<View
|
|
108
113
|
style={[
|
|
@@ -143,15 +148,18 @@ export const InputMoneyView = ({
|
|
|
143
148
|
onChangeText={onChangeText}
|
|
144
149
|
onFocus={onFocus}
|
|
145
150
|
onBlur={onBlur}
|
|
146
|
-
placeholder={
|
|
151
|
+
placeholder={inputPlaceholder}
|
|
147
152
|
selectionColor={theme.colors.primary}
|
|
148
153
|
placeholderTextColor={placeholderColor}
|
|
149
154
|
keyboardType={'numeric'}
|
|
150
155
|
maxLength={undefined}
|
|
151
156
|
/>
|
|
152
|
-
{
|
|
157
|
+
{shouldShowCurrency && (
|
|
153
158
|
<Text
|
|
154
|
-
style={[
|
|
159
|
+
style={[
|
|
160
|
+
textStyle,
|
|
161
|
+
{ color: displayValue ? textColor : placeholderColor },
|
|
162
|
+
]}
|
|
155
163
|
allowFontScaling={false}
|
|
156
164
|
>
|
|
157
165
|
{currency}
|
package/Layout/Screen.tsx
CHANGED
|
@@ -28,11 +28,14 @@ import { useScreenLayout } from './utils';
|
|
|
28
28
|
import { HeaderExtendHeader } from '../Application';
|
|
29
29
|
import { DuoScrollGradient } from '../Application/Components/DuoGlassBackground';
|
|
30
30
|
import { BottomTabInsetContext } from '../Application/BottomTab/BottomTabInset';
|
|
31
|
-
import {
|
|
32
|
-
import { ANIMATED_BANNER_HEIGHT, ScreenProps } from './screenTypes';
|
|
31
|
+
import { ScreenProps } from './screenTypes';
|
|
33
32
|
import { renderAnimatedHeader, renderContent } from './screenContent';
|
|
34
33
|
import { createScrollHandlers } from './screenScroll';
|
|
35
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
renderFooterSpacer,
|
|
36
|
+
ScreenFooter,
|
|
37
|
+
useFooterLayout,
|
|
38
|
+
} from './screenFooter';
|
|
36
39
|
import { useScreenHeader } from './screenHeader';
|
|
37
40
|
import { useScreenQuickReturn } from './screenQuickReturn';
|
|
38
41
|
|
|
@@ -54,6 +57,9 @@ const Screen = forwardRef(
|
|
|
54
57
|
headerComponent: Header,
|
|
55
58
|
footerComponent: Footer,
|
|
56
59
|
marginFooter = true,
|
|
60
|
+
footerStyle,
|
|
61
|
+
footerSeparator,
|
|
62
|
+
footerHasImageBackground: hasImageFooter,
|
|
57
63
|
layoutOffset = -56,
|
|
58
64
|
headerRightWidth,
|
|
59
65
|
backgroundColor,
|
|
@@ -79,9 +85,7 @@ const Screen = forwardRef(
|
|
|
79
85
|
const insets = useSafeAreaInsets();
|
|
80
86
|
const frame = useSafeAreaFrame();
|
|
81
87
|
const heightHeader = useHeaderHeight();
|
|
82
|
-
const
|
|
83
|
-
// the banner grows with its image on wide windows, the content keeps its overlap
|
|
84
|
-
const bannerBottom = ANIMATED_BANNER_HEIGHT * bannerScale + layoutOffset;
|
|
88
|
+
const footerLayout = useFooterLayout(layout, footerStyle, hasImageFooter);
|
|
85
89
|
|
|
86
90
|
const animatedValue = useRef<Animated.Value>(
|
|
87
91
|
customAnimatedValue ?? new Animated.Value(0),
|
|
@@ -148,7 +152,7 @@ const Screen = forwardRef(
|
|
|
148
152
|
useShadowHeader,
|
|
149
153
|
gradientColor,
|
|
150
154
|
headerBackground,
|
|
151
|
-
|
|
155
|
+
layoutOffset,
|
|
152
156
|
contentLayout,
|
|
153
157
|
});
|
|
154
158
|
|
|
@@ -199,7 +203,7 @@ const Screen = forwardRef(
|
|
|
199
203
|
|
|
200
204
|
let floatingButtonBottom = bottomInset + Spacing.S;
|
|
201
205
|
if (Footer) {
|
|
202
|
-
floatingButtonBottom = 12;
|
|
206
|
+
floatingButtonBottom = 12 + footerLayout.overlap;
|
|
203
207
|
} else if (isTab) {
|
|
204
208
|
floatingButtonBottom = 12 + duoTabInset;
|
|
205
209
|
}
|
|
@@ -283,12 +287,13 @@ const Screen = forwardRef(
|
|
|
283
287
|
>
|
|
284
288
|
{renderAnimatedHeader(
|
|
285
289
|
animatedHeader,
|
|
286
|
-
|
|
290
|
+
layoutOffset,
|
|
287
291
|
animatedValue.current,
|
|
288
292
|
sharedValue,
|
|
289
293
|
)}
|
|
290
294
|
|
|
291
295
|
{useGridLayout ? renderContent(children, layout) : children}
|
|
296
|
+
{renderFooterSpacer(footerLayout.overlap)}
|
|
292
297
|
</Component>
|
|
293
298
|
|
|
294
299
|
{floatingButtonProps && (
|
|
@@ -310,13 +315,11 @@ const Screen = forwardRef(
|
|
|
310
315
|
<ScreenFooter
|
|
311
316
|
footer={Footer}
|
|
312
317
|
marginFooter={marginFooter}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
hasContentInset={hasContentInset}
|
|
318
|
+
layout={footerLayout}
|
|
319
|
+
separator={footerSeparator}
|
|
316
320
|
isTab={isTab}
|
|
317
321
|
duoTabInset={duoTabInset}
|
|
318
322
|
bottomInset={bottomInset}
|
|
319
|
-
surfaceColor={theme.colors.background.surface}
|
|
320
323
|
/>
|
|
321
324
|
)}
|
|
322
325
|
</KeyboardAvoidingView>
|
package/Layout/Section.tsx
CHANGED
|
@@ -24,16 +24,22 @@ export interface SectionProps extends ViewProps {
|
|
|
24
24
|
* Optional. Background image for the Section component.
|
|
25
25
|
*/
|
|
26
26
|
backgroundImage?: string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Optional. Caps the row width, side margins excluded; a capped row is centered.
|
|
30
|
+
*/
|
|
31
|
+
maxWidth?: number;
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
/**
|
|
30
|
-
* Content-wide grid row (12 or 24 columns) with optional side margins
|
|
31
|
-
* themselves from its GridContext.
|
|
35
|
+
* Content-wide grid row (12 or 24 columns) with optional side margins, capped by
|
|
36
|
+
* `maxWidth`; child Items size themselves from its GridContext.
|
|
32
37
|
*/
|
|
33
38
|
const Section: React.FC<SectionProps> = ({
|
|
34
39
|
children,
|
|
35
40
|
useMargin = true,
|
|
36
41
|
backgroundImage,
|
|
42
|
+
maxWidth,
|
|
37
43
|
style,
|
|
38
44
|
...props
|
|
39
45
|
}) => {
|
|
@@ -45,7 +51,11 @@ const Section: React.FC<SectionProps> = ({
|
|
|
45
51
|
if (useMargin) {
|
|
46
52
|
margin = 12;
|
|
47
53
|
}
|
|
48
|
-
const
|
|
54
|
+
const isCapped = maxWidth !== undefined;
|
|
55
|
+
let widthSection = contentWidth - margin * 2;
|
|
56
|
+
if (isCapped) {
|
|
57
|
+
widthSection = Math.min(widthSection, maxWidth);
|
|
58
|
+
}
|
|
49
59
|
|
|
50
60
|
const columnsWidth = widthSection - gutterSize * (numberOfColumns - 1);
|
|
51
61
|
const sizePerSpan = columnsWidth / numberOfColumns - 1 / numberOfColumns;
|
|
@@ -68,6 +78,7 @@ const Section: React.FC<SectionProps> = ({
|
|
|
68
78
|
style,
|
|
69
79
|
styles.protectedStyle,
|
|
70
80
|
styles.rowWrap,
|
|
81
|
+
isCapped && styles.centered,
|
|
71
82
|
{
|
|
72
83
|
width: widthSection,
|
|
73
84
|
marginHorizontal: margin,
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getFooterGeometry,
|
|
3
|
+
getFooterRowWidth,
|
|
4
|
+
getFooterSeparator,
|
|
5
|
+
getFooterStyle,
|
|
6
|
+
} from '../screenFooter';
|
|
7
|
+
|
|
8
|
+
// the grid row pulls in every foundation component; geometry does not render
|
|
9
|
+
jest.mock('../Section', () => ({ __esModule: true, default: () => null }));
|
|
10
|
+
|
|
11
|
+
const NO_INSETS = { insetLeft: 0, insetRight: 0 };
|
|
12
|
+
const PHONE = { width: 390, height: 844, contentWidth: 390, ...NO_INSETS };
|
|
13
|
+
const FOLD_PORTRAIT = {
|
|
14
|
+
width: 760,
|
|
15
|
+
height: 900,
|
|
16
|
+
contentWidth: 760,
|
|
17
|
+
...NO_INSETS,
|
|
18
|
+
};
|
|
19
|
+
const FOLD_LANDSCAPE = {
|
|
20
|
+
width: 860,
|
|
21
|
+
height: 700,
|
|
22
|
+
contentWidth: 860,
|
|
23
|
+
...NO_INSETS,
|
|
24
|
+
};
|
|
25
|
+
const TABLET = { width: 1194, height: 834, contentWidth: 1194, ...NO_INSETS };
|
|
26
|
+
// iPhone Duo inner landscape: side column on the left, home indicator inset on the right
|
|
27
|
+
const DUO_INNER = {
|
|
28
|
+
width: 900,
|
|
29
|
+
height: 669,
|
|
30
|
+
contentWidth: 782,
|
|
31
|
+
insetLeft: 84,
|
|
32
|
+
insetRight: 34,
|
|
33
|
+
};
|
|
34
|
+
const ANCHORED = {
|
|
35
|
+
footerStyle: 'anchored' as const,
|
|
36
|
+
hasImageBackground: false,
|
|
37
|
+
};
|
|
38
|
+
const SHEET = { footerStyle: 'sheet' as const, hasImageBackground: false };
|
|
39
|
+
|
|
40
|
+
describe('getFooterGeometry', () => {
|
|
41
|
+
it('keeps the phone footer below 600pt, landscape included', () => {
|
|
42
|
+
expect(getFooterGeometry({ ...PHONE, ...SHEET }).kind).toBe('phone');
|
|
43
|
+
const landscape = {
|
|
44
|
+
...NO_INSETS,
|
|
45
|
+
width: 844,
|
|
46
|
+
height: 390,
|
|
47
|
+
contentWidth: 844,
|
|
48
|
+
};
|
|
49
|
+
expect(getFooterGeometry({ ...landscape, ...SHEET }).kind).toBe('phone');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('caps the width at 600pt below an 800pt window, 800pt from it', () => {
|
|
53
|
+
expect(getFooterGeometry({ ...FOLD_PORTRAIT, ...ANCHORED })).toMatchObject({
|
|
54
|
+
kind: 'anchored',
|
|
55
|
+
width: 600,
|
|
56
|
+
});
|
|
57
|
+
expect(getFooterGeometry({ ...FOLD_LANDSCAPE, ...SHEET })).toMatchObject({
|
|
58
|
+
kind: 'sheet',
|
|
59
|
+
width: 800,
|
|
60
|
+
});
|
|
61
|
+
expect(getFooterGeometry({ ...TABLET, ...SHEET }).width).toBe(800);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('keeps the width inside the content area minus its margins', () => {
|
|
65
|
+
const duoPortrait = {
|
|
66
|
+
...NO_INSETS,
|
|
67
|
+
width: 669,
|
|
68
|
+
height: 900,
|
|
69
|
+
contentWidth: 585,
|
|
70
|
+
};
|
|
71
|
+
expect(getFooterGeometry({ ...duoPortrait, ...ANCHORED }).width).toBe(561);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('drops the sheet for an image background', () => {
|
|
75
|
+
const input = { ...FOLD_LANDSCAPE, ...SHEET, hasImageBackground: true };
|
|
76
|
+
expect(getFooterGeometry(input).kind).toBe('anchored');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('keeps the phone bar clear of the iPhone Duo side column', () => {
|
|
80
|
+
const duoOuter = { width: 390, height: 844, contentWidth: 306 };
|
|
81
|
+
const input = { ...duoOuter, insetLeft: 84, insetRight: 0, ...ANCHORED };
|
|
82
|
+
expect(getFooterGeometry(input)).toMatchObject({
|
|
83
|
+
barMargin: { left: 84, right: 0 },
|
|
84
|
+
contentPadding: { left: 0, right: 0 },
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('spans the anchored bar over the window, its content inside the insets', () => {
|
|
89
|
+
expect(getFooterGeometry({ ...DUO_INNER, ...ANCHORED })).toEqual({
|
|
90
|
+
kind: 'anchored',
|
|
91
|
+
width: 758,
|
|
92
|
+
barMargin: { left: 0, right: 0 },
|
|
93
|
+
contentPadding: { left: 84, right: 34 },
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('centers the sheet on the window, its width kept from the content area', () => {
|
|
98
|
+
expect(getFooterGeometry({ ...DUO_INNER, ...SHEET })).toEqual({
|
|
99
|
+
kind: 'sheet',
|
|
100
|
+
width: 758,
|
|
101
|
+
barMargin: { left: 0, right: 0 },
|
|
102
|
+
contentPadding: { left: 0, right: 0 },
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
describe('getFooterRowWidth', () => {
|
|
108
|
+
it('keeps the 12pt margins inside the foldable content area', () => {
|
|
109
|
+
const portrait = getFooterGeometry({ ...FOLD_PORTRAIT, ...ANCHORED });
|
|
110
|
+
const landscape = getFooterGeometry({ ...FOLD_LANDSCAPE, ...ANCHORED });
|
|
111
|
+
expect(getFooterRowWidth(portrait, true)).toBe(576);
|
|
112
|
+
expect(getFooterRowWidth(landscape, true)).toBe(776);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('fills the area without margins and leaves the phone row uncapped', () => {
|
|
116
|
+
const landscape = getFooterGeometry({ ...FOLD_LANDSCAPE, ...ANCHORED });
|
|
117
|
+
expect(getFooterRowWidth(landscape, false)).toBe(800);
|
|
118
|
+
const phone = getFooterGeometry({ ...PHONE, ...ANCHORED });
|
|
119
|
+
expect(getFooterRowWidth(phone, true)).toBeUndefined();
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe('getFooterStyle', () => {
|
|
124
|
+
it('lets the screen prop win over the host config', () => {
|
|
125
|
+
expect(getFooterStyle('anchored', 'sheet')).toBe('anchored');
|
|
126
|
+
expect(getFooterStyle(undefined, 'sheet')).toBe('sheet');
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('falls back to anchored for a missing or unknown value', () => {
|
|
130
|
+
expect(getFooterStyle()).toBe('anchored');
|
|
131
|
+
expect(getFooterStyle(undefined, 'floating')).toBe('anchored');
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
describe('getFooterSeparator', () => {
|
|
136
|
+
it('lets the screen prop win over the host config', () => {
|
|
137
|
+
expect(getFooterSeparator('border', 'shadow')).toBe('border');
|
|
138
|
+
expect(getFooterSeparator(undefined, 'shadow')).toBe('shadow');
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('falls back to border for a missing or unknown value', () => {
|
|
142
|
+
expect(getFooterSeparator()).toBe('border');
|
|
143
|
+
expect(getFooterSeparator(undefined, 'line')).toBe('border');
|
|
144
|
+
});
|
|
145
|
+
});
|
package/Layout/layoutMetrics.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Header geometry. */
|
|
2
2
|
export const HeaderMetrics = {
|
|
3
|
-
/** Navigation bar row below the status bar
|
|
4
|
-
barHeight:
|
|
3
|
+
/** Navigation bar row below the status bar. */
|
|
4
|
+
barHeight: 52,
|
|
5
5
|
/** Header never shorter than this on iPhone (landscape, iPhone Duo). */
|
|
6
6
|
iPhoneMinHeight: 72,
|
|
7
7
|
/** A smaller top inset means the status bar is not on the top edge. */
|
package/Layout/screenContent.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import { Animated, View } from 'react-native';
|
|
|
3
3
|
import { Spacing } from '../Consts';
|
|
4
4
|
import styles from './styles';
|
|
5
5
|
import { validateChildren } from './utils';
|
|
6
|
+
import { ANIMATED_BANNER_HEIGHT } from './screenTypes';
|
|
6
7
|
import { AnimatedHeader } from '../Application/types';
|
|
7
8
|
|
|
8
9
|
type ContentInset = { insetLeft: number; insetRight: number };
|
|
@@ -64,18 +65,23 @@ export const renderContent = (content: any, layout: ContentInset): any => {
|
|
|
64
65
|
};
|
|
65
66
|
|
|
66
67
|
/**
|
|
67
|
-
* Animated banner from `animatedHeader.component`, clipped
|
|
68
|
-
*
|
|
68
|
+
* Animated banner from `animatedHeader.component`, clipped to the banner height plus
|
|
69
|
+
* `layoutOffset`. Nothing without a component.
|
|
69
70
|
*/
|
|
70
71
|
export const renderAnimatedHeader = (
|
|
71
72
|
animatedHeader: AnimatedHeader | undefined,
|
|
72
|
-
|
|
73
|
+
layoutOffset: number,
|
|
73
74
|
animatedValue: Animated.Value,
|
|
74
75
|
sharedValue: any,
|
|
75
76
|
) => {
|
|
76
77
|
if (typeof animatedHeader?.component === 'function') {
|
|
77
78
|
return (
|
|
78
|
-
<View
|
|
79
|
+
<View
|
|
80
|
+
style={[
|
|
81
|
+
styles.screenBanner,
|
|
82
|
+
{ maxHeight: ANIMATED_BANNER_HEIGHT + layoutOffset },
|
|
83
|
+
]}
|
|
84
|
+
>
|
|
79
85
|
{animatedHeader?.component({
|
|
80
86
|
animatedValue,
|
|
81
87
|
sharedValue,
|