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-18 18:20:32 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
39cec65b80d9cc1f109c276695cd7a47386e9158
39cec65b
1 parent
07e19036
Delete test function
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
48 deletions
source/AppTabNavigator/HistoryTab.js
source/AppTabNavigator/HomeTab.js
source/AppTabNavigator/SettingTab.js
source/component/DBhelper.js
source/component/circle_component.js
source/AppTabNavigator/HistoryTab.js
View file @
39cec65
...
...
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
import
{
View
,
Text
,
StyleSheet
,
ScrollView
,
RefreshControl
}
from
'react-native'
;
import
HistoryGraph
from
'../component/HistoryGraph'
import
SegmentedControlTab
from
"react-native-segmented-control-tab"
;
import
{
get_id
,
add_data
,
get_week_data
,
get_month_data
,
get_year_data
,
add_temp
_data
}
from
'../component/DBhelper.js'
;
import
{
get_id
,
add_data
,
get_week_data
,
get_month_data
,
get_year
_data
}
from
'../component/DBhelper.js'
;
//var today = new Date();
//today.setHours(today.getHours()+9);
...
...
@@ -41,7 +41,6 @@ export default class HomeTab extends Component {
}
componentWillUnmount
()
{
// Remove the event listener
this
.
focusListener
.
remove
();
}
...
...
@@ -75,8 +74,7 @@ export default class HomeTab extends Component {
.
then
((
response
)
=>
response
.
json
())
.
then
((
responseJson
)
=>
{
console
.
log
(
responseJson
)
//add_data(responseJson)
add_temp_data
();
add_data
(
responseJson
)
},
function
(){
})
.
then
(()
=>
{
this
.
handleIndexChange
(
this
.
state
.
selectedIndex
)})
...
...
source/AppTabNavigator/HomeTab.js
View file @
39cec65
...
...
@@ -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
,
get_today_data
,
add_data
,
add_temp_data
,
get_id
}
from
'../component/DBhelper.js'
;
import
{
get_now_weight
,
get_today_data
,
add_data
,
get_id
}
from
'../component/DBhelper.js'
;
var
date
=
new
Date
();
date
.
setHours
(
date
.
getHours
()
+
9
);
...
...
@@ -24,16 +24,12 @@ export default class HomeTab extends Component {
componentDidMount
()
{
const
{
navigation
}
=
this
.
props
;
this
.
focusListener
=
navigation
.
addListener
(
'didFocus'
,
()
=>
{
this
.
setState
({
current_weight
:
get_now_weight
(),
table_contents
:
get_today_data
()
});
this
.
setState
({
current_weight
:
get_now_weight
(),
table_contents
:
get_today_data
()});
});
}
componentWillUnmount
()
{
// Remove the event listener
this
.
focusListener
.
remove
();
this
.
focusListener
.
remove
();
}
get_diff_data
(){
...
...
@@ -51,14 +47,10 @@ export default class HomeTab extends Component {
.
then
((
response
)
=>
response
.
json
())
.
then
((
responseJson
)
=>
{
console
.
log
(
responseJson
)
//add_data(responseJson);
add_temp_data
();
add_data
(
responseJson
);
},
function
(){
})
.
then
(()
=>
{
this
.
setState
({
current_weight
:
get_now_weight
(),
table_contents
:
get_today_data
()
})})
.
then
(()
=>
{
this
.
setState
({
current_weight
:
get_now_weight
(),
table_contents
:
get_today_data
()})})
.
catch
((
error
)
=>
{
console
.
error
(
error
);
})
...
...
source/AppTabNavigator/SettingTab.js
View file @
39cec65
...
...
@@ -17,7 +17,7 @@ export default class SettingTab extends Component {
}
save_app_data
(){
return
fetch
(
'http://
10.0.2.2:3000
/app/save_data/'
,{
return
fetch
(
'http://
testloadbalancer-1847561458.ap-northeast-2.elb.amazonaws.com
/app/save_data/'
,{
method
:
'POST'
,
headers
:
{
'Accept'
:
'application/json'
,
...
...
source/component/DBhelper.js
View file @
39cec65
...
...
@@ -67,23 +67,6 @@ export function add_data(responseJson){
return
responseJson
.
length
;
}
export
function
add_temp_data
(){
realm
.
write
(()
=>
{
let
myWaste
=
realm
.
create
(
'Waste'
,
{
weight
:
parseFloat
(
747
),
diff
:
parseFloat
(
257
),
date
:
parseFloat
(
1576691588000
),
});
});
realm
.
write
(()
=>
{
let
myWaste
=
realm
.
create
(
'Waste'
,
{
weight
:
parseFloat
(
1466
),
diff
:
parseFloat
(
468
),
date
:
parseFloat
(
1576650859000
),
});
});
}
export
function
get_now_weight
(){
let
wastes
=
realm
.
objects
(
'Waste'
);
let
recent
=
wastes
.
max
(
'date'
);
...
...
@@ -92,7 +75,8 @@ export function get_now_weight(){
console
.
log
(
"now_weight"
,
recentWeight
)
if
(
recentWeight
.
length
!=
0
)
return
recentWeight
[
recentWeight
.
length
-
1
].
weight
;
else
return
0
;
else
return
0
;
}
export
function
get_last_update
(){
...
...
@@ -107,18 +91,6 @@ 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;
// }
export
function
get_today_data
(){
var
today_start
=
get_today_start
();
console
.
log
(
"today_start: "
,
today_start
)
...
...
source/component/circle_component.js
View file @
39cec65
...
...
@@ -18,6 +18,15 @@ export default class LoginButton extends Component {
onPress
:
()
=>
null
,
}
componentDidUpdate
(
prevProps
,
prevState
){
if
(
this
.
props
.
data
!==
prevProps
.
data
)
{
this
.
setState
({
...
this
.
state
,
title
:
this
.
props
.
data
.
current_weight
})
}
}
render
()
{
return
(
<
TouchableOpacity
...
...
Please
register
or
login
to post a comment