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-17 14:24:13 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
dfd529d0709d04e29b34d0d00fc36bc92ea85b5d
dfd529d0
1 parent
73cb7ecb
login check
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
7 deletions
App.js
source/AppTabNavigator/SettingTab.js
source/MainScreen.js
source/component/DBhelper.js
App.js
View file @
dfd529d
...
...
@@ -5,6 +5,7 @@ import { createStackNavigator } from 'react-navigation-stack'
// import MainScreen from './components/MainScreen';
import
Login
from
'./source/Login'
;
import
MainScreen
from
'./source/MainScreen'
;
import
{
getId
}
from
'./source/component/DBhelper'
// const AppStackNavigator = createStackNavigator({
// Main:{
...
...
@@ -14,11 +15,18 @@ import MainScreen from './source/MainScreen';
// export default createAppContainer(AppStackNavigator);
var
initialName
=
''
if
(
getId
()
==
true
){
initialName
=
'MainScreen'
}
else
initialName
=
'Login'
const
MainNavigator
=
createStackNavigator
({
Login
:
{
screen
:
Login
},
MainScreen
:
{
screen
:
MainScreen
},
},
{
initialRouteName
:
'Login'
,
headerMode
:
'none'
}
{
initialRouteName
:
initialName
,
headerMode
:
'none'
}
);
const
App
=
createAppContainer
(
MainNavigator
);
...
...
source/AppTabNavigator/SettingTab.js
View file @
dfd529d
import
React
,
{
Component
}
from
'react'
;
import
{
View
,
Text
,
StyleSheet
,
TextInput
,
TouchableOpacity
,
Image
}
from
'react-native'
;
import
AddButton
from
'../component/AddButton'
import
{
delete_all_data
}
from
'../component/DBhelper'
import
{
delete_all_data
,
deleteId
}
from
'../component/DBhelper'
var
date
=
new
Date
();
date
.
setHours
(
date
.
getHours
()
+
9
);
...
...
@@ -40,7 +40,9 @@ export default class SettingTab extends Component {
delete_id
(){
this
.
setState
({
ID
:
''
})
//save_app_data()
delete_all_data
()
//delete_all_data()
deleteId
()
this
.
props
.
navigation
.
navigate
(
'Login'
);
}
render
()
{
return
(
...
...
source/MainScreen.js
View file @
dfd529d
...
...
@@ -5,6 +5,7 @@ import { createMaterialTopTabNavigator } from 'react-navigation-tabs'
import
HomeTab
from
'./AppTabNavigator/HomeTab'
import
HistoryTab
from
'./AppTabNavigator/HistoryTab'
import
SettingTab
from
'./AppTabNavigator/SettingTab'
import
{
registerID
}
from
'../source/component/DBhelper'
// 하단 탭 네비게이터 생성
const
AppTabNavigator
=
createMaterialTopTabNavigator
({
...
...
@@ -39,14 +40,14 @@ export default class MainScreen extends Component {
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
ID
:
this
.
props
.
navigation
.
getParam
(
'ID'
),
ID
:
this
.
props
.
navigation
.
getParam
(
'ID'
,
''
),
};
}
static
navigationOptions
=
{
title
:
'FW IOT'
}
render
()
{
//registerID(this.state.ID);
return
<
AppTabContainet
/>
;
// AppTabContainet 컴포넌트를 리턴한다.
}
}
...
...
source/component/DBhelper.js
View file @
dfd529d
...
...
@@ -11,9 +11,41 @@ Waste.schema = {
}
};
// Get the default Realm with support for our objects
let
realm
=
new
Realm
({
schema
:
[
Waste
]});
class
ID
{}
ID
.
schema
=
{
name
:
'ID'
,
properties
:{
id
:
'string'
,
}
};
export
function
registerID
(
_id
){
if
(
_id
!=
''
){
realm
.
write
(()
=>
{
let
user
=
realm
.
create
(
'ID'
,{
id
:
_id
});
console
.
log
(
'success'
)
});
}
}
export
function
getId
(){
let
user
=
realm
.
objects
(
'ID'
);
console
.
log
(
user
.
length
);
if
(
user
.
length
>
0
)
return
true
;
return
false
;
}
export
function
deleteId
(){
let
user
=
realm
.
objects
(
'ID'
);
realm
.
write
(()
=>
{
realm
.
delete
(
user
);
console
.
log
(
'success'
)
})
}
// Get the default Realm with support for our objects
let
realm
=
new
Realm
({
schema
:
[
Waste
,
ID
]});
export
function
add_data
(
responseJson
){
for
(
i
=
0
;
i
<
responseJson
.
length
;
i
++
){
realm
.
write
(()
=>
{
...
...
@@ -36,7 +68,9 @@ export function get_now_weight(){
var
recentWeight
=
wastes
.
filtered
(
'date = $0'
,
recent
);
console
.
log
(
"now_weight"
,
recentWeight
)
if
(
recentWeight
.
length
!=
0
)
return
recentWeight
[
0
].
weight
;
else
return
0
;
}
export
function
get_last_update
(){
...
...
Please
register
or
login
to post a comment