-
Notifications
You must be signed in to change notification settings - Fork 0
/
CovidDataTable
124 lines (119 loc) · 3.32 KB
/
CovidDataTable
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
112
113
114
115
116
117
118
119
120
121
122
123
124
import React, { Component } from 'react';
import { StyleSheet,View, Button, Alert,Text, ActivityIndicator } from 'react-native';
import { ScrollView } from 'react-native-gesture-handler';
export default class App extends Component
{
constructor(props)
{
super(props);
this.state={
isLoading:true ,
dataSource:null,
};
}
componentDidMount()
{
return fetch('https://api.covid19india.org/data.json')
.then((response)=>response.json())
.then((responseJson)=>{
this.setState({
isLoading:false,
dataSource:responseJson.statewise
})
console.log(this.state.dataSource);
})
}
render(){
if(this.state.isLoading==true)
{
return(
<View>
<ActivityIndicator/>
</View>
);
}
else
{
let statewise=this.state.dataSource.map((val,key)=>{
return(
<View key={key}>
<View style={styles.textContainer}>
<Text style={styles.textformat}>{val.state}</Text>
<Text style={styles.confirmStyle}>{val.confirmed}</Text>
<Text style={styles.activeStyle}>{val.active}</Text>
<Text style={styles.deathStyle}>{val.deaths}</Text>
<Text style={styles.recoverStyle}>{val.recovered}</Text>
<Text style={styles.text}>{val.lastupdatedtime}</Text>
</View>
</View>
);
});
return(
<ScrollView>
<ScrollView horizontal>
<View style={styles.container}>
<View style={styles.textContainer}>
<Text style={styles.textformat}>STATE</Text>
<Text style={styles.confirmStyle}>CONFIRMED</Text>
<Text style={styles.activeStyle}>ACTIVE</Text>
<Text style={styles.deathStyle}>DEATH</Text>
<Text style={styles.recoverStyle}>RECOVERED</Text>
<Text style={styles.text}>LAST UPDATED</Text>
</View>
{statewise}
</View>
</ScrollView>
</ScrollView>
);
}
}
}
const styles=StyleSheet.create(
{
container:{
flex:1,
justifyContent:'center'
},
textContainer:{
backgroundColor:'#0f0f0f',
flexDirection:'row',
justifyContent:'space-between'
},
confirmStyle:
{
fontSize:24,
width:160,
color:'#f7e920'
},
activeStyle:
{
fontSize:24,
width:160,
color:'#f7ba00'
},
deathStyle:
{
fontSize:24,
width:160,
color:'#f50b07'
},
recoverStyle:
{
fontSize:24,
width:160,
color:'#1a961e'
},
textformat:
{
width:180,
fontSize:24,
color:'#ffffff'
},
text:
{
fontSize:24,
width:180,
color:'#f720da'
}
}
);