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-27 12:39:08 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
104f91c884e09798a9702da2ec3a8061bee4ed78
104f91c8
1 parent
ba1656c2
[frontend] Error 해결
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
59 additions
and
53 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/Register/BottleList.dart
frontend/flutter_application_1/lib/src/screens/Register/DetailMedicine.dart
frontend/flutter_application_1/lib/src/screens/Register/HubList.dart
frontend/flutter_application_1/lib/src/screens/Register/RegisterBottle.dart
frontend/flutter_application_1/lib/src/screens/Register/RegsiterHub.dart
frontend/flutter_application_1/lib/src/screens/Register/SignInPage.dart
frontend/flutter_application_1/lib/src/screens/Register/SignUpLocal.dart
frontend/flutter_application_1/lib/src/utils/user_secure_stoarge.dart
frontend/README.md
View file @
104f91c
...
...
@@ -84,3 +84,6 @@ appbar 관련 디자인은 추후 구현 예정
### 2021-05-25
+
로그인 권한 문제 해결
### 2021-05-26
+
future buillder 변경
\ No newline at end of file
...
...
frontend/flutter_application_1/.env
View file @
104f91c
SERVER_URL=
\ No newline at end of file
SERVER_URL=http://192.168.0.3:4717/api/
\ No newline at end of file
...
...
frontend/flutter_application_1/lib/src/screens/DashBoard.dart
View file @
104f91c
This diff is collapsed. Click to expand it.
frontend/flutter_application_1/lib/src/screens/Register/BottleList.dart
View file @
104f91c
...
...
@@ -10,46 +10,13 @@ import '../../utils/user_secure_stoarge.dart';
class
BottleList
extends
StatefulWidget
{
List
<
Bottle
>
bottlelist
;
String
hubid
;
BottleList
({
Key
key
,
this
.
bottlelist
,
this
.
hubid
})
:
super
(
key:
key
);
BottleList
({
Key
key
,
this
.
bottlelist
})
:
super
(
key:
key
);
@override
_BottleListState
createState
()
=>
_BottleListState
();
}
class
_BottleListState
extends
State
<
BottleList
>
{
Bottle
_bottleinformation
=
new
Bottle
();
Medicine
_medicineinformation
=
new
Medicine
();
Future
<
Bottle
>
getbottle
(
int
index
)
async
{
String
usertoken
=
await
UserSecureStorage
.
getUserToken
();
http
.
Response
response
=
await
http
.
get
(
Uri
.
encodeFull
(
DotEnv
().
env
[
'SERVER_URL'
]
+
'bottle/'
+
widget
.
bottlelist
[
index
].
bottleId
.
toString
()),
headers:
{
"authorization"
:
usertoken
});
if
(
response
.
statusCode
==
200
)
{
Map
<
String
,
dynamic
>
jsonData
=
jsonDecode
(
response
.
body
);
print
(
jsonData
);
_bottleinformation
=
Bottle
.
fromJson
(
jsonData
);
}
}
Future
<
Bottle
>
getmedicine
(
int
index
)
async
{
String
usertoken
=
await
UserSecureStorage
.
getUserToken
();
http
.
Response
medicineresponse
=
await
http
.
get
(
Uri
.
encodeFull
(
DotEnv
().
env
[
'SERVER_URL'
]
+
'medicine/'
+
widget
.
bottlelist
[
index
].
medicineId
.
toString
()),
headers:
{
"authorization"
:
usertoken
},
);
if
(
medicineresponse
.
statusCode
==
200
)
{
Map
<
String
,
dynamic
>
data
=
jsonDecode
(
medicineresponse
.
body
);
_medicineinformation
=
Medicine
.
fromJson
(
data
);
}
}
Widget
build
(
BuildContext
context
)
{
final
Size
size
=
MediaQuery
.
of
(
context
).
size
;
return
Scaffold
(
...
...
@@ -97,15 +64,15 @@ class _BottleListState extends State<BottleList> {
),
trailing:
Icon
(
Icons
.
arrow_forward
),
onTap:
()
async
{
await
getbottle
(
index
);
await
getmedicine
(
index
);
UserSecureStorage
.
setBottleId
(
widget
.
bottlelist
[
index
].
bottleId
.
toString
());
UserSecureStorage
.
setMedicineId
(
widget
.
bottlelist
[
index
].
medicineId
.
toString
());
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=>
DashBoard
(
pageNumber:
1
,
bottleInformation:
_bottleinformation
,
medicineInformation:
_medicineinformation
,
),
),
);
...
...
frontend/flutter_application_1/lib/src/screens/Register/DetailMedicine.dart
View file @
104f91c
...
...
@@ -215,7 +215,9 @@ class _DetailMedicineState extends State<DetailMedicine> {
context
,
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=>
HomePage
(),
DashBoard
(
pageNumber:
1
,
),
),
);
})
...
...
frontend/flutter_application_1/lib/src/screens/Register/HubList.dart
View file @
104f91c
...
...
@@ -45,6 +45,7 @@ class _HubListState extends State<HubList> {
}
else
{
return
"Error"
;
}
return
"Error"
;
}
Widget
build
(
BuildContext
context
)
{
...
...
@@ -95,14 +96,15 @@ class _HubListState extends State<HubList> {
var
result
=
await
getBottleList
(
widget
.
hublist
[
index
]);
if
(
result
==
"GET"
)
{
UserSecureStorage
.
setHubId
(
widget
.
hublist
[
index
].
toString
());
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=>
BottleList
(
bottlelist:
_bottleList
,
hubid:
widget
.
hublist
[
index
]
.
toString
()),
),
));
}
else
if
(
result
==
"Not Found"
)
{
showDialog
(
...
...
@@ -115,15 +117,15 @@ class _HubListState extends State<HubList> {
new
FlatButton
(
child:
new
Text
(
'등록'
),
onPressed:
()
{
UserSecureStorage
.
setHubId
(
widget
.
hublist
[
index
]
.
toString
());
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=>
RegisterBottle
(
hubid:
widget
.
hublist
[
index
]
.
toString
()),
RegisterBottle
(),
));
})
],
...
...
frontend/flutter_application_1/lib/src/screens/Register/RegisterBottle.dart
View file @
104f91c
...
...
@@ -20,16 +20,16 @@ class _RegisterBottleState extends State<RegisterBottle> {
Future
<
String
>
registerhub_Validate
()
async
{
String
usertoken
=
await
UserSecureStorage
.
getUserToken
();
String
hubid
=
await
UserSecureStorage
.
getHubId
();
print
(
hubid
);
http
.
Response
bottleresponse
=
await
http
.
post
(
Uri
.
encodeFull
(
DotEnv
().
env
[
'SERVER_URL'
]
+
'bottle'
),
headers:
{
"Content-Type"
:
"application/json"
,
"authorization"
:
usertoken
},
body:
jsonEncode
({
'bottleId'
:
medicineBottleIDController
.
text
,
'hubId'
:
widget
.
hubid
}));
body:
jsonEncode
(
{
'bottleId'
:
medicineBottleIDController
.
text
,
'hubId'
:
hubid
}));
if
(
bottleresponse
.
statusCode
==
201
)
{
return
"등록 완료"
;
...
...
frontend/flutter_application_1/lib/src/screens/Register/RegsiterHub.dart
View file @
104f91c
...
...
@@ -120,6 +120,7 @@ class _RegisterHubState extends State<RegisterHub> {
String
saveMessage
=
await
registerhub_Validate
();
print
(
saveMessage
);
if
(
saveMessage
==
"허브 등록 완료"
)
{
UserSecureStorage
.
setHubId
(
medicineHubIDController
.
text
);
Navigator
.
push
(
context
,
MaterialPageRoute
(
...
...
frontend/flutter_application_1/lib/src/screens/Register/SignInPage.dart
View file @
104f91c
...
...
@@ -28,6 +28,7 @@ class _SignInPageState extends State<SignInPage> {
//Login 함수
Future
<
String
>
login
(
String
_email
,
String
_password
)
async
{
print
(
Uri
.
encodeFull
(
DotEnv
().
env
[
'SERVER_URL'
]
+
'auth/login'
));
http
.
Response
response
=
await
http
.
post
(
Uri
.
encodeFull
(
DotEnv
().
env
[
'SERVER_URL'
]
+
'auth/login'
),
headers:
{
"Content-Type"
:
"application/json"
},
...
...
@@ -38,6 +39,7 @@ class _SignInPageState extends State<SignInPage> {
},
),
);
print
(
response
.
statusCode
);
if
(
response
.
statusCode
==
200
)
{
Map
<
String
,
dynamic
>
data
=
jsonDecode
(
response
.
body
);
...
...
@@ -51,7 +53,7 @@ class _SignInPageState extends State<SignInPage> {
}
}
//Get
Bottle
List 함수
//Get
Hub
List 함수
Future
<
String
>
getHubList
()
async
{
String
usertoken
=
await
UserSecureStorage
.
getUserToken
();
http
.
Response
response
=
await
http
.
get
(
...
...
@@ -207,6 +209,7 @@ class _SignInPageState extends State<SignInPage> {
String
saveMessage
=
await
login
(
emailController
.
text
,
passwordController
.
text
);
print
(
saveMessage
);
if
(
emailController
.
text
.
isEmpty
||
passwordController
.
text
.
isEmpty
)
{
showDialog
(
...
...
@@ -227,7 +230,6 @@ class _SignInPageState extends State<SignInPage> {
);
});
}
else
{
saveMessage
=
"로그인 성공"
;
if
(
saveMessage
==
"로그인 성공"
)
{
var
result
=
await
getHubList
();
print
(
result
);
...
...
@@ -242,6 +244,9 @@ class _SignInPageState extends State<SignInPage> {
}
else
if
(
result
==
"get완료"
)
{
UserSecureStorage
.
setUserToken
(
user
.
token
);
UserSecureStorage
.
setUserId
(
user
.
userId
);
print
(
'asdg'
);
Navigator
.
push
(
context
,
MaterialPageRoute
(
...
...
@@ -250,6 +255,8 @@ class _SignInPageState extends State<SignInPage> {
HubList
(
hublist:
_hublist
),
));
}
else
{}
}
else
{
print
(
'Error'
);
}
}
},
...
...
frontend/flutter_application_1/lib/src/screens/Register/SignUpLocal.dart
View file @
104f91c
import
'dart:convert'
;
import
'package:Smart_Medicine_Box/src/screens/Homepage.dart'
;
import
'package:flutter/material.dart'
;
import
'package:http/http.dart'
as
http
;
import
'package:flutter_dotenv/flutter_dotenv.dart'
;
...
...
@@ -182,7 +183,7 @@ class _SignUpLocalState extends State<SignUpLocal> {
context
,
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=>
RegisterHub
()));
HomePage
()));
})
],
);
...
...
frontend/flutter_application_1/lib/src/utils/user_secure_stoarge.dart
View file @
104f91c
...
...
@@ -7,6 +7,12 @@ class UserSecureStorage {
static
const
_keyUserId
=
'userid'
;
static
const
_keyBottleId
=
'bottleid'
;
static
const
_keyMedicineId
=
'medicineid'
;
static
const
_keyhubId
=
'hubid'
;
static
Future
setUserId
(
String
userid
)
async
=>
await
_storage
.
write
(
key:
_keyUserId
,
value:
userid
);
...
...
@@ -18,4 +24,21 @@ class UserSecureStorage {
static
Future
<
String
>
getUserToken
()
async
=>
await
_storage
.
read
(
key:
_keyToken
);
static
Future
setBottleId
(
String
bottleid
)
async
=>
await
_storage
.
write
(
key:
_keyBottleId
,
value:
bottleid
);
static
Future
<
String
>
getBottleId
()
async
=>
await
_storage
.
read
(
key:
_keyBottleId
);
static
Future
setMedicineId
(
String
medicineid
)
async
=>
await
_storage
.
write
(
key:
_keyMedicineId
,
value:
medicineid
);
static
Future
<
String
>
getMedicineId
()
async
=>
await
_storage
.
read
(
key:
_keyMedicineId
);
static
Future
setHubId
(
String
hubid
)
async
=>
await
_storage
.
write
(
key:
_keyhubId
,
value:
hubid
);
static
Future
<
String
>
getHubId
()
async
=>
await
_storage
.
read
(
key:
_keyhubId
);
}
...
...
Please
register
or
login
to post a comment