-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
37 lines (31 loc) · 1019 Bytes
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { StatusBar } from 'expo-status-bar';
import { useState } from 'react';
import { Image, Pressable, StyleSheet, Text, View } from 'react-native';
import cookieImage from './assets/cookie.png';
export default function App() {
const [clicks, setClicks] = useState(0);
const [clicking, setClicking] = useState(false);
const handlePress = () => {
setClicks(clicks + 1);
}
const cookieSize = clicking ? 180 : 200;
const cookieStyle = { width: cookieSize, height: cookieSize };
return (
<View style={styles.container}>
<Text>Cookie Clicker 2</Text>
<Text>Clicks: {clicks}</Text>
<Pressable onPress={handlePress} onPressIn={() => setClicking(true)} onPressOut={() => setClicking(false)}>
<Image source={cookieImage} style={cookieStyle} />
</Pressable>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
}
});