고원빈

[frontend] 2021-06-02

...@@ -99,4 +99,7 @@ appbar 관련 디자인은 추후 구현 예정 ...@@ -99,4 +99,7 @@ appbar 관련 디자인은 추후 구현 예정
99 + Sqlite 생성 99 + Sqlite 생성
100 100
101 ### 2021-06-01 101 ### 2021-06-01
102 -+ datetime 형식 한국 시간으로 변경
...\ No newline at end of file ...\ No newline at end of file
102 ++ datetime 형식 한국 시간으로 변경
103 +
104 +### 2021-06-02
105 ++ 약병 , 허브 추가 제거 관리 페이지 구현
......
1 import 'package:Smart_Medicine_Box/src/screens/DashBoard.dart'; 1 import 'package:Smart_Medicine_Box/src/screens/DashBoard.dart';
2 +import 'package:Smart_Medicine_Box/src/screens/Register/BottleList.dart';
2 import 'package:flutter/cupertino.dart'; 3 import 'package:flutter/cupertino.dart';
3 import 'dart:convert'; 4 import 'dart:convert';
4 import 'package:flutter/material.dart'; 5 import 'package:flutter/material.dart';
...@@ -10,7 +11,8 @@ import '../../utils/user_secure_stoarge.dart'; ...@@ -10,7 +11,8 @@ import '../../utils/user_secure_stoarge.dart';
10 11
11 class RegisterBottle extends StatefulWidget { 12 class RegisterBottle extends StatefulWidget {
12 final String hubid; 13 final String hubid;
13 - RegisterBottle({Key key, this.hubid}) : super(key: key); 14 + final bool modify_bottle;
15 + RegisterBottle({Key key, this.hubid, this.modify_bottle}) : super(key: key);
14 @override 16 @override
15 _RegisterBottleState createState() => _RegisterBottleState(); 17 _RegisterBottleState createState() => _RegisterBottleState();
16 } 18 }
...@@ -106,49 +108,74 @@ class _RegisterBottleState extends State<RegisterBottle> { ...@@ -106,49 +108,74 @@ class _RegisterBottleState extends State<RegisterBottle> {
106 onPressed: () async { 108 onPressed: () async {
107 String saveMessage = await registerhub_Validate(); 109 String saveMessage = await registerhub_Validate();
108 print(saveMessage); 110 print(saveMessage);
109 - if (saveMessage == "등록 완료") { 111 + print(widget.modify_bottle);
112 + if (saveMessage == "등록 완료" && widget.modify_bottle == false) {
110 showDialog( 113 showDialog(
111 - context: context, 114 + context: context,
112 - builder: (BuildContext context) { 115 + builder: (BuildContext context) {
113 - return AlertDialog( 116 + return AlertDialog(
114 - title: new Text('약병 등록'), 117 + title: new Text('약병 등록'),
115 - content: new Text('약병 등록이 완료 되었습니다.'), 118 + content: new Text('약병 등록이 완료 되었습니다.'),
116 - actions: <Widget>[ 119 + actions: <Widget>[
117 - new FlatButton( 120 + new FlatButton(
118 - child: new Text('Close'), 121 + child: new Text('Close'),
119 - onPressed: () { 122 + onPressed: () {
120 - UserSecureStorage.setBottleId( 123 + UserSecureStorage.setBottleId(
121 - medicineBottleIDController.text); 124 + medicineBottleIDController.text);
122 - Navigator.push( 125 + Navigator.push(
123 - context, 126 + context,
124 - MaterialPageRoute( 127 + MaterialPageRoute(
125 - builder: (BuildContext context) => 128 + builder: (BuildContext context) =>
126 - SearchMedicine( 129 + SearchMedicine(
127 - bottleId: medicineBottleIDController.text, 130 + bottleId: medicineBottleIDController.text,
128 - ),
129 ), 131 ),
130 - ); 132 + ),
131 - }, 133 + );
132 - ), 134 + },
133 - ], 135 + ),
134 - ); 136 + ],
135 - }); 137 + );
138 + },
139 + );
140 + } else if (saveMessage == "등록 완료" &&
141 + widget.modify_bottle == true) {
142 + print('asdg');
143 + await showDialog(
144 + context: context,
145 + builder: (BuildContext context) {
146 + return AlertDialog(
147 + title: new Text('약병 등록'),
148 + content: new Text('약병 등록이 완료 되었습니다.'),
149 + actions: <Widget>[
150 + new FlatButton(
151 + child: new Text('Close'),
152 + onPressed: () {
153 + Navigator.of(context).pop();
154 + },
155 + ),
156 + ],
157 + );
158 + },
159 + );
160 + Navigator.of(context).pop();
136 } else { 161 } else {
137 showDialog( 162 showDialog(
138 - context: context, 163 + context: context,
139 - builder: (BuildContext context) { 164 + builder: (BuildContext context) {
140 - return AlertDialog( 165 + return AlertDialog(
141 - title: new Text('오류'), 166 + title: new Text('오류'),
142 - content: new Text(saveMessage), 167 + content: new Text(saveMessage),
143 - actions: <Widget>[ 168 + actions: <Widget>[
144 - new FlatButton( 169 + new FlatButton(
145 - child: new Text('Close'), 170 + child: new Text('Close'),
146 - onPressed: () { 171 + onPressed: () {
147 - Navigator.of(context).pop(); 172 + Navigator.of(context).pop();
148 - }) 173 + },
149 - ], 174 + )
150 - ); 175 + ],
151 - }); 176 + );
177 + },
178 + );
152 } 179 }
153 }, 180 },
154 shape: RoundedRectangleBorder( 181 shape: RoundedRectangleBorder(
...@@ -167,25 +194,6 @@ class _RegisterBottleState extends State<RegisterBottle> { ...@@ -167,25 +194,6 @@ class _RegisterBottleState extends State<RegisterBottle> {
167 ) 194 )
168 ], 195 ],
169 ), 196 ),
170 - bottomNavigationBar: BottomAppBar(
171 - elevation: 0,
172 - child: Container(
173 - height: 70,
174 - child: Column(
175 - mainAxisAlignment: MainAxisAlignment.start,
176 - children: <Widget>[
177 - Padding(
178 - padding: const EdgeInsets.fromLTRB(70, 0, 70, 0),
179 - child: Text(
180 - '회원 가입시, 이용 약관 및 개인정보 처리 방침에 동의하는 것으로 간주합니다..',
181 - style: TextStyle(fontSize: 12, color: Color(0xff747474)),
182 - textAlign: TextAlign.center,
183 - ),
184 - )
185 - ],
186 - ),
187 - ),
188 - ),
189 ); 197 );
190 } 198 }
191 } 199 }
......
1 +import 'package:Smart_Medicine_Box/src/screens/SettingPage/HubModifyList.dart';
1 import 'package:flutter/cupertino.dart'; 2 import 'package:flutter/cupertino.dart';
2 import 'dart:convert'; 3 import 'dart:convert';
3 import 'package:flutter/material.dart'; 4 import 'package:flutter/material.dart';
...@@ -8,6 +9,9 @@ import 'RegisterBottle.dart'; ...@@ -8,6 +9,9 @@ import 'RegisterBottle.dart';
8 import '../../utils/user_secure_stoarge.dart'; 9 import '../../utils/user_secure_stoarge.dart';
9 10
10 class RegisterHub extends StatefulWidget { 11 class RegisterHub extends StatefulWidget {
12 + final int modify_hub;
13 +
14 + RegisterHub({Key key, this.modify_hub}) : super(key: key);
11 @override 15 @override
12 _RegisterHubState createState() => _RegisterHubState(); 16 _RegisterHubState createState() => _RegisterHubState();
13 } 17 }
...@@ -31,7 +35,7 @@ class _RegisterHubState extends State<RegisterHub> { ...@@ -31,7 +35,7 @@ class _RegisterHubState extends State<RegisterHub> {
31 'host': medicineHubHostController.text, 35 'host': medicineHubHostController.text,
32 'port': medicineHubPortController.text, 36 'port': medicineHubPortController.text,
33 })); 37 }));
34 - 38 + print(hubresponse.statusCode);
35 if (hubresponse.statusCode == 201) { 39 if (hubresponse.statusCode == 201) {
36 return "허브 등록 완료"; 40 return "허브 등록 완료";
37 } else if (hubresponse.statusCode == 409) { 41 } else if (hubresponse.statusCode == 409) {
...@@ -118,14 +122,40 @@ class _RegisterHubState extends State<RegisterHub> { ...@@ -118,14 +122,40 @@ class _RegisterHubState extends State<RegisterHub> {
118 child: RaisedButton( 122 child: RaisedButton(
119 onPressed: () async { 123 onPressed: () async {
120 String saveMessage = await registerhub_Validate(); 124 String saveMessage = await registerhub_Validate();
121 - if (saveMessage == "허브 등록 완료") { 125 + print(saveMessage);
126 + print(widget.modify_hub);
127 + if (saveMessage == "허브 등록 완료" && widget.modify_hub == 0) {
122 UserSecureStorage.setHubId(medicineHubIDController.text); 128 UserSecureStorage.setHubId(medicineHubIDController.text);
123 Navigator.push( 129 Navigator.push(
124 - context, 130 + context,
125 - MaterialPageRoute( 131 + MaterialPageRoute(
126 - builder: (BuildContext context) => 132 + builder: (BuildContext context) => RegisterBottle(
127 - RegisterBottle(hubid: medicineHubIDController.text), 133 + hubid: medicineHubIDController.text,
128 - )); 134 + modify_bottle: false,
135 + ),
136 + ),
137 + );
138 + } else if (saveMessage == "허브 등록 완료" &&
139 + widget.modify_hub == 1) {
140 + Navigator.of(context).pop();
141 + } else {
142 + showDialog(
143 + context: context,
144 + builder: (BuildContext context) {
145 + return AlertDialog(
146 + title: new Text('오류'),
147 + content: new Text(saveMessage),
148 + actions: <Widget>[
149 + new FlatButton(
150 + child: new Text('close'),
151 + onPressed: () {
152 + Navigator.of(context).pop();
153 + },
154 + )
155 + ],
156 + );
157 + },
158 + );
129 } 159 }
130 }, 160 },
131 shape: RoundedRectangleBorder( 161 shape: RoundedRectangleBorder(
...@@ -133,7 +163,7 @@ class _RegisterHubState extends State<RegisterHub> { ...@@ -133,7 +163,7 @@ class _RegisterHubState extends State<RegisterHub> {
133 side: BorderSide(color: Colors.blue)), 163 side: BorderSide(color: Colors.blue)),
134 color: Color(0xff1674f6), 164 color: Color(0xff1674f6),
135 child: Text( 165 child: Text(
136 - ' 허브 등록 ', 166 + '허브 등록 ',
137 textScaleFactor: 1.0, 167 textScaleFactor: 1.0,
138 style: TextStyle( 168 style: TextStyle(
139 fontSize: 16, 169 fontSize: 16,
...@@ -144,25 +174,6 @@ class _RegisterHubState extends State<RegisterHub> { ...@@ -144,25 +174,6 @@ class _RegisterHubState extends State<RegisterHub> {
144 ) 174 )
145 ], 175 ],
146 ), 176 ),
147 - bottomNavigationBar: BottomAppBar(
148 - elevation: 0,
149 - child: Container(
150 - height: 70,
151 - child: Column(
152 - mainAxisAlignment: MainAxisAlignment.start,
153 - children: <Widget>[
154 - Padding(
155 - padding: const EdgeInsets.fromLTRB(70, 0, 70, 0),
156 - child: Text(
157 - '회원 가입시, 이용 약관 및 개인정보 처리 방침에 동의하는 것으로 간주합니다..',
158 - style: TextStyle(fontSize: 12, color: Color(0xff747474)),
159 - textAlign: TextAlign.center,
160 - ),
161 - )
162 - ],
163 - ),
164 - ),
165 - ),
166 ); 177 );
167 } 178 }
168 } 179 }
......
...@@ -235,9 +235,9 @@ class _SignInPageState extends State<SignInPage> { ...@@ -235,9 +235,9 @@ class _SignInPageState extends State<SignInPage> {
235 Navigator.push( 235 Navigator.push(
236 context, 236 context,
237 MaterialPageRoute( 237 MaterialPageRoute(
238 - builder: 238 + builder: (BuildContext
239 - (BuildContext context) => 239 + context) =>
240 - RegisterHub(), 240 + RegisterHub(modify_hub: 0),
241 )); 241 ));
242 } else if (result == "get완료") { 242 } else if (result == "get완료") {
243 UserSecureStorage.setUserId( 243 UserSecureStorage.setUserId(
......
...@@ -3,8 +3,7 @@ import 'package:flutter/material.dart'; ...@@ -3,8 +3,7 @@ import 'package:flutter/material.dart';
3 import 'package:Smart_Medicine_Box/src/screens/DashBoard.dart'; 3 import 'package:Smart_Medicine_Box/src/screens/DashBoard.dart';
4 import 'package:Smart_Medicine_Box/src/screens/SettingPage/Alarm.dart'; 4 import 'package:Smart_Medicine_Box/src/screens/SettingPage/Alarm.dart';
5 import 'package:Smart_Medicine_Box/src/screens/SettingPage/DEVInformation.dart'; 5 import 'package:Smart_Medicine_Box/src/screens/SettingPage/DEVInformation.dart';
6 -import 'package:Smart_Medicine_Box/src/screens/SettingPage/InformationModify.dart'; 6 +import 'package:Smart_Medicine_Box/src/screens/SettingPage/BottleModifyList.dart';
7 -import '../screens/Register/HubList.dart';
8 7
9 class SettingPage extends StatefulWidget { 8 class SettingPage extends StatefulWidget {
10 @override 9 @override
...@@ -134,7 +133,7 @@ class _SettingPageState extends State<SettingPage> { ...@@ -134,7 +133,7 @@ class _SettingPageState extends State<SettingPage> {
134 )); 133 ));
135 }, 134 },
136 child: Text( 135 child: Text(
137 - '허브 등록', 136 + '허브 관리',
138 textScaleFactor: 1.0, 137 textScaleFactor: 1.0,
139 style: TextStyle( 138 style: TextStyle(
140 color: Colors.white, 139 color: Colors.white,
...@@ -159,11 +158,11 @@ class _SettingPageState extends State<SettingPage> { ...@@ -159,11 +158,11 @@ class _SettingPageState extends State<SettingPage> {
159 context, 158 context,
160 MaterialPageRoute( 159 MaterialPageRoute(
161 builder: (BuildContext context) => 160 builder: (BuildContext context) =>
162 - InformationModify(), 161 + BottleModifyList(),
163 )); 162 ));
164 }, 163 },
165 child: Text( 164 child: Text(
166 - '회원 정보 수정', 165 + '약병 관리',
167 textScaleFactor: 1.0, 166 textScaleFactor: 1.0,
168 style: TextStyle( 167 style: TextStyle(
169 color: Colors.white, 168 color: Colors.white,
......
1 +import 'package:Smart_Medicine_Box/src/screens/Register/RegsiterHub.dart';
1 import 'package:flutter/cupertino.dart'; 2 import 'package:flutter/cupertino.dart';
2 import 'package:flutter/material.dart'; 3 import 'package:flutter/material.dart';
3 import 'dart:convert'; 4 import 'dart:convert';
4 import 'package:http/http.dart' as http; 5 import 'package:http/http.dart' as http;
5 import 'package:flutter_dotenv/flutter_dotenv.dart'; 6 import 'package:flutter_dotenv/flutter_dotenv.dart';
6 // Screen import 7 // Screen import
7 -import '../models/Bottle.dart';
8 import '../../utils/user_secure_stoarge.dart'; 8 import '../../utils/user_secure_stoarge.dart';
9 9
10 class HubModifyList extends StatefulWidget { 10 class HubModifyList extends StatefulWidget {
...@@ -42,6 +42,19 @@ class _HubModifyListState extends State<HubModifyList> { ...@@ -42,6 +42,19 @@ class _HubModifyListState extends State<HubModifyList> {
42 } 42 }
43 } 43 }
44 44
45 + Future<String> deleteHub(int index) async {
46 + String usertoken = await UserSecureStorage.getUserToken();
47 + http.Response response = await http.delete(
48 + Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'hub/' + index.toString()),
49 + headers: {"authorization": usertoken},
50 + );
51 + if (response.statusCode == 204) {
52 + return "Delete";
53 + } else {
54 + return "Error";
55 + }
56 + }
57 +
45 Widget build(BuildContext context) { 58 Widget build(BuildContext context) {
46 final Size size = MediaQuery.of(context).size; 59 final Size size = MediaQuery.of(context).size;
47 return Scaffold( 60 return Scaffold(
...@@ -107,18 +120,65 @@ class _HubModifyListState extends State<HubModifyList> { ...@@ -107,18 +120,65 @@ class _HubModifyListState extends State<HubModifyList> {
107 BorderRadius.all(Radius.circular(25.0)), 120 BorderRadius.all(Radius.circular(25.0)),
108 ), 121 ),
109 child: ListTile( 122 child: ListTile(
110 - title: Text( 123 + title: Text(
111 - 'HUB ID: ' + '${_hublist[index]}', 124 + 'HUB ID: ' + '${_hublist[index]}',
112 - style: TextStyle( 125 + style: TextStyle(
113 - color: Colors.black, 126 + color: Colors.black,
114 - fontSize: 20, 127 + fontSize: 20,
115 - fontFamily: 'Noto', 128 + fontFamily: 'Noto',
116 - fontWeight: FontWeight.bold), 129 + fontWeight: FontWeight.bold),
117 - ), 130 + ),
118 - trailing: Icon(Icons.highlight_remove), 131 + trailing: Icon(Icons.highlight_remove),
119 - onTap: () async { 132 + onTap: () async {
120 - print('삭제 할거임'); 133 + if (_hublist.length == 1) {
121 - }), 134 + showDialog(
135 + context: context,
136 + builder: (BuildContext context) {
137 + return AlertDialog(
138 + title: new Text('허브 삭제'),
139 + content: new Text(
140 + '등록된 허브가 하나이므로 해제가 불가능 합니다.'),
141 + actions: <Widget>[
142 + new FlatButton(
143 + child: new Text('Cloes'),
144 + onPressed: () {
145 + Navigator.of(context).pop();
146 + }),
147 + ],
148 + );
149 + },
150 + );
151 + } else {
152 + showDialog(
153 + context: context,
154 + builder: (BuildContext context) {
155 + return AlertDialog(
156 + title: new Text('허브 삭제'),
157 + content: new Text(
158 + _hublist[index].toString() +
159 + '을 삭제 하시겠습니까?'),
160 + actions: <Widget>[
161 + new FlatButton(
162 + child: new Text('삭제'),
163 + onPressed: () async {
164 + await deleteHub(_hublist[index]);
165 + setState(() {});
166 + Navigator.of(context).pop();
167 + },
168 + ),
169 + new FlatButton(
170 + child: new Text('취소'),
171 + onPressed: () {
172 + Navigator.of(context).pop();
173 + },
174 + )
175 + ],
176 + );
177 + },
178 + );
179 + }
180 + },
181 + ),
122 ); 182 );
123 }, 183 },
124 separatorBuilder: (BuildContext contetx, int index) => 184 separatorBuilder: (BuildContext contetx, int index) =>
...@@ -132,7 +192,16 @@ class _HubModifyListState extends State<HubModifyList> { ...@@ -132,7 +192,16 @@ class _HubModifyListState extends State<HubModifyList> {
132 margin: EdgeInsets.only(bottom: 0), 192 margin: EdgeInsets.only(bottom: 0),
133 child: FlatButton( 193 child: FlatButton(
134 height: size.height * 0.07, 194 height: size.height * 0.07,
135 - onPressed: () {}, 195 + onPressed: () async {
196 + await Navigator.push(
197 + context,
198 + MaterialPageRoute(
199 + builder: (BuildContext context) =>
200 + RegisterHub(modify_hub: 1),
201 + ),
202 + );
203 + setState(() {});
204 + },
136 child: Text( 205 child: Text(
137 '허브 추가', 206 '허브 추가',
138 textScaleFactor: 1.0, 207 textScaleFactor: 1.0,
......