@momo-kits/foundation 0.103.2-rc.39 → 0.103.2-rc.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.
@@ -26,11 +26,7 @@ const HELP_CENTER_ICON = 'help_center';
26
26
  */
27
27
  const HeaderRight: React.FC<any> = props => {
28
28
  const {headerRight = {}} = props;
29
- const {
30
- useOnBoarding = false,
31
- buttonOnBoarding,
32
- onPressButtonOnBoarding,
33
- } = headerRight;
29
+ const {useOnBoarding = false, buttonOnBoarding, onPress} = headerRight;
34
30
  const context = useContext<any>(MiniAppContext);
35
31
  const {translate} = useContext(ApplicationContext);
36
32
  if (
@@ -44,11 +40,9 @@ const HeaderRight: React.FC<any> = props => {
44
40
  return <View />;
45
41
  }
46
42
 
47
- if (useOnBoarding && onPressButtonOnBoarding) {
43
+ if (useOnBoarding && onPress) {
48
44
  return (
49
- <TouchableOpacity
50
- onPress={onPressButtonOnBoarding}
51
- style={styles.onBoarding}>
45
+ <TouchableOpacity onPress={onPress} style={styles.onBoarding}>
52
46
  <Text typography={'action_s_bold'}>
53
47
  {buttonOnBoarding || translate?.('skip')}
54
48
  </Text>
@@ -236,7 +236,7 @@ const styles = StyleSheet.create({
236
236
  headerTitleContainer: {
237
237
  alignItems: 'center',
238
238
  justifyContent: 'center',
239
- width: Dimensions.get('window').width - 170,
239
+ width: Dimensions.get('window').width - 158,
240
240
  },
241
241
  circle: {
242
242
  width: 32,
@@ -1,30 +1,15 @@
1
1
  import {Radius, Spacing, Styles} from '../../Consts';
2
2
  import {InputRef, InputSearch} from '../../Input';
3
- import {
4
- Animated,
5
- Dimensions,
6
- StyleSheet,
7
- TouchableOpacity,
8
- View,
9
- } from 'react-native';
3
+ import {Animated, StyleSheet, TouchableOpacity, View} from 'react-native';
10
4
  import React, {useContext, useEffect, useRef} from 'react';
11
5
  import {SearchHeaderProps} from '../types';
12
- import {ApplicationContext} from '../index';
6
+ import {ApplicationContext, MiniAppContext} from '../index';
13
7
  import {Text} from '../../Text';
14
8
 
15
9
  const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
16
- (
17
- {
18
- animatedValue,
19
- buttonText = 'Huỷ',
20
- showButtonText = true,
21
- onPressButtonText,
22
- ...props
23
- },
24
- ref
25
- ) => {
26
- const {theme} = useContext(ApplicationContext);
27
- const width = Dimensions.get('window').width;
10
+ ({animatedValue, buttonText = 'Huỷ', onPressButtonText, ...props}, ref) => {
11
+ const {theme, navigator} = useContext(ApplicationContext);
12
+ const context = useContext<any>(MiniAppContext);
28
13
 
29
14
  const animated = useRef(new Animated.Value(0));
30
15
 
@@ -48,8 +33,38 @@ const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
48
33
  extrapolate: 'clamp',
49
34
  });
50
35
 
36
+ const goBack = () => {
37
+ const canGoBack = navigator?.ref?.current?.canGoBack?.();
38
+ const currentRoute = navigator?.ref?.current?.getCurrentRoute?.();
39
+ const params = {
40
+ ...context,
41
+ screen_name: currentRoute?.params?.screen?.name ?? currentRoute?.name,
42
+ trigger_id: '111154000000000000',
43
+ icon_name: 'back',
44
+ };
45
+ navigator?.maxApi?.showToastDebug?.({
46
+ appId: `auto - ${context.appId}`,
47
+ message: 'service_icon_clicked',
48
+ params,
49
+ });
50
+ navigator?.maxApi?.trackEvent?.('service_icon_clicked', params);
51
+ if (canGoBack) {
52
+ navigator?.ref?.current?.goBack?.();
53
+ } else if (navigator?.maxApi) {
54
+ navigator?.maxApi?.dismiss?.(navigator?.dismissData);
55
+ } else {
56
+ (global as any)?.miniAppApi?.dispatch?.('dismiss', context);
57
+ }
58
+ onPressButtonText?.();
59
+ };
60
+
61
+ const goBackSafe = () => {
62
+ goBack();
63
+ return true;
64
+ };
65
+
51
66
  return (
52
- <View style={[styles.container, {width: width - 60}]}>
67
+ <View style={styles.container}>
53
68
  <View style={Styles.flex}>
54
69
  <Animated.View style={{backgroundColor, borderRadius: Radius.XL}}>
55
70
  <InputSearch
@@ -60,13 +75,9 @@ const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
60
75
  />
61
76
  </Animated.View>
62
77
  </View>
63
- {showButtonText && (
64
- <TouchableOpacity
65
- onPress={onPressButtonText}
66
- style={styles.searchAction}>
67
- <Text typography={'action_default_bold'}>{buttonText}</Text>
68
- </TouchableOpacity>
69
- )}
78
+ <TouchableOpacity onPress={goBackSafe} style={styles.searchAction}>
79
+ <Text typography={'action_default_bold'}>{buttonText}</Text>
80
+ </TouchableOpacity>
70
81
  </View>
71
82
  );
72
83
  }
@@ -159,8 +159,7 @@ export interface NavigationOptions
159
159
 
160
160
  export type OnBoarding = {
161
161
  useOnBoarding?: boolean;
162
- buttonText?: string;
163
- onPressButtonOnBoarding?: () => void;
162
+ onPress?: () => void;
164
163
  };
165
164
 
166
165
  export type HeaderRightToolkit = {
package/Layout/Screen.tsx CHANGED
@@ -342,6 +342,7 @@ const Screen = forwardRef(
342
342
  const setSearchHeader = (params: SearchHeaderProps) => {
343
343
  const options: StackNavigationOptions = {
344
344
  headerRight: undefined,
345
+ headerLeft: () => {},
345
346
  headerTitle: (props: any) => (
346
347
  <SearchHeader
347
348
  {...props}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.103.2-rc.39",
3
+ "version": "0.103.2-rc.40",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},