Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.55 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { View, Text, StyleSheet, Dimensions,TextInput} from 'react-native';
  3.  
  4. import Animated, { Easing } from 'react-native-reanimated';
  5. import { TapGestureHandler, State } from 'react-native-gesture-handler';
  6. import Svg,{Image,Circle,ClipPath } from 'react-native-svg'
  7. const { width, height } = Dimensions.get('window');
  8.  
  9. const {
  10. Value,
  11. event,
  12. block,
  13. cond,
  14. eq,
  15. set,
  16. Clock,
  17. startClock,
  18. stopClock,
  19. debug,
  20. timing,
  21. clockRunning,
  22. interpolate,
  23. Extrapolate,
  24. concat
  25. } = Animated;
  26.  
  27. function runTiming(clock, value, dest) {
  28. const state = {
  29. finished: new Value(0),
  30. position: new Value(0),
  31. time: new Value(0),
  32. frameTime: new Value(0)
  33. };
  34.  
  35. const config = {
  36. duration: 1000,
  37. toValue: new Value(0),
  38. easing: Easing.inOut(Easing.ease)
  39. };
  40.  
  41. return block([
  42. cond(clockRunning(clock), 0, [
  43. set(state.finished, 0),
  44. set(state.time, 0),
  45. set(state.position, value),
  46. set(state.frameTime, 0),
  47. set(config.toValue, dest),
  48. startClock(clock)
  49. ]),
  50. timing(clock, state, config),
  51. cond(state.finished, debug('stop clock', stopClock(clock))),
  52. state.position
  53. ]);
  54. }
  55. class App extends Component {
  56. constructor() {
  57. super();
  58.  
  59. this.buttonOpacity = new Value(1);
  60.  
  61. this.onStateChange = event([
  62. {
  63. nativeEvent: ({ state }) =>
  64. block([
  65. cond(
  66. eq(state, State.END),
  67. set(this.buttonOpacity, runTiming(new Clock(), 1, 0))
  68. )
  69. ])
  70. }
  71. ]);
  72.  
  73. this.onCloseState = event([
  74. {
  75. nativeEvent: ({ state }) =>
  76. block([
  77. cond(
  78. eq(state, State.END),
  79. set(this.buttonOpacity, runTiming(new Clock(), 0, 1))
  80. )
  81. ])
  82. }
  83. ]);
  84.  
  85.  
  86.  
  87. this.buttonY = interpolate(this.buttonOpacity, {
  88. inputRange: [0, 1],
  89. outputRange: [100, 0],
  90. extrapolate: Extrapolate.CLAMP
  91. });
  92.  
  93. this.bgY = interpolate(this.buttonOpacity, {
  94. inputRange: [0, 1],
  95. outputRange: [-height / 3-50, 0],
  96. extrapolate: Extrapolate.CLAMP
  97. });
  98. this.textInputZindex = interpolate(this.buttonOpacity, {
  99. inputRange: [0, 1],
  100. outputRange: [1,-1],
  101. extrapolate: Extrapolate.CLAMP
  102. });
  103.  
  104. this.textInputY = interpolate(this.buttonOpacity, {
  105. inputRange: [0, 1],
  106. outputRange: [0,100],
  107. extrapolate: Extrapolate.CLAMP
  108. });
  109.  
  110.  
  111.  
  112. this.textInputOpacity = interpolate(this.buttonOpacity, {
  113. inputRange: [0, 1],
  114. outputRange: [1,0],
  115. extrapolate: Extrapolate.CLAMP
  116. });
  117.  
  118.  
  119. this.rotateCross = interpolate(this.buttonOpacity, {
  120. inputRange: [0, 1],
  121. outputRange: [180,360],
  122. extrapolate: Extrapolate.CLAMP
  123. });
  124.  
  125.  
  126.  
  127.  
  128. }
  129. render() {
  130. return (
  131. <View
  132. style={{
  133. flex: 1,
  134. backgroundColor: 'white',
  135. justifyContent: 'flex-end'
  136. }}
  137. >
  138. <Animated.View
  139. style={{
  140. ...StyleSheet.absoluteFill,
  141. transform: [{ translateY: this.bgY }]
  142. }}
  143. >
  144. <Svg height={height+50} width={width}>
  145. <ClipPath id="clip">
  146. <Circle r={height+50} cx={width/2}/>
  147.  
  148. </ClipPath>
  149. <Image
  150. href={require('./assets/bg.jpg')}
  151. width={width}
  152. height={height+50}
  153. preserveAspectRatio='xMidYMid slice'
  154. clipPath="url(#clip)"
  155. />
  156. </Svg>
  157. </Animated.View>
  158. <View style={{ height: height / 3, justifyContent: 'center' }}>
  159. <TapGestureHandler onHandlerStateChange={this.onStateChange}>
  160. <Animated.View
  161. style={{
  162. ...styles.button,
  163. opacity: this.buttonOpacity,
  164. transform: [{ translateY: this.buttonY }]
  165. }}
  166. >
  167. <Text style={{ fontSize: 20, fontWeight: 'bold' }}>SIGN IN</Text>
  168. </Animated.View>
  169. </TapGestureHandler>
  170. <Animated.View
  171. style={{
  172. ...styles.button,
  173. backgroundColor: '#2E71DC',
  174. opacity: this.buttonOpacity,
  175. transform: [{ translateY: this.buttonY }]
  176. }}
  177. >
  178. <Text style={{ fontSize: 20, fontWeight: 'bold', color: 'white' }}>
  179. SIGN IN WITH FACEBOOK
  180. </Text>
  181. </Animated.View>
  182. <Animated.View style={{zIndex:this.textInputZindex,opacity:this.textInputOpacity,transform:[{translateY:this.textInputY}],height:height/3,...StyleSheet.absoluteFill,top:null,justifyContent:'center'}}>
  183. <TapGestureHandler onHandlerStateChange={this.onCloseState}>
  184. <Animated.View style={styles.closeButton}>
  185. <Animated.Text style={{fontSize:15,transform:[{rotate:concat(this.rotateCross,'deg')}]}}>
  186. X
  187. </Animated.Text>
  188.  
  189. </Animated.View>
  190. </TapGestureHandler>
  191.  
  192. <TextInput placeholder = "EMAIL"
  193. style={styles.textInput}
  194. placeholderTextColor="black"
  195. />
  196. <TextInput placeholder = "PASSWORD"
  197. style={styles.textInput}
  198. placeholderTextColor="black"
  199. />
  200. <Animated.View style={styles.button}>
  201. <Text style={{fontSize:20,fontWeight:'bold'}}>SIGN IN</Text>
  202. </Animated.View>
  203.  
  204. </Animated.View>
  205. </View>
  206. </View>
  207. );
  208. }
  209. }
  210. export default App;
  211.  
  212. const styles = StyleSheet.create({
  213. container: {
  214. flex: 1,
  215. alignItems: 'center',
  216. justifyContent: 'center'
  217. },
  218. button: {
  219. backgroundColor: 'white',
  220. height: 70,
  221. marginHorizontal: 20,
  222. borderRadius: 35,
  223. alignItems: 'center',
  224. justifyContent: 'center',
  225. marginVertical: 5,
  226. shadowOffset:{width:2,height:2},
  227. shadowColor:'black',
  228. shadowOpacity:0.2,
  229. elevation:2
  230. },
  231. closeButton:{
  232. elevation:2,
  233. height:40,
  234. width:40,
  235. backgroundColor:'white',
  236. borderRadius:20,
  237. alignItems:'center',
  238. justifyContent:'center',
  239. position:'absolute',
  240. top:-20,
  241. left:width/2 -20,
  242. shadowOffset:{width:2,height:2},
  243. shadowColor:'black',
  244. shadowOpacity:0.2
  245.  
  246. },
  247. textInput:{
  248. height:50,
  249. borderRadius:25,
  250. borderWidth:0.5,
  251. marginHorizontal:20,
  252. paddingLeft:10,
  253. marginVertical:5,
  254. borderColor:'rgba(0,0,0,0.2)'
  255. }
  256. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement