@momo-kits/foundation 0.167.1-duo.5 → 0.167.1-sizescale.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.tsx +14 -115
- package/Application/BottomTab/BottomTabBar.tsx +3 -6
- package/Application/BottomTab/index.tsx +28 -38
- package/Application/Components/HeaderExtendHeader.tsx +27 -40
- package/Application/Components/HeaderLeft.tsx +0 -17
- package/Application/Components/HeaderRight.tsx +9 -59
- package/Application/Components/HeaderTitle.tsx +7 -29
- package/Application/Components/SearchHeader.tsx +14 -15
- package/Application/ModalScreen.tsx +2 -16
- package/Application/NavigationContainer.tsx +59 -8
- package/Application/Navigator.ts +3 -1
- package/Application/StackScreen.tsx +5 -2
- package/Application/types.ts +2 -5
- package/Application/utils.tsx +3 -6
- package/Consts/theme.ts +4 -3
- package/Input/Input.tsx +4 -3
- package/Input/InputMoney.tsx +8 -5
- package/Input/InputPhoneNumber.tsx +4 -3
- package/Input/InputSearch.tsx +4 -3
- package/Input/InputTextArea.tsx +4 -3
- package/Layout/Card.tsx +26 -8
- package/Layout/FloatingButton.tsx +3 -3
- package/Layout/GridSystem.tsx +137 -0
- package/Layout/Item.tsx +10 -1
- package/Layout/Screen.tsx +40 -146
- package/Layout/Section.tsx +18 -5
- package/Layout/index.ts +4 -4
- package/Layout/utils.ts +5 -280
- package/Popup/PopupNotify.tsx +22 -33
- package/Popup/PopupPromotion.tsx +8 -20
- package/Text/utils.ts +2 -1
- package/package.json +2 -3
- package/Application/BottomTab/DuoTabBar.tsx +0 -410
- package/Application/Components/DuoGlassBackground.tsx +0 -177
- package/Application/Components/OptionalGlassView.ts +0 -11
- package/Application/Components/SideBarButton.tsx +0 -128
- package/Application/device.ts +0 -29
- package/Popup/utils.ts +0 -32
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useCallback,
|
|
3
|
-
useContext,
|
|
4
|
-
useEffect,
|
|
5
|
-
useRef,
|
|
6
|
-
useState,
|
|
7
|
-
} from 'react';
|
|
1
|
+
import React, { useCallback, useContext, useEffect, useRef } from 'react';
|
|
8
2
|
import {
|
|
9
3
|
BackHandler,
|
|
10
4
|
Dimensions,
|
|
11
|
-
Keyboard,
|
|
12
5
|
KeyboardAvoidingView,
|
|
13
|
-
KeyboardEvent,
|
|
14
|
-
LayoutAnimation,
|
|
15
6
|
Modal,
|
|
16
7
|
PanResponder,
|
|
17
8
|
Platform,
|
|
18
9
|
Pressable,
|
|
19
10
|
StyleSheet,
|
|
20
11
|
TouchableOpacity,
|
|
21
|
-
useWindowDimensions,
|
|
22
12
|
View,
|
|
23
13
|
} from 'react-native';
|
|
24
14
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
@@ -32,38 +22,22 @@ import Animated, {
|
|
|
32
22
|
Easing,
|
|
33
23
|
Extrapolation,
|
|
34
24
|
interpolate,
|
|
25
|
+
runOnJS,
|
|
35
26
|
useAnimatedStyle,
|
|
36
27
|
useSharedValue,
|
|
37
28
|
withSpring,
|
|
38
29
|
withTiming,
|
|
39
30
|
} from 'react-native-reanimated';
|
|
40
|
-
import { scheduleOnRN } from 'react-native-worklets';
|
|
41
31
|
import layoutStyles from '../Layout/styles';
|
|
42
|
-
import { getDuoTopInset, isIPhoneDuo } from './device';
|
|
43
|
-
|
|
44
|
-
// iPhone Duo inner display: center the sheet instead of spanning the width
|
|
45
|
-
const DUO_REGULAR_MIN_WIDTH = 600;
|
|
46
32
|
|
|
47
33
|
const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
48
34
|
const { theme, navigator } = useContext(ApplicationContext);
|
|
49
35
|
const context = useContext<any>(MiniAppContext);
|
|
50
|
-
const
|
|
51
|
-
const isDuo = isIPhoneDuo();
|
|
52
|
-
const isDuoCentered = isDuo && windowSize.width >= DUO_REGULAR_MIN_WIDTH;
|
|
53
|
-
const isPortrait = windowSize.height > windowSize.width;
|
|
54
|
-
// 'screen' is the outer display on iPhone Duo, even when unfolded
|
|
55
|
-
const heightDevice = isDuo
|
|
56
|
-
? windowSize.height
|
|
57
|
-
: Dimensions.get('screen').height;
|
|
36
|
+
const heightDevice = Dimensions.get('screen').height;
|
|
58
37
|
const action = useRef<undefined | string>(undefined);
|
|
59
38
|
const insets = useSafeAreaInsets();
|
|
60
39
|
const heightHeader = useHeaderHeight();
|
|
61
|
-
const
|
|
62
|
-
getDuoTopInset(insets, windowSize.width, windowSize.height),
|
|
63
|
-
Spacing.XL,
|
|
64
|
-
);
|
|
65
|
-
const bottomInset =
|
|
66
|
-
Platform.OS === 'ios' ? Math.min(insets.bottom, 21) : insets.bottom;
|
|
40
|
+
const bottomInset = Platform.OS === 'ios' ? Math.min(insets.bottom, 21) : insets.bottom;
|
|
67
41
|
const keyboardOffset = heightHeader - bottomInset;
|
|
68
42
|
|
|
69
43
|
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
@@ -84,43 +58,6 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
84
58
|
}: BottomSheetParams = props.route.params;
|
|
85
59
|
|
|
86
60
|
const translateY = useSharedValue(heightDevice);
|
|
87
|
-
const [keyboardLift, setKeyboardLift] = useState(0);
|
|
88
|
-
|
|
89
|
-
// KeyboardAvoidingView lifts the whole sheet past the top on iPhone Duo,
|
|
90
|
-
// so lift it here and shrink maxHeight by the same amount instead
|
|
91
|
-
useEffect(() => {
|
|
92
|
-
if (!isDuo || !useKeyboardAvoidingView) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
const onKeyboardChange = (e: KeyboardEvent) => {
|
|
96
|
-
const overlap = windowSize.height - e.endCoordinates.screenY;
|
|
97
|
-
const lift = Math.max(
|
|
98
|
-
overlap - bottomInset - (keyboardVerticalOffset ?? 0),
|
|
99
|
-
0,
|
|
100
|
-
);
|
|
101
|
-
if (e.duration) {
|
|
102
|
-
LayoutAnimation.configureNext({
|
|
103
|
-
duration: e.duration,
|
|
104
|
-
update: {
|
|
105
|
-
duration: e.duration,
|
|
106
|
-
type: LayoutAnimation.Types[e.easing] || 'keyboard',
|
|
107
|
-
},
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
setKeyboardLift(lift);
|
|
111
|
-
};
|
|
112
|
-
const subscriptions = [
|
|
113
|
-
Keyboard.addListener('keyboardWillChangeFrame', onKeyboardChange),
|
|
114
|
-
Keyboard.addListener('keyboardWillHide', onKeyboardChange),
|
|
115
|
-
];
|
|
116
|
-
return () => subscriptions.forEach(sub => sub.remove());
|
|
117
|
-
}, [
|
|
118
|
-
bottomInset,
|
|
119
|
-
isDuo,
|
|
120
|
-
keyboardVerticalOffset,
|
|
121
|
-
useKeyboardAvoidingView,
|
|
122
|
-
windowSize.height,
|
|
123
|
-
]);
|
|
124
61
|
|
|
125
62
|
const openAnimation = useCallback(() => {
|
|
126
63
|
translateY.value = withTiming(0, {
|
|
@@ -137,7 +74,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
137
74
|
duration: 200,
|
|
138
75
|
easing: Easing.bezier(0.3, 0.0, 0.8, 0.15),
|
|
139
76
|
},
|
|
140
|
-
() =>
|
|
77
|
+
() => runOnJS(callback)(),
|
|
141
78
|
);
|
|
142
79
|
},
|
|
143
80
|
[heightDevice, translateY],
|
|
@@ -200,9 +137,9 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
200
137
|
}
|
|
201
138
|
closeAnimation(() => {
|
|
202
139
|
navigator?.pop();
|
|
203
|
-
|
|
140
|
+
runOnJS(() => {
|
|
204
141
|
callback?.();
|
|
205
|
-
});
|
|
142
|
+
})();
|
|
206
143
|
});
|
|
207
144
|
},
|
|
208
145
|
[barrierDismissible, closeAnimation, navigator],
|
|
@@ -311,23 +248,6 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
311
248
|
};
|
|
312
249
|
});
|
|
313
250
|
|
|
314
|
-
// landscape side buttons span the full height, so inset the content; in
|
|
315
|
-
// portrait the side status bar only covers the top corner
|
|
316
|
-
const sideInsetStyle = isDuo &&
|
|
317
|
-
!isDuoCentered &&
|
|
318
|
-
!isPortrait && {
|
|
319
|
-
paddingLeft: insets.left,
|
|
320
|
-
paddingRight: insets.right,
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
const screen = (
|
|
324
|
-
<Screen
|
|
325
|
-
{...props}
|
|
326
|
-
{...props.route.params}
|
|
327
|
-
onRequestClose={onRequestClose}
|
|
328
|
-
/>
|
|
329
|
-
);
|
|
330
|
-
|
|
331
251
|
return (
|
|
332
252
|
<Container
|
|
333
253
|
transparent
|
|
@@ -344,7 +264,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
344
264
|
android: undefined,
|
|
345
265
|
})}
|
|
346
266
|
keyboardVerticalOffset={keyboardVerticalOffset ?? keyboardOffset}
|
|
347
|
-
enabled={useKeyboardAvoidingView
|
|
267
|
+
enabled={useKeyboardAvoidingView}
|
|
348
268
|
contentContainerStyle={styles.container}
|
|
349
269
|
style={styles.container}
|
|
350
270
|
>
|
|
@@ -367,34 +287,15 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
367
287
|
borderTopRightRadius: Radius.M,
|
|
368
288
|
overflow: 'hidden',
|
|
369
289
|
},
|
|
370
|
-
isDuo && {
|
|
371
|
-
maxHeight: windowSize.height - topGap - keyboardLift,
|
|
372
|
-
marginBottom: keyboardLift,
|
|
373
|
-
},
|
|
374
|
-
isDuoCentered && {
|
|
375
|
-
// keeps the portrait width in landscape, like system sheets
|
|
376
|
-
width: Math.min(
|
|
377
|
-
Math.min(windowSize.width, windowSize.height) - Spacing.L * 2,
|
|
378
|
-
windowSize.width -
|
|
379
|
-
Math.max(insets.left, insets.right, Spacing.L) * 2,
|
|
380
|
-
),
|
|
381
|
-
alignSelf: 'center',
|
|
382
|
-
},
|
|
383
290
|
showBaseLineDebug && styles.debugBaseLine,
|
|
384
291
|
]}
|
|
385
292
|
>
|
|
386
|
-
{
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
) : (
|
|
393
|
-
<>
|
|
394
|
-
{renderHeader()}
|
|
395
|
-
{screen}
|
|
396
|
-
</>
|
|
397
|
-
)}
|
|
293
|
+
{renderHeader()}
|
|
294
|
+
<Screen
|
|
295
|
+
{...props}
|
|
296
|
+
{...props.route.params}
|
|
297
|
+
onRequestClose={onRequestClose}
|
|
298
|
+
/>
|
|
398
299
|
{footerComponent && (
|
|
399
300
|
<View
|
|
400
301
|
style={[
|
|
@@ -403,7 +304,6 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
403
304
|
paddingBottom: Spacing.S,
|
|
404
305
|
backgroundColor: theme.colors.background.surface,
|
|
405
306
|
},
|
|
406
|
-
sideInsetStyle,
|
|
407
307
|
]}
|
|
408
308
|
>
|
|
409
309
|
{footerComponent}
|
|
@@ -453,7 +353,6 @@ const styles = StyleSheet.create({
|
|
|
453
353
|
justifyContent: 'center',
|
|
454
354
|
marginHorizontal: Spacing.M,
|
|
455
355
|
},
|
|
456
|
-
shrink: { flexShrink: 1 },
|
|
457
356
|
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
458
357
|
});
|
|
459
358
|
|
|
@@ -58,13 +58,11 @@ export default function BottomTabBar({
|
|
|
58
58
|
const { theme } = useContext(ApplicationContext);
|
|
59
59
|
const { routes } = state;
|
|
60
60
|
const widthDevice = useWindowDimensions()?.width;
|
|
61
|
-
const insets = useSafeAreaInsets();
|
|
62
61
|
const useFloating = floatingButton && state.routes.length % 2 === 0;
|
|
63
|
-
const itemWidth =
|
|
64
|
-
(widthDevice - insets.left - insets.right) /
|
|
65
|
-
(state.routes.length + (useFloating ? 1 : 0));
|
|
62
|
+
const itemWidth = widthDevice / (state.routes.length + (useFloating ? 1 : 0));
|
|
66
63
|
// const buildLink = useLinkBuilder();
|
|
67
64
|
const indicatorAnimated = useSharedValue(0);
|
|
65
|
+
const insets = useSafeAreaInsets();
|
|
68
66
|
|
|
69
67
|
const indicatorStyle = useAnimatedStyle(() => ({
|
|
70
68
|
width: itemWidth,
|
|
@@ -248,8 +246,7 @@ export default function BottomTabBar({
|
|
|
248
246
|
},
|
|
249
247
|
{
|
|
250
248
|
paddingBottom: paddingBottom,
|
|
251
|
-
|
|
252
|
-
paddingRight: insets.right,
|
|
249
|
+
paddingHorizontal: Math.max(insets.left, insets.right),
|
|
253
250
|
},
|
|
254
251
|
style,
|
|
255
252
|
]}
|
|
@@ -27,9 +27,7 @@ import StackScreen from '../StackScreen';
|
|
|
27
27
|
import { BottomTabProps } from '../types';
|
|
28
28
|
import { getOptions, getStackOptions, useAppState } from '../utils';
|
|
29
29
|
import BottomTabBar from './BottomTabBar';
|
|
30
|
-
import { DuoTabBar } from './DuoTabBar';
|
|
31
30
|
import { ApplicationContext, MiniAppContext } from '../../Context';
|
|
32
|
-
import { useScreenLayout } from '../../Layout';
|
|
33
31
|
|
|
34
32
|
const Tab = createBottomTabNavigator();
|
|
35
33
|
const Stack = createStackNavigator();
|
|
@@ -38,13 +36,7 @@ const TabScreen: React.FC<any> = ({ route, navigation }) => {
|
|
|
38
36
|
const { navigator } = useContext(ApplicationContext);
|
|
39
37
|
const context = useContext<any>(MiniAppContext);
|
|
40
38
|
const { nested, options, screen, initialParams } = route?.params;
|
|
41
|
-
const
|
|
42
|
-
const headerStyleOptions = {
|
|
43
|
-
headerStyle: {
|
|
44
|
-
height: headerHeight,
|
|
45
|
-
},
|
|
46
|
-
headerStatusBarHeight,
|
|
47
|
-
};
|
|
39
|
+
const insets = useSafeAreaInsets();
|
|
48
40
|
|
|
49
41
|
const opacityValue = 0.3;
|
|
50
42
|
const scaleValue = 0.97;
|
|
@@ -147,7 +139,11 @@ const TabScreen: React.FC<any> = ({ route, navigation }) => {
|
|
|
147
139
|
return (
|
|
148
140
|
<Animated.View style={[styles.container, tabAnimatedStyle]}>
|
|
149
141
|
<Stack.Navigator
|
|
150
|
-
screenOptions={
|
|
142
|
+
screenOptions={{
|
|
143
|
+
headerStyle: {
|
|
144
|
+
height: 52 + insets.top,
|
|
145
|
+
},
|
|
146
|
+
}}
|
|
151
147
|
>
|
|
152
148
|
<Stack.Screen
|
|
153
149
|
name="Stack"
|
|
@@ -178,7 +174,11 @@ const TabScreen: React.FC<any> = ({ route, navigation }) => {
|
|
|
178
174
|
<NavigationIndependentTree>
|
|
179
175
|
<NavigationContainer>
|
|
180
176
|
<Stack.Navigator
|
|
181
|
-
screenOptions={
|
|
177
|
+
screenOptions={{
|
|
178
|
+
headerStyle: {
|
|
179
|
+
height: 52 + insets.top,
|
|
180
|
+
},
|
|
181
|
+
}}
|
|
182
182
|
>
|
|
183
183
|
<Stack.Screen
|
|
184
184
|
name="Stack"
|
|
@@ -207,7 +207,6 @@ const BottomTab: React.FC<BottomTabProps> = ({
|
|
|
207
207
|
floatingButton,
|
|
208
208
|
}) => {
|
|
209
209
|
const { theme, navigator } = useContext(ApplicationContext);
|
|
210
|
-
const { isIPhoneDuo } = useScreenLayout();
|
|
211
210
|
const dimensions = useWindowDimensions();
|
|
212
211
|
const insets = useSafeAreaInsets();
|
|
213
212
|
const initialIndex = tabs.findIndex(i => i.name === initialRouteName);
|
|
@@ -307,32 +306,23 @@ const BottomTab: React.FC<BottomTabProps> = ({
|
|
|
307
306
|
</View>
|
|
308
307
|
),
|
|
309
308
|
}}
|
|
310
|
-
tabBar={props =>
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
64 +
|
|
328
|
-
(Platform.OS === 'ios'
|
|
329
|
-
? Math.min(insets.bottom, 21)
|
|
330
|
-
: insets.bottom),
|
|
331
|
-
},
|
|
332
|
-
]}
|
|
333
|
-
/>
|
|
334
|
-
)
|
|
335
|
-
}
|
|
309
|
+
tabBar={props => (
|
|
310
|
+
<BottomTabBar
|
|
311
|
+
{...props}
|
|
312
|
+
floatingButton={floatingButton}
|
|
313
|
+
inactiveTintColor={theme.colors.text.hint}
|
|
314
|
+
activeTintColor={theme.colors.primary}
|
|
315
|
+
style={[
|
|
316
|
+
{
|
|
317
|
+
height:
|
|
318
|
+
64 +
|
|
319
|
+
(Platform.OS === 'ios'
|
|
320
|
+
? Math.min(insets.bottom, 21)
|
|
321
|
+
: insets.bottom),
|
|
322
|
+
},
|
|
323
|
+
]}
|
|
324
|
+
/>
|
|
325
|
+
)}
|
|
336
326
|
initialRouteName={initialRouteName}
|
|
337
327
|
>
|
|
338
328
|
{tabs.map((item, index) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { Ref, useContext } from 'react';
|
|
2
2
|
import LinearGradient from 'react-native-linear-gradient';
|
|
3
|
-
import { Platform, StyleSheet, View } from 'react-native';
|
|
3
|
+
import { Dimensions, Platform, StyleSheet, View } from 'react-native';
|
|
4
4
|
import Animated, {
|
|
5
5
|
Extrapolation,
|
|
6
6
|
interpolate,
|
|
@@ -14,18 +14,21 @@ import { Colors, Radius, Spacing } from '../../Consts';
|
|
|
14
14
|
import { Image } from '../../Image';
|
|
15
15
|
import { SearchHeaderProps } from '../types';
|
|
16
16
|
import BackgroundImageView from './BackgroundImageView';
|
|
17
|
-
import {
|
|
18
|
-
|
|
17
|
+
import {
|
|
18
|
+
AnimatedCompatValue,
|
|
19
|
+
useNormalizedSharedValue,
|
|
20
|
+
} from '../utils';
|
|
19
21
|
|
|
20
22
|
const SCREEN_PADDING = 12;
|
|
21
23
|
const BACK_WIDTH = 28;
|
|
22
|
-
|
|
24
|
+
|
|
25
|
+
const { width: screenWidth } = Dimensions.get('window');
|
|
23
26
|
|
|
24
27
|
const HeaderExtendHeader: React.FC<{
|
|
25
28
|
headerType?: HeaderType;
|
|
26
29
|
animatedValue: AnimatedCompatValue;
|
|
27
30
|
heightHeader: number;
|
|
28
|
-
headerRightWidth
|
|
31
|
+
headerRightWidth: number;
|
|
29
32
|
inputSearchProps?: SearchHeaderProps;
|
|
30
33
|
inputSearchRef?: Ref<InputRef>;
|
|
31
34
|
navigation?: Navigation;
|
|
@@ -36,7 +39,7 @@ const HeaderExtendHeader: React.FC<{
|
|
|
36
39
|
headerType = 'default',
|
|
37
40
|
animatedValue,
|
|
38
41
|
heightHeader,
|
|
39
|
-
headerRightWidth
|
|
42
|
+
headerRightWidth = 73,
|
|
40
43
|
inputSearchProps,
|
|
41
44
|
inputSearchRef,
|
|
42
45
|
useShadowHeader: useShadowHeaderProp = true,
|
|
@@ -48,19 +51,7 @@ const HeaderExtendHeader: React.FC<{
|
|
|
48
51
|
const sharedValue = useNormalizedSharedValue(animatedValue);
|
|
49
52
|
const gradientColor = customGradientColor ?? theme.colors.gradient;
|
|
50
53
|
const headerBackground = customBackground ?? theme.assets?.headerBackground;
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
const leftPosition =
|
|
54
|
-
inputSearchProps?.leftPosition ||
|
|
55
|
-
(layout.sideBar ? SCREEN_PADDING : BACK_WIDTH + 20);
|
|
56
|
-
const headerRightWidth =
|
|
57
|
-
customHeaderRightWidth ?? (layout.sideBar ? 0 : TOOLKIT_WIDTH);
|
|
58
|
-
const contentLeft = layout.insetLeft + SCREEN_PADDING;
|
|
59
|
-
const contentRight = layout.insetLeft + layout.contentWidth;
|
|
60
|
-
const collapsedLeft = layout.insetLeft + leftPosition;
|
|
61
|
-
const searchWidth = layout.contentWidth - SCREEN_PADDING * 2;
|
|
62
|
-
const collapsedSearchWidth =
|
|
63
|
-
contentRight - collapsedLeft - SCREEN_PADDING - headerRightWidth;
|
|
54
|
+
const leftPosition = inputSearchProps?.leftPosition || BACK_WIDTH + 20;
|
|
64
55
|
|
|
65
56
|
let useShadowHeader = useShadowHeaderProp;
|
|
66
57
|
if (inputSearchProps && Platform.OS === 'android') {
|
|
@@ -79,12 +70,7 @@ const HeaderExtendHeader: React.FC<{
|
|
|
79
70
|
}));
|
|
80
71
|
|
|
81
72
|
const gradientOpacityStyle = useAnimatedStyle(() => ({
|
|
82
|
-
opacity: interpolate(
|
|
83
|
-
sharedValue.value,
|
|
84
|
-
[0, 52],
|
|
85
|
-
[1, 0],
|
|
86
|
-
Extrapolation.CLAMP,
|
|
87
|
-
),
|
|
73
|
+
opacity: interpolate(sharedValue.value, [0, 52], [1, 0], Extrapolation.CLAMP),
|
|
88
74
|
}));
|
|
89
75
|
|
|
90
76
|
const searchTranslateStyle = useAnimatedStyle(() => ({
|
|
@@ -93,7 +79,7 @@ const HeaderExtendHeader: React.FC<{
|
|
|
93
79
|
translateX: interpolate(
|
|
94
80
|
sharedValue.value,
|
|
95
81
|
[0, 100],
|
|
96
|
-
[
|
|
82
|
+
[SCREEN_PADDING, leftPosition],
|
|
97
83
|
Extrapolation.CLAMP,
|
|
98
84
|
),
|
|
99
85
|
},
|
|
@@ -101,19 +87,19 @@ const HeaderExtendHeader: React.FC<{
|
|
|
101
87
|
width: interpolate(
|
|
102
88
|
sharedValue.value,
|
|
103
89
|
[0, 100],
|
|
104
|
-
[
|
|
90
|
+
[
|
|
91
|
+
screenWidth - SCREEN_PADDING * 2,
|
|
92
|
+
screenWidth - leftPosition - 12 - headerRightWidth,
|
|
93
|
+
],
|
|
105
94
|
Extrapolation.CLAMP,
|
|
106
95
|
),
|
|
107
96
|
}));
|
|
108
97
|
|
|
109
98
|
const searchBackgroundStyle = useAnimatedStyle(() => {
|
|
110
99
|
const t = Math.min(Math.max(sharedValue.value / 100, 0), 1);
|
|
111
|
-
return {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
? theme.colors.background.surface
|
|
115
|
-
: theme.colors.background.default,
|
|
116
|
-
};
|
|
100
|
+
return { backgroundColor: t === 0
|
|
101
|
+
? theme.colors.background.surface
|
|
102
|
+
: theme.colors.background.default };
|
|
117
103
|
});
|
|
118
104
|
|
|
119
105
|
const extendedHeightStyle = useAnimatedStyle(() => ({
|
|
@@ -138,7 +124,9 @@ const HeaderExtendHeader: React.FC<{
|
|
|
138
124
|
<Animated.View
|
|
139
125
|
style={[
|
|
140
126
|
styles.headerBox,
|
|
141
|
-
headerType === 'extended'
|
|
127
|
+
headerType === 'extended'
|
|
128
|
+
? heightStyle
|
|
129
|
+
: { height: heightHeader },
|
|
142
130
|
]}
|
|
143
131
|
>
|
|
144
132
|
{!!gradientColor && (
|
|
@@ -174,7 +162,10 @@ const HeaderExtendHeader: React.FC<{
|
|
|
174
162
|
style={[{ marginVertical: Spacing.S }, searchTranslateStyle]}
|
|
175
163
|
>
|
|
176
164
|
<Animated.View
|
|
177
|
-
style={[
|
|
165
|
+
style={[
|
|
166
|
+
{ borderRadius: Radius.XL },
|
|
167
|
+
searchBackgroundStyle,
|
|
168
|
+
]}
|
|
178
169
|
>
|
|
179
170
|
<InputSearch
|
|
180
171
|
{...inputSearchProps}
|
|
@@ -200,11 +191,7 @@ const HeaderExtendHeader: React.FC<{
|
|
|
200
191
|
/>
|
|
201
192
|
{!!gradientColor && (
|
|
202
193
|
<Animated.View
|
|
203
|
-
style={[
|
|
204
|
-
styles.extendedHeader,
|
|
205
|
-
gradientOpacityStyle,
|
|
206
|
-
extendedHeightStyle,
|
|
207
|
-
]}
|
|
194
|
+
style={[styles.extendedHeader, gradientOpacityStyle, extendedHeightStyle]}
|
|
208
195
|
>
|
|
209
196
|
<LinearGradient
|
|
210
197
|
colors={[gradientColor, gradientColor + '00']}
|
|
@@ -4,8 +4,6 @@ import React, { useCallback, useContext, useEffect } from 'react';
|
|
|
4
4
|
import { ApplicationContext, MiniAppContext } from '../../Context';
|
|
5
5
|
import { PopupNotify } from '../../Popup';
|
|
6
6
|
import { NavigationButton } from './NavigationButton';
|
|
7
|
-
import { SideBarButton } from './SideBarButton';
|
|
8
|
-
import { useSideBarItemStyle } from '../../Layout/utils';
|
|
9
7
|
|
|
10
8
|
/**
|
|
11
9
|
* default header left used for nav
|
|
@@ -15,11 +13,9 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
15
13
|
preventBack,
|
|
16
14
|
onPressLeftHeader,
|
|
17
15
|
onBackHandler,
|
|
18
|
-
floating = false,
|
|
19
16
|
}) => {
|
|
20
17
|
const context = useContext<any>(MiniAppContext);
|
|
21
18
|
const { navigator } = useContext(ApplicationContext);
|
|
22
|
-
const sideBarStyle = useSideBarItemStyle('left', 0);
|
|
23
19
|
|
|
24
20
|
const goBack = useCallback(() => {
|
|
25
21
|
const canGoBack = navigator?.ref?.current?.canGoBack?.();
|
|
@@ -76,19 +72,6 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
76
72
|
return () => backHandler.remove();
|
|
77
73
|
}, [goBackSafe]);
|
|
78
74
|
|
|
79
|
-
if (floating && sideBarStyle) {
|
|
80
|
-
return (
|
|
81
|
-
<View style={sideBarStyle} pointerEvents={'box-none'}>
|
|
82
|
-
<SideBarButton
|
|
83
|
-
accessibilityLabel="btn_navigation_back"
|
|
84
|
-
icon="arrow-back"
|
|
85
|
-
tintColor={tintColor}
|
|
86
|
-
onPress={goBackSafe}
|
|
87
|
-
/>
|
|
88
|
-
</View>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
75
|
return (
|
|
93
76
|
<View style={styles.headerLeft}>
|
|
94
77
|
<NavigationButton
|
|
@@ -13,8 +13,6 @@ import { PopupNotify } from '../../Popup';
|
|
|
13
13
|
import { Tool, ToolGroup } from '../types';
|
|
14
14
|
import { Icon } from '../../Icon';
|
|
15
15
|
import { Text } from '../../Text';
|
|
16
|
-
import { useSideBarItemStyle } from '../../Layout/utils';
|
|
17
|
-
import { SideBarButton, SideBarGroup, SideBarGroupItem } from './SideBarButton';
|
|
18
16
|
|
|
19
17
|
const DID_SYNC_NEW_HOME = 'did_sync_new_home';
|
|
20
18
|
|
|
@@ -23,9 +21,8 @@ const DID_SYNC_NEW_HOME = 'did_sync_new_home';
|
|
|
23
21
|
*/
|
|
24
22
|
const HeaderRight: React.FC<any> = props => {
|
|
25
23
|
const { translate } = useContext(ApplicationContext);
|
|
26
|
-
const { headerRight = {}
|
|
24
|
+
const { headerRight = {} } = props;
|
|
27
25
|
const { useOnBoarding = false, buttonOnBoarding, onPress } = headerRight;
|
|
28
|
-
const sideBarStyle = useSideBarItemStyle('right', 1);
|
|
29
26
|
|
|
30
27
|
if (typeof props.headerRight === 'function') {
|
|
31
28
|
return props.headerRight(props);
|
|
@@ -41,18 +38,6 @@ const HeaderRight: React.FC<any> = props => {
|
|
|
41
38
|
);
|
|
42
39
|
}
|
|
43
40
|
|
|
44
|
-
if (floating && sideBarStyle) {
|
|
45
|
-
return (
|
|
46
|
-
<View style={sideBarStyle} pointerEvents={'box-none'}>
|
|
47
|
-
<HeaderToolkitAction
|
|
48
|
-
{...props.headerRight}
|
|
49
|
-
tintColor={props.tintColor}
|
|
50
|
-
vertical
|
|
51
|
-
/>
|
|
52
|
-
</View>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
41
|
return (
|
|
57
42
|
<View style={styles.headerRightButton}>
|
|
58
43
|
<HeaderToolkitAction {...props.headerRight} tintColor={props.tintColor} />
|
|
@@ -71,7 +56,6 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
71
56
|
useMore = false,
|
|
72
57
|
tools = [],
|
|
73
58
|
useCloseIcon = false,
|
|
74
|
-
vertical = false,
|
|
75
59
|
}) => {
|
|
76
60
|
const { navigator } = useContext(ApplicationContext);
|
|
77
61
|
const context = useContext<any>(MiniAppContext);
|
|
@@ -276,43 +260,6 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
276
260
|
group?.items?.some?.(tool => tool?.showBadge),
|
|
277
261
|
);
|
|
278
262
|
|
|
279
|
-
const useHelpCenter = context.appId !== 'vn.momo.helpcenter';
|
|
280
|
-
const closeIcon = useCloseIcon
|
|
281
|
-
? '16_navigation_close_circle'
|
|
282
|
-
: '16_basic_home';
|
|
283
|
-
|
|
284
|
-
if (vertical) {
|
|
285
|
-
return (
|
|
286
|
-
<View style={styles.sideBarColumn}>
|
|
287
|
-
{useShortcut && (
|
|
288
|
-
<SideBarButton
|
|
289
|
-
disabled={isLoading}
|
|
290
|
-
icon={iconShortcut}
|
|
291
|
-
onPress={shortcutOnPress}
|
|
292
|
-
tintColor={tintColor}
|
|
293
|
-
showBadge={showBadge}
|
|
294
|
-
/>
|
|
295
|
-
)}
|
|
296
|
-
<SideBarGroup tintColor={tintColor}>
|
|
297
|
-
{useHelpCenter && (
|
|
298
|
-
<SideBarGroupItem
|
|
299
|
-
accessibilityLabel={'btn_navigation_help_center'}
|
|
300
|
-
icon={'help_center'}
|
|
301
|
-
tintColor={tintColor}
|
|
302
|
-
onPress={onPressHelpCenter}
|
|
303
|
-
/>
|
|
304
|
-
)}
|
|
305
|
-
<SideBarGroupItem
|
|
306
|
-
accessibilityLabel={'btn_navigation_close'}
|
|
307
|
-
icon={closeIcon}
|
|
308
|
-
tintColor={tintColor}
|
|
309
|
-
onPress={onClose}
|
|
310
|
-
/>
|
|
311
|
-
</SideBarGroup>
|
|
312
|
-
</View>
|
|
313
|
-
);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
263
|
return (
|
|
317
264
|
<View style={Styles.row}>
|
|
318
265
|
{useShortcut && (
|
|
@@ -333,7 +280,7 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
333
280
|
},
|
|
334
281
|
]}
|
|
335
282
|
>
|
|
336
|
-
{
|
|
283
|
+
{context.appId !== 'vn.momo.helpcenter' && (
|
|
337
284
|
<>
|
|
338
285
|
<TouchableOpacity
|
|
339
286
|
accessibilityLabel={'btn_navigation_help_center'}
|
|
@@ -352,7 +299,13 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
352
299
|
style={styles.toolkitButton}
|
|
353
300
|
hitSlop={{ top: 7, bottom: 7, left: 0, right: 7 }}
|
|
354
301
|
>
|
|
355
|
-
<Icon
|
|
302
|
+
<Icon
|
|
303
|
+
color={tintColor}
|
|
304
|
+
source={
|
|
305
|
+
useCloseIcon ? '16_navigation_close_circle' : '16_basic_home'
|
|
306
|
+
}
|
|
307
|
+
size={20}
|
|
308
|
+
/>
|
|
356
309
|
</TouchableOpacity>
|
|
357
310
|
</View>
|
|
358
311
|
</View>
|
|
@@ -423,9 +376,6 @@ const styles = StyleSheet.create({
|
|
|
423
376
|
width: 0.5,
|
|
424
377
|
height: 12,
|
|
425
378
|
},
|
|
426
|
-
sideBarColumn: {
|
|
427
|
-
gap: Spacing.M,
|
|
428
|
-
},
|
|
429
379
|
headerLeft: {
|
|
430
380
|
marginLeft: 12,
|
|
431
381
|
},
|