고원빈

[frontend] 2021-06-02

......@@ -100,3 +100,6 @@ appbar 관련 디자인은 추후 구현 예정
### 2021-06-01
+ datetime 형식 한국 시간으로 변경
### 2021-06-02
+ 약병 , 허브 추가 제거 관리 페이지 구현
......
import 'package:Smart_Medicine_Box/src/screens/DashBoard.dart';
import 'package:Smart_Medicine_Box/src/screens/Register/BottleList.dart';
import 'package:flutter/cupertino.dart';
import 'dart:convert';
import 'package:flutter/material.dart';
......@@ -10,7 +11,8 @@ import '../../utils/user_secure_stoarge.dart';
class RegisterBottle extends StatefulWidget {
final String hubid;
RegisterBottle({Key key, this.hubid}) : super(key: key);
final bool modify_bottle;
RegisterBottle({Key key, this.hubid, this.modify_bottle}) : super(key: key);
@override
_RegisterBottleState createState() => _RegisterBottleState();
}
......@@ -106,7 +108,8 @@ class _RegisterBottleState extends State<RegisterBottle> {
onPressed: () async {
String saveMessage = await registerhub_Validate();
print(saveMessage);
if (saveMessage == "등록 완료") {
print(widget.modify_bottle);
if (saveMessage == "등록 완료" && widget.modify_bottle == false) {
showDialog(
context: context,
builder: (BuildContext context) {
......@@ -132,7 +135,29 @@ class _RegisterBottleState extends State<RegisterBottle> {
),
],
);
});
},
);
} else if (saveMessage == "등록 완료" &&
widget.modify_bottle == true) {
print('asdg');
await 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();
},
),
],
);
},
);
Navigator.of(context).pop();
} else {
showDialog(
context: context,
......@@ -145,10 +170,12 @@ class _RegisterBottleState extends State<RegisterBottle> {
child: new Text('Close'),
onPressed: () {
Navigator.of(context).pop();
})
},
)
],
);
});
},
);
}
},
shape: RoundedRectangleBorder(
......@@ -167,25 +194,6 @@ class _RegisterBottleState extends State<RegisterBottle> {
)
],
),
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,
),
)
],
),
),
),
);
}
}
......
import 'package:Smart_Medicine_Box/src/screens/SettingPage/HubModifyList.dart';
import 'package:flutter/cupertino.dart';
import 'dart:convert';
import 'package:flutter/material.dart';
......@@ -8,6 +9,9 @@ import 'RegisterBottle.dart';
import '../../utils/user_secure_stoarge.dart';
class RegisterHub extends StatefulWidget {
final int modify_hub;
RegisterHub({Key key, this.modify_hub}) : super(key: key);
@override
_RegisterHubState createState() => _RegisterHubState();
}
......@@ -31,7 +35,7 @@ class _RegisterHubState extends State<RegisterHub> {
'host': medicineHubHostController.text,
'port': medicineHubPortController.text,
}));
print(hubresponse.statusCode);
if (hubresponse.statusCode == 201) {
return "허브 등록 완료";
} else if (hubresponse.statusCode == 409) {
......@@ -118,14 +122,40 @@ class _RegisterHubState extends State<RegisterHub> {
child: RaisedButton(
onPressed: () async {
String saveMessage = await registerhub_Validate();
if (saveMessage == "허브 등록 완료") {
print(saveMessage);
print(widget.modify_hub);
if (saveMessage == "허브 등록 완료" && widget.modify_hub == 0) {
UserSecureStorage.setHubId(medicineHubIDController.text);
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
RegisterBottle(hubid: medicineHubIDController.text),
));
builder: (BuildContext context) => RegisterBottle(
hubid: medicineHubIDController.text,
modify_bottle: false,
),
),
);
} else if (saveMessage == "허브 등록 완료" &&
widget.modify_hub == 1) {
Navigator.of(context).pop();
} 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.of(context).pop();
},
)
],
);
},
);
}
},
shape: RoundedRectangleBorder(
......@@ -133,7 +163,7 @@ class _RegisterHubState extends State<RegisterHub> {
side: BorderSide(color: Colors.blue)),
color: Color(0xff1674f6),
child: Text(
' 허브 등록 ',
'허브 등록 ',
textScaleFactor: 1.0,
style: TextStyle(
fontSize: 16,
......@@ -144,25 +174,6 @@ class _RegisterHubState extends State<RegisterHub> {
)
],
),
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,
),
)
],
),
),
),
);
}
}
......
......@@ -235,9 +235,9 @@ class _SignInPageState extends State<SignInPage> {
Navigator.push(
context,
MaterialPageRoute(
builder:
(BuildContext context) =>
RegisterHub(),
builder: (BuildContext
context) =>
RegisterHub(modify_hub: 0),
));
} else if (result == "get완료") {
UserSecureStorage.setUserId(
......
......@@ -3,8 +3,7 @@ import 'package:flutter/material.dart';
import 'package:Smart_Medicine_Box/src/screens/DashBoard.dart';
import 'package:Smart_Medicine_Box/src/screens/SettingPage/Alarm.dart';
import 'package:Smart_Medicine_Box/src/screens/SettingPage/DEVInformation.dart';
import 'package:Smart_Medicine_Box/src/screens/SettingPage/InformationModify.dart';
import '../screens/Register/HubList.dart';
import 'package:Smart_Medicine_Box/src/screens/SettingPage/BottleModifyList.dart';
class SettingPage extends StatefulWidget {
@override
......@@ -134,7 +133,7 @@ class _SettingPageState extends State<SettingPage> {
));
},
child: Text(
'허브 등록',
'허브 관리',
textScaleFactor: 1.0,
style: TextStyle(
color: Colors.white,
......@@ -159,11 +158,11 @@ class _SettingPageState extends State<SettingPage> {
context,
MaterialPageRoute(
builder: (BuildContext context) =>
InformationModify(),
BottleModifyList(),
));
},
child: Text(
'회원 정보 수정',
'약병 관리',
textScaleFactor: 1.0,
style: TextStyle(
color: Colors.white,
......
import 'package:Smart_Medicine_Box/src/screens/Register/RegsiterHub.dart';
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 '../models/Bottle.dart';
import '../../utils/user_secure_stoarge.dart';
class HubModifyList extends StatefulWidget {
......@@ -42,6 +42,19 @@ class _HubModifyListState extends State<HubModifyList> {
}
}
Future<String> deleteHub(int index) async {
String usertoken = await UserSecureStorage.getUserToken();
http.Response response = await http.delete(
Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'hub/' + index.toString()),
headers: {"authorization": usertoken},
);
if (response.statusCode == 204) {
return "Delete";
} else {
return "Error";
}
}
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
return Scaffold(
......@@ -117,8 +130,55 @@ class _HubModifyListState extends State<HubModifyList> {
),
trailing: Icon(Icons.highlight_remove),
onTap: () async {
print('삭제 할거임');
if (_hublist.length == 1) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: new Text('허브 삭제'),
content: new Text(
'등록된 허브가 하나이므로 해제가 불가능 합니다.'),
actions: <Widget>[
new FlatButton(
child: new Text('Cloes'),
onPressed: () {
Navigator.of(context).pop();
}),
],
);
},
);
} else {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: new Text('허브 삭제'),
content: new Text(
_hublist[index].toString() +
'을 삭제 하시겠습니까?'),
actions: <Widget>[
new FlatButton(
child: new Text('삭제'),
onPressed: () async {
await deleteHub(_hublist[index]);
setState(() {});
Navigator.of(context).pop();
},
),
new FlatButton(
child: new Text('취소'),
onPressed: () {
Navigator.of(context).pop();
},
)
],
);
},
);
}
},
),
);
},
separatorBuilder: (BuildContext contetx, int index) =>
......@@ -132,7 +192,16 @@ class _HubModifyListState extends State<HubModifyList> {
margin: EdgeInsets.only(bottom: 0),
child: FlatButton(
height: size.height * 0.07,
onPressed: () {},
onPressed: () async {
await Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
RegisterHub(modify_hub: 1),
),
);
setState(() {});
},
child: Text(
'허브 추가',
textScaleFactor: 1.0,
......