@momo-kits/foundation 0.169.17-beta.9 → 0.169.17
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 +12 -14
- package/Layout/Section.tsx +3 -14
- package/Layout/layoutMetrics.ts +2 -2
- package/Layout/screenContent.tsx +4 -10
- package/Layout/screenFooter.tsx +20 -175
- package/Layout/screenHeader.tsx +26 -31
- package/Layout/screenTypes.ts +4 -19
- package/Layout/styles.ts +0 -10
- package/Layout/types.ts +0 -6
- package/Layout/useHeaderBarOptions.ts +54 -0
- package/package.json +1 -1
- package/Layout/__tests__/screenFooter.test.ts +0 -56
|
@@ -2,14 +2,18 @@ import { useMemo } from 'react';
|
|
|
2
2
|
import { useWindowDimensions, type ViewStyle } from 'react-native';
|
|
3
3
|
import type { StackNavigationOptions } from '@react-navigation/stack';
|
|
4
4
|
import { Spacing } from '../Consts';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
getHeaderMargin,
|
|
7
|
+
getHeaderRowOptions,
|
|
8
|
+
useScreenLayout,
|
|
9
|
+
} from '../Layout/utils';
|
|
6
10
|
import { FOLDABLE_MIN_WIDTH } from './modalLayout';
|
|
7
11
|
import { isIPhoneDuo } from './utils';
|
|
8
12
|
|
|
9
13
|
// Top navigation spec, shared with the Compose / SwiftUI kits
|
|
10
14
|
const HEADER_FRAME_MAX_WIDTH = 600;
|
|
11
|
-
//
|
|
12
|
-
const
|
|
15
|
+
// banner image on wide windows and the iPhone Duo inner display: phone (375) × 1.2
|
|
16
|
+
const WIDE_BANNER_SCALE = 1.2;
|
|
13
17
|
|
|
14
18
|
/**
|
|
15
19
|
* Top navigation geometry on every device
|
|
@@ -17,10 +21,11 @@ const IS_STRETCH_FRAME_ENABLED = false;
|
|
|
17
21
|
* - pillWidth / pillHeight: help center | home capsule
|
|
18
22
|
* - clusterWidth: shortcut, gap and pill on the right of the bar
|
|
19
23
|
* - searchHeight: search field inside the header
|
|
24
|
+
* - searchBarHeight: header row holding the search, taller than the plain bar
|
|
20
25
|
* - titleGap: space between back and the title, and the title and the right cluster
|
|
21
26
|
* - sidePadding: bar edge to back and to the right cluster
|
|
22
27
|
* - gradientHeight: header gradient, kept at the phone height on wide windows
|
|
23
|
-
* - bannerWidth: animated banner image
|
|
28
|
+
* - bannerWidth: animated banner image on wide windows, centered (phone × 1.2)
|
|
24
29
|
*/
|
|
25
30
|
const HeaderBarMetrics = {
|
|
26
31
|
buttonSize: 32,
|
|
@@ -28,17 +33,17 @@ const HeaderBarMetrics = {
|
|
|
28
33
|
pillWidth: 72,
|
|
29
34
|
pillHeight: 32,
|
|
30
35
|
clusterWidth: 112,
|
|
31
|
-
searchHeight:
|
|
36
|
+
searchHeight: 40,
|
|
37
|
+
searchBarHeight: 56,
|
|
32
38
|
titleGap: Spacing.S,
|
|
33
39
|
sidePadding: Spacing.M,
|
|
34
40
|
gradientHeight: 154,
|
|
35
|
-
bannerWidth:
|
|
41
|
+
bannerWidth: 450,
|
|
36
42
|
};
|
|
37
43
|
|
|
38
44
|
/**
|
|
39
45
|
* `grid` keeps the header row at the bar edges, `stretch` centers it in a 600pt
|
|
40
|
-
* frame on wide windows
|
|
41
|
-
* bar always span the window.
|
|
46
|
+
* frame on wide windows. Background, status bar and the search always span the window.
|
|
42
47
|
*/
|
|
43
48
|
type HeaderContentLayout = 'grid' | 'stretch';
|
|
44
49
|
|
|
@@ -53,6 +58,10 @@ type HeaderLayout = typeof HeaderBarMetrics & {
|
|
|
53
58
|
* inner display, portrait and landscape.
|
|
54
59
|
*/
|
|
55
60
|
isBannerCentered: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Banner size against the phone banner: `WIDE_BANNER_SCALE` when centered, else 1.
|
|
63
|
+
*/
|
|
64
|
+
bannerScale: number;
|
|
56
65
|
/**
|
|
57
66
|
* Window edge to back and to the right cluster: `sidePadding`, or centering the
|
|
58
67
|
* row in the 600pt frame with `stretch` on a wide window.
|
|
@@ -71,6 +80,18 @@ type HeaderLayoutInput = {
|
|
|
71
80
|
contentLayout?: HeaderContentLayout;
|
|
72
81
|
};
|
|
73
82
|
|
|
83
|
+
type EdgePadding = { left: number; right: number };
|
|
84
|
+
|
|
85
|
+
type HeaderFrameInput = {
|
|
86
|
+
layout: HeaderLayout;
|
|
87
|
+
isDuo: boolean;
|
|
88
|
+
// side margin @react-navigation/elements already adds to the row
|
|
89
|
+
headerMargin: number;
|
|
90
|
+
// padding of the plain row containers: the iPhone Duo status bar clearance, else 0
|
|
91
|
+
edgePadding: EdgePadding;
|
|
92
|
+
contentLayout?: HeaderContentLayout;
|
|
93
|
+
};
|
|
94
|
+
|
|
74
95
|
/**
|
|
75
96
|
* Header geometry for a window, pure so it can be tested without a device.
|
|
76
97
|
*/
|
|
@@ -84,15 +105,19 @@ const getHeaderLayout = ({
|
|
|
84
105
|
const isLargeWindow = Math.min(width, height) >= FOLDABLE_MIN_WIDTH;
|
|
85
106
|
const isWide = !isDuo && isLargeWindow;
|
|
86
107
|
let frameInset = sidePadding;
|
|
87
|
-
|
|
88
|
-
if (isWide && isStretch) {
|
|
108
|
+
if (isWide && contentLayout === 'stretch') {
|
|
89
109
|
const centered = (width - HEADER_FRAME_MAX_WIDTH) / 2;
|
|
90
110
|
frameInset = Math.max(sidePadding, centered);
|
|
91
111
|
}
|
|
112
|
+
let bannerScale = 1;
|
|
113
|
+
if (isLargeWindow) {
|
|
114
|
+
bannerScale = WIDE_BANNER_SCALE;
|
|
115
|
+
}
|
|
92
116
|
return {
|
|
93
117
|
...HeaderBarMetrics,
|
|
94
118
|
isWide,
|
|
95
119
|
isBannerCentered: isLargeWindow,
|
|
120
|
+
bannerScale,
|
|
96
121
|
frameInset,
|
|
97
122
|
frameWidth: width - frameInset * 2,
|
|
98
123
|
};
|
|
@@ -117,6 +142,19 @@ const useHeaderLayout = (contentLayout?: HeaderContentLayout): HeaderLayout => {
|
|
|
117
142
|
}, [width, height, isDuo, contentLayout]);
|
|
118
143
|
};
|
|
119
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Header height once the search sits in its row: the row grows to `searchBarHeight`,
|
|
147
|
+
* a taller row (iPhone landscape, iPhone Duo) keeps its height.
|
|
148
|
+
*/
|
|
149
|
+
const getSearchHeaderHeight = (
|
|
150
|
+
headerHeight: number,
|
|
151
|
+
statusBarHeight: number,
|
|
152
|
+
) => {
|
|
153
|
+
const rowHeight = headerHeight - statusBarHeight;
|
|
154
|
+
const { searchBarHeight } = HeaderBarMetrics;
|
|
155
|
+
return statusBarHeight + Math.max(rowHeight, searchBarHeight);
|
|
156
|
+
};
|
|
157
|
+
|
|
120
158
|
const TITLE_CONTAINER_RESET: ViewStyle = {
|
|
121
159
|
marginLeft: 0,
|
|
122
160
|
marginEnd: 0,
|
|
@@ -127,33 +165,77 @@ const TITLE_CONTAINER_RESET: ViewStyle = {
|
|
|
127
165
|
};
|
|
128
166
|
|
|
129
167
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
|
|
168
|
+
* Container styles of the bar-edge row, set explicitly: options are merged, so a
|
|
169
|
+
* former `stretch` frame would otherwise stay after a layout switch or a fold.
|
|
170
|
+
*/
|
|
171
|
+
const getEdgeFrameOptions = (
|
|
172
|
+
edgePadding: EdgePadding,
|
|
173
|
+
): StackNavigationOptions => {
|
|
174
|
+
return {
|
|
175
|
+
headerLeftContainerStyle: { paddingLeft: edgePadding.left },
|
|
176
|
+
headerRightContainerStyle: { paddingRight: edgePadding.right },
|
|
177
|
+
headerTitleContainerStyle: {
|
|
178
|
+
...TITLE_CONTAINER_RESET,
|
|
179
|
+
left: HeaderBarMetrics.titleGap,
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* React Navigation container styles placing back, title and the right cluster for
|
|
186
|
+
* `contentLayout`: the 600pt frame with `stretch`, else the bar edges (also iPhone
|
|
187
|
+
* Duo). `undefined` when the screen leaves `contentLayout` unset.
|
|
188
|
+
*/
|
|
189
|
+
const getHeaderFrameOptions = ({
|
|
190
|
+
layout,
|
|
191
|
+
isDuo,
|
|
192
|
+
headerMargin,
|
|
193
|
+
edgePadding,
|
|
194
|
+
contentLayout,
|
|
195
|
+
}: HeaderFrameInput): StackNavigationOptions | undefined => {
|
|
196
|
+
if (!contentLayout) {
|
|
197
|
+
return undefined;
|
|
198
|
+
}
|
|
199
|
+
if (contentLayout !== 'stretch' || isDuo) {
|
|
200
|
+
return getEdgeFrameOptions(edgePadding);
|
|
201
|
+
}
|
|
202
|
+
// the header content row already sits this far in on large iOS windows
|
|
203
|
+
const shift = layout.frameInset - layout.sidePadding;
|
|
204
|
+
const containerShift = Math.max(0, shift - headerMargin);
|
|
205
|
+
return {
|
|
206
|
+
headerLeftContainerStyle: { paddingLeft: containerShift },
|
|
207
|
+
headerRightContainerStyle: { paddingRight: containerShift },
|
|
208
|
+
headerTitleContainerStyle: {
|
|
209
|
+
...TITLE_CONTAINER_RESET,
|
|
210
|
+
left: layout.titleGap,
|
|
211
|
+
maxWidth: getTitleBudget(layout),
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Container styles for `contentLayout` on the current window, re-computed on fold,
|
|
218
|
+
* unfold and rotation; see `getHeaderFrameOptions`.
|
|
133
219
|
*/
|
|
134
220
|
const useHeaderFrameOptions = (
|
|
135
221
|
contentLayout?: HeaderContentLayout,
|
|
136
222
|
): StackNavigationOptions | undefined => {
|
|
137
223
|
const layout = useHeaderLayout(contentLayout);
|
|
138
|
-
const
|
|
224
|
+
const screenLayout = useScreenLayout();
|
|
225
|
+
const rowOptions = getHeaderRowOptions(screenLayout);
|
|
226
|
+
const edgeLeft = rowOptions.headerLeftContainerStyle?.paddingLeft ?? 0;
|
|
227
|
+
const edgeRight = rowOptions.headerRightContainerStyle?.paddingRight ?? 0;
|
|
228
|
+
const headerMargin = getHeaderMargin(screenLayout.width);
|
|
139
229
|
const isDuo = isIPhoneDuo();
|
|
140
230
|
return useMemo(() => {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
headerRightContainerStyle: { paddingRight: containerShift },
|
|
150
|
-
headerTitleContainerStyle: {
|
|
151
|
-
...TITLE_CONTAINER_RESET,
|
|
152
|
-
left: layout.titleGap,
|
|
153
|
-
maxWidth: getTitleBudget(layout),
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
}, [contentLayout, isDuo, layout, width]);
|
|
231
|
+
return getHeaderFrameOptions({
|
|
232
|
+
layout,
|
|
233
|
+
isDuo,
|
|
234
|
+
headerMargin,
|
|
235
|
+
edgePadding: { left: edgeLeft, right: edgeRight },
|
|
236
|
+
contentLayout,
|
|
237
|
+
});
|
|
238
|
+
}, [contentLayout, isDuo, layout, headerMargin, edgeLeft, edgeRight]);
|
|
157
239
|
};
|
|
158
240
|
|
|
159
241
|
export type { HeaderContentLayout, HeaderLayout };
|
|
@@ -162,7 +244,9 @@ export {
|
|
|
162
244
|
HeaderBarMetrics,
|
|
163
245
|
HEADER_FRAME_MAX_WIDTH,
|
|
164
246
|
TITLE_CONTAINER_RESET,
|
|
247
|
+
getHeaderFrameOptions,
|
|
165
248
|
getHeaderLayout,
|
|
249
|
+
getSearchHeaderHeight,
|
|
166
250
|
getTitleBudget,
|
|
167
251
|
useHeaderLayout,
|
|
168
252
|
useHeaderFrameOptions,
|
|
@@ -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 = 600;
|
|
12
12
|
const SHEET_MIN_WIDTH = 296;
|
|
13
13
|
const SHEET_MIN_HEIGHT = 230;
|
|
14
14
|
const FOLDABLE_MIN_WIDTH = 600;
|
|
@@ -46,6 +46,12 @@ 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;
|
|
49
55
|
};
|
|
50
56
|
|
|
51
57
|
sheet: {
|
|
@@ -53,6 +59,12 @@ export type ModalLayout = {
|
|
|
53
59
|
* `undefined` on phones, the sheet spans the window.
|
|
54
60
|
*/
|
|
55
61
|
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;
|
|
56
68
|
maxHeight?: number;
|
|
57
69
|
minHeight?: number;
|
|
58
70
|
margin: number;
|
|
@@ -79,11 +91,22 @@ const clamp = (value: number, min: number, max: number) => {
|
|
|
79
91
|
};
|
|
80
92
|
|
|
81
93
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
94
|
+
* Window x of a `boxWidth` wide overlay: centered on `center` (the window, so
|
|
95
|
+
* an inset on one side does not push it off center) but `margin` inside the
|
|
96
|
+
* placement; centered in the placement when it does not fit with the margins.
|
|
84
97
|
*/
|
|
85
|
-
const
|
|
86
|
-
|
|
98
|
+
const overlayX = (
|
|
99
|
+
center: number,
|
|
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);
|
|
87
110
|
};
|
|
88
111
|
|
|
89
112
|
/**
|
|
@@ -96,9 +119,10 @@ const getModalLayout = ({
|
|
|
96
119
|
isDuo,
|
|
97
120
|
hinge,
|
|
98
121
|
}: ModalLayoutInput): ModalLayout => {
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
const
|
|
122
|
+
const shortSide = Math.min(width, height);
|
|
123
|
+
// short side, so a phone in landscape stays a phone
|
|
124
|
+
const isFoldable = isDuo || shortSide >= FOLDABLE_MIN_WIDTH;
|
|
125
|
+
const isDuoOuter = isDuo && shortSide < FOLDABLE_MIN_WIDTH;
|
|
102
126
|
const hingeRight = hinge ? hinge.x + hinge.width : 0;
|
|
103
127
|
const hasHinge = !!hinge && hinge.x > 0;
|
|
104
128
|
const isHingeInWindow = hingeRight < width - insets.right;
|
|
@@ -137,12 +161,20 @@ const getModalLayout = ({
|
|
|
137
161
|
const sheetSpace = placement.width - sheetMargin * 2;
|
|
138
162
|
const sheetMinWidth = Math.min(SHEET_MIN_WIDTH, sheetSpace);
|
|
139
163
|
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
|
+
}
|
|
140
171
|
|
|
141
172
|
return {
|
|
142
173
|
isFoldable,
|
|
143
174
|
placement,
|
|
144
175
|
popup: {
|
|
145
|
-
width:
|
|
176
|
+
width: popupWidth,
|
|
177
|
+
x: overlayX(overlayCenter, placement, popupWidth, popupMargin),
|
|
146
178
|
minWidth: popupMinWidth,
|
|
147
179
|
maxWidth: POPUP_MAX_WIDTH,
|
|
148
180
|
maxHeight: Math.min(POPUP_MAX_HEIGHT, placement.height - Spacing.XL * 2),
|
|
@@ -150,7 +182,8 @@ const getModalLayout = ({
|
|
|
150
182
|
radius: Radius.XL,
|
|
151
183
|
},
|
|
152
184
|
sheet: {
|
|
153
|
-
width:
|
|
185
|
+
width: sheetWidth,
|
|
186
|
+
x: overlayX(overlayCenter, placement, sheetWidth, sheetMargin),
|
|
154
187
|
maxHeight: sheetMaxHeight,
|
|
155
188
|
minHeight: Math.min(SHEET_MIN_HEIGHT, sheetMaxHeight),
|
|
156
189
|
margin: sheetMargin,
|
|
@@ -173,7 +206,6 @@ const useModalLayout = (): ModalLayout => {
|
|
|
173
206
|
|
|
174
207
|
export {
|
|
175
208
|
getModalLayout,
|
|
176
|
-
isFoldableWindow,
|
|
177
209
|
useModalLayout,
|
|
178
210
|
POPUP_MAX_WIDTH,
|
|
179
211
|
POPUP_MIN_WIDTH,
|
|
@@ -99,10 +99,16 @@ 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 is centered at phone width × 1.2; this
|
|
103
103
|
* color fills the sides and fades to transparent downward. No fill when unset.
|
|
104
|
+
* `bannerGradientColors` wins when both are set.
|
|
104
105
|
*/
|
|
105
106
|
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[];
|
|
106
112
|
}
|
|
107
113
|
|
|
108
114
|
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 (shown
|
|
57
|
+
* once there is a value) and the clear/trailing icons.
|
|
58
58
|
*/
|
|
59
59
|
export const InputMoneyView = ({
|
|
60
60
|
size,
|
|
@@ -101,13 +101,8 @@ export const InputMoneyView = ({
|
|
|
101
101
|
fontSize: scaledFontSize,
|
|
102
102
|
fontFamily: inputFontFamily,
|
|
103
103
|
};
|
|
104
|
-
const
|
|
105
|
-
const shouldShowCurrency = !!displayValue || hasCurrencyInPlaceholder;
|
|
104
|
+
const hasValue = displayValue.length > 0;
|
|
106
105
|
const shouldShowClearIcon = !!(showClearIcon && focused && displayValue);
|
|
107
|
-
let inputPlaceholder = placeholder;
|
|
108
|
-
if (hasCurrencyInPlaceholder) {
|
|
109
|
-
inputPlaceholder = placeholder.slice(0, -currency.length);
|
|
110
|
-
}
|
|
111
106
|
return (
|
|
112
107
|
<View
|
|
113
108
|
style={[
|
|
@@ -148,18 +143,15 @@ export const InputMoneyView = ({
|
|
|
148
143
|
onChangeText={onChangeText}
|
|
149
144
|
onFocus={onFocus}
|
|
150
145
|
onBlur={onBlur}
|
|
151
|
-
placeholder={
|
|
146
|
+
placeholder={placeholder}
|
|
152
147
|
selectionColor={theme.colors.primary}
|
|
153
148
|
placeholderTextColor={placeholderColor}
|
|
154
149
|
keyboardType={'numeric'}
|
|
155
150
|
maxLength={undefined}
|
|
156
151
|
/>
|
|
157
|
-
{
|
|
152
|
+
{hasValue && (
|
|
158
153
|
<Text
|
|
159
|
-
style={[
|
|
160
|
-
textStyle,
|
|
161
|
-
{ color: displayValue ? textColor : placeholderColor },
|
|
162
|
-
]}
|
|
154
|
+
style={[textStyle, { color: textColor }]}
|
|
163
155
|
allowFontScaling={false}
|
|
164
156
|
>
|
|
165
157
|
{currency}
|
package/Layout/Screen.tsx
CHANGED
|
@@ -28,14 +28,11 @@ 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 {
|
|
31
|
+
import { useHeaderLayout } from '../Application/headerLayout';
|
|
32
|
+
import { ANIMATED_BANNER_HEIGHT, ScreenProps } from './screenTypes';
|
|
32
33
|
import { renderAnimatedHeader, renderContent } from './screenContent';
|
|
33
34
|
import { createScrollHandlers } from './screenScroll';
|
|
34
|
-
import {
|
|
35
|
-
renderFooterSpacer,
|
|
36
|
-
ScreenFooter,
|
|
37
|
-
useFooterLayout,
|
|
38
|
-
} from './screenFooter';
|
|
35
|
+
import { ScreenFooter } from './screenFooter';
|
|
39
36
|
import { useScreenHeader } from './screenHeader';
|
|
40
37
|
import { useScreenQuickReturn } from './screenQuickReturn';
|
|
41
38
|
|
|
@@ -57,8 +54,6 @@ const Screen = forwardRef(
|
|
|
57
54
|
headerComponent: Header,
|
|
58
55
|
footerComponent: Footer,
|
|
59
56
|
marginFooter = true,
|
|
60
|
-
footerStyle,
|
|
61
|
-
footerHasImageBackground: hasImageFooter,
|
|
62
57
|
layoutOffset = -56,
|
|
63
58
|
headerRightWidth,
|
|
64
59
|
backgroundColor,
|
|
@@ -84,7 +79,9 @@ const Screen = forwardRef(
|
|
|
84
79
|
const insets = useSafeAreaInsets();
|
|
85
80
|
const frame = useSafeAreaFrame();
|
|
86
81
|
const heightHeader = useHeaderHeight();
|
|
87
|
-
const
|
|
82
|
+
const { bannerScale } = useHeaderLayout(contentLayout);
|
|
83
|
+
// the banner grows with its image on wide windows, the content keeps its overlap
|
|
84
|
+
const bannerBottom = ANIMATED_BANNER_HEIGHT * bannerScale + layoutOffset;
|
|
88
85
|
|
|
89
86
|
const animatedValue = useRef<Animated.Value>(
|
|
90
87
|
customAnimatedValue ?? new Animated.Value(0),
|
|
@@ -151,7 +148,7 @@ const Screen = forwardRef(
|
|
|
151
148
|
useShadowHeader,
|
|
152
149
|
gradientColor,
|
|
153
150
|
headerBackground,
|
|
154
|
-
|
|
151
|
+
bannerBottom,
|
|
155
152
|
contentLayout,
|
|
156
153
|
});
|
|
157
154
|
|
|
@@ -202,7 +199,7 @@ const Screen = forwardRef(
|
|
|
202
199
|
|
|
203
200
|
let floatingButtonBottom = bottomInset + Spacing.S;
|
|
204
201
|
if (Footer) {
|
|
205
|
-
floatingButtonBottom = 12
|
|
202
|
+
floatingButtonBottom = 12;
|
|
206
203
|
} else if (isTab) {
|
|
207
204
|
floatingButtonBottom = 12 + duoTabInset;
|
|
208
205
|
}
|
|
@@ -286,13 +283,12 @@ const Screen = forwardRef(
|
|
|
286
283
|
>
|
|
287
284
|
{renderAnimatedHeader(
|
|
288
285
|
animatedHeader,
|
|
289
|
-
|
|
286
|
+
bannerBottom,
|
|
290
287
|
animatedValue.current,
|
|
291
288
|
sharedValue,
|
|
292
289
|
)}
|
|
293
290
|
|
|
294
291
|
{useGridLayout ? renderContent(children, layout) : children}
|
|
295
|
-
{renderFooterSpacer(footerLayout.overlap)}
|
|
296
292
|
</Component>
|
|
297
293
|
|
|
298
294
|
{floatingButtonProps && (
|
|
@@ -314,7 +310,9 @@ const Screen = forwardRef(
|
|
|
314
310
|
<ScreenFooter
|
|
315
311
|
footer={Footer}
|
|
316
312
|
marginFooter={marginFooter}
|
|
317
|
-
|
|
313
|
+
insetLeft={layout.insetLeft}
|
|
314
|
+
insetRight={layout.insetRight}
|
|
315
|
+
hasContentInset={hasContentInset}
|
|
318
316
|
isTab={isTab}
|
|
319
317
|
duoTabInset={duoTabInset}
|
|
320
318
|
bottomInset={bottomInset}
|
package/Layout/Section.tsx
CHANGED
|
@@ -24,22 +24,16 @@ 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;
|
|
32
27
|
}
|
|
33
28
|
|
|
34
29
|
/**
|
|
35
|
-
* Content-wide grid row (12 or 24 columns) with optional side margins
|
|
36
|
-
*
|
|
30
|
+
* Content-wide grid row (12 or 24 columns) with optional side margins; child Items size
|
|
31
|
+
* themselves from its GridContext.
|
|
37
32
|
*/
|
|
38
33
|
const Section: React.FC<SectionProps> = ({
|
|
39
34
|
children,
|
|
40
35
|
useMargin = true,
|
|
41
36
|
backgroundImage,
|
|
42
|
-
maxWidth,
|
|
43
37
|
style,
|
|
44
38
|
...props
|
|
45
39
|
}) => {
|
|
@@ -51,11 +45,7 @@ const Section: React.FC<SectionProps> = ({
|
|
|
51
45
|
if (useMargin) {
|
|
52
46
|
margin = 12;
|
|
53
47
|
}
|
|
54
|
-
const
|
|
55
|
-
let widthSection = contentWidth - margin * 2;
|
|
56
|
-
if (isCapped) {
|
|
57
|
-
widthSection = Math.min(widthSection, maxWidth);
|
|
58
|
-
}
|
|
48
|
+
const widthSection = contentWidth - margin * 2;
|
|
59
49
|
|
|
60
50
|
const columnsWidth = widthSection - gutterSize * (numberOfColumns - 1);
|
|
61
51
|
const sizePerSpan = columnsWidth / numberOfColumns - 1 / numberOfColumns;
|
|
@@ -78,7 +68,6 @@ const Section: React.FC<SectionProps> = ({
|
|
|
78
68
|
style,
|
|
79
69
|
styles.protectedStyle,
|
|
80
70
|
styles.rowWrap,
|
|
81
|
-
isCapped && styles.centered,
|
|
82
71
|
{
|
|
83
72
|
width: widthSection,
|
|
84
73
|
marginHorizontal: margin,
|
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; a search row is taller (searchBarHeight). */
|
|
4
|
+
barHeight: 48,
|
|
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,7 +3,6 @@ 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';
|
|
7
6
|
import { AnimatedHeader } from '../Application/types';
|
|
8
7
|
|
|
9
8
|
type ContentInset = { insetLeft: number; insetRight: number };
|
|
@@ -65,23 +64,18 @@ export const renderContent = (content: any, layout: ContentInset): any => {
|
|
|
65
64
|
};
|
|
66
65
|
|
|
67
66
|
/**
|
|
68
|
-
* Animated banner from `animatedHeader.component`, clipped
|
|
69
|
-
* `layoutOffset
|
|
67
|
+
* Animated banner from `animatedHeader.component`, clipped at `bannerBottom` (banner
|
|
68
|
+
* height plus `layoutOffset`). Nothing without a component.
|
|
70
69
|
*/
|
|
71
70
|
export const renderAnimatedHeader = (
|
|
72
71
|
animatedHeader: AnimatedHeader | undefined,
|
|
73
|
-
|
|
72
|
+
bannerBottom: number,
|
|
74
73
|
animatedValue: Animated.Value,
|
|
75
74
|
sharedValue: any,
|
|
76
75
|
) => {
|
|
77
76
|
if (typeof animatedHeader?.component === 'function') {
|
|
78
77
|
return (
|
|
79
|
-
<View
|
|
80
|
-
style={[
|
|
81
|
-
styles.screenBanner,
|
|
82
|
-
{ maxHeight: ANIMATED_BANNER_HEIGHT + layoutOffset },
|
|
83
|
-
]}
|
|
84
|
-
>
|
|
78
|
+
<View style={[styles.screenBanner, { maxHeight: bannerBottom }]}>
|
|
85
79
|
{animatedHeader?.component({
|
|
86
80
|
animatedValue,
|
|
87
81
|
sharedValue,
|