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-06-05 04:52:57 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b27a94337beffee21e7a09dc6a4867ce2e0d8466
b27a9433
1 parent
41c8b0f2
[complete]
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
125 deletions
frontend/flutter_application_1/lib/src/screens/Register/BottleList.dart
frontend/flutter_application_1/lib/src/screens/Register/HubList.dart
frontend/flutter_application_1/lib/src/screens/SettingPage/BottleModifyList.dart
frontend/flutter_application_1/lib/src/screens/models/UserBottle.dart
frontend/flutter_application_1/lib/src/utils/DBHelper.dart
frontend/flutter_application_1/lib/src/screens/Register/BottleList.dart
View file @
b27a943
...
...
@@ -6,8 +6,6 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
import
'../models/Bottle.dart'
;
import
'../DashBoard.dart'
;
import
'../../utils/user_secure_stoarge.dart'
;
import
'../../utils/DBHelper.dart'
;
import
'../models/UserBottle.dart'
;
class
BottleList
extends
StatefulWidget
{
BottleList
({
Key
key
})
:
super
(
key:
key
);
...
...
@@ -17,12 +15,13 @@ class BottleList extends StatefulWidget {
}
class
_BottleListState
extends
State
<
BottleList
>
{
String
valueText
;
List
<
Bottle
>
_bottleList
=
new
List
<
Bottle
>();
TextEditingController
_textFieldController
=
TextEditingController
();
Future
<
String
>
getBottleList
()
async
{
String
hubid
=
await
UserSecureStorage
.
getHubId
();
String
usertoken
=
await
UserSecureStorage
.
getUserToken
();
var
provider
=
DBHelper
();
http
.
Response
response
=
await
http
.
get
(
Uri
.
encodeFull
(
DotEnv
().
env
[
'SERVER_URL'
]
+
'bottle/hub/'
+
hubid
.
toString
()),
...
...
@@ -40,19 +39,7 @@ class _BottleListState extends State<BottleList> {
Map
<
String
,
dynamic
>
map
=
values
[
i
];
_bottleList
.
add
(
Bottle
.
fromJson
(
map
));
}
for
(
int
i
=
0
;
i
<
_bottleList
.
length
;
i
++)
{
UserBottle
temp
=
new
UserBottle
();
temp
.
bottleId
=
_bottleList
[
i
].
bottleId
;
temp
.
bottleName
=
_bottleList
[
i
].
bottleId
.
toString
();
provider
.
createData
(
temp
);
}
List
<
UserBottle
>
_userbottleList
=
new
List
<
UserBottle
>();
_userbottleList
=
await
provider
.
getAllBottle
();
for
(
int
i
=
0
;
i
<
_userbottleList
.
length
;
i
++)
{
print
(
_userbottleList
[
i
].
bottleId
);
}
print
(
provider
.
getAllBottle
());
return
"GET"
;
}
else
if
(
response
.
statusCode
==
404
)
{
return
"Not Found"
;
...
...
frontend/flutter_application_1/lib/src/screens/Register/HubList.dart
View file @
b27a943
...
...
@@ -130,22 +130,23 @@ class _HubListState extends State<HubList> {
new
FlatButton
(
child:
new
Text
(
'등록'
),
onPressed:
()
{
UserSecureStorage
.
setHubId
(
widget
.
hublist
[
index
]
.
toString
());
UserSecureStorage
.
setHubId
(
widget
.
hublist
[
index
].
toString
());
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=>
builder:
(
BuildContext
context
)
=>
RegisterBottle
(),
));
})
],
);
});
},
);
}
}),
},
),
);
},
separatorBuilder:
(
BuildContext
contetx
,
int
index
)
=>
...
...
frontend/flutter_application_1/lib/src/screens/SettingPage/BottleModifyList.dart
View file @
b27a943
...
...
@@ -5,10 +5,7 @@ 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'
;
import
'../../utils/user_secure_stoarge.dart'
;
import
'../../utils/DBHelper.dart'
;
import
'../models/UserBottle.dart'
;
class
BottleModifyList
extends
StatefulWidget
{
BottleModifyList
({
Key
key
})
:
super
(
key:
key
);
...
...
@@ -23,7 +20,6 @@ class _BottleModifyListState extends State<BottleModifyList> {
String
hubid
=
await
UserSecureStorage
.
getHubId
();
String
usertoken
=
await
UserSecureStorage
.
getUserToken
();
var
provider
=
DBHelper
();
http
.
Response
response
=
await
http
.
get
(
Uri
.
encodeFull
(
DotEnv
().
env
[
'SERVER_URL'
]
+
'bottle/hub/'
+
hubid
.
toString
()),
...
...
@@ -41,19 +37,7 @@ class _BottleModifyListState extends State<BottleModifyList> {
Map
<
String
,
dynamic
>
map
=
values
[
i
];
_bottleList
.
add
(
Bottle
.
fromJson
(
map
));
}
for
(
int
i
=
0
;
i
<
_bottleList
.
length
;
i
++)
{
UserBottle
temp
=
new
UserBottle
();
temp
.
bottleId
=
_bottleList
[
i
].
bottleId
;
temp
.
bottleName
=
_bottleList
[
i
].
bottleId
.
toString
();
provider
.
createData
(
temp
);
}
List
<
UserBottle
>
_userbottleList
=
new
List
<
UserBottle
>();
_userbottleList
=
await
provider
.
getAllBottle
();
for
(
int
i
=
0
;
i
<
_userbottleList
.
length
;
i
++)
{
print
(
_userbottleList
[
i
].
bottleId
);
}
print
(
provider
.
getAllBottle
());
return
"GET"
;
}
else
if
(
response
.
statusCode
==
404
)
{
return
"Not Found"
;
...
...
frontend/flutter_application_1/lib/src/screens/models/UserBottle.dart
deleted
100644 → 0
View file @
41c8b0f
class
UserBottle
{
int
bottleId
;
String
bottleName
;
UserBottle
({
this
.
bottleId
,
this
.
bottleName
});
factory
UserBottle
.
fromJson
(
Map
<
String
,
dynamic
>
parsedJson
)
{
return
UserBottle
(
bottleId:
parsedJson
[
'bottleId'
],
bottleName:
parsedJson
[
'bottleName'
],
);
}
Map
<
String
,
dynamic
>
toJson
()
=>
{
"bottleId"
:
bottleId
,
"bottleName"
:
bottleName
};
}
frontend/flutter_application_1/lib/src/utils/DBHelper.dart
deleted
100644 → 0
View file @
41c8b0f
import
'dart:io'
;
import
'package:path_provider/path_provider.dart'
;
import
'package:sqflite/sqflite.dart'
;
import
'package:path/path.dart'
;
import
'../screens/models/UserBottle.dart'
;
final
String
tableName
=
'medicinename'
;
class
DBHelper
{
DBHelper
.
_
();
static
final
DBHelper
_db
=
DBHelper
.
_
();
factory
DBHelper
()
=>
_db
;
static
Database
_database
;
Future
<
Database
>
get
database
async
{
if
(
_database
!=
null
)
return
_database
;
_database
=
await
initDB
();
return
_database
;
}
initDB
()
async
{
Directory
documentsDirectory
=
await
getApplicationDocumentsDirectory
();
String
path
=
join
(
documentsDirectory
.
path
,
'medicinename.db'
);
return
await
openDatabase
(
path
,
version:
1
,
onCreate:
(
Database
db
,
int
version
)
async
{
await
db
.
execute
(
'''
CREATE TABLE
$tableName
(bottleId INTEGER PRIMARY KEY,
bottleName TEXT)
'''
);
},
);
}
createData
(
UserBottle
bottle
)
async
{
final
db
=
await
database
;
var
res
=
await
db
.
insert
(
tableName
,
bottle
.
toJson
(),
conflictAlgorithm:
ConflictAlgorithm
.
replace
);
return
res
;
}
getBottle
(
int
bottleId
)
async
{
final
db
=
await
database
;
var
res
=
await
db
.
query
(
tableName
,
where:
'bottleId=?'
,
whereArgs:
[
bottleId
]);
return
res
.
isNotEmpty
?
UserBottle
.
fromJson
(
res
.
first
)
:
Null
;
}
Future
<
List
<
UserBottle
>>
getAllBottle
()
async
{
final
db
=
await
database
;
var
res
=
await
db
.
query
(
tableName
);
List
<
UserBottle
>
list
=
res
.
isNotEmpty
?
res
.
map
((
c
)
=>
UserBottle
.
fromJson
(
c
)).
toList
()
:
[];
return
list
;
}
updateBottle
(
UserBottle
bottle
)
async
{
final
db
=
await
database
;
var
res
=
db
.
update
(
tableName
,
bottle
.
toJson
(),
where:
'bottleId=?'
,
whereArgs:
[
bottle
.
bottleId
]);
return
res
;
}
}
Please
register
or
login
to post a comment