|
1 |
| -import { Image, StyleSheet, Platform } from 'react-native'; |
| 1 | +import { Image, StyleSheet, Platform, View, Animated } from 'react-native'; |
2 | 2 |
|
3 | 3 | import { HelloWave } from '@/components/HelloWave';
|
4 | 4 | import ParallaxScrollView from '@/components/ParallaxScrollView';
|
5 | 5 | import { ThemedText } from '@/components/ThemedText';
|
6 | 6 | import { ThemedView } from '@/components/ThemedView';
|
| 7 | +import { times } from 'ramda'; |
| 8 | +import { useEffect } from 'react'; |
7 | 9 |
|
| 10 | +const positions = times(() => new Animated.ValueXY({x: 0, y: 0}))(100) |
8 | 11 | export default function HomeScreen() {
|
| 12 | + |
| 13 | + useEffect(() => { |
| 14 | + const interval = setInterval(() => { |
| 15 | + Animated.parallel(positions.map(position => Animated.timing(position, { |
| 16 | + toValue: { |
| 17 | + x: Math.random() * 500, |
| 18 | + y: Math.random() * 500, |
| 19 | + }, |
| 20 | + duration: 100, |
| 21 | + useNativeDriver: false, |
| 22 | + }))).start(); |
| 23 | + |
| 24 | + }, 100); |
| 25 | + |
| 26 | + return () => clearInterval(interval); |
| 27 | + }) |
| 28 | + |
| 29 | + |
9 | 30 | return (
|
10 |
| - <ParallaxScrollView |
11 |
| - headerBackgroundColor={{ light: '#A1CEDC', dark: '#1D3D47' }} |
12 |
| - headerImage={ |
13 |
| - <Image |
14 |
| - source={require('@/assets/images/partial-react-logo.png')} |
15 |
| - style={styles.reactLogo} |
| 31 | + <View style={{flex: 1}}> |
| 32 | + {positions.map((position, index) => ( |
| 33 | + <Animated.View |
| 34 | + key={index} |
| 35 | + style={{ |
| 36 | + position: 'absolute', |
| 37 | + left: position.x, |
| 38 | + top: position.y, |
| 39 | + width: 100, |
| 40 | + height: 100, |
| 41 | + backgroundColor: 'blue', |
| 42 | + }} |
16 | 43 | />
|
17 |
| - }> |
18 |
| - <ThemedView style={styles.titleContainer}> |
19 |
| - <ThemedText type="title">Welcome!</ThemedText> |
20 |
| - <HelloWave /> |
21 |
| - </ThemedView> |
22 |
| - <ThemedView style={styles.stepContainer}> |
23 |
| - <ThemedText type="subtitle">Step 1: Try it</ThemedText> |
24 |
| - <ThemedText> |
25 |
| - Edit <ThemedText type="defaultSemiBold">app/(tabs)/index.tsx</ThemedText> to see changes. |
26 |
| - Press{' '} |
27 |
| - <ThemedText type="defaultSemiBold"> |
28 |
| - {Platform.select({ |
29 |
| - ios: 'cmd + d', |
30 |
| - android: 'cmd + m', |
31 |
| - web: 'F12' |
32 |
| - })} |
33 |
| - </ThemedText>{' '} |
34 |
| - to open developer tools. |
35 |
| - </ThemedText> |
36 |
| - </ThemedView> |
37 |
| - <ThemedView style={styles.stepContainer}> |
38 |
| - <ThemedText type="subtitle">Step 2: Explore</ThemedText> |
39 |
| - <ThemedText> |
40 |
| - Tap the Explore tab to learn more about what's included in this starter app. |
41 |
| - </ThemedText> |
42 |
| - </ThemedView> |
43 |
| - <ThemedView style={styles.stepContainer}> |
44 |
| - <ThemedText type="subtitle">Step 3: Get a fresh start</ThemedText> |
45 |
| - <ThemedText> |
46 |
| - When you're ready, run{' '} |
47 |
| - <ThemedText type="defaultSemiBold">npm run reset-project</ThemedText> to get a fresh{' '} |
48 |
| - <ThemedText type="defaultSemiBold">app</ThemedText> directory. This will move the current{' '} |
49 |
| - <ThemedText type="defaultSemiBold">app</ThemedText> to{' '} |
50 |
| - <ThemedText type="defaultSemiBold">app-example</ThemedText>. |
51 |
| - </ThemedText> |
52 |
| - </ThemedView> |
53 |
| - </ParallaxScrollView> |
| 44 | + ))} |
| 45 | + </View> |
54 | 46 | );
|
55 | 47 | }
|
56 | 48 |
|
|
0 commit comments