@momo-kits/suggest-action 0.0.62-alpha.3 → 0.0.62-alpha.32

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.
Files changed (2) hide show
  1. package/index.js +52 -28
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -5,25 +5,32 @@ import {
5
5
  IconSource,
6
6
  Image,
7
7
  ScaleSize,
8
+ Shadow,
8
9
  Spacing,
9
10
  Text,
10
11
  TouchableOpacity,
11
- } from '@momo-kits/core';
12
- import React from 'react';
13
- import { StyleSheet, View } from 'react-native';
12
+ } from '@momo-kits/core-v2';
13
+ import React, {
14
+ forwardRef,
15
+ useEffect,
16
+ useImperativeHandle,
17
+ useRef,
18
+ } from 'react';
19
+ import { Animated, StyleSheet, View } from 'react-native';
14
20
  import ExpenseI18n from './ExpenseI18n';
15
21
 
16
- export default SuggestAction = ({
17
- icon,
18
- name,
19
- buttonTitle = 'Thêm ngay',
20
- onPressButton,
21
- onPressClose,
22
- iconTintColor,
23
- visible = false,
24
- style,
25
- contentType = 'add',
26
- }) => {
22
+ export default SuggestAction = forwardRef((props, ref) => {
23
+ const {
24
+ icon,
25
+ name,
26
+ buttonTitle = 'Thêm ngay',
27
+ onPressButton,
28
+ onPressClose,
29
+ iconTintColor,
30
+ style,
31
+ contentType = 'add',
32
+ } = props;
33
+
27
34
  const getContent = (contentType) => {
28
35
  switch (contentType) {
29
36
  case 'add':
@@ -43,12 +50,37 @@ export default SuggestAction = ({
43
50
  };
44
51
  }
45
52
  };
53
+ const fadeAnimation = useRef(new Animated.Value(0)).current;
46
54
 
47
55
  const contentStart = getContent(contentType).start;
48
56
  const contentEnd = getContent(contentType).end;
49
57
 
50
- return visible ? (
51
- <View style={[styles.container, style]}>
58
+ const show = () => {
59
+ Animated.timing(fadeAnimation, {
60
+ toValue: 1,
61
+ duration: 100,
62
+ useNativeDriver: true,
63
+ }).start();
64
+ };
65
+
66
+ const hide = () => {
67
+ Animated.timing(fadeAnimation, {
68
+ toValue: 0,
69
+ useNativeDriver: true,
70
+ duration: 100,
71
+ }).start();
72
+ };
73
+
74
+ useImperativeHandle(ref, () => ({ show, hide }), []);
75
+
76
+ return (
77
+ <Animated.View
78
+ style={[
79
+ styles.container,
80
+ style,
81
+ Shadow.Light,
82
+ { opacity: fadeAnimation },
83
+ ]}>
52
84
  {icon && (
53
85
  <Image
54
86
  source={icon}
@@ -56,7 +88,6 @@ export default SuggestAction = ({
56
88
  tintColor={iconTintColor}
57
89
  />
58
90
  )}
59
- <View></View>
60
91
  <Text style={styles.description} numberOfLines={2}>
61
92
  {contentStart}{' '}
62
93
  <Text style={[styles.description, { fontWeight: 'bold' }]}>
@@ -78,9 +109,9 @@ export default SuggestAction = ({
78
109
  style={styles.iconClose}
79
110
  />
80
111
  </TouchableOpacity>
81
- </View>
82
- ) : null;
83
- };
112
+ </Animated.View>
113
+ );
114
+ });
84
115
 
85
116
  const styles = StyleSheet.create({
86
117
  container: {
@@ -90,14 +121,7 @@ const styles = StyleSheet.create({
90
121
  paddingVertical: ScaleSize(14),
91
122
  borderRadius: Spacing.S,
92
123
  backgroundColor: Colors.white,
93
- shadowColor: Colors.black,
94
- shadowOffset: {
95
- width: 0,
96
- height: 4,
97
- },
98
- shadowOpacity: 0.3,
99
- shadowRadius: 4.65,
100
- elevation: 8,
124
+
101
125
  flexDirection: 'row',
102
126
  alignItems: 'center',
103
127
  position: 'absolute',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/suggest-action",
3
- "version": "0.0.62-alpha.3",
3
+ "version": "0.0.62-alpha.32",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "dependencies": {},
@@ -9,7 +9,7 @@
9
9
  "prop-types": "^15.7.2",
10
10
  "react": "16.9.0",
11
11
  "react-native": ">=0.55",
12
- "@momo-kits/core": ">=0.0.5-beta"
12
+ "@momo-kits/core-v2": ">=0.0.5-beta"
13
13
  },
14
14
  "devDependencies": {},
15
15
  "license": "MoMo"