@momo-kits/foundation 0.169.7-beta.2 → 0.169.7-beta.4
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.hooks.ts +8 -8
- package/Application/BottomSheet.parts.tsx +34 -44
- package/Application/BottomSheet.tsx +37 -40
- package/Application/BottomTab/ActiveIndicator.tsx +14 -15
- package/Application/BottomTab/BottomTabBar.tsx +62 -49
- package/Application/BottomTab/BottomTabInset.tsx +4 -8
- package/Application/BottomTab/CurvedContainer.tsx +12 -14
- package/Application/BottomTab/CustomBottomTabItem.tsx +13 -13
- package/Application/BottomTab/DuoBarCompression.tsx +19 -13
- package/Application/BottomTab/DuoRailTabBar.tsx +24 -20
- package/Application/BottomTab/DuoTabBar.tsx +10 -8
- package/Application/BottomTab/TabBarIcon.tsx +29 -15
- package/Application/BottomTab/TabScreen.tsx +5 -1
- package/Application/BottomTab/index.tsx +30 -33
- package/Application/BottomTab/metrics.ts +23 -23
- package/Application/BottomTab/tabItems.ts +1 -1
- package/Application/BottomTab/usePressLift.ts +2 -2
- package/Application/Components/BackgroundImageView.tsx +0 -4
- package/Application/Components/DuoGlassBackground.tsx +4 -5
- package/Application/Components/HeaderAnimated.tsx +0 -4
- package/Application/Components/HeaderBackground.tsx +0 -4
- package/Application/Components/HeaderExtendHeader.tsx +10 -11
- package/Application/Components/HeaderLeft.tsx +1 -2
- package/Application/Components/HeaderRight.tsx +1 -2
- package/Application/Components/HeaderTitle.shared.ts +9 -11
- package/Application/Components/HeaderTitle.tsx +3 -4
- package/Application/Components/HeaderToolkitAction.tsx +20 -17
- package/Application/Components/NavigationButton.tsx +1 -2
- package/Application/Components/SearchHeader.tsx +10 -17
- package/Application/Components/TitleJourney.tsx +2 -2
- package/Application/Components/TitleLocation.tsx +2 -2
- package/Application/Components/TitleUser.tsx +2 -2
- package/Application/Components/useToolkitActions.tsx +32 -17
- package/Application/KitAdoption/AdoptionBadge.tsx +119 -0
- package/Application/KitAdoption/AdoptionProbe.tsx +166 -0
- package/Application/KitAdoption/AdoptionStore.ts +80 -0
- package/Application/KitAdoption/Authorship/utils.ts +137 -0
- package/Application/KitAdoption/Slots/utils.ts +68 -0
- package/Application/KitAdoption/constants.ts +120 -0
- package/Application/KitAdoption/index.ts +12 -0
- package/Application/KitAdoption/styles.ts +55 -0
- package/Application/KitAdoption/types.ts +61 -0
- package/Application/KitAdoption/utils.ts +376 -0
- package/Application/Localize.ts +0 -7
- package/Application/ModalScreen.tsx +10 -10
- package/Application/Navigation.ts +16 -14
- package/Application/NavigationContainer.tsx +18 -19
- package/Application/Navigator.ts +48 -20
- package/Application/ScaleSizeProvider.tsx +6 -13
- package/Application/StackScreen.tracking.ts +33 -11
- package/Application/StackScreen.tsx +54 -10
- package/Application/TooltipPortal.tsx +5 -12
- package/Application/WidgetContainer.tsx +4 -10
- package/Application/__tests__/KitAdoption.integration.test.tsx +253 -0
- package/Application/__tests__/KitAdoption.test.ts +283 -0
- package/Application/__tests__/KitAdoptionAuthorship.test.ts +132 -0
- package/Application/__tests__/KitAdoptionStore.test.ts +110 -0
- package/Application/__tests__/KitAdoptionStructural.test.ts +193 -0
- package/Application/__tests__/modalLayout.test.ts +128 -0
- package/Application/modalLayout.ts +14 -16
- package/Application/navigationOptions.tsx +17 -21
- package/Badge/Badge.tsx +0 -5
- package/Badge/BadgeDot.tsx +0 -1
- package/Badge/BadgeDotAnimation.tsx +7 -15
- package/Badge/BadgeRibbon.tsx +38 -46
- package/Badge/Shape.tsx +0 -2
- package/Badge/types.ts +2 -2
- package/Button/index.tsx +16 -5
- package/Button/utils.ts +15 -9
- package/CheckBox/index.tsx +0 -4
- package/Consts/theme.ts +10 -10
- package/Context/index.ts +1 -5
- package/Divider/DashDivider.tsx +0 -1
- package/Divider/index.tsx +0 -4
- 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 +9 -8
- package/Input/InputDropDown.tsx +12 -10
- package/Input/InputMoney.tsx +8 -12
- package/Input/InputMoneyView.tsx +7 -14
- package/Input/InputOTP.tsx +33 -35
- package/Input/InputPhoneNumber.tsx +9 -8
- package/Input/InputSearch.tsx +6 -4
- package/Input/InputTextArea.tsx +0 -4
- package/Input/SearchTextTyping.tsx +0 -4
- package/Input/SystemTextInput.tsx +2 -7
- package/Input/TextTyping.tsx +0 -4
- package/Input/common.tsx +12 -26
- package/Input/index.tsx +20 -17
- package/Input/moneyUtils.ts +4 -10
- package/Input/styles.ts +5 -0
- package/Input/utils.ts +12 -14
- package/Layout/Card.tsx +4 -7
- package/Layout/FloatingButton.tsx +0 -4
- package/Layout/Item.tsx +2 -6
- package/Layout/ItemList.tsx +7 -9
- package/Layout/ItemSectionList.tsx +1 -2
- package/Layout/ReservedRegions.tsx +25 -25
- package/Layout/Screen.tsx +58 -56
- package/Layout/Section.tsx +5 -8
- package/Layout/TrackingScope.tsx +0 -1
- package/Layout/screenContent.tsx +2 -4
- package/Layout/screenFooter.tsx +18 -28
- package/Layout/screenHeader.tsx +31 -34
- package/Layout/screenQuickReturn.tsx +20 -17
- package/Layout/screenScroll.ts +7 -4
- package/Layout/screenTypes.ts +2 -3
- package/Layout/types.ts +4 -2
- package/Layout/utils.ts +37 -31
- package/Loader/DotLoader.tsx +0 -4
- package/Loader/Loader.tsx +0 -4
- package/Loader/ProgressBar.tsx +0 -1
- package/Loader/Spinner.tsx +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 +48 -44
- package/Popup/PopupPromotion.tsx +7 -4
- package/Popup/types.ts +4 -4
- package/Popup/utils.ts +0 -4
- package/Radio/index.tsx +0 -4
- package/Skeleton/index.tsx +0 -8
- package/Switch/index.tsx +0 -1
- package/Tag/index.tsx +1 -5
- package/Tag/types.ts +3 -3
- package/Text/index.tsx +3 -14
- package/Text/styles.ts +1 -1
- package/Text/types.ts +6 -1
- package/Text/utils.ts +4 -20
- package/Title/index.tsx +32 -41
- package/ViewBoundary/index.tsx +2 -4
- package/index.ts +6 -0
- package/package.json +1 -1
|
@@ -31,10 +31,6 @@ export interface FloatingButtonProps {
|
|
|
31
31
|
renderComponent?: () => React.ReactNode;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
/**
|
|
35
|
-
* Floating action button above the screen bottom. With a label and a scroll value it
|
|
36
|
-
* shrinks to its icon while scrolling down and expands again on scroll up.
|
|
37
|
-
*/
|
|
38
34
|
export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
39
35
|
renderComponent,
|
|
40
36
|
label = '',
|
package/Layout/Item.tsx
CHANGED
|
@@ -7,20 +7,16 @@ import { SpanNumber } from './types';
|
|
|
7
7
|
|
|
8
8
|
export interface ItemProps extends ViewProps {
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Represents the width of the Card component in terms of span numbers (1-12).
|
|
11
11
|
*/
|
|
12
12
|
widthSpan?: SpanNumber;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Optional.
|
|
15
|
+
* Optional. Represents the height of the Card component in terms of span numbers (1-12).
|
|
16
16
|
*/
|
|
17
17
|
heightSpan?: SpanNumber;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* Grid cell sized from the enclosing GridContext; outlined when the mini app turns on
|
|
22
|
-
* the baseline debug feature.
|
|
23
|
-
*/
|
|
24
20
|
const Item: React.FC<ItemProps> = ({
|
|
25
21
|
widthSpan,
|
|
26
22
|
heightSpan,
|
package/Layout/ItemList.tsx
CHANGED
|
@@ -7,16 +7,12 @@ import { SpanNumber } from './types';
|
|
|
7
7
|
|
|
8
8
|
export interface ItemListProps extends FlatListProps<any> {
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Represents the width of the Card component in terms of span numbers (1-12).
|
|
11
11
|
*/
|
|
12
12
|
widthSpan?: SpanNumber;
|
|
13
13
|
data: any[];
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* FlatList on the grid: `widthSpan` sets how many items share a row, and every item but
|
|
18
|
-
* the first of a row gets the gutter on its left.
|
|
19
|
-
*/
|
|
20
16
|
const ItemList = forwardRef(
|
|
21
17
|
(
|
|
22
18
|
{
|
|
@@ -34,9 +30,6 @@ const ItemList = forwardRef(
|
|
|
34
30
|
const indexBegin = props?.data?.map(
|
|
35
31
|
(_i: any, index: number) => index * numColumns,
|
|
36
32
|
);
|
|
37
|
-
const defaultKeyExtractor = (item: any, index: number) => {
|
|
38
|
-
return (item?.id ?? item?.key ?? index).toString();
|
|
39
|
-
};
|
|
40
33
|
const _renderItem = (item: any) => {
|
|
41
34
|
if (indexBegin?.includes(item?.index)) {
|
|
42
35
|
return <Item widthSpan={widthItem}>{renderItem?.(item)}</Item>;
|
|
@@ -53,7 +46,12 @@ const ItemList = forwardRef(
|
|
|
53
46
|
ref={ref as React.RefObject<FlatList>}
|
|
54
47
|
{...props}
|
|
55
48
|
key={`ItemList-${numColumns}`}
|
|
56
|
-
keyExtractor={
|
|
49
|
+
keyExtractor={
|
|
50
|
+
// prefer caller's keyExtractor; fallback to common id/key/index
|
|
51
|
+
(props as any)?.keyExtractor ??
|
|
52
|
+
((item: any, index: number) =>
|
|
53
|
+
(item?.id ?? item?.key ?? index).toString())
|
|
54
|
+
}
|
|
57
55
|
numColumns={numColumns}
|
|
58
56
|
renderItem={_renderItem}
|
|
59
57
|
horizontal={false}
|
|
@@ -7,12 +7,11 @@ import { SpanNumber } from './types';
|
|
|
7
7
|
|
|
8
8
|
export interface ItemSectionListProps extends SectionListProps<any> {
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Represents the width of the Card component in terms of span numbers (1-12).
|
|
11
11
|
*/
|
|
12
12
|
widthSpan?: SpanNumber;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
/** SectionList whose items sit on the grid, `widthSpan` columns wide, a gutter apart. */
|
|
16
15
|
const ItemSectionList: FC<ItemSectionListProps> = ({
|
|
17
16
|
renderItem,
|
|
18
17
|
widthSpan,
|
|
@@ -19,43 +19,43 @@ try {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
* the root view so they line up with window coordinates
|
|
22
|
+
* screen regions the system currently occludes, relative to the provider, which fills
|
|
23
|
+
* the root view so they line up with window coordinates
|
|
24
24
|
*/
|
|
25
25
|
const ReservedRegionsContext = createContext<ReservedRegion[]>([]);
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
* half folded. `undefined` while the display is flat or the system reports none
|
|
28
|
+
* vertical seam splitting the display into left and right halves, e.g. iPhone Duo
|
|
29
|
+
* half folded. `undefined` while the display is flat or the system reports none
|
|
30
30
|
*/
|
|
31
31
|
const HingeContext = createContext<ReservedRegion | undefined>(undefined);
|
|
32
32
|
|
|
33
|
-
/** Frame of the vertical hinge (see HingeContext), `undefined` while the display is flat. */
|
|
34
33
|
const useHinge = () => useContext(HingeContext);
|
|
35
34
|
|
|
36
35
|
/**
|
|
37
|
-
*
|
|
38
|
-
* provider.
|
|
36
|
+
* keeps the occlusion regions and the vertical division reported by the native provider
|
|
39
37
|
*/
|
|
40
38
|
const OcclusionRegions: React.FC<{
|
|
41
39
|
useRegions: NativeReservedRegions['useReservedRegions'];
|
|
42
40
|
children: ReactNode;
|
|
43
41
|
}> = ({ useRegions, children }) => {
|
|
44
42
|
const regions = useRegions();
|
|
45
|
-
const occlusion = useMemo(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
43
|
+
const occlusion = useMemo(
|
|
44
|
+
() =>
|
|
45
|
+
regions
|
|
46
|
+
.filter(region => region.kind === 'occlusion')
|
|
47
|
+
.map(region => region.frame),
|
|
48
|
+
[regions],
|
|
49
|
+
);
|
|
50
|
+
const hinge = useMemo(
|
|
51
|
+
() =>
|
|
52
|
+
regions.find(
|
|
53
|
+
region =>
|
|
54
|
+
region.kind === 'division' &&
|
|
55
|
+
region.frame.height > region.frame.width,
|
|
56
|
+
)?.frame,
|
|
57
|
+
[regions],
|
|
58
|
+
);
|
|
59
59
|
|
|
60
60
|
return (
|
|
61
61
|
<ReservedRegionsContext.Provider value={occlusion}>
|
|
@@ -65,8 +65,8 @@ const OcclusionRegions: React.FC<{
|
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
69
|
-
* cluster growing for a call or a Live Activity
|
|
68
|
+
* tracks the system occlusion regions (iOS 27.1+), e.g. the iPhone Duo status bar
|
|
69
|
+
* cluster growing for a call or a Live Activity
|
|
70
70
|
*/
|
|
71
71
|
const ReservedRegionsProvider: React.FC<{ children: ReactNode }> = ({
|
|
72
72
|
children,
|
|
@@ -75,8 +75,8 @@ const ReservedRegionsProvider: React.FC<{ children: ReactNode }> = ({
|
|
|
75
75
|
return <>{children}</>;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
const NativeProvider =
|
|
79
|
-
|
|
78
|
+
const { ReservedRegionsProvider: NativeProvider, useReservedRegions } =
|
|
79
|
+
nativeLib;
|
|
80
80
|
return (
|
|
81
81
|
<NativeProvider style={styles.container}>
|
|
82
82
|
<OcclusionRegions useRegions={useReservedRegions}>
|
package/Layout/Screen.tsx
CHANGED
|
@@ -37,10 +37,6 @@ import { useScreenQuickReturn } from './screenQuickReturn';
|
|
|
37
37
|
|
|
38
38
|
export type { ScreenProps };
|
|
39
39
|
|
|
40
|
-
/**
|
|
41
|
-
* Screen container: sets the navigation header, lays children on the grid, and adds the
|
|
42
|
-
* scroll view, floating button and footer, with iPhone Duo side bar and tab bar insets.
|
|
43
|
-
*/
|
|
44
40
|
const Screen = forwardRef(
|
|
45
41
|
(
|
|
46
42
|
{
|
|
@@ -112,12 +108,14 @@ const Screen = forwardRef(
|
|
|
112
108
|
const isIOS = Platform.OS === 'ios';
|
|
113
109
|
const bottomInset = isIOS ? Math.min(insets.bottom, 21) : insets.bottom;
|
|
114
110
|
const hasSideBar = !!layout.sideBar;
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
const useDuoGlass =
|
|
112
|
+
hasSideBar &&
|
|
113
|
+
(headerType === 'default' || headerType === 'extended') &&
|
|
114
|
+
!animatedHeader &&
|
|
115
|
+
!inputSearchProps;
|
|
118
116
|
|
|
119
|
-
const
|
|
120
|
-
|
|
117
|
+
const useQuickReturn =
|
|
118
|
+
hasSideBar && scrollable && (useDuoGlass || !!animatedHeader);
|
|
121
119
|
const { quickReturnOptions, snapQuickReturnHeader } = useScreenQuickReturn(
|
|
122
120
|
sharedValue,
|
|
123
121
|
useQuickReturn,
|
|
@@ -125,10 +123,18 @@ const Screen = forwardRef(
|
|
|
125
123
|
);
|
|
126
124
|
|
|
127
125
|
let keyboardOffset = heightHeader - bottomInset;
|
|
128
|
-
if (
|
|
126
|
+
if (
|
|
127
|
+
headerType === 'extended' ||
|
|
128
|
+
animatedHeader ||
|
|
129
|
+
inputSearchProps ||
|
|
130
|
+
useDuoGlass
|
|
131
|
+
) {
|
|
129
132
|
keyboardOffset = -bottomInset;
|
|
130
133
|
}
|
|
131
134
|
|
|
135
|
+
/**
|
|
136
|
+
* inject params for screen tracking
|
|
137
|
+
*/
|
|
132
138
|
screen?.onSetParams?.(trackingParams);
|
|
133
139
|
|
|
134
140
|
const { setSearchHeader, currentTint } = useScreenHeader({
|
|
@@ -146,7 +152,9 @@ const Screen = forwardRef(
|
|
|
146
152
|
layoutOffset,
|
|
147
153
|
});
|
|
148
154
|
|
|
149
|
-
|
|
155
|
+
/**
|
|
156
|
+
* expose ref for screen
|
|
157
|
+
*/
|
|
150
158
|
useImperativeHandle(ref, () => {
|
|
151
159
|
return Object.assign(screenRef.current || {}, {
|
|
152
160
|
setOptions: (params: NavigationOptions) => {
|
|
@@ -157,18 +165,19 @@ const Screen = forwardRef(
|
|
|
157
165
|
});
|
|
158
166
|
});
|
|
159
167
|
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
168
|
+
const { handleScroll, handleScrollEnd, handleMomentumScrollEnd } =
|
|
169
|
+
createScrollHandlers({
|
|
170
|
+
scrollable,
|
|
171
|
+
animatedValue: animatedValue.current,
|
|
172
|
+
sharedValue,
|
|
173
|
+
scrollViewProps,
|
|
174
|
+
animatedHeader,
|
|
175
|
+
inputSearchProps,
|
|
176
|
+
currentTint,
|
|
177
|
+
navigation,
|
|
178
|
+
snapQuickReturnHeader,
|
|
179
|
+
ref,
|
|
180
|
+
});
|
|
172
181
|
const Component: any = scrollable ? Animated.ScrollView : View;
|
|
173
182
|
|
|
174
183
|
const getHeight = () => {
|
|
@@ -198,35 +207,6 @@ const Screen = forwardRef(
|
|
|
198
207
|
floatingButtonBottom = 12 + duoTabInset;
|
|
199
208
|
}
|
|
200
209
|
|
|
201
|
-
const renderHeaderLayer = () => {
|
|
202
|
-
if (useDuoGlass) {
|
|
203
|
-
return (
|
|
204
|
-
<DuoScrollGradient
|
|
205
|
-
animatedValue={sharedValue}
|
|
206
|
-
gradientColor={gradientColor}
|
|
207
|
-
headerBackground={headerBackground}
|
|
208
|
-
heightHeader={heightHeader}
|
|
209
|
-
extended={headerType === 'extended'}
|
|
210
|
-
followScroll={useQuickReturn}
|
|
211
|
-
/>
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
return (
|
|
215
|
-
<HeaderExtendHeader
|
|
216
|
-
headerType={headerType}
|
|
217
|
-
heightHeader={heightHeader}
|
|
218
|
-
headerRightWidth={headerRightWidth}
|
|
219
|
-
animatedValue={sharedValue}
|
|
220
|
-
inputSearchProps={inputSearchProps}
|
|
221
|
-
navigation={navigation}
|
|
222
|
-
inputSearchRef={inputSearchRef}
|
|
223
|
-
useShadowHeader={useShadowHeader}
|
|
224
|
-
gradientColor={gradientColor}
|
|
225
|
-
headerBackground={headerBackground}
|
|
226
|
-
/>
|
|
227
|
-
);
|
|
228
|
-
};
|
|
229
|
-
|
|
230
210
|
return (
|
|
231
211
|
<View
|
|
232
212
|
style={[
|
|
@@ -237,7 +217,29 @@ const Screen = forwardRef(
|
|
|
237
217
|
},
|
|
238
218
|
]}
|
|
239
219
|
>
|
|
240
|
-
{
|
|
220
|
+
{useDuoGlass ? (
|
|
221
|
+
<DuoScrollGradient
|
|
222
|
+
animatedValue={sharedValue}
|
|
223
|
+
gradientColor={gradientColor}
|
|
224
|
+
headerBackground={headerBackground}
|
|
225
|
+
heightHeader={heightHeader}
|
|
226
|
+
extended={headerType === 'extended'}
|
|
227
|
+
followScroll={useQuickReturn}
|
|
228
|
+
/>
|
|
229
|
+
) : (
|
|
230
|
+
<HeaderExtendHeader
|
|
231
|
+
headerType={headerType}
|
|
232
|
+
heightHeader={heightHeader}
|
|
233
|
+
headerRightWidth={headerRightWidth}
|
|
234
|
+
animatedValue={sharedValue}
|
|
235
|
+
inputSearchProps={inputSearchProps}
|
|
236
|
+
navigation={navigation}
|
|
237
|
+
inputSearchRef={inputSearchRef}
|
|
238
|
+
useShadowHeader={useShadowHeader}
|
|
239
|
+
gradientColor={gradientColor}
|
|
240
|
+
headerBackground={headerBackground}
|
|
241
|
+
/>
|
|
242
|
+
)}
|
|
241
243
|
|
|
242
244
|
<KeyboardAvoidingView
|
|
243
245
|
style={[
|
|
@@ -257,9 +259,9 @@ const Screen = forwardRef(
|
|
|
257
259
|
{...scrollViewProps}
|
|
258
260
|
ref={screenRef}
|
|
259
261
|
showsVerticalScrollIndicator={false}
|
|
260
|
-
onScroll={
|
|
261
|
-
onScrollEndDrag={
|
|
262
|
-
onMomentumScrollEnd={
|
|
262
|
+
onScroll={handleScroll}
|
|
263
|
+
onScrollEndDrag={handleScrollEnd}
|
|
264
|
+
onMomentumScrollEnd={handleMomentumScrollEnd}
|
|
263
265
|
scrollEventThrottle={16}
|
|
264
266
|
style={[
|
|
265
267
|
Styles.flex,
|
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,
|
package/Layout/TrackingScope.tsx
CHANGED
package/Layout/screenContent.tsx
CHANGED
|
@@ -9,8 +9,7 @@ import { AnimatedHeader } from '../Application/types';
|
|
|
9
9
|
type ContentInset = { insetLeft: number; insetRight: number };
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
* and side insets; a child with `useMargin: false` gets no top spacing.
|
|
12
|
+
* build content for screen for grid rule
|
|
14
13
|
*/
|
|
15
14
|
export const renderContent = (content: any, layout: ContentInset): any => {
|
|
16
15
|
const results = validateChildren(content, [undefined]);
|
|
@@ -65,8 +64,7 @@ export const renderContent = (content: any, layout: ContentInset): any => {
|
|
|
65
64
|
};
|
|
66
65
|
|
|
67
66
|
/**
|
|
68
|
-
*
|
|
69
|
-
* `layoutOffset`. Nothing without a component.
|
|
67
|
+
* render top navigation banner
|
|
70
68
|
*/
|
|
71
69
|
export const renderAnimatedHeader = (
|
|
72
70
|
animatedHeader: AnimatedHeader | undefined,
|
package/Layout/screenFooter.tsx
CHANGED
|
@@ -16,10 +16,6 @@ type ScreenFooterProps = {
|
|
|
16
16
|
surfaceColor: string;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
* Screen footer on the surface color with a top shadow, padded above the home indicator,
|
|
21
|
-
* or above the floating tab bar on a tab screen.
|
|
22
|
-
*/
|
|
23
19
|
export const ScreenFooter = ({
|
|
24
20
|
footer,
|
|
25
21
|
marginFooter,
|
|
@@ -30,34 +26,28 @@ export const ScreenFooter = ({
|
|
|
30
26
|
duoTabInset,
|
|
31
27
|
bottomInset,
|
|
32
28
|
surfaceColor,
|
|
33
|
-
}: ScreenFooterProps) =>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
}: ScreenFooterProps) => (
|
|
30
|
+
<View
|
|
31
|
+
pointerEvents={'box-none'}
|
|
32
|
+
style={[
|
|
33
|
+
hasContentInset && styles.footerClip,
|
|
34
|
+
{
|
|
35
|
+
marginLeft: insetLeft,
|
|
36
|
+
marginRight: insetRight,
|
|
37
|
+
},
|
|
38
|
+
]}
|
|
39
|
+
>
|
|
40
40
|
<View
|
|
41
|
-
pointerEvents={'box-none'}
|
|
42
41
|
style={[
|
|
43
|
-
|
|
42
|
+
styles.shadow,
|
|
44
43
|
{
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
paddingBottom:
|
|
45
|
+
(isTab && duoTabInset ? duoTabInset : bottomInset) + Spacing.S,
|
|
46
|
+
backgroundColor: surfaceColor,
|
|
47
47
|
},
|
|
48
48
|
]}
|
|
49
49
|
>
|
|
50
|
-
<
|
|
51
|
-
style={[
|
|
52
|
-
styles.shadow,
|
|
53
|
-
{
|
|
54
|
-
paddingBottom: bottomSpace + Spacing.S,
|
|
55
|
-
backgroundColor: surfaceColor,
|
|
56
|
-
},
|
|
57
|
-
]}
|
|
58
|
-
>
|
|
59
|
-
<Section useMargin={marginFooter}>{footer}</Section>
|
|
60
|
-
</View>
|
|
50
|
+
<Section useMargin={marginFooter}>{footer}</Section>
|
|
61
51
|
</View>
|
|
62
|
-
|
|
63
|
-
|
|
52
|
+
</View>
|
|
53
|
+
);
|
package/Layout/screenHeader.tsx
CHANGED
|
@@ -31,10 +31,6 @@ type ScreenHeaderParams = {
|
|
|
31
31
|
layoutOffset: number;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
/**
|
|
35
|
-
* Applies the Screen's navigation header (plain, extended, animated banner or search) and
|
|
36
|
-
* re-applies it when those props change. Returns the search header setter and the tint.
|
|
37
|
-
*/
|
|
38
34
|
export const useScreenHeader = ({
|
|
39
35
|
navigation,
|
|
40
36
|
layout,
|
|
@@ -52,7 +48,10 @@ export const useScreenHeader = ({
|
|
|
52
48
|
const currentTint = useRef<string | undefined>(undefined);
|
|
53
49
|
const appliedHeaderMode = useRef<string | undefined>(undefined);
|
|
54
50
|
|
|
55
|
-
|
|
51
|
+
/**
|
|
52
|
+
* export options for screen
|
|
53
|
+
* @param type
|
|
54
|
+
*/
|
|
56
55
|
const setHeaderType = useCallback(
|
|
57
56
|
(type: HeaderType, keepTitle = false) => {
|
|
58
57
|
let options: StackNavigationOptions;
|
|
@@ -70,12 +69,10 @@ export const useScreenHeader = ({
|
|
|
70
69
|
...quickReturnOptions,
|
|
71
70
|
headerShown: true,
|
|
72
71
|
headerTransparent: true,
|
|
73
|
-
headerBackground: () =>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return <DuoGlassBackground animatedValue={sharedValue} />;
|
|
78
|
-
},
|
|
72
|
+
headerBackground: () =>
|
|
73
|
+
hasSideBar ? (
|
|
74
|
+
<DuoGlassBackground animatedValue={sharedValue} />
|
|
75
|
+
) : null,
|
|
79
76
|
headerTitle: (props: any) => <HeaderTitle {...props} />,
|
|
80
77
|
};
|
|
81
78
|
if (inputSearchProps) {
|
|
@@ -163,7 +160,10 @@ export const useScreenHeader = ({
|
|
|
163
160
|
],
|
|
164
161
|
);
|
|
165
162
|
|
|
166
|
-
|
|
163
|
+
/**
|
|
164
|
+
* export animatedHeader options for screen
|
|
165
|
+
* @param nextAnimatedHeader
|
|
166
|
+
*/
|
|
167
167
|
const setAnimatedHeader = useCallback(
|
|
168
168
|
(nextAnimatedHeader: AnimatedHeader) => {
|
|
169
169
|
let options: StackNavigationOptions;
|
|
@@ -175,16 +175,13 @@ export const useScreenHeader = ({
|
|
|
175
175
|
...quickReturnOptions,
|
|
176
176
|
headerTintColor: currentTint.current ?? Colors.black_17,
|
|
177
177
|
headerTransparent: true,
|
|
178
|
-
headerBackground: (props: any) =>
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
return (
|
|
178
|
+
headerBackground: (props: any) =>
|
|
179
|
+
hasSideBar ? (
|
|
180
|
+
<DuoGlassBackground
|
|
181
|
+
animatedValue={sharedValue}
|
|
182
|
+
bannerBottom={ANIMATED_BANNER_HEIGHT + layoutOffset}
|
|
183
|
+
/>
|
|
184
|
+
) : (
|
|
188
185
|
<HeaderBackground
|
|
189
186
|
{...props}
|
|
190
187
|
animatedValue={sharedValue}
|
|
@@ -193,8 +190,7 @@ export const useScreenHeader = ({
|
|
|
193
190
|
headerBackground={headerBackground}
|
|
194
191
|
gradientColor={gradientColor}
|
|
195
192
|
/>
|
|
196
|
-
)
|
|
197
|
-
},
|
|
193
|
+
),
|
|
198
194
|
headerTitle: (props: any) => {
|
|
199
195
|
return <HeaderTitle {...props} />;
|
|
200
196
|
},
|
|
@@ -221,6 +217,9 @@ export const useScreenHeader = ({
|
|
|
221
217
|
],
|
|
222
218
|
);
|
|
223
219
|
|
|
220
|
+
/**
|
|
221
|
+
* export animatedHeader options for screen
|
|
222
|
+
*/
|
|
224
223
|
const setAnimatedSearch = useCallback(() => {
|
|
225
224
|
const options: StackNavigationOptions = {
|
|
226
225
|
headerShown: true,
|
|
@@ -241,7 +240,9 @@ export const useScreenHeader = ({
|
|
|
241
240
|
navigation?.instance?.setOptions({ header: undefined, ...options });
|
|
242
241
|
}, [navigation?.instance, sharedValue]);
|
|
243
242
|
|
|
244
|
-
|
|
243
|
+
/**
|
|
244
|
+
* export search header
|
|
245
|
+
*/
|
|
245
246
|
const setSearchHeader = (params: SearchHeaderProps) => {
|
|
246
247
|
let searchWidth = layout.width - 24;
|
|
247
248
|
let searchLeft = Spacing.M;
|
|
@@ -249,9 +250,9 @@ export const useScreenHeader = ({
|
|
|
249
250
|
searchWidth = layout.contentWidth - Spacing.M * 2;
|
|
250
251
|
searchLeft = Spacing.M - getHeaderMargin(layout.width);
|
|
251
252
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
253
|
+
if (layout.statusBarClearance) {
|
|
254
|
+
searchWidth -=
|
|
255
|
+
layout.statusBarClearance.left + layout.statusBarClearance.right;
|
|
255
256
|
}
|
|
256
257
|
const options: StackNavigationOptions = {
|
|
257
258
|
headerRight: undefined,
|
|
@@ -266,12 +267,8 @@ export const useScreenHeader = ({
|
|
|
266
267
|
margin: 0,
|
|
267
268
|
left: searchLeft,
|
|
268
269
|
},
|
|
269
|
-
headerLeft: (props: any) =>
|
|
270
|
-
|
|
271
|
-
return null;
|
|
272
|
-
}
|
|
273
|
-
return <HeaderLeft {...props} floating />;
|
|
274
|
-
},
|
|
270
|
+
headerLeft: (props: any) =>
|
|
271
|
+
params?.hiddenBack ? null : <HeaderLeft {...props} floating />,
|
|
275
272
|
headerTitle: () => (
|
|
276
273
|
<SearchHeader {...params} animatedValue={sharedValue} />
|
|
277
274
|
),
|
|
@@ -8,10 +8,6 @@ import {
|
|
|
8
8
|
} from 'react-native-reanimated';
|
|
9
9
|
import { DuoQuickReturnHeader } from '../Application/Components/DuoQuickReturnHeader';
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
* iPhone Duo quick return header: it slides out while the content scrolls down and back
|
|
13
|
-
* on scroll up. Returns the header options and a snap to call when scrolling ends.
|
|
14
|
-
*/
|
|
15
11
|
export const useScreenQuickReturn = (
|
|
16
12
|
sharedValue: SharedValue<number>,
|
|
17
13
|
useQuickReturn: boolean,
|
|
@@ -37,22 +33,29 @@ export const useScreenQuickReturn = (
|
|
|
37
33
|
[useQuickReturn, heightHeader],
|
|
38
34
|
);
|
|
39
35
|
|
|
40
|
-
const quickReturnOptions: StackNavigationOptions = useMemo(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
const quickReturnOptions: StackNavigationOptions = useMemo(
|
|
37
|
+
() =>
|
|
38
|
+
useQuickReturn
|
|
39
|
+
? {
|
|
40
|
+
header: (props: any) => (
|
|
41
|
+
<DuoQuickReturnHeader {...props} offset={headerHide} />
|
|
42
|
+
),
|
|
43
|
+
}
|
|
44
|
+
: { header: undefined },
|
|
45
|
+
[useQuickReturn, headerHide],
|
|
46
|
+
);
|
|
50
47
|
|
|
51
|
-
|
|
48
|
+
/**
|
|
49
|
+
* a half-shown quick return header settles fully in or out
|
|
50
|
+
*/
|
|
52
51
|
const snapQuickReturnHeader = (offsetY: number) => {
|
|
53
52
|
const hide = headerHide.value;
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
if (
|
|
54
|
+
!useQuickReturn ||
|
|
55
|
+
offsetY < heightHeader ||
|
|
56
|
+
hide <= 0 ||
|
|
57
|
+
hide >= heightHeader
|
|
58
|
+
) {
|
|
56
59
|
return;
|
|
57
60
|
}
|
|
58
61
|
headerHide.value = withTiming(hide > heightHeader / 2 ? heightHeader : 0, {
|