@momo-kits/template 0.81.14 → 0.81.16-cns.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.
@@ -1,19 +1,12 @@
1
- import React, {FC, useContext} from 'react';
2
- import {View} from 'react-native';
1
+ import React, {FC} from 'react';
2
+ import {Image, Text, View} from 'react-native';
3
3
  import styles from './styles';
4
- import {ApplicationContext, Colors, Image, Text} from '@momo-kits/foundation';
5
4
  import {CustomAvatarProps} from './types';
6
5
 
7
6
  const CustomAvatar: FC<CustomAvatarProps> = ({image, text, style}) => {
8
- const {theme} = useContext(ApplicationContext);
9
-
10
7
  const renderContent = () => {
11
8
  if (text) {
12
- return (
13
- <Text color={theme.colors.primary} typography={'description_xs'}>
14
- {text}
15
- </Text>
16
- );
9
+ return <Text style={styles.description_xs}>{text}</Text>;
17
10
  }
18
11
 
19
12
  return <Image style={styles.avatarImage} source={{uri: image}} />;
@@ -24,8 +17,8 @@ const CustomAvatar: FC<CustomAvatarProps> = ({image, text, style}) => {
24
17
  style={[
25
18
  styles.customAvatar,
26
19
  {
27
- backgroundColor: Colors.black_01,
28
- borderColor: theme.colors.border.default,
20
+ backgroundColor: '#fff',
21
+ borderColor: '#E8E8E8',
29
22
  },
30
23
  style,
31
24
  ]}>
@@ -1,18 +1,9 @@
1
- import React, {FC, useContext, useEffect, useState} from 'react';
2
- import {
3
- requireNativeComponent,
4
- TouchableOpacity,
5
- UIManager,
6
- View,
7
- } from 'react-native';
8
- import {TrackingParams, TrustBannerProps} from './types';
1
+ import React, {FC, useEffect, useState} from 'react';
2
+ import {Image, Text, TouchableOpacity, View} from 'react-native';
3
+ import {TrustBannerCallbackParams, TrustBannerProps} from './types';
9
4
  import styles from './styles';
10
- import {ApplicationContext, Colors, Image, Text} from '@momo-kits/foundation';
11
5
  import CustomAvatar from './CustomAvatar';
12
6
 
13
- const NativeTrustBanner =
14
- requireNativeComponent<TrustBannerProps>('TrustBannerView');
15
-
16
7
  const dataJsonUrl =
17
8
  'https://static.momocdn.net/app/json/component-kits/design_system.json';
18
9
 
@@ -30,6 +21,8 @@ const defaultData = {
30
21
  },
31
22
  pciImage: 'https://static.momocdn.net/app/img/kits/trustBanner/pci.png',
32
23
  sslImage: 'https://static.momocdn.net/app/img/kits/trustBanner/ssl.png',
24
+ url_config: 'https://momo.vn/an-toan-bao-mat',
25
+ feature_code: 'login_and_security',
33
26
  icons: defaultIcons,
34
27
  momoImage:
35
28
  'https://static.momocdn.net/app/img/kits/trustBanner/ic_momo_secu.png',
@@ -37,20 +30,28 @@ const defaultData = {
37
30
 
38
31
  const TrustBanner: FC<TrustBannerProps> = ({
39
32
  style,
40
- trackEvent,
41
33
  screenName = '',
42
34
  serviceName = '',
43
- openWeb,
44
- openUrl = 'https://momo.vn/an-toan-bao-mat',
35
+ onPress,
36
+ trackEvent,
37
+ language = 'vi',
45
38
  }) => {
46
- const {theme, language} = useContext(ApplicationContext);
47
39
  const [data, setData] = useState(defaultData);
48
- const {icons, sslImage, pciImage, momoImage, content} = data;
49
- const trackingParams: TrackingParams = {
40
+ const {
41
+ icons,
42
+ sslImage,
43
+ pciImage,
44
+ momoImage,
45
+ url_config,
46
+ content,
47
+ feature_code,
48
+ } = data;
49
+ const trackingParams: TrustBannerCallbackParams = {
50
50
  screen_name: screenName,
51
51
  service_name: serviceName,
52
52
  component_name: 'logo_trust',
53
53
  };
54
+
54
55
  useEffect(() => {
55
56
  trackEvent?.('service_component_displayed', trackingParams);
56
57
  fetchJson();
@@ -67,6 +68,9 @@ const TrustBanner: FC<TrustBannerProps> = ({
67
68
  pciImage: dataJSon.trustBanner.pciImage || defaultData.pciImage,
68
69
  momoImage: dataJSon.trustBanner.momoImage || defaultData.momoImage,
69
70
  content: dataJSon.trustBanner.content || defaultData.content,
71
+ url_config: dataJSon.trustBanner.url_config || defaultData.url_config,
72
+ feature_code:
73
+ dataJSon.trustBanner.feature_code || defaultData.feature_code,
70
74
  });
71
75
  }
72
76
  };
@@ -81,8 +85,8 @@ const TrustBanner: FC<TrustBannerProps> = ({
81
85
  style={[
82
86
  styles.customAvatar,
83
87
  {
84
- borderColor: theme.colors.border.default,
85
- backgroundColor: Colors.pink_09,
88
+ borderColor: '#E8E8E8',
89
+ backgroundColor: '#FDEAF4',
86
90
  },
87
91
  ]}
88
92
  text="+36"
@@ -111,30 +115,15 @@ const TrustBanner: FC<TrustBannerProps> = ({
111
115
  );
112
116
  };
113
117
 
114
- if (UIManager.getViewManagerConfig('TrustBannerView')) {
115
- return (
116
- <TouchableOpacity
117
- onPress={() => {
118
- trackEvent?.('service_component_clicked', trackingParams);
119
- openWeb?.(openUrl);
120
- }}
121
- activeOpacity={0.7}
122
- style={style}>
123
- <NativeTrustBanner
124
- content={defaultData.content.vi}
125
- style={{height: 88}}
126
- />
127
- </TouchableOpacity>
128
- );
129
- }
118
+ const _onPress = () => {
119
+ trackEvent?.('service_component_clicked', trackingParams);
120
+ onPress?.({...trackingParams, url_config, feature_code});
121
+ };
130
122
 
131
123
  return (
132
124
  <TouchableOpacity
133
- onPress={() => {
134
- trackEvent?.('service_component_clicked', trackingParams);
135
- openWeb?.(openUrl);
136
- }}
137
- activeOpacity={0.7}
125
+ onPress={_onPress}
126
+ activeOpacity={onPress ? 0.7 : 1}
138
127
  style={[style, styles.container]}>
139
128
  <Image
140
129
  style={styles.momoImage}
@@ -144,7 +133,7 @@ const TrustBanner: FC<TrustBannerProps> = ({
144
133
  }}
145
134
  />
146
135
  <View style={styles.flex}>
147
- <Text style={styles.message} typography={'description_s'}>
136
+ <Text style={[styles.message, styles.description_s]}>
148
137
  {content?.[language || 'vi'] || defaultData.content.vi}
149
138
  </Text>
150
139
  {renderFooter()}
@@ -1,19 +1,30 @@
1
- import {StyleSheet} from 'react-native';
2
- import {Colors, Radius, scaleSize, Spacing} from '@momo-kits/foundation';
1
+ import {Dimensions, StyleSheet} from 'react-native';
2
+
3
+ const deviceWidth = Dimensions.get('window').width;
4
+ const DEFAULT_SCREEN_SIZE = 375;
5
+ const scaleSize = (size: number) => {
6
+ const scaleRate = deviceWidth / DEFAULT_SCREEN_SIZE;
7
+
8
+ if (scaleRate > 1) {
9
+ return Math.min(Math.round(size * scaleRate), size + 3);
10
+ }
11
+
12
+ return size;
13
+ };
3
14
 
4
15
  export default StyleSheet.create({
5
16
  container: {
6
17
  flexDirection: 'row',
7
- padding: Spacing.M,
8
- borderRadius: Radius.S,
9
- backgroundColor: Colors.blue_10,
18
+ padding: 12,
19
+ borderRadius: 8,
20
+ backgroundColor: '#F2F8FF',
10
21
  width: '100%',
11
22
  },
12
23
  flex: {flex: 1},
13
24
  momoImage: {
14
25
  width: scaleSize(64),
15
26
  height: scaleSize(64),
16
- marginRight: Spacing.S,
27
+ marginRight: 8,
17
28
  },
18
29
  image: {
19
30
  width: scaleSize(52),
@@ -23,9 +34,9 @@ export default StyleSheet.create({
23
34
  flexDirection: 'row',
24
35
  },
25
36
  pciImage: {
26
- marginRight: Spacing.XS,
37
+ marginRight: 4,
27
38
  },
28
- message: {marginBottom: Spacing.S},
39
+ message: {marginBottom: 8},
29
40
  footer: {
30
41
  flexDirection: 'row',
31
42
  justifyContent: 'space-between',
@@ -34,7 +45,7 @@ export default StyleSheet.create({
34
45
  width: scaleSize(24),
35
46
  height: scaleSize(24),
36
47
  borderWidth: 1,
37
- borderRadius: Radius.L,
48
+ borderRadius: 16,
38
49
  alignItems: 'center',
39
50
  justifyContent: 'center',
40
51
  marginLeft: scaleSize(-6),
@@ -43,4 +54,14 @@ export default StyleSheet.create({
43
54
  flexDirection: 'row',
44
55
  },
45
56
  avatarImage: {width: '100%', height: '100%'},
57
+ description_s: {
58
+ fontSize: scaleSize(12),
59
+ lineHeight: scaleSize(16),
60
+ color: '#484848',
61
+ },
62
+ description_xs: {
63
+ fontSize: scaleSize(10),
64
+ lineHeight: scaleSize(14),
65
+ color: '#EB2F96',
66
+ },
46
67
  });
@@ -1,20 +1,49 @@
1
1
  import {ViewStyle} from 'react-native';
2
2
 
3
- export type TrackingParams = {
3
+ export type TrustBannerCallbackParams = {
4
4
  service_name: string;
5
5
  screen_name: string;
6
6
  component_name: string;
7
7
  url_config?: string;
8
+ feature_code?: string;
8
9
  };
9
10
 
10
11
  export type TrustBannerProps = {
11
- trackEvent?: (eventName: string, trackingParams: TrackingParams) => void;
12
+ /**
13
+ * Optional. Styles to customize the appearance of the banner. Can be a single
14
+ * style object or an array of style objects.
15
+ */
12
16
  style?: ViewStyle | ViewStyle[];
13
- openWeb?: (params: string) => void;
17
+
18
+ /**
19
+ * Optional. The name of the screen where the banner is displayed. This can be
20
+ * used to identify the context in which the banner appears.
21
+ */
14
22
  screenName?: string;
23
+
24
+ /**
25
+ * Optional. The name of the service or feature the banner is associated with.
26
+ * This helps in providing contextual information within the banner content.
27
+ */
15
28
  serviceName?: string;
16
- openUrl?: string;
17
- content?: string;
29
+
30
+ /**
31
+ * Optional. A callback function can be openWeb or startFeatureCode,
32
+ * return params:
33
+ * service_name,
34
+ * screen_name,
35
+ * component_name,
36
+ * url_config,
37
+ * feature_code,
38
+ */
39
+ onPress?: (params: TrustBannerCallbackParams) => void;
40
+
41
+ /**
42
+ * Optional. instance of maxApi trackEvent function.
43
+ */
44
+ trackEvent?: (eventName: string, params: TrustBannerCallbackParams) => void;
45
+
46
+ language?: 'vi' | 'en';
18
47
  };
19
48
 
20
49
  export type CustomAvatarProps = {
package/index.tsx CHANGED
@@ -1,3 +1,2 @@
1
- import HeaderSliderBanner from './HeaderSliderBanner';
2
1
  import TrustBanner from './TrustBanner';
3
- export {HeaderSliderBanner, TrustBanner};
2
+ export {TrustBanner};
package/package.json CHANGED
@@ -1,18 +1,13 @@
1
1
  {
2
2
  "name": "@momo-kits/template",
3
- "version": "0.81.14",
3
+ "version": "0.81.16-cns.1",
4
4
  "private": false,
5
5
  "main": "index.tsx",
6
6
  "dependencies": {},
7
7
  "peerDependencies": {
8
- "@momo-kits/foundation": "latest",
9
- "@momo-kits/carousel": "0.81.6-beta.12",
10
8
  "prop-types": "^15.7.2",
11
9
  "react": "16.9.0",
12
10
  "react-native": ">=0.55"
13
11
  },
14
- "devDependencies": {
15
- "@momo-platform/versions": "4.1.11"
16
- },
17
12
  "license": "MoMo"
18
- }
13
+ }
@@ -1,85 +0,0 @@
1
- import React, {FC} from 'react';
2
- import {Animated, TouchableOpacity, View} from 'react-native';
3
- import Carousel from '@momo-kits/carousel';
4
- import {Image, Pagination, Spacing} from '@momo-kits/foundation';
5
- import {HeaderSliderBannerProps} from './types';
6
-
7
- const HeaderSliderBanner: FC<HeaderSliderBannerProps> = ({
8
- animatedValue = new Animated.Value(0),
9
- paginationBottom = 56,
10
- data = [],
11
- activeIndex = 0,
12
- paginationProps,
13
- carouselProps,
14
- onSnapToItem,
15
- onPressItem,
16
- paginationType = 'black_white',
17
- }) => {
18
- const scale = animatedValue.interpolate({
19
- inputRange: [-300, 0, 300],
20
- outputRange: [4, 1, 1],
21
- extrapolate: 'clamp',
22
- });
23
- const opacity = animatedValue.interpolate({
24
- inputRange: [0, 150, 300],
25
- outputRange: [1, 0.5, 0],
26
- extrapolate: 'clamp',
27
- });
28
- const translateY = animatedValue.interpolate({
29
- inputRange: [-300, 0],
30
- outputRange: [-80, -2],
31
- extrapolate: 'clamp',
32
- });
33
-
34
- const paginationOpacity = animatedValue.interpolate({
35
- inputRange: [-40, 0],
36
- outputRange: [0, 1],
37
- });
38
-
39
- const renderItem = (info: {item: any; index: number}) => {
40
- const {item, index} = info;
41
- return (
42
- <TouchableOpacity disabled={!onPressItem} onPress={onPressItem}>
43
- <Image
44
- key={`Header banner ${item}_${index}`}
45
- source={{
46
- uri: item,
47
- }}
48
- />
49
- </TouchableOpacity>
50
- );
51
- };
52
-
53
- return (
54
- <Animated.View
55
- style={{
56
- height: 210,
57
- opacity: opacity,
58
- transform: [{scale}, {translateY}],
59
- }}>
60
- <Carousel
61
- {...carouselProps}
62
- full={true}
63
- data={data}
64
- onSnapToItem={onSnapToItem}
65
- renderItem={renderItem}
66
- />
67
- <Animated.View
68
- style={{
69
- position: 'absolute',
70
- bottom: paginationBottom - Spacing.S,
71
- alignSelf: 'center',
72
- opacity: paginationOpacity,
73
- }}>
74
- <Pagination
75
- {...paginationProps}
76
- activeIndex={activeIndex}
77
- dataLength={data.length}
78
- type={paginationType}
79
- />
80
- </Animated.View>
81
- </Animated.View>
82
- );
83
- };
84
-
85
- export default HeaderSliderBanner;
@@ -1,16 +0,0 @@
1
- import {PaginationProps} from '@momo-kits/foundation';
2
- import {CarouselProps} from '@momo-kits/carousel';
3
- import {Animated} from 'react-native';
4
- import AnimatedValue = Animated.AnimatedValue;
5
-
6
- export type HeaderSliderBannerProps = {
7
- animatedValue: AnimatedValue;
8
- data: string[];
9
- onSnapToItem: (index: number) => void;
10
- activeIndex: number;
11
- paginationProps?: PaginationProps;
12
- carouselProps?: CarouselProps;
13
- paginationBottom?: 8 | 24 | 56;
14
- onPressItem?: () => void;
15
- paginationType: 'black_white' | 'number';
16
- };