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-20 02:56:49 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b7bf49c6a5b1dd5485f8c079291faba454f55b70
b7bf49c6
1 parent
2203f80c
[frontend] 2021-05-19
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
538 additions
and
56 deletions
frontend/README.md
frontend/flutter_application_1/.env
frontend/flutter_application_1/lib/src/screens/DashBoard.dart
frontend/flutter_application_1/lib/src/screens/MainPage.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/SignUpLocal.dart
frontend/flutter_application_1/lib/src/screens/models/Bottle.dart
frontend/README.md
View file @
b7bf49c
...
...
@@ -55,3 +55,7 @@ appbar 관련 디자인은 추후 구현 예정
+
server test 완료
### 2021-05-18
+
회원 가입 SERVER 연동
### 2021-05-19
+
Login 연동
+
약병 등록 ,허브 등록 구현
...
...
frontend/flutter_application_1/.env
View file @
b7bf49c
SERVER_URL=포트 주소
\ No newline at end of file
SERVER_URL=
\ No newline at end of file
...
...
frontend/flutter_application_1/lib/src/screens/DashBoard.dart
View file @
b7bf49c
import
'package:flutter/material.dart'
;
import
'package:Smart_Medicine_Box/src/screens/SettingPage.dart'
;
import
'dart:convert'
;
import
'package:shared_preferences/shared_preferences.dart'
;
import
'package:http/http.dart'
as
http
;
import
'package:flutter_dotenv/flutter_dotenv.dart'
;
class
DashBoard
extends
StatefulWidget
{
int
pageNumber
=
1
;
...
...
@@ -108,6 +112,15 @@ class _DashBoardState extends State<DashBoard> {
}
Widget
mainpage
(
BuildContext
context
)
{
Future
<
String
>
getHubList
()
async
{
SharedPreferences
prefs
=
await
SharedPreferences
.
getInstance
();
http
.
Response
response
=
await
http
.
get
(
Uri
.
encodeFull
(
DotEnv
().
env
[
'SERVER_URL'
]
+
'hub'
));
print
(
response
.
statusCode
);
}
final
Size
size
=
MediaQuery
.
of
(
context
).
size
;
/*
Main 화면
...
...
@@ -191,6 +204,27 @@ Widget mainpage(BuildContext context) {
],
),
),
Container
(
height:
80
,
padding:
const
EdgeInsets
.
fromLTRB
(
20
,
20
,
20
,
20
),
child:
RaisedButton
(
onPressed:
()
async
{
String
saveMessage
=
await
getHubList
();
},
shape:
RoundedRectangleBorder
(
borderRadius:
new
BorderRadius
.
circular
(
18.0
),
side:
BorderSide
(
color:
Colors
.
blue
)),
color:
Color
(
0xff1674f6
),
child:
Text
(
'회원 가입'
,
textScaleFactor:
1.0
,
style:
TextStyle
(
fontSize:
16
,
color:
Colors
.
white
,
fontWeight:
FontWeight
.
bold
),
),
),
)
],
),
),
...
...
frontend/flutter_application_1/lib/src/screens/MainPage.dart
deleted
100644 → 0
View file @
2203f80
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'../shared/colors.dart'
;
import
'package:flutter_screenutil/flutter_screenutil.dart'
;
class
MainPage
extends
StatefulWidget
{
@override
_MainPageState
createState
()
=>
_MainPageState
();
}
class
_MainPageState
extends
State
<
MainPage
>
{
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
title:
'Welcome to Flutter'
,
home:
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'Welcome to Flutter'
),
),
body:
Center
(
child:
Text
(
'Main PAge 작업 영역'
),
),
),
);
}
}
frontend/flutter_application_1/lib/src/screens/RegisterBottle.dart
0 → 100644
View file @
b7bf49c
import
'package:Smart_Medicine_Box/src/screens/DashBoard.dart'
;
import
'package:flutter/cupertino.dart'
;
import
'dart:convert'
;
import
'package:flutter/material.dart'
;
import
'package:http/http.dart'
as
http
;
import
'package:flutter_dotenv/flutter_dotenv.dart'
;
class
RegsiterBottle
extends
StatefulWidget
{
final
String
hubid
;
RegsiterBottle
({
Key
key
,
this
.
hubid
})
:
super
(
key:
key
);
@override
_RegsiterBottleState
createState
()
=>
_RegsiterBottleState
();
}
class
_RegsiterBottleState
extends
State
<
RegsiterBottle
>
{
final
medicineBottleIDController
=
TextEditingController
();
final
medicineHubIDController
=
TextEditingController
();
final
medicineHubPortController
=
TextEditingController
();
final
medicineHubHostController
=
TextEditingController
();
Future
<
String
>
registerhub_Validate
()
async
{
http
.
Response
bottleresponse
=
await
http
.
post
(
Uri
.
encodeFull
(
DotEnv
().
env
[
'SERVER_URL'
]
+
'bottle'
),
headers:
{
"Content-Type"
:
"application/json"
},
body:
jsonEncode
({
'bottleId'
:
medicineBottleIDController
.
text
,
'hubId'
:
widget
.
hubid
}));
if
(
bottleresponse
.
statusCode
==
201
)
{
return
"등록 완료"
;
}
else
if
(
bottleresponse
.
statusCode
==
404
)
{
return
"Hub 없음"
;
}
else
if
(
bottleresponse
.
statusCode
==
403
)
{
return
"유저 정보 없음 "
;
}
else
if
(
bottleresponse
.
statusCode
==
404
)
{
return
"HOST 없음"
;
}
else
{
return
"오류"
;
}
}
Widget
build
(
BuildContext
context
)
{
final
Size
size
=
MediaQuery
.
of
(
context
).
size
;
// int goals = 60;
// int points = 75;
return
Scaffold
(
backgroundColor:
Colors
.
white
,
body:
ListView
(
children:
<
Widget
>[
Padding
(
padding:
const
EdgeInsets
.
fromLTRB
(
20
,
25
,
20
,
0
),
child:
Row
(
children:
<
Widget
>[
Text
(
'약병 등록'
,
textScaleFactor:
1.0
,
style:
TextStyle
(
fontSize:
34
),
)
],
),
),
Padding
(
padding:
const
EdgeInsets
.
fromLTRB
(
20
,
10
,
20
,
0
),
child:
Row
(
children:
<
Widget
>[
Text
(
'SmartMedicine 회원가입'
,
textScaleFactor:
1.0
,
style:
TextStyle
(
fontSize:
16
),
)
],
),
),
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
textScaleFactor:
1.0
),
child:
Container
(
height:
size
.
height
*
0.6
,
child:
Padding
(
padding:
const
EdgeInsets
.
fromLTRB
(
20
,
5
,
20
,
20
),
child:
new
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
TextFormField
(
keyboardType:
TextInputType
.
text
,
controller:
medicineBottleIDController
,
decoration:
InputDecoration
(
labelText:
'약병 ID'
,
helperText:
'현재 사용하시는 약병의 고유번호를 입력하세요'
,
),
),
],
),
),
),
),
Container
(
height:
80
,
padding:
const
EdgeInsets
.
fromLTRB
(
20
,
20
,
20
,
20
),
child:
RaisedButton
(
onPressed:
()
async
{
String
saveMessage
=
await
registerhub_Validate
();
print
(
saveMessage
);
if
(
saveMessage
==
"등록 완료"
)
{
showDialog
(
context:
context
,
builder:
(
BuildContext
context
)
{
return
AlertDialog
(
title:
new
Text
(
'약병 등록'
),
content:
new
Text
(
'약병 등록이 완료 되었습니다.'
),
actions:
<
Widget
>[
new
FlatButton
(
child:
new
Text
(
'Close'
),
onPressed:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=>
DashBoard
(
pageNumber:
1
,
)));
})
],
);
});
}
else
{
showDialog
(
context:
context
,
builder:
(
BuildContext
context
)
{
return
AlertDialog
(
title:
new
Text
(
'약병 등록'
),
content:
new
Text
(
saveMessage
),
actions:
<
Widget
>[
new
FlatButton
(
child:
new
Text
(
'Close'
),
onPressed:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=>
DashBoard
(
pageNumber:
1
,
)));
})
],
);
});
}
},
shape:
RoundedRectangleBorder
(
borderRadius:
new
BorderRadius
.
circular
(
18.0
),
side:
BorderSide
(
color:
Colors
.
blue
)),
color:
Color
(
0xff1674f6
),
child:
Text
(
'약병 등록'
,
textScaleFactor:
1.0
,
style:
TextStyle
(
fontSize:
16
,
color:
Colors
.
white
,
fontWeight:
FontWeight
.
bold
),
),
),
)
],
),
bottomNavigationBar:
BottomAppBar
(
elevation:
0
,
child:
Container
(
height:
70
,
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
children:
<
Widget
>[
Padding
(
padding:
const
EdgeInsets
.
fromLTRB
(
70
,
0
,
70
,
0
),
child:
Text
(
'회원 가입시, 이용 약관 및 개인정보 처리 방침에 동의하는 것으로 간주합니다..'
,
style:
TextStyle
(
fontSize:
12
,
color:
Color
(
0xff747474
)),
textAlign:
TextAlign
.
center
,
),
)
],
),
),
),
);
}
}
frontend/flutter_application_1/lib/src/screens/RegsiterHub.dart
0 → 100644
View file @
b7bf49c
import
'package:flutter/cupertino.dart'
;
import
'dart:convert'
;
import
'package:flutter/material.dart'
;
import
'package:http/http.dart'
as
http
;
import
'package:flutter_dotenv/flutter_dotenv.dart'
;
import
'RegisterBottle.dart'
;
class
RegsiterHub
extends
StatefulWidget
{
@override
_RegsiterHubState
createState
()
=>
_RegsiterHubState
();
}
class
_RegsiterHubState
extends
State
<
RegsiterHub
>
{
final
medicineBottleIDController
=
TextEditingController
();
final
medicineHubIDController
=
TextEditingController
();
final
medicineHubPortController
=
TextEditingController
();
final
medicineHubHostController
=
TextEditingController
();
Future
<
String
>
registerhub_Validate
()
async
{
http
.
Response
hubresponse
=
await
http
.
post
(
Uri
.
encodeFull
(
DotEnv
().
env
[
'SERVER_URL'
]
+
'hub'
),
headers:
{
"Content-Type"
:
"application/json"
},
body:
jsonEncode
({
'hubId'
:
medicineHubIDController
.
text
,
'host'
:
medicineHubHostController
.
text
,
'port'
:
medicineHubPortController
.
text
,
}));
if
(
hubresponse
.
statusCode
==
201
)
{
return
"허브 등록 완료"
;
}
else
if
(
hubresponse
.
statusCode
==
409
)
{
return
"이미 존재하는 hub"
;
}
else
{
return
"오류"
;
}
}
Widget
build
(
BuildContext
context
)
{
final
Size
size
=
MediaQuery
.
of
(
context
).
size
;
// int goals = 60;
// int points = 75;
return
Scaffold
(
backgroundColor:
Colors
.
white
,
body:
ListView
(
children:
<
Widget
>[
Padding
(
padding:
const
EdgeInsets
.
fromLTRB
(
20
,
25
,
20
,
0
),
child:
Row
(
children:
<
Widget
>[
Text
(
'약병 등록'
,
textScaleFactor:
1.0
,
style:
TextStyle
(
fontSize:
34
),
)
],
),
),
Padding
(
padding:
const
EdgeInsets
.
fromLTRB
(
20
,
10
,
20
,
0
),
child:
Row
(
children:
<
Widget
>[
Text
(
'SmartMedicine 회원가입'
,
textScaleFactor:
1.0
,
style:
TextStyle
(
fontSize:
16
),
)
],
),
),
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
textScaleFactor:
1.0
),
child:
Container
(
height:
size
.
height
*
0.6
,
child:
Padding
(
padding:
const
EdgeInsets
.
fromLTRB
(
20
,
5
,
20
,
20
),
child:
new
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
TextFormField
(
keyboardType:
TextInputType
.
text
,
controller:
medicineHubIDController
,
decoration:
InputDecoration
(
labelText:
'허브 ID'
,
helperText:
'현자 등록하시는 허브의 고유 번호를 입력하세요'
,
),
),
TextFormField
(
keyboardType:
TextInputType
.
text
,
controller:
medicineHubHostController
,
decoration:
InputDecoration
(
labelText:
'Host'
,
helperText:
'현재 사용하시는 허브의 HOST를 입력하세요'
,
),
),
TextFormField
(
keyboardType:
TextInputType
.
text
,
controller:
medicineHubPortController
,
decoration:
InputDecoration
(
labelText:
'Port'
,
helperText:
'현재 사용하시는 허브의 PORT를 입력하세요'
,
),
),
],
),
),
),
),
Container
(
height:
80
,
padding:
const
EdgeInsets
.
fromLTRB
(
20
,
20
,
20
,
20
),
child:
RaisedButton
(
onPressed:
()
async
{
String
saveMessage
=
await
registerhub_Validate
();
print
(
saveMessage
);
if
(
saveMessage
==
"허브 등록 완료"
)
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=>
RegsiterBottle
(
hubid:
medicineHubIDController
.
text
),
));
}
},
shape:
RoundedRectangleBorder
(
borderRadius:
new
BorderRadius
.
circular
(
18.0
),
side:
BorderSide
(
color:
Colors
.
blue
)),
color:
Color
(
0xff1674f6
),
child:
Text
(
' 허브 등록 '
,
textScaleFactor:
1.0
,
style:
TextStyle
(
fontSize:
16
,
color:
Colors
.
white
,
fontWeight:
FontWeight
.
bold
),
),
),
)
],
),
bottomNavigationBar:
BottomAppBar
(
elevation:
0
,
child:
Container
(
height:
70
,
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
children:
<
Widget
>[
Padding
(
padding:
const
EdgeInsets
.
fromLTRB
(
70
,
0
,
70
,
0
),
child:
Text
(
'회원 가입시, 이용 약관 및 개인정보 처리 방침에 동의하는 것으로 간주합니다..'
,
style:
TextStyle
(
fontSize:
12
,
color:
Color
(
0xff747474
)),
textAlign:
TextAlign
.
center
,
),
)
],
),
),
),
);
}
}
frontend/flutter_application_1/lib/src/screens/SignInPage.dart
View file @
b7bf49c
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
'package:shared_preferences/shared_preferences.dart'
;
import
'./DashBoard.dart'
;
import
'RegsiterHub.dart'
;
class
SignInPage
extends
StatefulWidget
{
@override
...
...
@@ -15,6 +20,40 @@ class _SignInPageState extends State<SignInPage> {
final
emailController
=
TextEditingController
();
final
passwordController
=
TextEditingController
();
//Login 함수
Future
<
String
>
login
(
String
_email
,
String
_password
)
async
{
http
.
Response
response
=
await
http
.
post
(
Uri
.
encodeFull
(
DotEnv
().
env
[
'SERVER_URL'
]
+
'auth/login'
),
headers:
{
"Content-Type"
:
"application/json"
},
body:
jsonEncode
({
'userId'
:
_email
,
'password'
:
_password
,
}));
if
(
response
.
statusCode
==
200
)
{
return
"로그인 성공"
;
}
else
if
(
response
.
statusCode
==
400
)
{
return
"올바르지 않은 아이디 및 패스워드"
;
}
else
{
return
"존재하지 않는 아이디 이거나 비밀번호가 불일치 합니다."
;
}
}
//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'
));
if
(
response
.
statusCode
==
200
)
{
return
"get완료"
;
}
else
if
(
response
.
statusCode
==
404
)
{
return
"Not Found"
;
}
else
{
return
"Error"
;
}
}
Widget
build
(
BuildContext
context
)
{
final
Size
size
=
MediaQuery
.
of
(
context
).
size
;
final
mqData
=
MediaQuery
.
of
(
context
);
...
...
@@ -142,7 +181,9 @@ class _SignInPageState extends State<SignInPage> {
fontFamily:
'Noto'
,
fontWeight:
FontWeight
.
bold
)),
onPressed:
()
async
{
String
saveMessage
;
String
saveMessage
=
await
login
(
emailController
.
text
,
passwordController
.
text
);
if
(
emailController
.
text
.
isEmpty
||
passwordController
.
text
.
isEmpty
)
{
showDialog
(
...
...
@@ -163,18 +204,27 @@ class _SignInPageState extends State<SignInPage> {
);
});
}
else
{
emailController
.
text
=
emailController
.
text
.
trim
();
passwordController
.
text
=
passwordController
.
text
.
trim
();
saveMessage
=
"로그인 성공"
;
if
(
saveMessage
==
"로그인 성공"
)
{
var
result
=
await
getHubList
();
print
(
result
);
if
(
result
==
"Not Found"
)
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=>
RegsiterHub
(),
));
}
else
if
(
result
==
"get완료"
)
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=>
builder:
(
BuildContext
context
)
=>
DashBoard
(
pageNumber:
1
),
));
}
else
{}
}
}
},
...
...
frontend/flutter_application_1/lib/src/screens/SignUpLocal.dart
View file @
b7bf49c
...
...
@@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
import
'package:http/http.dart'
as
http
;
import
'package:flutter_dotenv/flutter_dotenv.dart'
;
import
'Homepage.dart'
;
class
SignUpLocal
extends
StatefulWidget
{
@override
_SignUpLocalState
createState
()
=>
_SignUpLocalState
();
...
...
@@ -12,9 +14,6 @@ class _SignUpLocalState extends State<SignUpLocal> {
final
emailController
=
TextEditingController
();
final
passwordController
=
TextEditingController
();
final
passwordValidController
=
TextEditingController
();
final
medicineNameController
=
TextEditingController
();
final
medicineFactureController
=
TextEditingController
();
bool
_validate
=
false
;
int
userRole
=
0
;
...
...
@@ -31,6 +30,13 @@ class _SignUpLocalState extends State<SignUpLocal> {
'password'
:
passwordController
.
text
,
'passwordCheck'
:
passwordValidController
.
text
}));
print
(
response
.
statusCode
);
if
(
response
.
statusCode
==
201
)
{
return
"정보 입력 완료"
;
}
else
{
return
"오류"
;
}
}
@override
...
...
@@ -150,22 +156,6 @@ class _SignUpLocalState extends State<SignUpLocal> {
),
),
),
TextFormField
(
keyboardType:
TextInputType
.
text
,
controller:
medicineNameController
,
decoration:
InputDecoration
(
labelText:
'약 이름'
,
helperText:
'약의 이름을 읿력하세요'
,
),
),
TextFormField
(
keyboardType:
TextInputType
.
text
,
controller:
medicineFactureController
,
decoration:
InputDecoration
(
labelText:
'약 제조사 이름'
,
helperText:
'약 제조사의 이름을 읿력하세요'
,
),
),
],
),
),
...
...
@@ -177,11 +167,43 @@ class _SignUpLocalState extends State<SignUpLocal> {
child:
RaisedButton
(
onPressed:
()
async
{
String
saveMessage
=
await
signup_Validate
();
print
(
'saveMessage'
);
print
(
saveMessage
);
print
(
emailController
.
text
);
print
(
passwordController
.
text
);
print
(
passwordValidController
.
text
);
if
(
saveMessage
==
"정보 입력 완료"
)
{
showDialog
(
context:
context
,
builder:
(
BuildContext
context
)
{
return
AlertDialog
(
title:
new
Text
(
'회원 가입'
),
content:
new
Text
(
'회원 가입이 완료 되었습니다.'
),
actions:
<
Widget
>[
new
FlatButton
(
child:
new
Text
(
'Close'
),
onPressed:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=>
HomePage
()));
})
],
);
});
}
else
{
showDialog
(
context:
context
,
builder:
(
BuildContext
context
)
{
return
AlertDialog
(
title:
new
Text
(
'회원 가입 오류'
),
content:
new
Text
(
'정확한 이메일, 비밀번호를 입력해 주세요.'
),
actions:
<
Widget
>[
new
FlatButton
(
child:
new
Text
(
'Close'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pop
();
})
],
);
});
}
},
shape:
RoundedRectangleBorder
(
borderRadius:
new
BorderRadius
.
circular
(
18.0
),
...
...
frontend/flutter_application_1/lib/src/screens/models/Bottle.dart
0 → 100644
View file @
b7bf49c
class
Bottle
{
final
int
bottleId
;
final
int
temperature
;
final
int
humidity
;
final
int
balance
;
final
DateTime
recentOpen
;
final
int
medicineId
;
final
int
hubId
;
final
int
dosage
;
Bottle
(
{
this
.
bottleId
,
this
.
temperature
,
this
.
humidity
,
this
.
balance
,
this
.
recentOpen
,
this
.
medicineId
,
this
.
hubId
,
this
.
dosage
});
factory
Bottle
.
fromJson
(
Map
<
String
,
dynamic
>
parsedJson
)
{
var
list
=
parsedJson
[
'data'
]
as
List
;
return
Bottle
(
bottleId:
parsedJson
[
'bottleId'
],
temperature:
parsedJson
[
'temperature'
],
humidity:
parsedJson
[
'humidity'
],
balance:
parsedJson
[
'balance'
],
recentOpen:
parsedJson
[
'recentOpen'
],
medicineId:
parsedJson
[
'medicineId'
],
hubId:
parsedJson
[
'hubId'
],
dosage:
parsedJson
[
'dosage'
],
);
}
Map
<
String
,
dynamic
>
toJson
()
=>
{
"bottleId"
:
bottleId
,
"temperature"
:
temperature
,
"humidity:"
:
humidity
,
"balance"
:
balance
,
"recentOpen"
:
recentOpen
,
"medicineId"
:
medicineId
,
"hubId"
:
hubId
,
"dosage"
:
dosage
,
};
}
Please
register
or
login
to post a comment