Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design1
/
RIT_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
고원빈
2021-05-22 16:26:34 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8c5e6fb23a80eaf5617ec3d6b69020b974e48452
8c5e6fb2
1 parent
b7bf49c6
[frontend] 2021-05-20~2021-05-22
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
257 additions
and
16 deletions
frontend/README.md
frontend/flutter_application_1/.env
frontend/flutter_application_1/lib/src/screens/BottleList.dart
frontend/flutter_application_1/lib/src/screens/DashBoard.dart
frontend/flutter_application_1/lib/src/screens/HubList.dart
frontend/flutter_application_1/lib/src/screens/RegisterBottle.dart
frontend/flutter_application_1/lib/src/screens/RegsiterHub.dart
frontend/flutter_application_1/lib/src/screens/SignInPage.dart
frontend/flutter_application_1/lib/src/screens/models/Bottle.dart
frontend/flutter_application_1/lib/src/screens/models/Hub.dart
frontend/README.md
View file @
8c5e6fb
...
...
@@ -53,9 +53,17 @@ appbar 관련 디자인은 추후 구현 예정
### 2021-05-17
+
server test 완료
### 2021-05-18
+
회원 가입 SERVER 연동
### 2021-05-19
+
Login 연동
+
약병 등록 ,허브 등록 구현
### 2021-05-20
+
시나리오 수정
### 2021-05-21
+
약병 ,허브 리스트 출력 구현
...
...
frontend/flutter_application_1/.env
View file @
8c5e6fb
SERVER_URL=
\ No newline at end of file
SERVER_URL=http://192.168.0.3:4000/api/
\ No newline at end of file
...
...
frontend/flutter_application_1/lib/src/screens/BottleList.dart
0 → 100644
View file @
8c5e6fb
import
'dart:convert'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:http/http.dart'
as
http
;
import
'package:flutter_dotenv/flutter_dotenv.dart'
;
import
'models/Bottle.dart'
;
import
'DashBoard.dart'
;
class
BottleList
extends
StatefulWidget
{
List
<
Bottle
>
bottlelist
;
BottleList
({
Key
key
,
this
.
bottlelist
})
:
super
(
key:
key
);
@override
_BottleListState
createState
()
=>
_BottleListState
();
}
class
_BottleListState
extends
State
<
BottleList
>
{
Widget
build
(
BuildContext
context
)
{
final
Size
size
=
MediaQuery
.
of
(
context
).
size
;
return
Scaffold
(
body:
Container
(
height:
size
.
height
,
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
SizedBox
(
height:
70
),
Container
(
height:
size
.
height
*
0.1
,
width:
size
.
width
,
child:
Center
(
child:
Text
(
'등록된 약병 리스트'
,
textScaleFactor:
1.0
,
style:
TextStyle
(
fontSize:
28
,
fontFamily:
'Noto'
,
fontWeight:
FontWeight
.
bold
),
),
),
decoration:
BoxDecoration
(
border:
Border
.
all
()),
),
SizedBox
(
height:
30
),
Expanded
(
child:
ListView
.
separated
(
padding:
const
EdgeInsets
.
all
(
30
),
itemCount:
widget
.
bottlelist
.
length
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
Container
(
padding:
EdgeInsets
.
all
(
8.0
),
decoration:
BoxDecoration
(
border:
Border
.
all
()),
child:
ListTile
(
title:
Text
(
'BOTTLE ID : '
+
'
${widget.bottlelist[index].bottleId}
'
,
style:
TextStyle
(
color:
Colors
.
black
,
fontSize:
20
,
fontFamily:
'Noto'
,
fontWeight:
FontWeight
.
bold
),
),
trailing:
Icon
(
Icons
.
arrow_forward
),
onTap:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=>
DashBoard
(
pageNumber:
1
,
bottleID:
widget
.
bottlelist
[
index
].
bottleId
,
),
));
}),
);
},
separatorBuilder:
(
BuildContext
contetx
,
int
index
)
=>
const
Divider
(),
),
)
],
)),
);
}
}
frontend/flutter_application_1/lib/src/screens/DashBoard.dart
View file @
8c5e6fb
...
...
@@ -6,8 +6,9 @@ import 'package:http/http.dart' as http;
import
'package:flutter_dotenv/flutter_dotenv.dart'
;
class
DashBoard
extends
StatefulWidget
{
int
pageNumber
=
1
;
DashBoard
({
Key
key
,
this
.
pageNumber
})
:
super
(
key:
key
);
int
pageNumber
;
int
bottleID
;
DashBoard
({
Key
key
,
this
.
pageNumber
,
this
.
bottleID
})
:
super
(
key:
key
);
@override
_DashBoardState
createState
()
=>
_DashBoardState
();
...
...
frontend/flutter_application_1/lib/src/screens/HubList.dart
0 → 100644
View file @
8c5e6fb
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'dart:convert'
;
import
'package:http/http.dart'
as
http
;
import
'package:flutter_dotenv/flutter_dotenv.dart'
;
// Screen import
import
'RegisterBottle.dart'
;
import
'models/Bottle.dart'
;
import
'BottleList.dart'
;
class
HubList
extends
StatefulWidget
{
List
<
int
>
hublist
;
HubList
({
Key
key
,
this
.
hublist
})
:
super
(
key:
key
);
@override
_HubListState
createState
()
=>
_HubListState
();
}
class
_HubListState
extends
State
<
HubList
>
{
List
<
Bottle
>
_bottleList
=
new
List
<
Bottle
>();
//Get BottleList
Future
<
String
>
getBottleList
(
int
hubid
)
async
{
http
.
Response
response
=
await
http
.
get
(
Uri
.
encodeFull
(
DotEnv
().
env
[
'SERVER_URL'
]
+
'bottle/hub/'
+
hubid
.
toString
()));
if
(
_bottleList
.
length
!=
0
)
{
_bottleList
.
clear
();
}
if
(
response
.
statusCode
==
200
)
{
List
<
dynamic
>
values
=
new
List
<
dynamic
>();
values
=
json
.
decode
(
response
.
body
);
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
Map
<
String
,
dynamic
>
map
=
values
[
i
];
_bottleList
.
add
(
Bottle
.
fromJson
(
map
));
return
"GET"
;
}
}
else
if
(
response
.
statusCode
==
404
)
{
return
"Not Found"
;
}
else
{
return
"Error"
;
}
}
Widget
build
(
BuildContext
context
)
{
final
Size
size
=
MediaQuery
.
of
(
context
).
size
;
return
Scaffold
(
body:
Container
(
height:
size
.
height
,
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
SizedBox
(
height:
70
),
Container
(
height:
size
.
height
*
0.1
,
width:
size
.
width
,
child:
Center
(
child:
Text
(
'등록된 허브 리스트'
,
textScaleFactor:
1.0
,
style:
TextStyle
(
fontSize:
28
,
fontFamily:
'Noto'
,
fontWeight:
FontWeight
.
bold
),
),
),
decoration:
BoxDecoration
(
border:
Border
.
all
()),
),
SizedBox
(
height:
30
),
Expanded
(
child:
ListView
.
separated
(
padding:
const
EdgeInsets
.
all
(
30
),
itemCount:
widget
.
hublist
.
length
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
Container
(
padding:
EdgeInsets
.
all
(
8.0
),
decoration:
BoxDecoration
(
border:
Border
.
all
()),
child:
ListTile
(
title:
Text
(
'HUB ID: '
+
'
${widget.hublist[index]}
'
,
style:
TextStyle
(
color:
Colors
.
black
,
fontSize:
20
,
fontFamily:
'Noto'
,
fontWeight:
FontWeight
.
bold
),
),
trailing:
Icon
(
Icons
.
arrow_forward
),
onTap:
()
async
{
//허브 id로 가져와서 있으면 바로 넘기기
var
result
=
await
getBottleList
(
widget
.
hublist
[
index
]);
if
(
result
==
"GET"
)
{
print
(
0
);
print
(
_bottleList
);
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=>
BottleList
(
bottlelist:
_bottleList
,
),
));
}
else
if
(
result
==
"Not Found"
)
{
showDialog
(
context:
context
,
builder:
(
BuildContext
context
)
{
return
AlertDialog
(
title:
new
Text
(
'Error'
),
content:
new
Text
(
'등록된 약병이 없습니다.'
),
actions:
<
Widget
>[
new
FlatButton
(
child:
new
Text
(
'등록'
),
onPressed:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=>
RegisterBottle
(
hubid:
widget
.
hublist
[
index
]
.
toString
()),
));
})
],
);
});
}
}),
);
},
separatorBuilder:
(
BuildContext
contetx
,
int
index
)
=>
const
Divider
(),
),
)
],
)),
);
}
}
frontend/flutter_application_1/lib/src/screens/RegisterBottle.dart
View file @
8c5e6fb
...
...
@@ -5,14 +5,14 @@ import 'package:flutter/material.dart';
import
'package:http/http.dart'
as
http
;
import
'package:flutter_dotenv/flutter_dotenv.dart'
;
class
Reg
si
terBottle
extends
StatefulWidget
{
class
Reg
is
terBottle
extends
StatefulWidget
{
final
String
hubid
;
Reg
si
terBottle
({
Key
key
,
this
.
hubid
})
:
super
(
key:
key
);
Reg
is
terBottle
({
Key
key
,
this
.
hubid
})
:
super
(
key:
key
);
@override
_Reg
siterBottleState
createState
()
=>
_Regsi
terBottleState
();
_Reg
isterBottleState
createState
()
=>
_Regis
terBottleState
();
}
class
_Reg
siterBottleState
extends
State
<
Regsi
terBottle
>
{
class
_Reg
isterBottleState
extends
State
<
Regis
terBottle
>
{
final
medicineBottleIDController
=
TextEditingController
();
final
medicineHubIDController
=
TextEditingController
();
final
medicineHubPortController
=
TextEditingController
();
...
...
frontend/flutter_application_1/lib/src/screens/RegsiterHub.dart
View file @
8c5e6fb
...
...
@@ -6,12 +6,12 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
import
'RegisterBottle.dart'
;
class
Reg
si
terHub
extends
StatefulWidget
{
class
Reg
is
terHub
extends
StatefulWidget
{
@override
_Reg
siterHubState
createState
()
=>
_Regsi
terHubState
();
_Reg
isterHubState
createState
()
=>
_Regis
terHubState
();
}
class
_Reg
siterHubState
extends
State
<
Regsi
terHub
>
{
class
_Reg
isterHubState
extends
State
<
Regis
terHub
>
{
final
medicineBottleIDController
=
TextEditingController
();
final
medicineHubIDController
=
TextEditingController
();
final
medicineHubPortController
=
TextEditingController
();
...
...
@@ -119,7 +119,7 @@ class _RegsiterHubState extends State<RegsiterHub> {
context
,
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=>
Reg
si
terBottle
(
hubid:
medicineHubIDController
.
text
),
Reg
is
terBottle
(
hubid:
medicineHubIDController
.
text
),
));
}
},
...
...
frontend/flutter_application_1/lib/src/screens/SignInPage.dart
View file @
8c5e6fb
...
...
@@ -5,6 +5,7 @@ import 'package:http/http.dart' as http;
import
'package:flutter_dotenv/flutter_dotenv.dart'
;
import
'package:shared_preferences/shared_preferences.dart'
;
import
'./DashBoard.dart'
;
import
'HubList.dart'
;
import
'RegsiterHub.dart'
;
class
SignInPage
extends
StatefulWidget
{
...
...
@@ -20,6 +21,8 @@ class _SignInPageState extends State<SignInPage> {
final
emailController
=
TextEditingController
();
final
passwordController
=
TextEditingController
();
List
<
int
>
_hublist
=
new
List
<
int
>();
//허브이름을 만들어야 할 것 같은데 임시로 허브 id만 고르게 함
//Login 함수
Future
<
String
>
login
(
String
_email
,
String
_password
)
async
{
http
.
Response
response
=
await
http
.
post
(
...
...
@@ -41,10 +44,17 @@ class _SignInPageState extends State<SignInPage> {
//Get Bottle List 함수
Future
<
String
>
getHubList
()
async
{
SharedPreferences
prefs
=
await
SharedPreferences
.
getInstance
();
http
.
Response
response
=
await
http
.
get
(
Uri
.
encodeFull
(
DotEnv
().
env
[
'SERVER_URL'
]
+
'hub'
));
List
<
dynamic
>
values
=
new
List
<
dynamic
>();
values
=
json
.
decode
(
response
.
body
);
if
(
_hublist
.
length
!=
0
)
{
_hublist
.
clear
();
}
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
_hublist
.
add
(
values
[
i
][
'hubId'
]);
}
if
(
response
.
statusCode
==
200
)
{
return
"get완료"
;
}
else
if
(
response
.
statusCode
==
404
)
{
...
...
@@ -214,7 +224,7 @@ class _SignInPageState extends State<SignInPage> {
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=>
Reg
si
terHub
(),
Reg
is
terHub
(),
));
}
else
if
(
result
==
"get완료"
)
{
Navigator
.
push
(
...
...
@@ -222,7 +232,7 @@ class _SignInPageState extends State<SignInPage> {
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=>
DashBoard
(
pageNumber:
1
),
HubList
(
hublist:
_hublist
),
));
}
else
{}
}
...
...
frontend/flutter_application_1/lib/src/screens/models/Bottle.dart
View file @
8c5e6fb
...
...
@@ -3,7 +3,7 @@ class Bottle {
final
int
temperature
;
final
int
humidity
;
final
int
balance
;
final
DateTime
recentOpen
;
final
String
recentOpen
;
final
int
medicineId
;
final
int
hubId
;
final
int
dosage
;
...
...
frontend/flutter_application_1/lib/src/screens/models/Hub.dart
0 → 100644
View file @
8c5e6fb
Please
register
or
login
to post a comment