Showing
2 changed files
with
23 additions
and
12 deletions
... | @@ -2,7 +2,7 @@ import React, { Component } from 'react'; | ... | @@ -2,7 +2,7 @@ import React, { Component } from 'react'; |
2 | import { View, Text, StyleSheet, SafeAreaView, ScrollView, Image } from 'react-native'; | 2 | import { View, Text, StyleSheet, SafeAreaView, ScrollView, Image } from 'react-native'; |
3 | import Circle from '../component/circle_component' | 3 | import Circle from '../component/circle_component' |
4 | import {Table, TableWrapper, Row,Rows} from 'react-native-table-component' | 4 | import {Table, TableWrapper, Row,Rows} from 'react-native-table-component' |
5 | -import {get_now_weight} from'../component/DBhelper.js'; | 5 | +import {get_now_weight, get_today_data} from'../component/DBhelper.js'; |
6 | 6 | ||
7 | var date = new Date(); | 7 | var date = new Date(); |
8 | date.setHours(date.getHours()+9); | 8 | date.setHours(date.getHours()+9); |
... | @@ -19,12 +19,7 @@ export default class HomeTab extends Component { | ... | @@ -19,12 +19,7 @@ export default class HomeTab extends Component { |
19 | // today : date.getFullYear() + "." + month + "." + date.getDate(), | 19 | // today : date.getFullYear() + "." + month + "." + date.getDate(), |
20 | today : "1576237044146.4011", | 20 | today : "1576237044146.4011", |
21 | current_weight : get_now_weight() , | 21 | current_weight : get_now_weight() , |
22 | - table_contents : [['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'],['오후','4:27:52', '+0.12kg', 'Total : 1.38kg'], | 22 | + table_contents : get_today_data() |
23 | - ['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'],['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'], | ||
24 | - ['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'],['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'], | ||
25 | - ['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'],['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'], | ||
26 | - ['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'],['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'] | ||
27 | - ] | ||
28 | } | 23 | } |
29 | } | 24 | } |
30 | 25 | ||
... | @@ -37,7 +32,7 @@ export default class HomeTab extends Component { | ... | @@ -37,7 +32,7 @@ export default class HomeTab extends Component { |
37 | }, | 32 | }, |
38 | body:JSON.stringify({ | 33 | body:JSON.stringify({ |
39 | ras_id : this.state.ID, | 34 | ras_id : this.state.ID, |
40 | - //date : this.state.today, | 35 | + //date : date, |
41 | date : "1576237047226.6567" | 36 | date : "1576237047226.6567" |
42 | }), | 37 | }), |
43 | }) | 38 | }) |
... | @@ -56,7 +51,7 @@ export default class HomeTab extends Component { | ... | @@ -56,7 +51,7 @@ export default class HomeTab extends Component { |
56 | return ( | 51 | return ( |
57 | <View style={style.container}> | 52 | <View style={style.container}> |
58 | <View style={style.header}> | 53 | <View style={style.header}> |
59 | - <Text style={style.tabName}>Home {this.state.ID}</Text> | 54 | + <Text style={style.tabName}>Home</Text> |
60 | </View> | 55 | </View> |
61 | <View style={{flexDirection:'row',flex:0.8,backgroundColor: "rgba(230,230,230,0.5)"}}> | 56 | <View style={{flexDirection:'row',flex:0.8,backgroundColor: "rgba(230,230,230,0.5)"}}> |
62 | <View style={{flex:1,justifyContent:'center'}}> | 57 | <View style={{flex:1,justifyContent:'center'}}> |
... | @@ -79,8 +74,8 @@ export default class HomeTab extends Component { | ... | @@ -79,8 +74,8 @@ export default class HomeTab extends Component { |
79 | <Text style={style.history}>Today's History</Text> | 74 | <Text style={style.history}>Today's History</Text> |
80 | <Table> | 75 | <Table> |
81 | <TableWrapper> | 76 | <TableWrapper> |
82 | - <Row data={['시간', '증감량', '총량']} flexArr={[2.5, 1.5, 1.5]} textStyle={style.row_style1}/> | 77 | + <Row data={['시간', '증감량', '총량']} flexArr={[1, 1, 1]} textStyle={style.row_style1}/> |
83 | - <Rows data={this.state.table_contents} flexArr={[1, 1.5, 1.5, 1.5]} textStyle={style.row_style2}/> | 78 | + <Rows data={this.state.table_contents} flexArr={[1, 1, 1]} textStyle={style.row_style2}/> |
84 | </TableWrapper> | 79 | </TableWrapper> |
85 | 80 | ||
86 | </Table> | 81 | </Table> | ... | ... |
... | @@ -54,7 +54,7 @@ export function add_data(responseJson){ | ... | @@ -54,7 +54,7 @@ export function add_data(responseJson){ |
54 | } | 54 | } |
55 | 55 | ||
56 | return responseJson.length; | 56 | return responseJson.length; |
57 | -} ㅊ | 57 | +} |
58 | 58 | ||
59 | export function get_now_weight(){ | 59 | export function get_now_weight(){ |
60 | let wastes = realm.objects('Waste'); | 60 | let wastes = realm.objects('Waste'); |
... | @@ -68,4 +68,20 @@ export function get_now_weight(){ | ... | @@ -68,4 +68,20 @@ export function get_now_weight(){ |
68 | export function get_recent_date(){ | 68 | export function get_recent_date(){ |
69 | 69 | ||
70 | return realm.objects('Waste').max("date"); | 70 | return realm.objects('Waste').max("date"); |
71 | +} | ||
72 | + | ||
73 | +export function get_today_data(today){ | ||
74 | + let wastes = realm.objects('Waste'); | ||
75 | + var list = []; | ||
76 | + for(var i =0; i<wastes.length; i++){ | ||
77 | + if(get_date(wastes[i].date) == get_date(today)){ | ||
78 | + temp = [waste[i].date, waste[i].diff, waste[i].weight] | ||
79 | + list.append(temp); | ||
80 | + } | ||
81 | + } | ||
82 | + return list; | ||
83 | +} | ||
84 | + | ||
85 | +var get_date = function (date){ | ||
86 | + return pad(date.getFullyear(),4)+pad(date.getMonth()+1, 2)+ pad(date.getDate(), 2) | ||
71 | } | 87 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment