Showing
7 changed files
with
239 additions
and
76 deletions
... | @@ -89,4 +89,8 @@ appbar 관련 디자인은 추후 구현 예정 | ... | @@ -89,4 +89,8 @@ appbar 관련 디자인은 추후 구현 예정 |
89 | + future buillder 변경 | 89 | + future buillder 변경 |
90 | 90 | ||
91 | ### 2021-05-27 | 91 | ### 2021-05-27 |
92 | -+ app 뒤로가기 설정 변경 | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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,88 +5,199 @@ import 'package:http/http.dart' as http; | ... | @@ -5,88 +5,199 @@ 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( |
25 | - height: size.height, | 53 | + backgroundColor: Colors.white, |
26 | - child: Column( | 54 | + leading: new Icon(Icons.medical_services_rounded, |
27 | - mainAxisAlignment: MainAxisAlignment.center, | 55 | + color: Colors.black, size: 45.0), |
28 | - children: <Widget>[ | 56 | + title: Text( |
29 | - SizedBox(height: 70), | 57 | + 'Smart Medicine Box', |
30 | - Container( | 58 | + style: TextStyle( |
31 | - height: size.height * 0.1, | 59 | + color: Colors.black, |
32 | - width: size.width, | 60 | + fontSize: 23, |
33 | - child: Center( | 61 | + fontFamily: 'Noto', |
34 | - child: Text( | 62 | + fontWeight: FontWeight.bold), |
35 | - '등록된 약병 리스트', | 63 | + ), |
36 | - textScaleFactor: 1.0, | 64 | + ), |
37 | - style: TextStyle( | 65 | + body: FutureBuilder( |
38 | - fontSize: 28, | 66 | + future: getBottleList(), |
39 | - fontFamily: 'Noto', | 67 | + builder: (BuildContext context, AsyncSnapshot snapshot) { |
40 | - fontWeight: FontWeight.bold), | 68 | + if (snapshot.hasData == false) { |
41 | - ), | 69 | + return CircularProgressIndicator(); |
42 | - ), | 70 | + } else if (snapshot.hasError) { |
43 | - decoration: BoxDecoration(border: Border.all()), | 71 | + return Padding( |
72 | + padding: const EdgeInsets.all(8.0), | ||
73 | + child: Text( | ||
74 | + 'Error: ${snapshot.error}', | ||
75 | + style: TextStyle(fontSize: 15), | ||
44 | ), | 76 | ), |
45 | - SizedBox(height: 30), | 77 | + ); |
46 | - Expanded( | 78 | + } else { |
47 | - child: ListView.separated( | 79 | + return Container( |
48 | - padding: const EdgeInsets.all(30), | 80 | + height: size.height, |
49 | - itemCount: widget.bottlelist.length == null | 81 | + child: Column( |
50 | - ? 0 | 82 | + mainAxisAlignment: MainAxisAlignment.center, |
51 | - : widget.bottlelist.length, | 83 | + children: <Widget>[ |
52 | - itemBuilder: (BuildContext context, int index) { | 84 | + SizedBox(height: 10), |
53 | - return Container( | 85 | + Container( |
54 | - padding: EdgeInsets.all(8.0), | 86 | + height: size.height * 0.07, |
55 | - decoration: BoxDecoration(border: Border.all()), | 87 | + width: size.width, |
56 | - child: ListTile( | 88 | + child: Center( |
57 | - title: Text( | 89 | + child: Text( |
58 | - 'BOTTLE ID : ' + | 90 | + '등록된 약병 리스트', |
59 | - '${widget.bottlelist[index].bottleId}', | 91 | + textScaleFactor: 1.0, |
60 | - style: TextStyle( | 92 | + style: TextStyle( |
61 | - color: Colors.black, | 93 | + fontSize: 28, |
62 | - fontSize: 20, | 94 | + fontFamily: 'Noto', |
63 | - fontFamily: 'Noto', | 95 | + fontWeight: FontWeight.bold), |
64 | - fontWeight: FontWeight.bold), | 96 | + ), |
65 | - ), | 97 | + ), |
66 | - trailing: Icon(Icons.arrow_forward), | 98 | + ), |
67 | - onTap: () async { | 99 | + SizedBox(height: 10), |
68 | - UserSecureStorage.setBottleId( | 100 | + Expanded( |
69 | - widget.bottlelist[index].bottleId.toString()); | 101 | + child: GridView.builder( |
70 | - UserSecureStorage.setMedicineId( | 102 | + padding: const EdgeInsets.all(30), |
71 | - widget.bottlelist[index].medicineId.toString()); | 103 | + itemCount: |
72 | - Navigator.push( | 104 | + _bottleList.length == null ? 0 : _bottleList.length, |
73 | - context, | 105 | + gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( |
74 | - MaterialPageRoute( | 106 | + maxCrossAxisExtent: 200, |
75 | - builder: (BuildContext context) => DashBoard( | 107 | + crossAxisSpacing: 10, |
76 | - pageNumber: 1, | 108 | + mainAxisSpacing: 10, |
109 | + ), | ||
110 | + itemBuilder: (BuildContext context, int index) { | ||
111 | + return InkResponse( | ||
112 | + splashColor: Colors.transparent, | ||
113 | + child: Container( | ||
114 | + height: 140, | ||
115 | + padding: const EdgeInsets.all(10), | ||
116 | + decoration: BoxDecoration( | ||
117 | + border: Border.all(), | ||
118 | + borderRadius: BorderRadius.all( | ||
119 | + Radius.circular(16.0), | ||
77 | ), | 120 | ), |
78 | ), | 121 | ), |
79 | - ); | 122 | + child: Column( |
80 | - }, | 123 | + children: [ |
81 | - ), | 124 | + Container( |
82 | - ); | 125 | + decoration: BoxDecoration( |
83 | - }, | 126 | + border: Border( |
84 | - separatorBuilder: (BuildContext contetx, int index) => | 127 | + bottom: BorderSide( |
85 | - const Divider(), | 128 | + color: Colors.black, |
86 | - ), | 129 | + width: 1, |
87 | - ) | 130 | + style: BorderStyle.solid), |
88 | - ], | 131 | + ), |
89 | - )), | 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}', | ||
143 | + style: TextStyle( | ||
144 | + color: Colors.black, | ||
145 | + fontSize: 20, | ||
146 | + fontFamily: 'Noto', | ||
147 | + fontWeight: FontWeight.bold), | ||
148 | + ), | ||
149 | + ), | ||
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: () { | ||
178 | + UserSecureStorage.setBottleId( | ||
179 | + _bottleList[index].bottleId.toString()); | ||
180 | + UserSecureStorage.setMedicineId( | ||
181 | + _bottleList[index].medicineId.toString()); | ||
182 | + Navigator.push( | ||
183 | + context, | ||
184 | + MaterialPageRoute( | ||
185 | + builder: (BuildContext context) => DashBoard( | ||
186 | + pageNumber: 1, | ||
187 | + ), | ||
188 | + ), | ||
189 | + ); | ||
190 | + }, | ||
191 | + ); | ||
192 | + }, | ||
193 | + ), | ||
194 | + ) | ||
195 | + ], | ||
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( | ... | ... |
... | @@ -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: | ... | ... |
-
Please register or login to post a comment