@momo-kits/foundation 0.168.1-beta.39 → 0.168.1-beta.40
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.tsx +398 -86
- package/Application/BottomTab/BottomTabBar.tsx +275 -215
- package/Application/BottomTab/CustomBottomTabItem.tsx +107 -131
- package/Application/BottomTab/DuoBarCompression.tsx +28 -14
- package/Application/BottomTab/DuoTabBar.tsx +540 -32
- package/Application/BottomTab/TabBarIcon.tsx +72 -146
- package/Application/BottomTab/index.tsx +353 -89
- package/Application/BottomTab/useLiquidSelection.ts +374 -0
- package/Application/Components/BackgroundImageView.tsx +0 -4
- package/Application/Components/DuoGlassBackground.tsx +5 -7
- package/Application/Components/HeaderAnimated.tsx +13 -41
- package/Application/Components/HeaderBackground.tsx +3 -20
- package/Application/Components/HeaderExtendHeader.tsx +46 -66
- package/Application/Components/HeaderLeft.tsx +18 -5
- package/Application/Components/HeaderRight.tsx +529 -8
- package/Application/Components/HeaderTitle.tsx +579 -16
- package/Application/Components/NavigationButton.tsx +11 -18
- package/Application/Components/SearchHeader.tsx +18 -38
- package/Application/Localize.ts +0 -7
- package/Application/ModalScreen.tsx +18 -41
- package/Application/Navigation.ts +17 -15
- package/Application/NavigationContainer.tsx +21 -23
- package/Application/Navigator.ts +48 -20
- package/Application/ScaleSizeProvider.tsx +6 -13
- package/Application/StackScreen.tsx +172 -27
- package/Application/TooltipPortal.tsx +5 -12
- package/Application/WidgetContainer.tsx +7 -20
- package/Application/device.ts +52 -0
- package/Application/index.ts +1 -23
- package/Application/types.ts +242 -17
- package/Application/utils.tsx +493 -0
- package/Badge/Badge.tsx +0 -5
- package/Badge/BadgeDot.tsx +0 -1
- package/Badge/BadgeDotAnimation.tsx +7 -15
- package/Badge/BadgeRibbon.tsx +39 -47
- package/Badge/Shape.tsx +0 -2
- package/Badge/styles.ts +0 -2
- package/Badge/types.ts +2 -2
- package/Button/index.tsx +152 -21
- package/Button/styles.ts +1 -1
- package/CheckBox/index.tsx +6 -5
- package/Consts/theme.ts +10 -10
- package/Context/index.ts +1 -5
- package/Divider/DashDivider.tsx +11 -11
- package/Divider/index.tsx +7 -21
- package/FoundationList/index.tsx +0 -4
- package/Icon/index.tsx +6 -6
- package/Icon/types.ts +1 -1
- package/IconButton/index.tsx +12 -4
- package/Image/index.tsx +7 -9
- package/Input/Input.tsx +12 -10
- package/Input/InputDropDown.tsx +13 -10
- package/Input/InputMoney.tsx +152 -45
- package/Input/InputOTP.tsx +34 -36
- package/Input/InputPhoneNumber.tsx +5 -8
- package/Input/InputSearch.tsx +111 -19
- package/Input/InputTextArea.tsx +5 -5
- package/Input/SystemTextInput.tsx +2 -7
- package/Input/TextTyping.tsx +0 -4
- package/Input/common.tsx +17 -31
- package/Input/index.tsx +21 -24
- package/Input/styles.ts +5 -25
- package/Input/utils.ts +12 -14
- package/Layout/Card.tsx +4 -7
- package/Layout/FloatingButton.tsx +21 -26
- package/Layout/Item.tsx +2 -6
- package/Layout/ItemList.tsx +7 -9
- package/Layout/ItemSectionList.tsx +1 -2
- package/Layout/ReservedRegions.tsx +17 -34
- package/Layout/Screen.tsx +696 -122
- package/Layout/Section.tsx +7 -9
- package/Layout/TrackingScope.tsx +0 -1
- package/Layout/index.ts +4 -10
- package/Layout/styles.ts +0 -2
- package/Layout/types.ts +4 -2
- package/Layout/utils.ts +181 -40
- package/Loader/DotLoader.tsx +3 -11
- package/Loader/Loader.tsx +0 -4
- package/Loader/ProgressBar.tsx +6 -3
- package/Loader/Spinner.tsx +3 -11
- package/Loader/styles.ts +0 -4
- package/Loader/utils.ts +7 -11
- package/Pagination/Dot.tsx +0 -4
- package/Pagination/PaginationDot.tsx +0 -1
- package/Pagination/PaginationNumber.tsx +3 -5
- package/Pagination/PaginationScroll.tsx +0 -5
- package/Pagination/PaginationWhiteDot.tsx +0 -1
- package/Pagination/index.tsx +0 -4
- package/Pagination/types.ts +2 -2
- package/Popup/PopupNotify.tsx +102 -94
- package/Popup/PopupPromotion.tsx +11 -9
- package/Popup/types.ts +4 -11
- package/Popup/utils.ts +18 -50
- package/Radio/index.tsx +10 -6
- package/Radio/styles.ts +0 -6
- package/Skeleton/index.tsx +9 -9
- package/Skeleton/styles.ts +0 -1
- package/Switch/index.tsx +0 -1
- package/Tag/index.tsx +4 -8
- package/Tag/types.ts +3 -3
- package/Text/index.tsx +5 -25
- package/Text/styles.ts +1 -1
- package/Text/types.ts +6 -1
- package/Text/utils.ts +4 -20
- package/Title/index.tsx +40 -42
- package/Title/styles.ts +0 -6
- package/ViewBoundary/index.tsx +2 -4
- package/index.ts +6 -0
- package/package.json +1 -2
- package/Application/BottomSheet.hooks.ts +0 -195
- package/Application/BottomSheet.parts.tsx +0 -157
- package/Application/BottomSheet.styles.ts +0 -43
- package/Application/BottomTab/ActiveIndicator.tsx +0 -91
- package/Application/BottomTab/BottomTabBar.styles.ts +0 -65
- package/Application/BottomTab/BottomTabInset.tsx +0 -18
- package/Application/BottomTab/CurvedContainer.tsx +0 -155
- package/Application/BottomTab/DuoRailTabBar.tsx +0 -223
- package/Application/BottomTab/DuoTabBar.styles.ts +0 -81
- package/Application/BottomTab/TabScreen.tsx +0 -160
- package/Application/BottomTab/metrics.ts +0 -164
- package/Application/BottomTab/tabItems.ts +0 -46
- package/Application/BottomTab/usePressLift.ts +0 -32
- package/Application/Components/HeaderRight.styles.ts +0 -146
- package/Application/Components/HeaderTitle.shared.ts +0 -44
- package/Application/Components/HeaderTitle.styles.ts +0 -125
- package/Application/Components/HeaderToolkitAction.tsx +0 -180
- package/Application/Components/SwipeBackHaptic.tsx +0 -95
- package/Application/Components/TitleJourney.tsx +0 -110
- package/Application/Components/TitleLocation.tsx +0 -73
- package/Application/Components/TitleUser.tsx +0 -304
- package/Application/Components/useToolkitActions.tsx +0 -218
- package/Application/ModalIconButton.tsx +0 -66
- package/Application/StackScreen.tracking.ts +0 -143
- package/Application/headerLayout.ts +0 -158
- package/Application/hooks.ts +0 -137
- package/Application/modalLayout.ts +0 -176
- package/Application/navigationOptions.tsx +0 -212
- package/Application/types.header.ts +0 -121
- package/Application/types.tabs.ts +0 -48
- package/Application/types.theme.ts +0 -87
- package/Application/utils.ts +0 -107
- package/Button/utils.ts +0 -133
- package/Input/InputMoneyView.tsx +0 -194
- package/Input/SearchTextTyping.tsx +0 -108
- package/Input/moneyUtils.ts +0 -23
- package/Layout/layoutMetrics.ts +0 -58
- package/Layout/layoutTypes.ts +0 -86
- package/Layout/screenContent.tsx +0 -92
- package/Layout/screenFooter.tsx +0 -63
- package/Layout/screenHeader.tsx +0 -321
- package/Layout/screenQuickReturn.tsx +0 -64
- package/Layout/screenScroll.ts +0 -107
- package/Layout/screenTypes.ts +0 -143
package/Layout/Section.tsx
CHANGED
|
@@ -15,8 +15,8 @@ export interface SectionProps extends ViewProps {
|
|
|
15
15
|
expanded?: boolean;
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* Optional. If `true`,
|
|
19
|
-
* Defaults to `
|
|
18
|
+
* Optional. If `true`, margin will be applied to the Section component.
|
|
19
|
+
* Defaults to `false` if not provided.
|
|
20
20
|
*/
|
|
21
21
|
useMargin?: boolean;
|
|
22
22
|
|
|
@@ -26,10 +26,6 @@ export interface SectionProps extends ViewProps {
|
|
|
26
26
|
backgroundImage?: string;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
/**
|
|
30
|
-
* Content-wide grid row (12 or 24 columns) with optional side margins; child Items size
|
|
31
|
-
* themselves from its GridContext.
|
|
32
|
-
*/
|
|
33
29
|
const Section: React.FC<SectionProps> = ({
|
|
34
30
|
children,
|
|
35
31
|
useMargin = true,
|
|
@@ -47,8 +43,9 @@ const Section: React.FC<SectionProps> = ({
|
|
|
47
43
|
}
|
|
48
44
|
const widthSection = contentWidth - margin * 2;
|
|
49
45
|
|
|
50
|
-
const
|
|
51
|
-
|
|
46
|
+
const sizePerSpan =
|
|
47
|
+
(widthSection - gutterSize * (numberOfColumns - 1)) / numberOfColumns -
|
|
48
|
+
1 / numberOfColumns;
|
|
52
49
|
|
|
53
50
|
const gridContext: GridContextProps = {
|
|
54
51
|
numberOfColumns,
|
|
@@ -67,10 +64,11 @@ const Section: React.FC<SectionProps> = ({
|
|
|
67
64
|
style={[
|
|
68
65
|
style,
|
|
69
66
|
styles.protectedStyle,
|
|
70
|
-
styles.rowWrap,
|
|
71
67
|
{
|
|
72
68
|
width: widthSection,
|
|
73
69
|
marginHorizontal: margin,
|
|
70
|
+
flexDirection: 'row',
|
|
71
|
+
flexWrap: 'wrap',
|
|
74
72
|
gap: gutterSize,
|
|
75
73
|
},
|
|
76
74
|
]}
|
package/Layout/TrackingScope.tsx
CHANGED
package/Layout/index.ts
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import Card from './Card';
|
|
2
2
|
import Section from './Section';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
validateChildren,
|
|
6
|
-
type ScreenLayout,
|
|
7
|
-
type SideBarEdge,
|
|
8
|
-
type SideBarLayout,
|
|
9
|
-
} from './utils';
|
|
3
|
+
import { useScreenLayout, validateChildren } from './utils';
|
|
4
|
+
import type { ScreenLayout, SideBarEdge, SideBarLayout } from './utils';
|
|
10
5
|
import { createContext } from 'react';
|
|
11
6
|
import { GridContextProps } from './types';
|
|
12
7
|
import Item from './Item';
|
|
13
8
|
import ItemList from './ItemList';
|
|
14
9
|
import ItemSectionList from './ItemSectionList';
|
|
15
|
-
import Screen
|
|
10
|
+
import Screen from './Screen';
|
|
16
11
|
import { TrackingScope } from './TrackingScope';
|
|
17
|
-
import {
|
|
12
|
+
import { ScreenProps } from './Screen';
|
|
18
13
|
|
|
19
14
|
const GridContext = createContext<GridContextProps>({
|
|
20
15
|
numberOfColumns: 12,
|
|
@@ -36,5 +31,4 @@ export {
|
|
|
36
31
|
ItemSectionList,
|
|
37
32
|
Screen,
|
|
38
33
|
TrackingScope,
|
|
39
|
-
useHinge,
|
|
40
34
|
};
|
package/Layout/styles.ts
CHANGED
package/Layout/types.ts
CHANGED
|
@@ -4,12 +4,14 @@ export type HeaderType = 'default' | 'extended' | 'none';
|
|
|
4
4
|
|
|
5
5
|
export type ScreenRef = {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Set options for screen
|
|
8
|
+
* @param params
|
|
8
9
|
*/
|
|
9
10
|
setOptions: (params: NavigationOptions) => void;
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* Show search header
|
|
14
|
+
* @param params
|
|
13
15
|
*/
|
|
14
16
|
setSearchHeader: (params: SearchHeaderProps) => void;
|
|
15
17
|
};
|
package/Layout/utils.ts
CHANGED
|
@@ -5,18 +5,12 @@ import {
|
|
|
5
5
|
SafeAreaInsetsContext,
|
|
6
6
|
} from 'react-native-safe-area-context';
|
|
7
7
|
import { Spacing } from '../Consts';
|
|
8
|
-
import { HeaderMetrics, DuoMetrics } from './layoutMetrics';
|
|
9
|
-
import {
|
|
10
|
-
ScreenLayout,
|
|
11
|
-
SideBarEdge,
|
|
12
|
-
SideBarLayout,
|
|
13
|
-
StatusBarClearance,
|
|
14
|
-
} from './layoutTypes';
|
|
15
8
|
import { ReservedRegion, ReservedRegionsContext } from './ReservedRegions';
|
|
16
9
|
|
|
17
10
|
/**
|
|
18
|
-
*
|
|
19
|
-
* children
|
|
11
|
+
* validate children type
|
|
12
|
+
* @param children
|
|
13
|
+
* @param childrenTypes
|
|
20
14
|
*/
|
|
21
15
|
const validateChildren = (
|
|
22
16
|
children: React.ReactNode | React.ReactNode[],
|
|
@@ -50,23 +44,82 @@ const validateChildren = (
|
|
|
50
44
|
}
|
|
51
45
|
};
|
|
52
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Header geometry
|
|
49
|
+
* - barHeight: navigation bar row below the status bar
|
|
50
|
+
* - iPhoneMinHeight: header never shorter than this on iPhone (landscape, iPhone Duo)
|
|
51
|
+
* - statusBarMinInset: a smaller top inset means the status bar is not on the top edge
|
|
52
|
+
* - largeWidth / largeMargin: @react-navigation/elements Header gives its content row
|
|
53
|
+
* 5pt side margins on iOS from 414pt wide
|
|
54
|
+
*/
|
|
55
|
+
const HeaderMetrics = {
|
|
56
|
+
barHeight: 52,
|
|
57
|
+
iPhoneMinHeight: 72,
|
|
58
|
+
statusBarMinInset: 20,
|
|
59
|
+
largeWidth: 414,
|
|
60
|
+
largeMargin: 5,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* iPhone Duo geometry, iOS 27.1 (Xcode 27.1 simulator)
|
|
65
|
+
* - maxAspectRatio: both displays are near 1.42 (inner) and 1.45 (outer), every slab
|
|
66
|
+
* iPhone is 1.77 or taller
|
|
67
|
+
* - innerMinHeight: window height from which the inner display is in use (outer display
|
|
68
|
+
* is 466pt tall in landscape, inner display 669pt)
|
|
69
|
+
* - controlSize / itemPitch: vertical bar of 48pt circular controls, item groups as 48pt
|
|
70
|
+
* wide capsules at a 50pt pitch, 12pt from the strip's inner edge and 12pt apart
|
|
71
|
+
* - firstItemTop: with the status bar in the strip, the first control sits under the
|
|
72
|
+
* camera, clock and connectivity cluster (cluster ends near y 151 on the outer display,
|
|
73
|
+
* y 98 on the inner display in landscape)
|
|
74
|
+
* - outerHeaderHeight / outerCameraCenterY: on the outer display in portrait the header
|
|
75
|
+
* is 4pt taller than iPhoneMinHeight and its title lines up with the camera punchout
|
|
76
|
+
* (y 24–66 at the top of the strip)
|
|
77
|
+
* - edgeInset: on the outer display in landscape the strip holds no status bar, so its
|
|
78
|
+
* controls start this far from the top and stay this far above the bottom, unless a
|
|
79
|
+
* reserved region (the camera at either end) asks for more
|
|
80
|
+
* - innerStatusBarCenterY / innerStatusBarWidth: on the inner display in portrait the
|
|
81
|
+
* clock and connectivity cluster sits at the top right corner (x 550–643 of 669, clock
|
|
82
|
+
* digits centered on y 47); its reserved region, when reported, is taller than the glyphs
|
|
83
|
+
* - floatingTabBarHeight / floatingTabBarMargin / floatingTabBarInsetOverlap: the host
|
|
84
|
+
* app's iOS 26 system tab bar on the inner display in portrait, a 62pt Liquid Glass pill
|
|
85
|
+
* sized to its tabs with the QR as a pinned 62pt platter beside it, centered and at
|
|
86
|
+
* least 20pt from the side edges; it overlaps the home indicator inset by 13pt (21pt
|
|
87
|
+
* above the screen bottom with a 34pt inset)
|
|
88
|
+
*/
|
|
89
|
+
const DuoMetrics = {
|
|
90
|
+
maxAspectRatio: 1.6,
|
|
91
|
+
innerMinHeight: 600,
|
|
92
|
+
controlSize: 48,
|
|
93
|
+
itemPitch: 50,
|
|
94
|
+
firstItemTop: 170,
|
|
95
|
+
firstItemTopLandscape: 120,
|
|
96
|
+
outerHeaderHeight: 76,
|
|
97
|
+
outerCameraCenterY: 45,
|
|
98
|
+
edgeInset: 24,
|
|
99
|
+
innerStatusBarCenterY: 47,
|
|
100
|
+
innerStatusBarWidth: 120,
|
|
101
|
+
floatingTabBarHeight: 62,
|
|
102
|
+
floatingTabBarMargin: 20,
|
|
103
|
+
floatingTabBarInsetOverlap: 13,
|
|
104
|
+
};
|
|
105
|
+
|
|
53
106
|
const NO_INSETS: EdgeInsets = { top: 0, right: 0, bottom: 0, left: 0 };
|
|
54
107
|
|
|
55
108
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* furthest from the top
|
|
109
|
+
* how far system regions reach into a side strip from its top and from its bottom end
|
|
110
|
+
* (e.g. the camera, which sits at either end depending on the rotation), and the center
|
|
111
|
+
* y of the region reaching furthest from the top
|
|
59
112
|
*/
|
|
60
113
|
const getStripOcclusion = (
|
|
61
114
|
regions: ReservedRegion[],
|
|
62
115
|
stripLeft: number,
|
|
63
116
|
stripRight: number,
|
|
64
117
|
windowHeight: number,
|
|
65
|
-
) =>
|
|
66
|
-
|
|
118
|
+
) =>
|
|
119
|
+
regions.reduce(
|
|
67
120
|
(occlusion, region) => {
|
|
68
|
-
const
|
|
69
|
-
|
|
121
|
+
const overlapsStrip =
|
|
122
|
+
region.x < stripRight && region.x + region.width > stripLeft;
|
|
70
123
|
if (!overlapsStrip) {
|
|
71
124
|
return occlusion;
|
|
72
125
|
}
|
|
@@ -83,11 +136,10 @@ const getStripOcclusion = (
|
|
|
83
136
|
},
|
|
84
137
|
{ top: 0, topCenter: 0, bottom: 0 },
|
|
85
138
|
);
|
|
86
|
-
};
|
|
87
139
|
|
|
88
140
|
/**
|
|
89
|
-
*
|
|
90
|
-
* each side. `undefined` without reserved regions there
|
|
141
|
+
* how far the clock and battery clusters of a status bar on the top edge reach in from
|
|
142
|
+
* each side. `undefined` without reserved regions there
|
|
91
143
|
*/
|
|
92
144
|
const getStatusBarClusters = (
|
|
93
145
|
regions: ReservedRegion[],
|
|
@@ -95,11 +147,12 @@ const getStatusBarClusters = (
|
|
|
95
147
|
topInset: number,
|
|
96
148
|
) => {
|
|
97
149
|
const midX = windowWidth / 2;
|
|
98
|
-
const clusters = regions.filter(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
150
|
+
const clusters = regions.filter(
|
|
151
|
+
region =>
|
|
152
|
+
region.y < topInset &&
|
|
153
|
+
region.y + region.height <= topInset &&
|
|
154
|
+
(region.x + region.width <= midX || region.x >= midX),
|
|
155
|
+
);
|
|
103
156
|
if (!clusters.length) {
|
|
104
157
|
return undefined;
|
|
105
158
|
}
|
|
@@ -117,10 +170,8 @@ const getStatusBarClusters = (
|
|
|
117
170
|
);
|
|
118
171
|
};
|
|
119
172
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return Platform.OS === 'ios' && Platform.constants.interfaceIdiom === 'phone';
|
|
123
|
-
};
|
|
173
|
+
const isIPhone = () =>
|
|
174
|
+
Platform.OS === 'ios' && Platform.constants.interfaceIdiom === 'phone';
|
|
124
175
|
|
|
125
176
|
/**
|
|
126
177
|
* Header height and the room it keeps above the bar row for the status bar. On iPhone the
|
|
@@ -142,7 +193,7 @@ const getHeaderLayout = (topInset: number) => {
|
|
|
142
193
|
|
|
143
194
|
/**
|
|
144
195
|
* Header whose bar row is centered on a window y, at least iPhoneMinHeight tall and
|
|
145
|
-
* reaching 8pt below a side bar control centered there
|
|
196
|
+
* reaching 8pt below a side bar control centered there
|
|
146
197
|
*/
|
|
147
198
|
const getCenteredHeaderLayout = (centerY: number) => {
|
|
148
199
|
const headerHeight = Math.max(
|
|
@@ -155,6 +206,91 @@ const getCenteredHeaderLayout = (centerY: number) => {
|
|
|
155
206
|
};
|
|
156
207
|
};
|
|
157
208
|
|
|
209
|
+
export type SideBarEdge = 'left' | 'right';
|
|
210
|
+
|
|
211
|
+
export type SideBarLayout = {
|
|
212
|
+
/**
|
|
213
|
+
* Edge holding the side bar, the one with the larger safe-area inset.
|
|
214
|
+
*/
|
|
215
|
+
edge: SideBarEdge;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Width of the side bar column, the safe-area inset on that edge.
|
|
219
|
+
*/
|
|
220
|
+
width: number;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Window y of the first side bar item, below the navigation bar and the side status bar.
|
|
224
|
+
*/
|
|
225
|
+
top: number;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Room to keep free above the window bottom, clear of a camera at the bottom end.
|
|
229
|
+
*/
|
|
230
|
+
bottom: number;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
export type ScreenLayout = {
|
|
234
|
+
/**
|
|
235
|
+
* Window width, from useWindowDimensions.
|
|
236
|
+
*/
|
|
237
|
+
width: number;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Window height, from useWindowDimensions.
|
|
241
|
+
*/
|
|
242
|
+
height: number;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* `true` when running on iPhone Duo, outer or inner display.
|
|
246
|
+
*/
|
|
247
|
+
isIPhoneDuo: boolean;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Raw safe-area insets.
|
|
251
|
+
*/
|
|
252
|
+
insets: EdgeInsets;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Horizontal insets the screen content keeps clear of. 0 outside iPhone Duo.
|
|
256
|
+
*/
|
|
257
|
+
insetLeft: number;
|
|
258
|
+
insetRight: number;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Width available to the screen content: window width minus the horizontal insets.
|
|
262
|
+
*/
|
|
263
|
+
contentWidth: number;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Header height: the top safe-area inset plus the navigation bar row, at least 72pt on iPhone.
|
|
267
|
+
*/
|
|
268
|
+
headerHeight: number;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Room above the navigation bar row for the status bar, the rest of headerHeight is
|
|
272
|
+
* the row, which centers the title vertically. 0 when the status bar is not on top.
|
|
273
|
+
*/
|
|
274
|
+
headerStatusBarHeight: number;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Side column holding the back button and the toolkit, when iPhone Duo moves the
|
|
278
|
+
* bars to the side. `undefined` while the bars stay horizontal.
|
|
279
|
+
*/
|
|
280
|
+
sideBar?: SideBarLayout;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Room the header row keeps from each side for the clock and battery clusters, when
|
|
284
|
+
* iPhone Duo puts the row on the status bar (inner display in portrait).
|
|
285
|
+
*/
|
|
286
|
+
statusBarClearance?: StatusBarClearance;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
export type StatusBarClearance = {
|
|
290
|
+
left: number;
|
|
291
|
+
right: number;
|
|
292
|
+
};
|
|
293
|
+
|
|
158
294
|
/**
|
|
159
295
|
* Detect iPhone Duo from the window shape and the safe area: a phone idiom window
|
|
160
296
|
* near square, or a phone with asymmetric side insets (slab iPhones report equal
|
|
@@ -222,7 +358,8 @@ const useScreenLayout = (): ScreenLayout => {
|
|
|
222
358
|
if (sideInset >= DuoMetrics.controlSize + Spacing.M) {
|
|
223
359
|
const edge = insets.right >= insets.left ? 'right' : 'left';
|
|
224
360
|
const stripLeft = edge === 'right' ? width - sideInset : 0;
|
|
225
|
-
// clear the camera and status bar cluster
|
|
361
|
+
// keep controls clear of the camera and of the status bar cluster, which grows for
|
|
362
|
+
// calls and Live Activities. Region frames already include the system's margin
|
|
226
363
|
const occlusion = getStripOcclusion(
|
|
227
364
|
reservedRegions,
|
|
228
365
|
stripLeft,
|
|
@@ -242,7 +379,8 @@ const useScreenLayout = (): ScreenLayout => {
|
|
|
242
379
|
} else if (height >= DuoMetrics.innerMinHeight) {
|
|
243
380
|
top = DuoMetrics.firstItemTopLandscape;
|
|
244
381
|
} else {
|
|
245
|
-
// outer landscape:
|
|
382
|
+
// outer display in landscape: no status bar in the strip, the title row centers
|
|
383
|
+
// on the camera when it sits at the top end, otherwise on the back button
|
|
246
384
|
top = DuoMetrics.edgeInset;
|
|
247
385
|
const cameraAtTop = occlusion.top > top;
|
|
248
386
|
const backCenterY = top + DuoMetrics.controlSize / 2;
|
|
@@ -284,7 +422,7 @@ const useScreenLayout = (): ScreenLayout => {
|
|
|
284
422
|
|
|
285
423
|
/**
|
|
286
424
|
* Header row options for react-navigation: its height, the room for the status bar, and
|
|
287
|
-
* on iPhone Duo inner portrait the buttons kept clear of the clock and battery clusters
|
|
425
|
+
* on iPhone Duo inner portrait the buttons kept clear of the clock and battery clusters
|
|
288
426
|
*/
|
|
289
427
|
const getHeaderRowOptions = ({
|
|
290
428
|
headerHeight,
|
|
@@ -304,7 +442,9 @@ const getHeaderRowOptions = ({
|
|
|
304
442
|
};
|
|
305
443
|
};
|
|
306
444
|
|
|
307
|
-
/**
|
|
445
|
+
/**
|
|
446
|
+
* Side margin @react-navigation/elements Header adds to its content row
|
|
447
|
+
*/
|
|
308
448
|
const getHeaderMargin = (width: number) => {
|
|
309
449
|
if (Platform.OS === 'ios' && width >= HeaderMetrics.largeWidth) {
|
|
310
450
|
return HeaderMetrics.largeMargin;
|
|
@@ -318,9 +458,11 @@ const InnerEdgeStyles: Record<SideBarEdge, ViewStyle> = {
|
|
|
318
458
|
};
|
|
319
459
|
|
|
320
460
|
/**
|
|
321
|
-
* Absolute style
|
|
322
|
-
*
|
|
461
|
+
* Absolute style that floats a header item into the side bar, relative to the header
|
|
462
|
+
* container (left or right) rendering it, 12pt from the strip's inner edge.
|
|
323
463
|
* `undefined` while there is no side bar.
|
|
464
|
+
* @param container header container rendering the item
|
|
465
|
+
* @param slot position in the side bar, 0 for back, 1 for the toolkit below it
|
|
324
466
|
*/
|
|
325
467
|
const useSideBarItemStyle = (
|
|
326
468
|
container: 'left' | 'right',
|
|
@@ -333,8 +475,10 @@ const useSideBarItemStyle = (
|
|
|
333
475
|
|
|
334
476
|
const margin = getHeaderMargin(width);
|
|
335
477
|
const columnLeft = sideBar.edge === 'left' ? 0 : width - sideBar.width;
|
|
336
|
-
const
|
|
337
|
-
|
|
478
|
+
const top =
|
|
479
|
+
sideBar.top -
|
|
480
|
+
headerStatusBarHeight +
|
|
481
|
+
slot * (DuoMetrics.controlSize + Spacing.M);
|
|
338
482
|
const innerEdgeStyle = InnerEdgeStyles[sideBar.edge];
|
|
339
483
|
|
|
340
484
|
if (container === 'left') {
|
|
@@ -357,15 +501,12 @@ const useSideBarItemStyle = (
|
|
|
357
501
|
};
|
|
358
502
|
};
|
|
359
503
|
|
|
360
|
-
/** Column count of the content grid: 24 on content wider than 600pt, otherwise 12. */
|
|
361
504
|
const useGridSystem = () => {
|
|
362
505
|
const { contentWidth } = useScreenLayout();
|
|
363
506
|
const numberOfColumns = contentWidth > 600 ? 24 : 12;
|
|
364
507
|
return { numberOfColumns };
|
|
365
508
|
};
|
|
366
509
|
|
|
367
|
-
export type { ScreenLayout, SideBarEdge, SideBarLayout, StatusBarClearance };
|
|
368
|
-
|
|
369
510
|
export {
|
|
370
511
|
DuoMetrics,
|
|
371
512
|
HeaderMetrics,
|
package/Loader/DotLoader.tsx
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import React, { FC, useContext } from 'react';
|
|
2
|
-
import { Platform
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
3
|
import AnimatedLottieView from 'lottie-react-native';
|
|
4
4
|
import animation from '../Assets/DotAnimation.json';
|
|
5
5
|
import { ApplicationContext } from '../Context';
|
|
6
6
|
import { hexToRGBA } from './utils';
|
|
7
7
|
import { LoaderProps } from './types';
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Three-dot Lottie loader recolored to `color` (theme primary by default).
|
|
11
|
-
* Recoloring mutates the shared animation JSON, so `Loader` remounts on change.
|
|
12
|
-
*/
|
|
13
9
|
const DotLoader: FC<LoaderProps> = ({ color, style }) => {
|
|
14
10
|
const { theme } = useContext(ApplicationContext);
|
|
15
11
|
|
|
@@ -33,15 +29,11 @@ const DotLoader: FC<LoaderProps> = ({ color, style }) => {
|
|
|
33
29
|
return (
|
|
34
30
|
<AnimatedLottieView
|
|
35
31
|
source={source}
|
|
36
|
-
style={[
|
|
37
|
-
webStyle={Platform.OS === 'web' ?
|
|
32
|
+
style={[{ width: 52, height: 18 }, style]}
|
|
33
|
+
webStyle={Platform.OS === 'web' ? { width: 52, height: 18 } : undefined}
|
|
38
34
|
autoPlay
|
|
39
35
|
/>
|
|
40
36
|
);
|
|
41
37
|
};
|
|
42
38
|
|
|
43
|
-
const styles = StyleSheet.create({
|
|
44
|
-
size: { width: 52, height: 18 },
|
|
45
|
-
});
|
|
46
|
-
|
|
47
39
|
export default DotLoader;
|
package/Loader/Loader.tsx
CHANGED
|
@@ -3,10 +3,6 @@ import {LoaderProps} from './types';
|
|
|
3
3
|
import DotLoader from './DotLoader';
|
|
4
4
|
import Spinner from './Spinner';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Dot (default) or spinner loader. Keyed by `color` so a color change remounts
|
|
8
|
-
* the Lottie view with the recolored source.
|
|
9
|
-
*/
|
|
10
6
|
const Loader: FC<LoaderProps> = ({type = 'dot', ...props}) => {
|
|
11
7
|
if (type === 'spinner') {
|
|
12
8
|
return <Spinner {...props} key={props.color} />;
|
package/Loader/ProgressBar.tsx
CHANGED
|
@@ -8,8 +8,8 @@ import Animated, {
|
|
|
8
8
|
import styles from './styles';
|
|
9
9
|
import { ProgressBarProps } from './types';
|
|
10
10
|
import { ApplicationContext } from '../Context';
|
|
11
|
+
import { Radius } from '../Consts';
|
|
11
12
|
|
|
12
|
-
/** Full-width bar that animates its fill to `percent`, clamped to 0–100. */
|
|
13
13
|
const ProgressBar: FC<ProgressBarProps> = ({ percent = 0, style }) => {
|
|
14
14
|
const { theme } = useContext(ApplicationContext);
|
|
15
15
|
const animation = useSharedValue(0);
|
|
@@ -32,8 +32,11 @@ const ProgressBar: FC<ProgressBarProps> = ({ percent = 0, style }) => {
|
|
|
32
32
|
>
|
|
33
33
|
<Animated.View
|
|
34
34
|
style={[
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
{
|
|
36
|
+
height: 4,
|
|
37
|
+
borderRadius: Radius.XXS,
|
|
38
|
+
backgroundColor: theme.colors.primary,
|
|
39
|
+
},
|
|
37
40
|
animatedStyle,
|
|
38
41
|
]}
|
|
39
42
|
/>
|
package/Loader/Spinner.tsx
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import React, { FC, useContext } from 'react';
|
|
2
|
-
import { Platform
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
3
|
import AnimatedLottieView from 'lottie-react-native';
|
|
4
4
|
import animation from '../Assets/SpinnerAnimation.json';
|
|
5
5
|
import { hexToRGBA } from './utils';
|
|
6
6
|
import { ApplicationContext } from '../Context';
|
|
7
7
|
import { LoaderProps } from './types';
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Lottie spinner recolored to `color` (theme primary by default).
|
|
11
|
-
* Recoloring mutates the shared animation JSON, so `Loader` remounts on change.
|
|
12
|
-
*/
|
|
13
9
|
const Spinner: FC<LoaderProps> = ({ color, style }) => {
|
|
14
10
|
const { theme } = useContext(ApplicationContext);
|
|
15
11
|
|
|
@@ -25,15 +21,11 @@ const Spinner: FC<LoaderProps> = ({ color, style }) => {
|
|
|
25
21
|
return (
|
|
26
22
|
<AnimatedLottieView
|
|
27
23
|
source={source}
|
|
28
|
-
style={[
|
|
29
|
-
webStyle={Platform.OS === 'web' ?
|
|
24
|
+
style={[{ width: 24, height: 24 }, style]}
|
|
25
|
+
webStyle={Platform.OS === 'web' ? { width: 24, height: 24 } : undefined}
|
|
30
26
|
autoPlay
|
|
31
27
|
/>
|
|
32
28
|
);
|
|
33
29
|
};
|
|
34
30
|
|
|
35
|
-
const styles = StyleSheet.create({
|
|
36
|
-
size: { width: 24, height: 24 },
|
|
37
|
-
});
|
|
38
|
-
|
|
39
31
|
export default Spinner;
|
package/Loader/styles.ts
CHANGED
package/Loader/utils.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts `#rgb`/`#rrggbb` (the `#` is optional) to Lottie's `[r, g, b]` in
|
|
3
|
-
* 0–1, rounded to 3 decimals. Throws on an invalid hex.
|
|
4
|
-
*/
|
|
5
1
|
export const hexToRGBA = (hex: string) => {
|
|
6
2
|
const normalizedHex = hex.startsWith('#') ? hex.slice(1) : hex;
|
|
7
3
|
|
|
@@ -9,13 +5,13 @@ export const hexToRGBA = (hex: string) => {
|
|
|
9
5
|
throw new Error('Invalid HEX color.');
|
|
10
6
|
}
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
const expandedHex =
|
|
9
|
+
normalizedHex.length === 3
|
|
10
|
+
? normalizedHex
|
|
11
|
+
.split('')
|
|
12
|
+
.map(val => val + val)
|
|
13
|
+
.join('')
|
|
14
|
+
: normalizedHex;
|
|
19
15
|
|
|
20
16
|
const hexMatch = expandedHex.match(/.{2}/g);
|
|
21
17
|
|
package/Pagination/Dot.tsx
CHANGED
|
@@ -4,10 +4,6 @@ import styles from './styles';
|
|
|
4
4
|
import { DotProps } from './types';
|
|
5
5
|
import { ApplicationContext } from '../Context';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* One pagination dot: a wide bar in the caller's color when active, otherwise
|
|
9
|
-
* a small dot in the theme pressed color.
|
|
10
|
-
*/
|
|
11
7
|
const Dot: FC<DotProps> = ({ active, style }) => {
|
|
12
8
|
const { theme } = useContext(ApplicationContext);
|
|
13
9
|
const pressedColor = theme.colors.background.pressed;
|
|
@@ -6,7 +6,6 @@ import styles from './styles';
|
|
|
6
6
|
import { Spacing } from '../Consts';
|
|
7
7
|
import { ApplicationContext, MiniAppContext } from '../Context';
|
|
8
8
|
|
|
9
|
-
/** Row of primary-color dots with the `activeIndex` dot widened. */
|
|
10
9
|
const PaginationDot: FC<ChildPaginationProps> = ({
|
|
11
10
|
dataLength = 2,
|
|
12
11
|
activeIndex = 0,
|
|
@@ -6,7 +6,6 @@ import { Text } from '../Text';
|
|
|
6
6
|
import { Colors } from '../Consts';
|
|
7
7
|
import { MiniAppContext } from '../Context';
|
|
8
8
|
|
|
9
|
-
/** `n/total` counter on a translucent dark pill. */
|
|
10
9
|
const PaginationNumber: FC<ChildPaginationProps> = ({
|
|
11
10
|
activeIndex = 0,
|
|
12
11
|
dataLength = 2,
|
|
@@ -15,16 +14,15 @@ const PaginationNumber: FC<ChildPaginationProps> = ({
|
|
|
15
14
|
const context = useContext<any>(MiniAppContext);
|
|
16
15
|
|
|
17
16
|
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
18
|
-
const pageLabel = `${activeIndex + 1}/${dataLength}`;
|
|
19
17
|
|
|
20
18
|
return (
|
|
21
19
|
<View
|
|
22
20
|
style={[style, styles.row, showBaseLineDebug && styles.debugBaseLine]}
|
|
23
21
|
>
|
|
24
22
|
<View style={styles.paginationNumberContainer}>
|
|
25
|
-
<Text color={Colors.black_01} typography={'label_default_medium'}>
|
|
26
|
-
|
|
27
|
-
</Text>
|
|
23
|
+
<Text color={Colors.black_01} typography={'label_default_medium'}>{`${
|
|
24
|
+
activeIndex + 1
|
|
25
|
+
}/${dataLength}`}</Text>
|
|
28
26
|
</View>
|
|
29
27
|
</View>
|
|
30
28
|
);
|
|
@@ -13,11 +13,6 @@ import { ApplicationContext, MiniAppContext } from '../Context';
|
|
|
13
13
|
|
|
14
14
|
const INDICATOR_WIDTH = 24;
|
|
15
15
|
const INDICATOR_CONTAINER_WIDTH = 72;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Horizontal scroll view with a small indicator that tracks the scroll offset.
|
|
19
|
-
* The indicator shows only when the content is wider than the view.
|
|
20
|
-
*/
|
|
21
16
|
const PaginationScroll: FC<ScrollIndicatorProps> = ({
|
|
22
17
|
style,
|
|
23
18
|
children,
|
|
@@ -6,7 +6,6 @@ import Dot from './Dot';
|
|
|
6
6
|
import { Colors, Spacing } from '../Consts';
|
|
7
7
|
import { MiniAppContext } from '../Context';
|
|
8
8
|
|
|
9
|
-
/** Pagination dots on a translucent dark pill, for use over images. */
|
|
10
9
|
const PaginationWhiteDot: FC<ChildPaginationProps> = ({
|
|
11
10
|
dataLength = 2,
|
|
12
11
|
activeIndex = 0,
|