고원빈

[frontend] 새로 고침 + ui 변경

...@@ -90,3 +90,7 @@ appbar 관련 디자인은 추후 구현 예정 ...@@ -90,3 +90,7 @@ appbar 관련 디자인은 추후 구현 예정
90 90
91 ### 2021-05-27 91 ### 2021-05-27
92 + app 뒤로가기 설정 변경 92 + app 뒤로가기 설정 변경
93 +
94 +### 2021-05-29
95 ++ 약병 리스트 ui 변경
96 ++ DashBoard 새로고침
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -118,6 +118,13 @@ class _DashBoardState extends State<DashBoard> { ...@@ -118,6 +118,13 @@ class _DashBoardState extends State<DashBoard> {
118 ), 118 ),
119 ), 119 ),
120 body: _tabs[_selectedIndex], 120 body: _tabs[_selectedIndex],
121 + floatingActionButton: FloatingActionButton(
122 + onPressed: () {
123 + setState(() {});
124 + },
125 + child: const Icon(Icons.refresh_outlined),
126 + backgroundColor: Colors.blue,
127 + ),
121 bottomNavigationBar: BottomNavigationBar( 128 bottomNavigationBar: BottomNavigationBar(
122 type: BottomNavigationBarType.fixed, 129 type: BottomNavigationBarType.fixed,
123 backgroundColor: Colors.grey, 130 backgroundColor: Colors.grey,
...@@ -132,11 +139,12 @@ class _DashBoardState extends State<DashBoard> { ...@@ -132,11 +139,12 @@ class _DashBoardState extends State<DashBoard> {
132 }) 139 })
133 }, 140 },
134 items: [ 141 items: [
135 - BottomNavigationBarItem(icon: Icon(Icons.favorite), label: 'In'), 142 + BottomNavigationBarItem(
143 + icon: Icon(Icons.device_thermostat), label: 'In'),
136 BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'), 144 BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
137 BottomNavigationBarItem( 145 BottomNavigationBarItem(
138 label: 'Out', 146 label: 'Out',
139 - icon: Icon(Icons.favorite), 147 + icon: Icon(Icons.access_time),
140 ) 148 )
141 ], 149 ],
142 ), 150 ),
...@@ -146,8 +154,7 @@ class _DashBoardState extends State<DashBoard> { ...@@ -146,8 +154,7 @@ class _DashBoardState extends State<DashBoard> {
146 Navigator.push( 154 Navigator.push(
147 context, 155 context,
148 MaterialPageRoute( 156 MaterialPageRoute(
149 - builder: (BuildContext context) => 157 + builder: (BuildContext context) => BottleList(),
150 - BottleList(bottlelist: _bottleList),
151 )); 158 ));
152 }, 159 },
153 ); 160 );
......
...@@ -5,30 +5,85 @@ import 'package:http/http.dart' as http; ...@@ -5,30 +5,85 @@ import 'package:http/http.dart' as http;
5 import 'package:flutter_dotenv/flutter_dotenv.dart'; 5 import 'package:flutter_dotenv/flutter_dotenv.dart';
6 import '../models/Bottle.dart'; 6 import '../models/Bottle.dart';
7 import '../DashBoard.dart'; 7 import '../DashBoard.dart';
8 -import '../models/Medicine.dart';
9 import '../../utils/user_secure_stoarge.dart'; 8 import '../../utils/user_secure_stoarge.dart';
10 9
11 class BottleList extends StatefulWidget { 10 class BottleList extends StatefulWidget {
12 - List<Bottle> bottlelist; 11 + BottleList({Key key}) : super(key: key);
13 - BottleList({Key key, this.bottlelist}) : super(key: key);
14 12
15 @override 13 @override
16 _BottleListState createState() => _BottleListState(); 14 _BottleListState createState() => _BottleListState();
17 } 15 }
18 16
19 class _BottleListState extends State<BottleList> { 17 class _BottleListState extends State<BottleList> {
18 + List<Bottle> _bottleList = new List<Bottle>();
19 + Future<String> getBottleList() async {
20 + String hubid = await UserSecureStorage.getHubId();
21 + String usertoken = await UserSecureStorage.getUserToken();
22 + http.Response response = await http.get(
23 + Uri.encodeFull(
24 + DotEnv().env['SERVER_URL'] + 'bottle/hub/' + hubid.toString()),
25 + headers: {"authorization": usertoken},
26 + );
27 + print(response.body);
28 + print(1);
29 + if (_bottleList.length != 0) {
30 + _bottleList.clear();
31 + }
32 + if (response.statusCode == 200) {
33 + List<dynamic> values = new List<dynamic>();
34 + values = json.decode(response.body);
35 +
36 + for (int i = 0; i < values.length; i++) {
37 + Map<String, dynamic> map = values[i];
38 + _bottleList.add(Bottle.fromJson(map));
39 + }
40 + return "GET";
41 + } else if (response.statusCode == 404) {
42 + return "Not Found";
43 + } else {
44 + return "Error";
45 + }
46 + }
47 +
20 Widget build(BuildContext context) { 48 Widget build(BuildContext context) {
21 final Size size = MediaQuery.of(context).size; 49 final Size size = MediaQuery.of(context).size;
22 return WillPopScope( 50 return WillPopScope(
23 child: Scaffold( 51 child: Scaffold(
24 - body: Container( 52 + appBar: AppBar(
53 + backgroundColor: Colors.white,
54 + leading: new Icon(Icons.medical_services_rounded,
55 + color: Colors.black, size: 45.0),
56 + title: Text(
57 + 'Smart Medicine Box',
58 + style: TextStyle(
59 + color: Colors.black,
60 + fontSize: 23,
61 + fontFamily: 'Noto',
62 + fontWeight: FontWeight.bold),
63 + ),
64 + ),
65 + body: FutureBuilder(
66 + future: getBottleList(),
67 + builder: (BuildContext context, AsyncSnapshot snapshot) {
68 + if (snapshot.hasData == false) {
69 + return CircularProgressIndicator();
70 + } else if (snapshot.hasError) {
71 + return Padding(
72 + padding: const EdgeInsets.all(8.0),
73 + child: Text(
74 + 'Error: ${snapshot.error}',
75 + style: TextStyle(fontSize: 15),
76 + ),
77 + );
78 + } else {
79 + return Container(
25 height: size.height, 80 height: size.height,
26 child: Column( 81 child: Column(
27 mainAxisAlignment: MainAxisAlignment.center, 82 mainAxisAlignment: MainAxisAlignment.center,
28 children: <Widget>[ 83 children: <Widget>[
29 - SizedBox(height: 70), 84 + SizedBox(height: 10),
30 Container( 85 Container(
31 - height: size.height * 0.1, 86 + height: size.height * 0.07,
32 width: size.width, 87 width: size.width,
33 child: Center( 88 child: Center(
34 child: Text( 89 child: Text(
...@@ -40,35 +95,90 @@ class _BottleListState extends State<BottleList> { ...@@ -40,35 +95,90 @@ class _BottleListState extends State<BottleList> {
40 fontWeight: FontWeight.bold), 95 fontWeight: FontWeight.bold),
41 ), 96 ),
42 ), 97 ),
43 - decoration: BoxDecoration(border: Border.all()),
44 ), 98 ),
45 - SizedBox(height: 30), 99 + SizedBox(height: 10),
46 Expanded( 100 Expanded(
47 - child: ListView.separated( 101 + child: GridView.builder(
48 padding: const EdgeInsets.all(30), 102 padding: const EdgeInsets.all(30),
49 - itemCount: widget.bottlelist.length == null 103 + itemCount:
50 - ? 0 104 + _bottleList.length == null ? 0 : _bottleList.length,
51 - : widget.bottlelist.length, 105 + gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
106 + maxCrossAxisExtent: 200,
107 + crossAxisSpacing: 10,
108 + mainAxisSpacing: 10,
109 + ),
52 itemBuilder: (BuildContext context, int index) { 110 itemBuilder: (BuildContext context, int index) {
53 - return Container( 111 + return InkResponse(
54 - padding: EdgeInsets.all(8.0), 112 + splashColor: Colors.transparent,
55 - decoration: BoxDecoration(border: Border.all()), 113 + child: Container(
56 - child: ListTile( 114 + height: 140,
57 - title: Text( 115 + padding: const EdgeInsets.all(10),
58 - 'BOTTLE ID : ' + 116 + decoration: BoxDecoration(
59 - '${widget.bottlelist[index].bottleId}', 117 + border: Border.all(),
118 + borderRadius: BorderRadius.all(
119 + Radius.circular(16.0),
120 + ),
121 + ),
122 + child: Column(
123 + children: [
124 + Container(
125 + decoration: BoxDecoration(
126 + border: Border(
127 + bottom: BorderSide(
128 + color: Colors.black,
129 + width: 1,
130 + style: BorderStyle.solid),
131 + ),
132 + ),
133 + height: 40,
134 + child: Row(
135 + mainAxisAlignment:
136 + MainAxisAlignment.spaceBetween,
137 + children: [
138 + Container(
139 + height: 40,
140 + child: Center(
141 + child: Text(
142 + '${_bottleList[index].bottleId}',
60 style: TextStyle( 143 style: TextStyle(
61 color: Colors.black, 144 color: Colors.black,
62 fontSize: 20, 145 fontSize: 20,
63 fontFamily: 'Noto', 146 fontFamily: 'Noto',
64 fontWeight: FontWeight.bold), 147 fontWeight: FontWeight.bold),
65 ), 148 ),
66 - trailing: Icon(Icons.arrow_forward), 149 + ),
67 - onTap: () async { 150 + ),
151 + Container(
152 + child: IconButton(
153 + alignment: Alignment(0.9, 0),
154 + icon: Icon(
155 + Icons.create_sharp,
156 + color: Colors.black,
157 + ),
158 + onPressed: () {
159 + print("asdfg");
160 + },
161 + ),
162 + ),
163 + ],
164 + ),
165 + ),
166 + SizedBox(height: 10),
167 + Container(
168 + height: 90,
169 + child: Icon(
170 + Icons.medical_services_outlined,
171 + size: 100,
172 + ),
173 + )
174 + ],
175 + ),
176 + ),
177 + onTap: () {
68 UserSecureStorage.setBottleId( 178 UserSecureStorage.setBottleId(
69 - widget.bottlelist[index].bottleId.toString()); 179 + _bottleList[index].bottleId.toString());
70 UserSecureStorage.setMedicineId( 180 UserSecureStorage.setMedicineId(
71 - widget.bottlelist[index].medicineId.toString()); 181 + _bottleList[index].medicineId.toString());
72 Navigator.push( 182 Navigator.push(
73 context, 183 context,
74 MaterialPageRoute( 184 MaterialPageRoute(
...@@ -78,15 +188,16 @@ class _BottleListState extends State<BottleList> { ...@@ -78,15 +188,16 @@ class _BottleListState extends State<BottleList> {
78 ), 188 ),
79 ); 189 );
80 }, 190 },
81 - ),
82 ); 191 );
83 }, 192 },
84 - separatorBuilder: (BuildContext contetx, int index) =>
85 - const Divider(),
86 ), 193 ),
87 ) 194 )
88 ], 195 ],
89 - )), 196 + ),
197 + );
198 + }
199 + },
200 + ),
90 ), 201 ),
91 onWillPop: () { 202 onWillPop: () {
92 SystemNavigator.pop(); 203 SystemNavigator.pop();
......
...@@ -102,9 +102,7 @@ class _HubListState extends State<HubList> { ...@@ -102,9 +102,7 @@ class _HubListState extends State<HubList> {
102 context, 102 context,
103 MaterialPageRoute( 103 MaterialPageRoute(
104 builder: (BuildContext context) => 104 builder: (BuildContext context) =>
105 - BottleList( 105 + BottleList(),
106 - bottlelist: _bottleList,
107 - ),
108 )); 106 ));
109 } else if (result == "Not Found") { 107 } else if (result == "Not Found") {
110 showDialog( 108 showDialog(
......
1 +class UserBottle {
2 + String bottleId;
3 + String bottleName;
4 +
5 + UserBottle({this.bottleId, this.bottleName});
6 +}
...@@ -233,6 +233,13 @@ packages: ...@@ -233,6 +233,13 @@ packages:
233 url: "https://pub.dartlang.org" 233 url: "https://pub.dartlang.org"
234 source: hosted 234 source: hosted
235 version: "1.8.0-nullsafety.1" 235 version: "1.8.0-nullsafety.1"
236 + path_provider:
237 + dependency: "direct main"
238 + description:
239 + name: path_provider
240 + url: "https://pub.dartlang.org"
241 + source: hosted
242 + version: "1.6.28"
236 path_provider_linux: 243 path_provider_linux:
237 dependency: transitive 244 dependency: transitive
238 description: 245 description:
...@@ -240,6 +247,13 @@ packages: ...@@ -240,6 +247,13 @@ packages:
240 url: "https://pub.dartlang.org" 247 url: "https://pub.dartlang.org"
241 source: hosted 248 source: hosted
242 version: "0.0.1+2" 249 version: "0.0.1+2"
250 + path_provider_macos:
251 + dependency: transitive
252 + description:
253 + name: path_provider_macos
254 + url: "https://pub.dartlang.org"
255 + source: hosted
256 + version: "0.0.4+8"
243 path_provider_platform_interface: 257 path_provider_platform_interface:
244 dependency: transitive 258 dependency: transitive
245 description: 259 description:
...@@ -350,6 +364,20 @@ packages: ...@@ -350,6 +364,20 @@ packages:
350 url: "https://pub.dartlang.org" 364 url: "https://pub.dartlang.org"
351 source: hosted 365 source: hosted
352 version: "1.8.0-nullsafety.2" 366 version: "1.8.0-nullsafety.2"
367 + sqflite:
368 + dependency: "direct main"
369 + description:
370 + name: sqflite
371 + url: "https://pub.dartlang.org"
372 + source: hosted
373 + version: "1.3.2+4"
374 + sqflite_common:
375 + dependency: transitive
376 + description:
377 + name: sqflite_common
378 + url: "https://pub.dartlang.org"
379 + source: hosted
380 + version: "1.0.3+3"
353 stack_trace: 381 stack_trace:
354 dependency: transitive 382 dependency: transitive
355 description: 383 description:
...@@ -371,6 +399,13 @@ packages: ...@@ -371,6 +399,13 @@ packages:
371 url: "https://pub.dartlang.org" 399 url: "https://pub.dartlang.org"
372 source: hosted 400 source: hosted
373 version: "1.1.0-nullsafety.1" 401 version: "1.1.0-nullsafety.1"
402 + synchronized:
403 + dependency: transitive
404 + description:
405 + name: synchronized
406 + url: "https://pub.dartlang.org"
407 + source: hosted
408 + version: "2.2.0+2"
374 term_glyph: 409 term_glyph:
375 dependency: transitive 410 dependency: transitive
376 description: 411 description:
...@@ -421,5 +456,5 @@ packages: ...@@ -421,5 +456,5 @@ packages:
421 source: hosted 456 source: hosted
422 version: "0.1.2" 457 version: "0.1.2"
423 sdks: 458 sdks:
424 - dart: ">=2.10.0-110 <2.11.0" 459 + dart: ">=2.10.2 <2.11.0"
425 - flutter: ">=1.20.0 <2.0.0" 460 + flutter: ">=1.22.2 <2.0.0"
......
...@@ -39,6 +39,8 @@ dependencies: ...@@ -39,6 +39,8 @@ dependencies:
39 flutter_dotenv: ^2.1.0 39 flutter_dotenv: ^2.1.0
40 numberpicker: ^1.3.0 40 numberpicker: ^1.3.0
41 flutter_secure_storage: ^3.3.5 41 flutter_secure_storage: ^3.3.5
42 + sqflite: ^1.1.6
43 + path_provider: ^1.2.0
42 44
43 dev_dependencies: 45 dev_dependencies:
44 flutter_test: 46 flutter_test:
......