-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
111 lines (107 loc) · 2.56 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import { useEffect, useState } from "react";
import {
StyleSheet,
Text,
View,
Image,
StatusBar,
TouchableOpacity,
} from "react-native";
import axios from "axios";
export default function App() {
const [activity, setActivity] = useState("");
const fetchActivity = async () => {
try {
const response = await axios.get(
"https://www.boredapi.com/api/activity/"
);
setActivity(response.data.activity);
} catch (error) {
console.error("Error fetching activity:", error);
}
};
useEffect(() => {
fetchActivity();
}, []);
return (
<View style={styles.container}>
<View style={styles.screenContainer}>
<Text style={styles.Title}>BoredomBuddy</Text>
<Text style={styles.SubTitle}>Banish Boredom, Embrace Adventure!</Text>
<Image style={styles.mascot} source={require("./assets/mascot.png")} />
<Text style={{ ...styles.SubTitle, fontSize: 18, marginTop:20 }}>
Hello!{"\n"}Here is your task.
</Text>
<View style={styles.activityContainer}>
<Text style={styles.Task}>"{activity}"</Text>
</View>
<TouchableOpacity style={styles.Button} onPress={fetchActivity}>
<Text style={{ fontSize: 18, color: "aliceblue", fontWeight: "500" }}>
Get New Activity
</Text>
</TouchableOpacity>
</View>
<StatusBar backgroundColor="aliceblue" barStyle={"dark-content"} />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "aliceblue",
alignItems: "center",
justifyContent: "center",
},
mascot: {
marginTop:25,
height: 150,
width: 150,
},
screenContainer: {
flex: 1,
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "flex-start",
boxSizing: "borderBox",
width: "100%",
paddingVertical: 50,
},
Title: {
fontSize: 28,
fontWeight: "600",
color: "#1e2227",
},
SubTitle: {
fontSize: 14,
fontWeight: "300",
color: "#2c2e33",
textAlign: "center",
},
Task: {
marginVertical: "10%",
fontSize: 24,
width: "95%",
textAlign: "center",
height: "auto",
fontWeight: "300",
},
Button: {
backgroundColor: "#9D8DF1",
height: 50,
width: 160,
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
borderRadius: 8,
elevation:2
},
activityContainer:{
width:'90%',
height:300,
display:'flex',
alignItems:'center',
justifyContent:'flex-start'
}
});