-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
66 lines (61 loc) · 1.68 KB
/
App.js
File metadata and controls
66 lines (61 loc) · 1.68 KB
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
import React, { useEffect, useState } from 'react';
import { FlatList, Text, View, StyleSheet, ImageBackground } from 'react-native';
import { StatusBar } from 'expo-status-bar';
export default App = () => {
const [isLoading, setLoading] = useState(true);
const [data, setData] = useState([]);
useEffect(() => {
fetch('http://api.wordnik.com/v4/words.json/wordOfTheDay?api_key=a2a73e7b926c924fad7001ca3111acd55af2ffabf50eb4ae5')
.then((response) => response.json())
.then((json) => setData(json))
.catch((error) => console.error(error))
.finally(() => setLoading(false));
}, []);
return (
<ImageBackground source={require("./assets/pexels-anand-dandekar-1532771.jpg")} style={styles.image}>
<View style={styles.container}>
{isLoading ? <Text>Loading...</Text> :
(
<>
<Text style={styles.word}>{data["word"]}</Text>
<Text style={styles.meaning}>{data.definitions[0].text}</Text>
<StatusBar style="auto" />
</>
)}
</View>
</ImageBackground>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
justifyContent: 'center',
},
title: {
fontSize: 30,
},
word: {
fontWeight: "bold",
marginTop: "5%",
fontSize: 40,
color: "white",
textShadowColor: "black",
textShadowOffset: {width: -0.5, height: 0.5},
textShadowRadius: 5,
shadowOpacity: 20
},
meaning: {
marginTop: "5%",
fontStyle: "italic",
fontSize: 20,
color: "white",
textShadowColor: "black",
textShadowOffset: {width: -0.5, height: 0.5},
textShadowRadius: 5
},
image: {
flex: 1,
justifyContent: "center"
},
});