@momo-kits/template 0.81.10 → 0.81.12

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,11 +1,20 @@
1
- import React, {FC, useContext} from 'react';
2
- import {requireNativeComponent, UIManager, View, ViewProps} from 'react-native';
3
- import {TrustBannerProps} from './types';
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';
4
9
  import styles from './styles';
5
10
  import {ApplicationContext, Colors, Image, Text} from '@momo-kits/foundation';
6
11
  import CustomAvatar from './CustomAvatar';
7
12
 
8
- const NativeTrustBanner = requireNativeComponent<ViewProps>('TrustBannerView');
13
+ const NativeTrustBanner =
14
+ requireNativeComponent<TrustBannerProps>('TrustBannerView');
15
+
16
+ const dataJsonUrl =
17
+ 'https://static.momocdn.net/app/json/component-kits/design_system.json';
9
18
 
10
19
  const defaultIcons = [
11
20
  'https://static.momocdn.net/app/img/kits/trustBanner/ic_viettinbank.png',
@@ -13,18 +22,55 @@ const defaultIcons = [
13
22
  'https://static.momocdn.net/app/img/kits/trustBanner/ic_vietcombank.png',
14
23
  'https://static.momocdn.net/app/img/kits/trustBanner/ic_bidv.png',
15
24
  ];
25
+
26
+ const defaultData = {
27
+ content: {
28
+ vi: 'Bảo mật thông tin & An toàn tài sản của bạn là ưu tiên hàng đầu của MoMo.',
29
+ en: "Your data security and money safety are MoMo's top priorities.",
30
+ },
31
+ pciImage: 'https://static.momocdn.net/app/img/kits/trustBanner/pci.png',
32
+ sslImage: 'https://static.momocdn.net/app/img/kits/trustBanner/ssl.png',
33
+ icons: defaultIcons,
34
+ momoImage:
35
+ 'https://static.momocdn.net/app/img/kits/trustBanner/ic_momo_secu.png',
36
+ };
37
+
16
38
  const TrustBanner: FC<TrustBannerProps> = ({
17
- content = 'Bảo mật thông tin & An toàn tài sản của bạn là ưu tiên hàng đầu của MoMo.',
18
- pciImage = 'https://static.momocdn.net/app/img/kits/trustBanner/pci.png',
19
- sslImage = 'https://static.momocdn.net/app/img/kits/trustBanner/ssl.png',
20
- icons = defaultIcons,
21
39
  style,
40
+ trackEvent,
41
+ screenName = '',
42
+ serviceName = '',
43
+ openWeb,
44
+ openUrl = 'https://momo.vn/an-toan-bao-mat',
22
45
  }) => {
23
- const {theme} = useContext(ApplicationContext);
46
+ const {theme, language} = useContext(ApplicationContext);
47
+ const [data, setData] = useState(defaultData);
48
+ const {icons, sslImage, pciImage, momoImage, content} = data;
49
+ const trackingParams: TrackingParams = {
50
+ screen_name: screenName,
51
+ service_name: serviceName,
52
+ component_name: 'logo_trust',
53
+ };
54
+ useEffect(() => {
55
+ trackEvent?.('service_component_displayed', trackingParams);
56
+ fetchJson();
57
+ }, []);
58
+
59
+ const fetchJson = async () => {
60
+ const res = await fetch(dataJsonUrl);
61
+ const dataJSon = await res.json();
62
+
63
+ if (dataJSon && dataJSon?.trustBanner) {
64
+ setData({
65
+ icons: dataJSon.trustBanner.icons || defaultData.icons,
66
+ sslImage: dataJSon.trustBanner.sslImage || defaultData.sslImage,
67
+ pciImage: dataJSon.trustBanner.pciImage || defaultData.pciImage,
68
+ momoImage: dataJSon.trustBanner.momoImage || defaultData.momoImage,
69
+ content: dataJSon.trustBanner.content || defaultData.content,
70
+ });
71
+ }
72
+ };
24
73
 
25
- /**
26
- * update platform_config
27
- */
28
74
  const renderIconList = () => {
29
75
  return (
30
76
  <View style={styles.iconList}>
@@ -66,25 +112,44 @@ const TrustBanner: FC<TrustBannerProps> = ({
66
112
  };
67
113
 
68
114
  if (UIManager.getViewManagerConfig('TrustBannerView')) {
69
- return <NativeTrustBanner style={{height: 88}} />;
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
+ );
70
129
  }
71
130
 
72
131
  return (
73
- <View style={[style, styles.container]}>
132
+ <TouchableOpacity
133
+ onPress={() => {
134
+ trackEvent?.('service_component_clicked', trackingParams);
135
+ openWeb?.(openUrl);
136
+ }}
137
+ activeOpacity={0.7}
138
+ style={[style, styles.container]}>
74
139
  <Image
75
140
  style={styles.momoImage}
76
141
  resizeMode={'contain'}
77
142
  source={{
78
- uri: 'https://static.momocdn.net/app/img/kits/trustBanner/ic_momo_secu.png',
143
+ uri: momoImage,
79
144
  }}
80
145
  />
81
146
  <View style={styles.flex}>
82
147
  <Text style={styles.message} typography={'description_s'}>
83
- {content}
148
+ {content?.[language || 'vi'] || defaultData.content.vi}
84
149
  </Text>
85
150
  {renderFooter()}
86
151
  </View>
87
- </View>
152
+ </TouchableOpacity>
88
153
  );
89
154
  };
90
155
 
@@ -1,11 +1,20 @@
1
1
  import {ViewStyle} from 'react-native';
2
2
 
3
+ export type TrackingParams = {
4
+ service_name: string;
5
+ screen_name: string;
6
+ component_name: string;
7
+ url_config?: string;
8
+ };
9
+
3
10
  export type TrustBannerProps = {
4
- content?: string;
5
- icons?: string[];
6
- pciImage?: string;
7
- sslImage?: string;
11
+ trackEvent?: (eventName: string, trackingParams: TrackingParams) => void;
8
12
  style?: ViewStyle | ViewStyle[];
13
+ openWeb?: (params: string) => void;
14
+ screenName?: string;
15
+ serviceName?: string;
16
+ openUrl?: string;
17
+ content?: string;
9
18
  };
10
19
 
11
20
  export type CustomAvatarProps = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/template",
3
- "version": "0.81.10",
3
+ "version": "0.81.12",
4
4
  "private": false,
5
5
  "main": "index.tsx",
6
6
  "dependencies": {},