@momo-kits/template 0.74.2-react-native.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.
@@ -0,0 +1,85 @@
1
+ import React, {FC} from 'react';
2
+ import {Animated, TouchableOpacity} 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;
@@ -0,0 +1,16 @@
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
+ };
@@ -0,0 +1,39 @@
1
+ import React, {FC, useContext} from 'react';
2
+ import {View} from 'react-native';
3
+ import styles from './styles';
4
+ import {ApplicationContext, Colors, Image, Text} from '@momo-kits/foundation';
5
+ import {CustomAvatarProps} from './types';
6
+
7
+ const CustomAvatar: FC<CustomAvatarProps> = ({image, text, style}) => {
8
+ const {theme} = useContext(ApplicationContext);
9
+
10
+ const renderContent = () => {
11
+ if (text) {
12
+ return (
13
+ <Text
14
+ color={theme.colors.primary}
15
+ typography={'description_xs_regular'}>
16
+ {text}
17
+ </Text>
18
+ );
19
+ }
20
+
21
+ return <Image style={styles.avatarImage} source={{uri: image}} />;
22
+ };
23
+
24
+ return (
25
+ <View
26
+ style={[
27
+ styles.customAvatar,
28
+ {
29
+ backgroundColor: Colors.black_01,
30
+ borderColor: theme.colors.border.default,
31
+ },
32
+ style,
33
+ ]}>
34
+ {renderContent()}
35
+ </View>
36
+ );
37
+ };
38
+
39
+ export default CustomAvatar;
@@ -0,0 +1,143 @@
1
+ import React, {FC, useContext, useEffect, useState} from 'react';
2
+ import {NativeModules, TouchableOpacity, View} from 'react-native';
3
+ import {TrustBannerCallbackParams, TrustBannerProps} from './types';
4
+ import styles from './styles';
5
+ import {ApplicationContext, Colors, Image, Text} from '@momo-kits/foundation';
6
+ import CustomAvatar from './CustomAvatar';
7
+ import MaxApi from '@momo-platform/api';
8
+
9
+ const defaultData = {
10
+ content: {
11
+ 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.',
12
+ en: "Your data security and money safety are MoMo's top priorities.",
13
+ },
14
+ pciImage: 'https://static.momocdn.net/app/img/kits/trustBanner/pci.png',
15
+ sslImage: 'https://static.momocdn.net/app/img/kits/trustBanner/ssl.png',
16
+ momoImage:
17
+ 'https://static.momocdn.net/app/img/kits/trustBanner/ic_momo_secu.png',
18
+ urlConfig: 'login_and_security',
19
+ icons: [
20
+ 'https://static.momocdn.net/app/img/kits/trustBanner/ic_viettinbank.png',
21
+ 'https://static.momocdn.net/app/img/kits/trustBanner/ic_agribank.png',
22
+ 'https://static.momocdn.net/app/img/kits/trustBanner/ic_vietcombank.png',
23
+ 'https://static.momocdn.net/app/img/kits/trustBanner/ic_bidv.png',
24
+ ],
25
+ };
26
+
27
+ const TrustBanner: FC<TrustBannerProps> = ({
28
+ style,
29
+ screenName = '',
30
+ serviceName = '',
31
+ trackEvent,
32
+ }) => {
33
+ const {theme, language} = useContext(ApplicationContext);
34
+ const [data, setData] = useState(defaultData);
35
+ const {icons, sslImage, pciImage, momoImage, urlConfig, content} = data;
36
+ const trackingParams: TrustBannerCallbackParams = {
37
+ screen_name: screenName,
38
+ service_name: serviceName,
39
+ component_name: 'logo_trust',
40
+ };
41
+
42
+ useEffect(() => {
43
+ trackEvent?.('service_component_displayed', trackingParams);
44
+ fetchJson();
45
+ }, []);
46
+
47
+ const fetchJson = () => {
48
+ try {
49
+ const config = JSON.parse(
50
+ NativeModules?.ConfigsModule?.getConfigSync?.('DESIGN_SYSTEM'),
51
+ );
52
+ const dataJSon = config?.trustBanner;
53
+
54
+ if (dataJSon && dataJSon?.trustBanner) {
55
+ setData({
56
+ icons: dataJSon.trustBanner.icons || defaultData.icons,
57
+ sslImage: dataJSon.trustBanner.sslImage || defaultData.sslImage,
58
+ pciImage: dataJSon.trustBanner.pciImage || defaultData.pciImage,
59
+ momoImage: dataJSon.trustBanner.momoImage || defaultData.momoImage,
60
+ content: dataJSon.trustBanner.content || defaultData.content,
61
+ urlConfig: dataJSon.trustBanner.urlConfig || defaultData.urlConfig,
62
+ });
63
+ }
64
+ } catch (e) {
65
+ console.log(e);
66
+ }
67
+ };
68
+
69
+ const renderIconList = () => {
70
+ return (
71
+ <View style={styles.iconList}>
72
+ {icons.map(icon => {
73
+ return <CustomAvatar image={icon} />;
74
+ })}
75
+ <CustomAvatar
76
+ style={[
77
+ styles.customAvatar,
78
+ {
79
+ borderColor: theme.colors.border.default,
80
+ backgroundColor: Colors.pink_09,
81
+ },
82
+ ]}
83
+ text="36+"
84
+ />
85
+ </View>
86
+ );
87
+ };
88
+
89
+ const renderFooter = () => {
90
+ return (
91
+ <View style={styles.footer}>
92
+ <View style={styles.imageList}>
93
+ <Image
94
+ resizeMode={'contain'}
95
+ style={[styles.image, styles.pciImage]}
96
+ source={{uri: pciImage}}
97
+ />
98
+ <Image
99
+ resizeMode={'contain'}
100
+ style={styles.image}
101
+ source={{uri: sslImage}}
102
+ />
103
+ </View>
104
+ {renderIconList()}
105
+ </View>
106
+ );
107
+ };
108
+
109
+ const _onPress = () => {
110
+ trackEvent?.('service_component_clicked', {...trackingParams, urlConfig});
111
+ if (urlConfig.indexOf('https') > -1) {
112
+ MaxApi.openWeb(urlConfig, {}, () => {});
113
+ } else {
114
+ MaxApi.startFeatureCode(urlConfig, {}, () => {});
115
+ }
116
+ };
117
+
118
+ return (
119
+ <TouchableOpacity
120
+ onPress={_onPress}
121
+ activeOpacity={0.7}
122
+ style={[style, styles.container]}>
123
+ <Image
124
+ style={styles.momoImage}
125
+ resizeMode={'contain'}
126
+ source={{
127
+ uri: momoImage,
128
+ }}
129
+ />
130
+ <View style={styles.flex}>
131
+ <Text
132
+ style={styles.message}
133
+ color={theme.colors.text.secondary}
134
+ typography={'description_default_regular'}>
135
+ {content?.[language || 'vi'] || defaultData.content.vi}
136
+ </Text>
137
+ {renderFooter()}
138
+ </View>
139
+ </TouchableOpacity>
140
+ );
141
+ };
142
+
143
+ export default TrustBanner;
@@ -0,0 +1,46 @@
1
+ import {StyleSheet} from 'react-native';
2
+ import {Colors, Radius, scaleSize, Spacing} from '@momo-kits/foundation';
3
+
4
+ export default StyleSheet.create({
5
+ container: {
6
+ flexDirection: 'row',
7
+ padding: Spacing.M,
8
+ borderRadius: Radius.S,
9
+ backgroundColor: Colors.blue_10,
10
+ width: '100%',
11
+ },
12
+ flex: {flex: 1},
13
+ momoImage: {
14
+ width: scaleSize(64),
15
+ height: scaleSize(64),
16
+ marginRight: Spacing.S,
17
+ },
18
+ image: {
19
+ width: scaleSize(52),
20
+ height: scaleSize(20),
21
+ },
22
+ imageList: {
23
+ flexDirection: 'row',
24
+ },
25
+ pciImage: {
26
+ marginRight: Spacing.XS,
27
+ },
28
+ message: {marginBottom: Spacing.S},
29
+ footer: {
30
+ flexDirection: 'row',
31
+ justifyContent: 'space-between',
32
+ },
33
+ customAvatar: {
34
+ width: scaleSize(24),
35
+ height: scaleSize(24),
36
+ borderWidth: 1,
37
+ borderRadius: Radius.L,
38
+ alignItems: 'center',
39
+ justifyContent: 'center',
40
+ marginLeft: scaleSize(-6),
41
+ },
42
+ iconList: {
43
+ flexDirection: 'row',
44
+ },
45
+ avatarImage: {width: '100%', height: '100%'},
46
+ });
@@ -0,0 +1,50 @@
1
+ import {ViewStyle} from 'react-native';
2
+
3
+ export type TrustBannerCallbackParams = {
4
+ service_name: string;
5
+ screen_name: string;
6
+ component_name: string;
7
+ urlConfig?: string;
8
+ };
9
+
10
+ export type TrustBannerProps = {
11
+ /**
12
+ * Optional. Styles to customize the appearance of the banner. Can be a single
13
+ * style object or an array of style objects.
14
+ */
15
+ style?: ViewStyle | ViewStyle[];
16
+
17
+ /**
18
+ * Optional. The name of the screen where the banner is displayed. This can be
19
+ * used to identify the context in which the banner appears.
20
+ */
21
+ screenName?: string;
22
+
23
+ /**
24
+ * Optional. The name of the service or feature the banner is associated with.
25
+ * This helps in providing contextual information within the banner content.
26
+ */
27
+ serviceName?: string;
28
+
29
+ /**
30
+ * Optional. A callback function can be openWeb or startFeatureCode,
31
+ * return params:
32
+ * service_name,
33
+ * screen_name,
34
+ * component_name,
35
+ * url_config,
36
+ * feature_code,
37
+ */
38
+ onPress?: (params: TrustBannerCallbackParams) => void;
39
+
40
+ /**
41
+ * Optional. instance of maxApi trackEvent function.
42
+ */
43
+ trackEvent?: (eventName: string, params: TrustBannerCallbackParams) => void;
44
+ };
45
+
46
+ export type CustomAvatarProps = {
47
+ image?: string;
48
+ text?: string;
49
+ style?: ViewStyle[] | ViewStyle;
50
+ };
package/index.tsx ADDED
@@ -0,0 +1,3 @@
1
+ import HeaderSliderBanner from './HeaderSliderBanner';
2
+ import TrustBanner from './TrustBanner';
3
+ export {HeaderSliderBanner, TrustBanner};
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@momo-kits/template",
3
+ "version": "0.74.2-react-native.1",
4
+ "private": false,
5
+ "main": "index.tsx",
6
+ "peerDependencies": {
7
+ "@momo-kits/foundation": "*",
8
+ "@momo-kits/carousel": "*",
9
+ "prop-types": "15.7.2",
10
+ "react": "*",
11
+ "react-native": "*",
12
+ "@momo-platform/api": "0.1.67-rc.3"
13
+ },
14
+ "license": "MoMo",
15
+ "dependencies": {}
16
+ }
package/publish.sh ADDED
@@ -0,0 +1,28 @@
1
+ #!/bin/bash
2
+ rm -rf dist
3
+ mkdir dist
4
+
5
+ cp . ./dist
6
+
7
+ # GET VERSION from mck_package.json
8
+ VERSIONSTRING=( v$(jq .version package.json) )
9
+ VERSION=(${VERSIONSTRING//[\"]/})
10
+ echo VERSION: $VERSION
11
+
12
+ rsync -r --verbose --exclude '*.mdx' --exclude '*Demo.js' --exclude 'props-type.js' --exclude 'prop-types.js' ./* dist
13
+
14
+ # #babel component to dist
15
+ #babel ./dist -d dist --copy-files
16
+
17
+ #copy option
18
+ #cp -r ./src/ dist
19
+
20
+
21
+ #npm login
22
+ #publish dist to npm
23
+ cd dist
24
+ npm publish --tag beta --access=public
25
+ cd ..
26
+ rm -rf dist
27
+
28
+ ##curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/bank new version release: '*"$VERSION"*' `https://www.npmjs.com/package/@momo-kits/avatar`"}'