react-native-biometric-verifier 0.0.57 → 0.0.58
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.
- package/package.json +1 -1
- package/src/components/Notification.js +14 -38
package/package.json
CHANGED
|
@@ -1,32 +1,23 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
2
|
import { Animated, Text, Platform, StyleSheet } from 'react-native';
|
|
3
3
|
import Icon from 'react-native-vector-icons/MaterialIcons';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
4
|
import { Global } from '../utils/Global';
|
|
6
5
|
|
|
7
|
-
export const Notification = ({ notification, fadeAnim, slideAnim }) => {
|
|
8
|
-
|
|
9
|
-
console.warn('Notification: Invalid or missing notification object');
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
6
|
+
export const Notification = ({ notification = {}, fadeAnim, slideAnim }) => {
|
|
7
|
+
const { visible = false, type = 'info', message = '' } = notification;
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
// Animations (must ALWAYS exist)
|
|
10
|
+
const scaleAnim = useRef(new Animated.Value(1)).current;
|
|
11
|
+
const shakeAnim = useRef(new Animated.Value(0)).current;
|
|
15
12
|
|
|
16
|
-
// Icon and color mapping
|
|
17
13
|
const iconMap = {
|
|
18
14
|
success: { name: 'check-circle', color: Global.AppTheme.success },
|
|
19
15
|
error: { name: 'error', color: Global.AppTheme.error },
|
|
20
16
|
info: { name: 'info', color: Global.AppTheme.info },
|
|
21
17
|
};
|
|
22
18
|
|
|
23
|
-
const { name: iconName, color: iconColor } =
|
|
24
|
-
|
|
25
|
-
// Heartbeat animation (scale in/out)
|
|
26
|
-
const scaleAnim = useRef(new Animated.Value(1)).current;
|
|
27
|
-
|
|
28
|
-
// Shake animation (rotation wiggle)
|
|
29
|
-
const shakeAnim = useRef(new Animated.Value(0)).current;
|
|
19
|
+
const { name: iconName, color: iconColor } =
|
|
20
|
+
iconMap[type] || iconMap.info;
|
|
30
21
|
|
|
31
22
|
useEffect(() => {
|
|
32
23
|
const heartbeat = Animated.loop(
|
|
@@ -78,20 +69,20 @@ export const Notification = ({ notification, fadeAnim, slideAnim }) => {
|
|
|
78
69
|
heartbeat.stop();
|
|
79
70
|
shake.stop();
|
|
80
71
|
};
|
|
81
|
-
}, [visible, type
|
|
72
|
+
}, [visible, type]);
|
|
82
73
|
|
|
83
|
-
|
|
84
|
-
const shakeInterpolate = shakeAnim.interpolate({
|
|
74
|
+
const shakeRotate = shakeAnim.interpolate({
|
|
85
75
|
inputRange: [-1, 1],
|
|
86
76
|
outputRange: ['-10deg', '10deg'],
|
|
87
77
|
});
|
|
88
78
|
|
|
89
79
|
return (
|
|
90
80
|
<Animated.View
|
|
81
|
+
pointerEvents={visible ? 'auto' : 'none'}
|
|
91
82
|
style={[
|
|
92
83
|
styles.container,
|
|
93
84
|
{
|
|
94
|
-
opacity:
|
|
85
|
+
opacity: visible ? 1 : 0,
|
|
95
86
|
transform: [
|
|
96
87
|
{ translateY: slideAnim instanceof Animated.Value ? slideAnim : 0 },
|
|
97
88
|
],
|
|
@@ -102,12 +93,13 @@ export const Notification = ({ notification, fadeAnim, slideAnim }) => {
|
|
|
102
93
|
style={{
|
|
103
94
|
transform: [
|
|
104
95
|
{ scale: scaleAnim },
|
|
105
|
-
...(type === 'error' ? [{ rotate:
|
|
96
|
+
...(type === 'error' ? [{ rotate: shakeRotate }] : []),
|
|
106
97
|
],
|
|
107
98
|
}}
|
|
108
99
|
>
|
|
109
|
-
<Icon name={iconName} size={50} color={iconColor}
|
|
100
|
+
<Icon name={iconName} size={50} color={iconColor} />
|
|
110
101
|
</Animated.View>
|
|
102
|
+
|
|
111
103
|
<Text style={styles.message}>
|
|
112
104
|
{message || 'No message provided'}
|
|
113
105
|
</Text>
|
|
@@ -142,20 +134,4 @@ const styles = StyleSheet.create({
|
|
|
142
134
|
},
|
|
143
135
|
});
|
|
144
136
|
|
|
145
|
-
Notification.propTypes = {
|
|
146
|
-
notification: PropTypes.shape({
|
|
147
|
-
visible: PropTypes.bool.isRequired,
|
|
148
|
-
type: PropTypes.oneOf(['success', 'error', 'info']),
|
|
149
|
-
message: PropTypes.string,
|
|
150
|
-
}),
|
|
151
|
-
fadeAnim: PropTypes.instanceOf(Animated.Value),
|
|
152
|
-
slideAnim: PropTypes.instanceOf(Animated.Value),
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
Notification.defaultProps = {
|
|
156
|
-
notification: { visible: false, type: 'info', message: '' },
|
|
157
|
-
fadeAnim: new Animated.Value(1),
|
|
158
|
-
slideAnim: new Animated.Value(0),
|
|
159
|
-
};
|
|
160
|
-
|
|
161
137
|
export default Notification;
|