고원빈

[frontend] app 뒤로가기 설정 변경

......@@ -87,3 +87,6 @@ appbar 관련 디자인은 추후 구현 예정
### 2021-05-26
+ future buillder 변경
### 2021-05-27
+ app 뒤로가기 설정 변경
\ No newline at end of file
......
......@@ -9,6 +9,7 @@ import '../utils/user_secure_stoarge.dart';
import 'models/Bottle.dart';
import 'models/Medicine.dart';
import 'package:Smart_Medicine_Box/src/screens/SettingPage.dart';
import 'Register/BottleList.dart';
class DashBoard extends StatefulWidget {
int pageNumber;
......@@ -24,6 +25,35 @@ class DashBoard extends StatefulWidget {
class _DashBoardState extends State<DashBoard> {
int _selectedIndex = 0;
List<Bottle> _bottleList = new List<Bottle>();
//Get BottleList
Future<String> getBottleList() async {
String usertoken = await UserSecureStorage.getUserToken();
String hubid = await UserSecureStorage.getHubId();
http.Response response = await http.get(
Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'bottle/hub/' + hubid),
headers: {"authorization": usertoken},
);
print(response.body);
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";
}
return "Error";
}
Widget build(BuildContext context) {
_selectedIndex = widget.pageNumber;
......@@ -33,7 +63,8 @@ class _DashBoardState extends State<DashBoard> {
outerInformationpage(context),
];
return Scaffold(
return WillPopScope(
child: Scaffold(
backgroundColor: Color(0xffe5f4ff),
appBar: AppBar(
iconTheme: IconThemeData(color: Colors.black),
......@@ -109,6 +140,16 @@ class _DashBoardState extends State<DashBoard> {
)
],
),
),
onWillPop: () async {
await getBottleList();
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
BottleList(bottlelist: _bottleList),
));
},
);
}
......@@ -314,7 +355,6 @@ Widget mainpage(BuildContext context) {
}
Widget ineerInformationpage(BuildContext context) {
Bottle _bottleinformation = new Bottle();
//get bottle
Future<Bottle> _getbottle() async {
String usertoken = await UserSecureStorage.getUserToken();
......
......@@ -55,7 +55,7 @@ class _HomePageState extends State<HomePage> {
textScaleFactor: 1.0,
style: TextStyle(
color: Color(0xff004ca2),
fontSize: 20,
fontSize: 30,
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
......
......@@ -19,7 +19,8 @@ class BottleList extends StatefulWidget {
class _BottleListState extends State<BottleList> {
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
return Scaffold(
return WillPopScope(
child: Scaffold(
body: Container(
height: size.height,
child: Column(
......@@ -86,6 +87,10 @@ class _BottleListState extends State<BottleList> {
)
],
)),
),
onWillPop: () {
SystemNavigator.pop();
},
);
}
}
......
......@@ -117,6 +117,8 @@ class _RegisterBottleState extends State<RegisterBottle> {
new FlatButton(
child: new Text('Close'),
onPressed: () {
UserSecureStorage.setBottleId(
medicineBottleIDController.text);
Navigator.push(
context,
MaterialPageRoute(
......
......@@ -121,6 +121,7 @@ class _RegisterHubState extends State<RegisterHub> {
print(saveMessage);
if (saveMessage == "허브 등록 완료") {
UserSecureStorage.setHubId(medicineHubIDController.text);
print(UserSecureStorage.getHubId());
Navigator.push(
context,
MaterialPageRoute(
......