Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. import { Transitioning, Transition } from 'react-native-reanimated';
  2. import React, { useRef, useEffect, useState } from 'react';
  3. import { Platform, StyleSheet, Text, View, Button } from 'react-native';
  4.  
  5. const instructions = Platform.select({
  6. ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
  7. android:
  8. 'Double tap R on your keyboard to reload,\n' +
  9. 'Shake or press menu button for dev menu',
  10. });
  11.  
  12. const transition1 = (
  13. <Transition.Sequence>
  14. <Transition.In
  15. type="slide-right"
  16. durationMs={400}
  17. interpolation="easeOut"
  18. propagation="top"
  19. />
  20. </Transition.Sequence>
  21. );
  22. const transition2 = (
  23. <Transition.Together>
  24. <Transition.Change durationMs={400} />
  25. <Transition.In
  26. type="slide-right"
  27. durationMs={400}
  28. interpolation="easeOut"
  29. propagation="top"
  30. />
  31. </Transition.Together>
  32. );
  33.  
  34. const App = () => {
  35. const [extra, setExtra] = useState(0);
  36.  
  37. const ref = useRef();
  38. const ref2 = useRef();
  39.  
  40. useEffect(() => {
  41. ref2.current.animateNextTransition();
  42. }, []);
  43.  
  44. return (
  45. <View style={styles.container}>
  46. <Transitioning.View ref={ref} transition={transition2}>
  47. <Transitioning.View ref={ref2} transition={transition1}>
  48. <View
  49. style={{
  50. backgroundColor: 'lightblue',
  51. borderRadius: 10,
  52. }}
  53. >
  54. <Text style={styles.welcome}>Welcome to React Native!</Text>
  55. <Text style={styles.instructions}>To get started, edit App.js</Text>
  56. <Text style={styles.instructions}>{instructions}</Text>
  57. {new Array(extra).fill(0).map((_, index) => (
  58. <View
  59. key={index}
  60. style={{
  61. backgroundColor: 'lightgray',
  62. margin: 3,
  63. borderRadius: 10,
  64. }}
  65. >
  66. <Text
  67. style={{
  68. textAlign: 'center',
  69. }}
  70. >
  71. {`View number ${index}`}
  72. </Text>
  73. </View>
  74. ))}
  75. </View>
  76. </Transitioning.View>
  77. </Transitioning.View>
  78. <View style={{ position: 'absolute', bottom: 100 }}>
  79. <Button
  80. title="Boing"
  81. onPress={() => {
  82. ref.current.animateNextTransition();
  83. setExtra(oldExtra => oldExtra + 1);
  84. }}
  85. />
  86. </View>
  87. </View>
  88. );
  89. };
  90.  
  91. export default App;
  92.  
  93. const styles = StyleSheet.create({
  94. container: {
  95. flex: 1,
  96. justifyContent: 'center',
  97. alignItems: 'center',
  98. backgroundColor: '#F5FCFF',
  99. },
  100. welcome: {
  101. fontSize: 20,
  102. textAlign: 'center',
  103. margin: 10,
  104. },
  105. instructions: {
  106. textAlign: 'center',
  107. color: '#333333',
  108. marginBottom: 5,
  109. },
  110. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement