-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
87 lines (78 loc) · 2.1 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import React, { useState } from 'react';
import { StyleSheet, Text, View, TouchableOpacity, useColorScheme } from 'react-native';
export default function App() {
const [cookieCount, setCookieCount ] = useState(0);
const handlePress = () => {
setCookieCount(cookieCount + 1);
};
const reset = () => {
setCookieCount(0);
}
const colorScheme = useColorScheme();
const themeTextStyle = colorScheme === 'light' ? styles.lightThemeText : styles.darkThemeText;
const themeContainerStyle =
colorScheme === 'light' ? styles.lightContainer : styles.darkContainer;
const themeButton =
colorScheme === 'light' ? styles.lightButton : styles.darkButton;
const themeTextButton =
colorScheme == 'light' ? styles.lightTextButton : styles.darkTextButton;
return (
<View style={[styles.container, themeContainerStyle]}>
<TouchableOpacity style={[styles.button, themeButton]} onPress={reset}>
<Text style={[styles.buttonText, themeTextButton]}>Resetar</Text>
</TouchableOpacity>
<Text style={[styles.cookieText, themeTextStyle]}>Toques: {cookieCount}</Text>
<TouchableOpacity style={[styles.button, themeButton]} onPress={handlePress}>
<Text style={[styles.buttonText, themeTextButton]}>Clique Aqui</Text>
</TouchableOpacity>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f5f5f5',
},
cookieText: {
fontSize: 32,
marginBottom: 20,
},
button: {
padding: 20,
borderRadius: 5,
margin: 10,
},
buttonText: {
fontSize: 30,
color: '#fff',
},
darkTextButton: {
color: '#2A314B',
},
lightTextButton: {
color: '#fff'
},
lightButton: {
backgroundColor: '#2A314B',
},
darkButton: {
backgroundColor: '#fff'
},
text: {
fontSize: 20,
},
lightContainer: {
backgroundColor: '#f5f5f5',
},
darkContainer: {
backgroundColor: '#242c40',
},
lightThemeText: {
color: '#242c40',
},
darkThemeText: {
color: '#fff',
},
})