-
Notifications
You must be signed in to change notification settings - Fork 0
/
DateWise.js
89 lines (83 loc) · 3.23 KB
/
DateWise.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
import React from "react"
import {View,Text,SectionList,TouchableWithoutFeedback} from "react-native"
import {AntDesign} from "@expo/vector-icons"
export default class DateWise extends React.Component{
constructor(props){
super(props)
this.updated = this.props.navigation.getParam('data')[0][this.props.navigation.getParam('data')[0].length-1]['date']
this.state ={data:this.props.navigation.getParam('data')[0],reversedData:this.props.navigation.getParam('data')[1]}
}
static navigationOptions = {
title:'Date Wise Analysis',
headerStyle:{
backgroundColor:'#3399FF'
}
}
sort=()=>{
var x = this.state.data
this.setState({data:this.state.reversedData,reversedData:x})
}
renderSubjects = ({item})=>{
console.log(item)
return (
<View >
<Text style={{alignSelf:'center'}}>{item.date}</Text>
<View style={{flexDirection:'row',marginTop:20,marginBottom:10,alignItems:'center',width:'100%',justifyContent:'space-between'}}>
<View style={{flexWrap:'wrap',maxWidth:'60%'}}>
<Text style={{marginLeft:20}}>{Object.keys(item)}</Text>
</View>
<View></View>
</View>
</View>
)
}
renderSectionHeader = ({section})=>{
return(
<View style={{marginTop:10}}>
<View style={{alignItems:'center',height:15}}>
<Text style={{fontSize:16,fontWeight:'bold'}}>
{section.date}
</Text>
</View>
</View>
)
}
renderItems = ({item})=>{
return (
<View >
<View style={{maxWidth:'80%',flexWrap:'wrap',flexDirection:'row',marginTop:20,marginBottom:10,alignItems:'center',width:'100%',justifyContent:'space-between'}}>
<View style={{flexWrap:'wrap',maxWidth:'60%'}}>
<Text style={{marginLeft:20}}>{Object.keys(item)}</Text>
</View>
<View><Text>{Object.values(item)}</Text></View>
</View>
<View style={{width:'100%',borderBottomWidth:0.5,marginTop:10}}/>
</View>
)
}
render(){
return (
<View>
<View style={{flexDirection:'row',justifyContent:'space-evenly',height:50,borderBottomWidth:1,width:'100%',alignItems:'center',backgroundColor:'#F0FFFF'}}>
<Text style={{fontSize:18}}>Updated till {this.updated}</Text>
<View style={{width:40}}>
<TouchableWithoutFeedback onPress={this.sort}>
<View>
<AntDesign size={20} name="filter" />
<Text>
Sort
</Text>
</View>
</TouchableWithoutFeedback>
</View>
</View>
<SectionList
sections = {this.state.data}
renderItem={this.renderItems}
renderSectionHeader={this.renderSectionHeader}
/>
<View style={{height:30}} />
</View>
)
}
}