@momo-kits/foundation 0.168.1-beta.20 → 0.168.1-beta.21
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.
|
@@ -10,12 +10,10 @@ import { ApplicationContext } from '../../Context';
|
|
|
10
10
|
import { Shadow } from '../../Consts';
|
|
11
11
|
import { Image } from '../../Image';
|
|
12
12
|
import { AnimatedCompatValue, useNormalizedSharedValue } from '../utils';
|
|
13
|
+
import { useScreenLayout } from '../../Layout';
|
|
13
14
|
|
|
14
|
-
// extended headers run their gradient this far below the header, as off Duo
|
|
15
15
|
const EXTENDED_GRADIENT_EXTRA = 52;
|
|
16
|
-
// scroll distance over which the extended gradient collapses to the header
|
|
17
16
|
const EXTENDED_COLLAPSE_DISTANCE = 100;
|
|
18
|
-
// scroll distance over which the bar material fades in
|
|
19
17
|
const FADE_DISTANCE = 16;
|
|
20
18
|
const TRANSLUCENT_ALPHA = 'CC';
|
|
21
19
|
|
|
@@ -25,11 +23,12 @@ const TRANSLUCENT_ALPHA = 'CC';
|
|
|
25
23
|
*/
|
|
26
24
|
const DuoGlassBackground: React.FC<{
|
|
27
25
|
animatedValue?: AnimatedCompatValue;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}> = ({ animatedValue, fadeStart = 0 }) => {
|
|
26
|
+
bannerBottom?: number;
|
|
27
|
+
}> = ({ animatedValue, bannerBottom = 0 }) => {
|
|
31
28
|
const { theme } = useContext(ApplicationContext);
|
|
29
|
+
const { headerHeight } = useScreenLayout();
|
|
32
30
|
const sharedValue = useNormalizedSharedValue(animatedValue);
|
|
31
|
+
const fadeStart = Math.max(bannerBottom - headerHeight, 0);
|
|
33
32
|
|
|
34
33
|
const fadeStyle = useAnimatedStyle(() => ({
|
|
35
34
|
opacity: interpolate(
|
|
@@ -68,7 +67,6 @@ const DuoScrollGradient: React.FC<{
|
|
|
68
67
|
headerBackground?: string;
|
|
69
68
|
heightHeader: number;
|
|
70
69
|
extended?: boolean;
|
|
71
|
-
// quick return header: the gradient leaves with the content instead of fading
|
|
72
70
|
followScroll?: boolean;
|
|
73
71
|
}> = ({
|
|
74
72
|
animatedValue,
|
|
@@ -147,7 +145,6 @@ const styles = StyleSheet.create({
|
|
|
147
145
|
right: 0,
|
|
148
146
|
overflow: 'hidden',
|
|
149
147
|
},
|
|
150
|
-
// banner image keeps its 375:154 shape, the gradient box clips it
|
|
151
148
|
gradientFill: {
|
|
152
149
|
width: '100%',
|
|
153
150
|
position: 'absolute',
|
package/Application/utils.tsx
CHANGED
|
@@ -32,6 +32,8 @@ import { HeaderBackground } from './Components/HeaderBackground';
|
|
|
32
32
|
import { HeaderLeft } from './Components/HeaderLeft';
|
|
33
33
|
import { HeaderRight } from './Components/HeaderRight';
|
|
34
34
|
|
|
35
|
+
const SWIPE_BACK_HAPTIC_THRESHOLD = 50;
|
|
36
|
+
|
|
35
37
|
const forStackTransitionWithOverlay = (
|
|
36
38
|
props: StackCardInterpolationProps,
|
|
37
39
|
): StackCardInterpolatedStyle => {
|
|
@@ -374,13 +376,6 @@ const useNormalizedSharedValue = (
|
|
|
374
376
|
return fallback;
|
|
375
377
|
};
|
|
376
378
|
|
|
377
|
-
/**
|
|
378
|
-
* Travel, in points, at which the swipe back gesture ticks. Flat and well short of
|
|
379
|
-
* react-navigation's own `distance / 2` commit rule: the tick marks "the gesture is
|
|
380
|
-
* recognised", not "you are past the point of no return".
|
|
381
|
-
*/
|
|
382
|
-
const SWIPE_BACK_HAPTIC_THRESHOLD = 50;
|
|
383
|
-
|
|
384
379
|
/**
|
|
385
380
|
* `current.progress` is `gesture.interpolate(...)` built by CardStack
|
|
386
381
|
* (@react-navigation/stack 7.4.2, views/Stack/CardStack.tsx `getProgressFromGesture`).
|
|
@@ -478,8 +473,9 @@ const SwipeBackHaptic = () => {
|
|
|
478
473
|
return null;
|
|
479
474
|
};
|
|
480
475
|
|
|
481
|
-
const isWhiteListDesignSystem = (context: any): boolean =>
|
|
482
|
-
context?.designSystemConfig?.isWhiteListDesignSystem === true;
|
|
476
|
+
const isWhiteListDesignSystem = (context: any): boolean => {
|
|
477
|
+
return context?.designSystemConfig?.isWhiteListDesignSystem === true;
|
|
478
|
+
};
|
|
483
479
|
|
|
484
480
|
export {
|
|
485
481
|
getStackOptions,
|
package/Layout/Screen.tsx
CHANGED
|
@@ -64,6 +64,8 @@ import {
|
|
|
64
64
|
import { DuoQuickReturnHeader } from '../Application/Components/DuoQuickReturnHeader';
|
|
65
65
|
import { useDuoTabBarInset } from '../Application/BottomTab/DuoTabBar';
|
|
66
66
|
|
|
67
|
+
const ANIMATED_BANNER_HEIGHT = 210;
|
|
68
|
+
|
|
67
69
|
export interface ScreenProps extends ViewProps {
|
|
68
70
|
/**
|
|
69
71
|
* ReactNode representing the content of the screen.
|
|
@@ -222,19 +224,6 @@ const Screen = forwardRef(
|
|
|
222
224
|
const frame = useSafeAreaFrame();
|
|
223
225
|
const heightHeader = useHeaderHeight();
|
|
224
226
|
|
|
225
|
-
/**
|
|
226
|
-
* Dual animation source:
|
|
227
|
-
* - `animatedValue` is a react-native `Animated.Value` driven natively by the
|
|
228
|
-
* scroll event. It is what legacy consumers receive (`animatedValue`).
|
|
229
|
-
* - `sharedValue` is a reanimated `SharedValue` consumed by every internal
|
|
230
|
-
* foundation component (and offered to modern consumers). It is kept in
|
|
231
|
-
* sync from the scroll `listener` (see below), which fires on the JS
|
|
232
|
-
* thread even when the scroll uses the native driver.
|
|
233
|
-
* If a legacy value is driven outside of Screen, its listener also
|
|
234
|
-
* mirrors JS-driven updates into the shared value.
|
|
235
|
-
* Consumers pass only `Animated.Value`; the reanimated shared value stays
|
|
236
|
-
* an internal implementation detail.
|
|
237
|
-
*/
|
|
238
227
|
const animatedValue = useRef<Animated.Value>(
|
|
239
228
|
customAnimatedValue ?? new Animated.Value(0),
|
|
240
229
|
);
|
|
@@ -258,7 +247,6 @@ const Screen = forwardRef(
|
|
|
258
247
|
const currentTint = useRef<string | undefined>(undefined);
|
|
259
248
|
|
|
260
249
|
const isTab = !!screen?.bottomTab;
|
|
261
|
-
// Duo floating tab bar overlays the tab content instead of taking layout space
|
|
262
250
|
const duoTabInset = useDuoTabBarInset();
|
|
263
251
|
|
|
264
252
|
let handleScroll;
|
|
@@ -267,14 +255,12 @@ const Screen = forwardRef(
|
|
|
267
255
|
const isIOS = Platform.OS === 'ios';
|
|
268
256
|
const bottomInset = isIOS ? Math.min(insets.bottom, 21) : insets.bottom;
|
|
269
257
|
const hasSideBar = !!layout.sideBar;
|
|
270
|
-
// iPhone Duo: content scrolls under a glass header instead of starting below it
|
|
271
258
|
const useDuoGlass =
|
|
272
259
|
hasSideBar &&
|
|
273
260
|
(headerType === 'default' || headerType === 'extended') &&
|
|
274
261
|
!animatedHeader &&
|
|
275
262
|
!inputSearchProps;
|
|
276
263
|
|
|
277
|
-
// iPhone Duo: the header leaves with the content and returns on a reverse scroll
|
|
278
264
|
const useQuickReturn =
|
|
279
265
|
hasSideBar && scrollable && (useDuoGlass || !!animatedHeader);
|
|
280
266
|
const headerHide = useSharedValue(0);
|
|
@@ -324,12 +310,14 @@ const Screen = forwardRef(
|
|
|
324
310
|
*/
|
|
325
311
|
screen?.onSetParams?.(trackingParams);
|
|
326
312
|
|
|
313
|
+
const appliedHeaderMode = useRef<string | undefined>(undefined);
|
|
314
|
+
|
|
327
315
|
/**
|
|
328
316
|
* export options for screen
|
|
329
317
|
* @param headerType
|
|
330
318
|
*/
|
|
331
319
|
const setHeaderType = useCallback(
|
|
332
|
-
(headerType: HeaderType) => {
|
|
320
|
+
(headerType: HeaderType, keepTitle = false) => {
|
|
333
321
|
let options: StackNavigationOptions;
|
|
334
322
|
switch (headerType) {
|
|
335
323
|
case 'none':
|
|
@@ -418,6 +406,10 @@ const Screen = forwardRef(
|
|
|
418
406
|
}
|
|
419
407
|
}
|
|
420
408
|
|
|
409
|
+
if (keepTitle) {
|
|
410
|
+
delete options.headerTitle;
|
|
411
|
+
}
|
|
412
|
+
|
|
421
413
|
navigation?.instance?.setOptions({ header: undefined, ...options });
|
|
422
414
|
},
|
|
423
415
|
[
|
|
@@ -449,10 +441,9 @@ const Screen = forwardRef(
|
|
|
449
441
|
headerTransparent: true,
|
|
450
442
|
headerBackground: (props: any) =>
|
|
451
443
|
hasSideBar ? (
|
|
452
|
-
// glass shows once the banner has scrolled under the header
|
|
453
444
|
<DuoGlassBackground
|
|
454
445
|
animatedValue={sharedValue}
|
|
455
|
-
|
|
446
|
+
bannerBottom={ANIMATED_BANNER_HEIGHT + layoutOffset}
|
|
456
447
|
/>
|
|
457
448
|
) : (
|
|
458
449
|
<HeaderBackground
|
|
@@ -486,7 +477,6 @@ const Screen = forwardRef(
|
|
|
486
477
|
useShadowHeader,
|
|
487
478
|
hasSideBar,
|
|
488
479
|
layoutOffset,
|
|
489
|
-
heightHeader,
|
|
490
480
|
quickReturnOptions,
|
|
491
481
|
],
|
|
492
482
|
);
|
|
@@ -521,7 +511,6 @@ const Screen = forwardRef(
|
|
|
521
511
|
let searchWidth = layout.width - 24;
|
|
522
512
|
let searchLeft = Spacing.M;
|
|
523
513
|
if (layout.sideBar) {
|
|
524
|
-
// back floats in the side bar: the search spans the content width
|
|
525
514
|
searchWidth = layout.contentWidth - Spacing.M * 2;
|
|
526
515
|
searchLeft = Spacing.M - getHeaderMargin(layout.width);
|
|
527
516
|
}
|
|
@@ -563,10 +552,13 @@ const Screen = forwardRef(
|
|
|
563
552
|
|
|
564
553
|
if (animatedHeader) {
|
|
565
554
|
setAnimatedHeader(animatedHeader);
|
|
555
|
+
appliedHeaderMode.current = 'animated';
|
|
566
556
|
} else if (inputSearchProps) {
|
|
567
557
|
setAnimatedSearch();
|
|
558
|
+
appliedHeaderMode.current = 'search';
|
|
568
559
|
} else {
|
|
569
|
-
setHeaderType(headerType);
|
|
560
|
+
setHeaderType(headerType, appliedHeaderMode.current === headerType);
|
|
561
|
+
appliedHeaderMode.current = headerType;
|
|
570
562
|
}
|
|
571
563
|
|
|
572
564
|
return () => {
|
|
@@ -613,7 +605,6 @@ const Screen = forwardRef(
|
|
|
613
605
|
useNativeDriver: true,
|
|
614
606
|
listener: (e: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
615
607
|
const offsetY = e.nativeEvent.contentOffset.y;
|
|
616
|
-
// keep the reanimated source in sync for the internal components.
|
|
617
608
|
sharedValue.value = offsetY;
|
|
618
609
|
scrollViewProps?.onScroll?.(e);
|
|
619
610
|
if (animatedHeader) {
|
|
@@ -648,7 +639,6 @@ const Screen = forwardRef(
|
|
|
648
639
|
*/
|
|
649
640
|
const snapQuickReturnHeader = (offsetY: number) => {
|
|
650
641
|
const hide = headerHide.value;
|
|
651
|
-
// above heightHeader the header still sits on the content
|
|
652
642
|
if (
|
|
653
643
|
!useQuickReturn ||
|
|
654
644
|
offsetY < heightHeader ||
|
|
@@ -692,11 +682,12 @@ const Screen = forwardRef(
|
|
|
692
682
|
if (typeof animatedHeader?.component === 'function') {
|
|
693
683
|
return (
|
|
694
684
|
<View
|
|
695
|
-
style={[
|
|
685
|
+
style={[
|
|
686
|
+
styles.screenBanner,
|
|
687
|
+
{ maxHeight: ANIMATED_BANNER_HEIGHT + layoutOffset },
|
|
688
|
+
]}
|
|
696
689
|
>
|
|
697
690
|
{animatedHeader?.component({
|
|
698
|
-
// legacy consumers read `animatedValue` (Animated.Value),
|
|
699
|
-
// modern consumers read `sharedValue` (SharedValue).
|
|
700
691
|
animatedValue: animatedValue.current,
|
|
701
692
|
sharedValue: sharedValue,
|
|
702
693
|
})}
|
|
@@ -756,11 +747,6 @@ const Screen = forwardRef(
|
|
|
756
747
|
}
|
|
757
748
|
};
|
|
758
749
|
|
|
759
|
-
// Cap the screen container height so a scrollable body with a sticky footer
|
|
760
|
-
// can't push the footer past the visible frame (web previews measure the
|
|
761
|
-
// safe-area frame from the seeded SafeAreaProvider metrics). Subtract the
|
|
762
|
-
// bottom tab bar when present and the header unless it's an animated/extended
|
|
763
|
-
// header (those overlay rather than offset the body).
|
|
764
750
|
const getHeight = () => {
|
|
765
751
|
let newHeight = frame.height;
|
|
766
752
|
if (isTab) {
|
|
@@ -772,8 +758,6 @@ const Screen = forwardRef(
|
|
|
772
758
|
return newHeight;
|
|
773
759
|
};
|
|
774
760
|
|
|
775
|
-
// without the grid, the content container keeps clear of the horizontal insets.
|
|
776
|
-
// Only set when there are insets, so a caller's paddingHorizontal is never overridden.
|
|
777
761
|
const hasContentInset = layout.insetLeft > 0 || layout.insetRight > 0;
|
|
778
762
|
const needsContentInset = !useGridLayout && hasContentInset;
|
|
779
763
|
const contentInsetStyle = needsContentInset && {
|
|
@@ -796,8 +780,6 @@ const Screen = forwardRef(
|
|
|
796
780
|
Styles.flex,
|
|
797
781
|
{
|
|
798
782
|
backgroundColor: backgroundColor ?? theme.colors.background.default,
|
|
799
|
-
// Web-only cap so a scrollable body with a sticky footer can't push
|
|
800
|
-
// the footer past the frame. Native handles this without a cap.
|
|
801
783
|
maxHeight: Platform.OS === 'web' ? getHeight() : undefined,
|
|
802
784
|
},
|
|
803
785
|
]}
|
|
@@ -882,7 +864,6 @@ const Screen = forwardRef(
|
|
|
882
864
|
)}
|
|
883
865
|
|
|
884
866
|
{Footer && (
|
|
885
|
-
// with side insets, the clip keeps the shadow off the side bar, only the top one shows
|
|
886
867
|
<View
|
|
887
868
|
pointerEvents={'box-none'}
|
|
888
869
|
style={[
|
|
@@ -904,8 +885,6 @@ const Screen = forwardRef(
|
|
|
904
885
|
},
|
|
905
886
|
]}
|
|
906
887
|
>
|
|
907
|
-
{/* The footer inset is a caller decision, not a platform one — a footer
|
|
908
|
-
that carries its own horizontal padding passes `marginFooter={false}`. */}
|
|
909
888
|
<Section useMargin={marginFooter}>{Footer}</Section>
|
|
910
889
|
</View>
|
|
911
890
|
</View>
|
package/package.json
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
2
|
+
"name": "@momo-kits/foundation",
|
|
3
|
+
"version": "0.168.1-beta.21",
|
|
4
|
+
"description": "React Native Component Kits",
|
|
5
|
+
"main": "index.ts",
|
|
6
|
+
"scripts": {},
|
|
7
|
+
"keywords": [
|
|
8
|
+
"@momo-kits/foundation"
|
|
9
|
+
],
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"react-native-fast-image": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-fast-image.git#v8.11.0",
|
|
12
|
+
"@react-navigation/bottom-tabs": "7.4.2",
|
|
13
|
+
"@react-navigation/core": "7.12.1",
|
|
14
|
+
"@react-navigation/elements": "2.5.2",
|
|
15
|
+
"@react-navigation/native": "7.1.14",
|
|
16
|
+
"@react-navigation/routers": "7.4.1",
|
|
17
|
+
"@react-navigation/stack": "7.4.2",
|
|
18
|
+
"react-native-gesture-handler": "2.27.1",
|
|
19
|
+
"react-native-linear-gradient": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-linear-gradient#v3.0.0",
|
|
20
|
+
"react-native-reanimated": "4.2.2",
|
|
21
|
+
"react-native-worklets": "0.6.1",
|
|
22
|
+
"react-native-safe-area-context": "5.5.2",
|
|
23
|
+
"react-native-reserved-regions": "0.2.0",
|
|
24
|
+
"@shopify/flash-list": "2.1.0",
|
|
25
|
+
"lottie-react-native": "7.2.4"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"react-native": "*",
|
|
29
|
+
"react-native-worklets": "0.6.1"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/color": "3.0.6"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"registry": "https://registry.npmjs.org/"
|
|
36
|
+
},
|
|
37
|
+
"license": "MoMo"
|
|
38
|
+
}
|