@momo-kits/foundation 0.169.18-beta.3 → 0.169.19-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 +8 -18
- package/Application/BottomTab/BottomTabBar.styles.ts +1 -1
- package/Application/BottomTab/DuoTabBar.styles.ts +1 -1
- package/Application/BottomTab/TabBarIcon.tsx +1 -1
- 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 +15 -6
- package/Application/StackScreen.tsx +6 -2
- package/Application/TooltipPortal.tsx +3 -3
- package/Application/__tests__/headerLayout.test.ts +113 -0
- package/Application/headerLayout.ts +114 -30
- package/Application/hooks.ts +1 -1
- package/Application/modalLayout.ts +43 -11
- package/Application/types.header.ts +7 -1
- package/Button/index.tsx +2 -2
- package/Divider/DashDivider.tsx +2 -2
- package/Divider/index.tsx +3 -3
- package/FoundationList/index.tsx +1 -1
- package/Icon/types.ts +1 -2
- package/Image/index.tsx +62 -7
- package/Image/styles.ts +2 -0
- package/Image/types.ts +9 -1
- package/Input/CountryCodeView.tsx +18 -2
- package/Input/ErrorView.tsx +1 -1
- package/Input/Input.tsx +2 -2
- package/Input/InputMoney.tsx +7 -2
- package/Input/InputMoneyView.tsx +8 -16
- package/Input/InputOTP.tsx +2 -2
- package/Input/InputPhoneNumber.tsx +2 -2
- package/Input/InputSearch.tsx +2 -2
- package/Input/InputTextArea.tsx +2 -2
- package/Input/SearchTextTyping.tsx +2 -2
- package/Input/SystemTextInput.tsx +2 -1
- package/Input/TextTyping.tsx +7 -2
- package/Input/index.tsx +2 -1
- 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 -273
- 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/Pagination/types.ts +6 -2
- package/package.json +28 -26
- package/Layout/__tests__/screenFooter.test.ts +0 -142
|
@@ -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,
|
package/Application/hooks.ts
CHANGED
|
@@ -54,7 +54,7 @@ const useAppState = () => {
|
|
|
54
54
|
|
|
55
55
|
useEffect(() => {
|
|
56
56
|
const subscription = AppState.addEventListener('change', nextAppState => {
|
|
57
|
-
const wasInBackground = /inactive|background/.test(appState.current);
|
|
57
|
+
const wasInBackground = /inactive|background/.test(appState.current ?? '');
|
|
58
58
|
const isReturning = wasInBackground && nextAppState === 'active';
|
|
59
59
|
isBackgroundToForeground.current = isReturning;
|
|
60
60
|
appState.current = nextAppState;
|
|
@@ -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/Button/index.tsx
CHANGED
|
@@ -192,10 +192,10 @@ const Button: FC<ButtonProps> = ({
|
|
|
192
192
|
|
|
193
193
|
const sizeStyle = getSizeStyle();
|
|
194
194
|
const typeStyle = getTypeStyle(type, theme, color);
|
|
195
|
-
const containerStyle
|
|
195
|
+
const containerStyle = StyleSheet.flatten([
|
|
196
196
|
full && { width: '100%' },
|
|
197
197
|
loading && { opacity: 0.75 },
|
|
198
|
-
]);
|
|
198
|
+
]) as ViewStyle;
|
|
199
199
|
const buttonStyle = StyleSheet.flatten([sizeStyle, typeStyle]);
|
|
200
200
|
|
|
201
201
|
const animatedStyle = useAnimatedStyle(() => {
|
package/Divider/DashDivider.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
|
-
import { StyleSheet, View, ViewStyle } from 'react-native';
|
|
2
|
+
import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
|
|
3
3
|
import { ApplicationContext } from '../Context';
|
|
4
4
|
import { Spacing } from '../Consts';
|
|
5
5
|
import Svg, { Line } from 'react-native-svg';
|
|
@@ -8,7 +8,7 @@ export interface DashDividerProps {
|
|
|
8
8
|
/**
|
|
9
9
|
* Custom styles for dash divider
|
|
10
10
|
*/
|
|
11
|
-
style?: ViewStyle
|
|
11
|
+
style?: StyleProp<ViewStyle>;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/** 1px dashed horizontal line in the default border color. */
|
package/Divider/index.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
|
-
import { StyleSheet, View, ViewStyle } from 'react-native';
|
|
2
|
+
import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
|
|
3
3
|
import { ApplicationContext } from '../Context';
|
|
4
4
|
import { Spacing } from '../Consts';
|
|
5
5
|
import { DashDivider } from './DashDivider';
|
|
@@ -8,7 +8,7 @@ export interface DividerProps {
|
|
|
8
8
|
/**
|
|
9
9
|
* Custom styles for divider
|
|
10
10
|
*/
|
|
11
|
-
style?: ViewStyle
|
|
11
|
+
style?: StyleProp<ViewStyle>;
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Enable margin vertical 4px
|
|
@@ -34,10 +34,10 @@ const Divider: React.FC<DividerProps> = ({
|
|
|
34
34
|
return (
|
|
35
35
|
<View
|
|
36
36
|
style={[
|
|
37
|
-
style,
|
|
38
37
|
styles.divider,
|
|
39
38
|
useMargin ? styles.margin : styles.noMargin,
|
|
40
39
|
{ backgroundColor: theme.colors.border.default },
|
|
40
|
+
style,
|
|
41
41
|
]}
|
|
42
42
|
/>
|
|
43
43
|
);
|
package/FoundationList/index.tsx
CHANGED
|
@@ -10,7 +10,7 @@ type CombinedListProps<ItemT> = FlatListProps<ItemT> &
|
|
|
10
10
|
* switch to it without type changes.
|
|
11
11
|
*/
|
|
12
12
|
const FoundationList = <ItemT,>(props: CombinedListProps<ItemT>) => {
|
|
13
|
-
return <FlashList {...props} />;
|
|
13
|
+
return <FlashList {...(props as FlashListProps<ItemT>)} />;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export { FoundationList };
|
package/Icon/types.ts
CHANGED
package/Image/index.tsx
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import React, { useContext, useRef, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
ImageBackground,
|
|
4
|
+
ImageSourcePropType,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
View,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
import FastImage, { FastImageProps } from 'react-native-fast-image';
|
|
4
9
|
import styles from './styles';
|
|
5
10
|
import {
|
|
6
11
|
ApplicationContext,
|
|
@@ -24,6 +29,10 @@ export const getImageName = (source: any): string => {
|
|
|
24
29
|
return '';
|
|
25
30
|
};
|
|
26
31
|
|
|
32
|
+
const isDataUriSource = (source: any): boolean => {
|
|
33
|
+
return typeof source?.uri === 'string' && source.uri.startsWith('data:');
|
|
34
|
+
};
|
|
35
|
+
|
|
27
36
|
/**
|
|
28
37
|
* FastImage that shows a skeleton while loading (if `loading`) or inside a
|
|
29
38
|
* loading `SkeletonProvider`, and a fail icon on error.
|
|
@@ -48,6 +57,7 @@ const Image: React.FC<ImageProps> = ({
|
|
|
48
57
|
const [status, setStatus] = useState<Status>('success');
|
|
49
58
|
|
|
50
59
|
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
60
|
+
const useFastImage = !isDataUriSource(source);
|
|
51
61
|
|
|
52
62
|
const imageName = getImageName(source);
|
|
53
63
|
let accessibilityLabel: any = `img|${imageName}`;
|
|
@@ -81,16 +91,61 @@ const Image: React.FC<ImageProps> = ({
|
|
|
81
91
|
return children;
|
|
82
92
|
};
|
|
83
93
|
|
|
94
|
+
if (!useFastImage) {
|
|
95
|
+
// RN <Image> throws when given children (skeleton / fail icon), so use
|
|
96
|
+
// ImageBackground, which renders them on top of the image like FastImage.
|
|
97
|
+
return (
|
|
98
|
+
<ImageBackground
|
|
99
|
+
{...(rest as any)}
|
|
100
|
+
{...{
|
|
101
|
+
accessibilityLabel: rest.accessibilityLabel ?? accessibilityLabel,
|
|
102
|
+
}}
|
|
103
|
+
source={source as ImageSourcePropType}
|
|
104
|
+
style={[
|
|
105
|
+
styles.dataUriContainer,
|
|
106
|
+
styles.container,
|
|
107
|
+
style,
|
|
108
|
+
showBaseLineDebug && styles.debugBaseLine,
|
|
109
|
+
]}
|
|
110
|
+
onLoadStart={() => {
|
|
111
|
+
hasErrorRef.current = false;
|
|
112
|
+
if (status !== 'loading' && loading) {
|
|
113
|
+
setStatus('loading');
|
|
114
|
+
}
|
|
115
|
+
}}
|
|
116
|
+
onLoad={() => {
|
|
117
|
+
hasErrorRef.current = false;
|
|
118
|
+
}}
|
|
119
|
+
onLoadEnd={() => {
|
|
120
|
+
let current: Status = 'success';
|
|
121
|
+
if (hasErrorRef.current) {
|
|
122
|
+
current = 'error';
|
|
123
|
+
}
|
|
124
|
+
setStatus(prevState =>
|
|
125
|
+
prevState !== current ? current : prevState,
|
|
126
|
+
);
|
|
127
|
+
}}
|
|
128
|
+
onError={() => {
|
|
129
|
+
hasErrorRef.current = true;
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
132
|
+
{renderContent()}
|
|
133
|
+
</ImageBackground>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
84
137
|
return (
|
|
85
138
|
<FastImage
|
|
86
139
|
{...rest}
|
|
87
140
|
{...{ accessibilityLabel: rest.accessibilityLabel ?? accessibilityLabel }}
|
|
88
141
|
source={source}
|
|
89
|
-
style={
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
142
|
+
style={
|
|
143
|
+
[
|
|
144
|
+
styles.container,
|
|
145
|
+
style,
|
|
146
|
+
showBaseLineDebug && styles.debugBaseLine,
|
|
147
|
+
] as FastImageProps['style']
|
|
148
|
+
}
|
|
94
149
|
onProgress={event => {
|
|
95
150
|
hasErrorRef.current = false;
|
|
96
151
|
if (status !== 'loading' && loading) {
|
package/Image/styles.ts
CHANGED
|
@@ -3,5 +3,7 @@ import { Colors } from '../Consts';
|
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
5
|
container: {},
|
|
6
|
+
// same clipping as FastImage's container, so borderRadius rounds the image
|
|
7
|
+
dataUriContainer: { overflow: 'hidden' },
|
|
6
8
|
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
7
9
|
});
|
package/Image/types.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
import { ImageStyle, StyleProp } from 'react-native';
|
|
1
2
|
import { FastImageProps } from 'react-native-fast-image';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* `style` uses React Native's own `ImageStyle`: from RN 0.87 (Strict TS API)
|
|
6
|
+
* react-native no longer exports `FlexStyle`/`ShadowStyleIOS`, which
|
|
7
|
+
* react-native-fast-image's `ImageStyle` extends, so that type lost layout
|
|
8
|
+
* props such as `width`, `margin*` or `position`.
|
|
9
|
+
*/
|
|
10
|
+
export interface ImageProps extends Omit<FastImageProps, 'style'> {
|
|
11
|
+
style?: StyleProp<ImageStyle>;
|
|
4
12
|
loading?: boolean;
|
|
5
13
|
accessibilityLabel?: any;
|
|
6
14
|
params?: any;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
3
3
|
import { Colors, Spacing, Styles } from '../Consts';
|
|
4
|
+
import { Icon } from '../Icon';
|
|
4
5
|
import { Image } from '../Image';
|
|
5
6
|
import { Text } from '../Text';
|
|
6
7
|
import { Typography } from '../Text/types';
|
|
7
8
|
import styles from './styles';
|
|
8
9
|
|
|
9
10
|
const FLAG_SIZE = 24;
|
|
11
|
+
const CHEVRON_SIZE = 16;
|
|
10
12
|
|
|
11
13
|
type CountryCodeViewProps = {
|
|
12
14
|
countryCode: string;
|
|
@@ -20,8 +22,9 @@ type CountryCodeViewProps = {
|
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
|
-
* Flag, dial code and divider ahead of a phone number. Only becomes a button
|
|
24
|
-
* when `onPress` is given, so the default
|
|
25
|
+
* Flag, dial code and divider ahead of a phone number. Only becomes a button,
|
|
26
|
+
* with a chevron after the code, when `onPress` is given, so the default
|
|
27
|
+
* render stays a plain view.
|
|
25
28
|
*/
|
|
26
29
|
const CountryCodeView: React.FC<CountryCodeViewProps> = ({
|
|
27
30
|
countryCode,
|
|
@@ -45,6 +48,16 @@ const CountryCodeView: React.FC<CountryCodeViewProps> = ({
|
|
|
45
48
|
<Text typography={typography} color={textColor}>
|
|
46
49
|
{countryCode}
|
|
47
50
|
</Text>
|
|
51
|
+
{/* Kept while disabled (greyed by textColor) so the layout doesn't shift. */}
|
|
52
|
+
{onPress && (
|
|
53
|
+
<Icon
|
|
54
|
+
source="arrow_chevron_down_small"
|
|
55
|
+
size={CHEVRON_SIZE}
|
|
56
|
+
color={textColor}
|
|
57
|
+
style={innerStyle.chevron}
|
|
58
|
+
accessibilityLabel={`${componentId}|leading-chevron`}
|
|
59
|
+
/>
|
|
60
|
+
)}
|
|
48
61
|
</>
|
|
49
62
|
);
|
|
50
63
|
|
|
@@ -88,6 +101,9 @@ const innerStyle = StyleSheet.create({
|
|
|
88
101
|
height: FLAG_SIZE,
|
|
89
102
|
marginHorizontal: Spacing.XXS,
|
|
90
103
|
},
|
|
104
|
+
chevron: {
|
|
105
|
+
marginLeft: Spacing.XS,
|
|
106
|
+
},
|
|
91
107
|
});
|
|
92
108
|
|
|
93
109
|
export { CountryCodeView };
|
package/Input/ErrorView.tsx
CHANGED
package/Input/Input.tsx
CHANGED
|
@@ -6,10 +6,10 @@ import React, {
|
|
|
6
6
|
useState,
|
|
7
7
|
} from 'react';
|
|
8
8
|
import {
|
|
9
|
-
TextInput,
|
|
10
9
|
TextInputFocusEvent,
|
|
11
10
|
TouchableOpacity,
|
|
12
11
|
View,
|
|
12
|
+
type TextInputInstance,
|
|
13
13
|
} from 'react-native';
|
|
14
14
|
import { useComponentId } from '../Application';
|
|
15
15
|
import { Icon } from '../Icon';
|
|
@@ -81,7 +81,7 @@ const Input = forwardRef(
|
|
|
81
81
|
const [isFocused, setIsFocused] = useState(false);
|
|
82
82
|
const [internalText, setInternalText] = useState(defaultValue || '');
|
|
83
83
|
const hasValue = value !== undefined ? !!value : !!internalText;
|
|
84
|
-
const inputRef = useRef<
|
|
84
|
+
const inputRef = useRef<TextInputInstance | null>(null);
|
|
85
85
|
const componentName = 'Input';
|
|
86
86
|
|
|
87
87
|
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|