Toggle navigation
Toggle navigation
This project
Loading...
Sign in
유희정
/
fwiot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
유희정
2019-12-14 13:01:38 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d9378bcb05fab585beca3deb49dc8d3726e643a4
d9378bcb
1 parent
26ef81c9
get today data from db
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
12 deletions
source/AppTabNavigator/HomeTab.js
source/component/DBhelper.js
source/AppTabNavigator/HomeTab.js
View file @
d9378bc
...
...
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
import
{
View
,
Text
,
StyleSheet
,
SafeAreaView
,
ScrollView
,
Image
}
from
'react-native'
;
import
Circle
from
'../component/circle_component'
import
{
Table
,
TableWrapper
,
Row
,
Rows
}
from
'react-native-table-component'
import
{
get_now_weight
}
from
'../component/DBhelper.js'
;
import
{
get_now_weight
,
get_today_data
}
from
'../component/DBhelper.js'
;
var
date
=
new
Date
();
date
.
setHours
(
date
.
getHours
()
+
9
);
...
...
@@ -19,12 +19,7 @@ export default class HomeTab extends Component {
// today : date.getFullYear() + "." + month + "." + date.getDate(),
today
:
"1576237044146.4011"
,
current_weight
:
get_now_weight
()
,
table_contents
:
[[
'오후'
,
'6:12:15'
,
'+0.25kg'
,
'Total : 1.5 kg'
],[
'오후'
,
'4:27:52'
,
'+0.12kg'
,
'Total : 1.38kg'
],
[
'오후'
,
'6:12:15'
,
'+0.25kg'
,
'Total : 1.5 kg'
],[
'오후'
,
'6:12:15'
,
'+0.25kg'
,
'Total : 1.5 kg'
],
[
'오후'
,
'6:12:15'
,
'+0.25kg'
,
'Total : 1.5 kg'
],[
'오후'
,
'6:12:15'
,
'+0.25kg'
,
'Total : 1.5 kg'
],
[
'오후'
,
'6:12:15'
,
'+0.25kg'
,
'Total : 1.5 kg'
],[
'오후'
,
'6:12:15'
,
'+0.25kg'
,
'Total : 1.5 kg'
],
[
'오후'
,
'6:12:15'
,
'+0.25kg'
,
'Total : 1.5 kg'
],[
'오후'
,
'6:12:15'
,
'+0.25kg'
,
'Total : 1.5 kg'
]
]
table_contents
:
get_today_data
()
}
}
...
...
@@ -37,7 +32,7 @@ export default class HomeTab extends Component {
},
body
:
JSON
.
stringify
({
ras_id
:
this
.
state
.
ID
,
//date :
this.state.today
,
//date :
date
,
date
:
"1576237047226.6567"
}),
})
...
...
@@ -56,7 +51,7 @@ export default class HomeTab extends Component {
return
(
<
View
style
=
{
style
.
container
}
>
<
View
style
=
{
style
.
header
}
>
<
Text
style
=
{
style
.
tabName
}
>
Home
{
this
.
state
.
ID
}
<
/Text
>
<
Text
style
=
{
style
.
tabName
}
>
Home
<
/Text
>
<
/View
>
<
View
style
=
{{
flexDirection
:
'row'
,
flex
:
0.8
,
backgroundColor
:
"rgba(230,230,230,0.5)"
}}
>
<
View
style
=
{{
flex
:
1
,
justifyContent
:
'center'
}}
>
...
...
@@ -79,8 +74,8 @@ export default class HomeTab extends Component {
<
Text
style
=
{
style
.
history
}
>
Today
's History</Text>
<Table>
<TableWrapper>
<Row data={['
시간
', '
증감량
', '
총량
']} flexArr={[
2.5, 1.5, 1.5
]} textStyle={style.row_style1}/>
<Rows data={this.state.table_contents} flexArr={[1, 1
.5, 1.5, 1.5
]} textStyle={style.row_style2}/>
<Row data={['
시간
', '
증감량
', '
총량
']} flexArr={[
1, 1, 1
]} textStyle={style.row_style1}/>
<Rows data={this.state.table_contents} flexArr={[1, 1
, 1
]} textStyle={style.row_style2}/>
</TableWrapper>
</Table>
...
...
source/component/DBhelper.js
View file @
d9378bc
...
...
@@ -54,7 +54,7 @@ export function add_data(responseJson){
}
return
responseJson
.
length
;
}
ㅊ
}
export
function
get_now_weight
(){
let
wastes
=
realm
.
objects
(
'Waste'
);
...
...
@@ -68,4 +68,20 @@ export function get_now_weight(){
export
function
get_recent_date
(){
return
realm
.
objects
(
'Waste'
).
max
(
"date"
);
}
export
function
get_today_data
(
today
){
let
wastes
=
realm
.
objects
(
'Waste'
);
var
list
=
[];
for
(
var
i
=
0
;
i
<
wastes
.
length
;
i
++
){
if
(
get_date
(
wastes
[
i
].
date
)
==
get_date
(
today
)){
temp
=
[
waste
[
i
].
date
,
waste
[
i
].
diff
,
waste
[
i
].
weight
]
list
.
append
(
temp
);
}
}
return
list
;
}
var
get_date
=
function
(
date
){
return
pad
(
date
.
getFullyear
(),
4
)
+
pad
(
date
.
getMonth
()
+
1
,
2
)
+
pad
(
date
.
getDate
(),
2
)
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment