1
1
import React from 'react' ;
2
- import { View , Text , StyleSheet , Button , TouchableOpacity } from 'react-native' ;
2
+ import { View , Text , StyleSheet , Button , TouchableOpacity , Animated , Easing } from 'react-native' ;
3
3
import Icon from "react-native-vector-icons/Ionicons" ;
4
4
import { getLabelPrinter } from 'jest-matcher-utils' ;
5
5
@@ -32,7 +32,8 @@ class MyScreen extends React.Component {
32
32
super ( props )
33
33
this . state = {
34
34
isOn : false ,
35
- count : 1
35
+ animatedRightValue : new Animated . Value ( - 140 ) ,
36
+ animatedValue : new Animated . Value ( 0 ) ,
36
37
}
37
38
}
38
39
@@ -42,15 +43,34 @@ class MyScreen extends React.Component {
42
43
43
44
toggleHandle = ( ) => {
44
45
this . modelComponent ( )
45
- this . setState ( {
46
+ this . setState ( {
46
47
isOn : ! this . state . isOn
47
- } ) ;
48
+ } ,
49
+ ( ) => {
50
+ Animated . timing (
51
+ this . state . animatedRightValue ,
52
+ {
53
+ toValue : this . state . isOn ? 7 : - 140 ,
54
+ // easing: Easing.ease,
55
+ duration : 100 ,
56
+ }
57
+ ) . start ( )
58
+ }
59
+ ) ;
48
60
}
49
61
50
62
modelComponent = ( ) => {
51
- if ( this . state . isOn ) {
52
63
return (
53
- < View style = { styles . model } >
64
+ < Animated . View style = { {
65
+ position : 'absolute' ,
66
+ top : 10 ,
67
+ right : this . state . animatedRightValue ,
68
+ width : 140 ,
69
+ height : 240 ,
70
+ backgroundColor : '#555' ,
71
+ borderRadius : 5 ,
72
+ zIndex :999 ,
73
+ } } >
54
74
< Text style = { styles . modelArrow } > </ Text >
55
75
< View style = { styles . modelContainer } >
56
76
< View style = { { height : 35 , marginBottom : 10 } } >
@@ -104,11 +124,9 @@ class MyScreen extends React.Component {
104
124
</ TouchableOpacity >
105
125
</ View >
106
126
</ View >
107
- </ View >
127
+ </ Animated . View >
108
128
)
109
- } else {
110
- return < View > </ View >
111
- }
129
+ // return <Animated.View style={{width: 0}}></Animated.View>
112
130
}
113
131
114
132
toFriendCicle = ( ) => {
0 commit comments