Showing
15 changed files
with
687 additions
and
275 deletions
frontend/.idea/frontend.iml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<module type="JAVA_MODULE" version="4"> | ||
3 | + <component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
4 | + <exclude-output /> | ||
5 | + <content url="file://$MODULE_DIR$" /> | ||
6 | + <orderEntry type="inheritedJdk" /> | ||
7 | + <orderEntry type="sourceFolder" forTests="false" /> | ||
8 | + </component> | ||
9 | +</module> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
frontend/.idea/modules.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project version="4"> | ||
3 | + <component name="ProjectModuleManager"> | ||
4 | + <modules> | ||
5 | + <module fileurl="file://$PROJECT_DIR$/.idea/frontend.iml" filepath="$PROJECT_DIR$/.idea/frontend.iml" /> | ||
6 | + </modules> | ||
7 | + </component> | ||
8 | +</project> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
frontend/.idea/vcs.xml
0 → 100644
frontend/.idea/workspace.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project version="4"> | ||
3 | + <component name="ChangeListManager"> | ||
4 | + <list default="true" id="147dc7b8-1063-4e12-b6bb-adb3717b8080" name="Default Changelist" comment="" /> | ||
5 | + <option name="SHOW_DIALOG" value="false" /> | ||
6 | + <option name="HIGHLIGHT_CONFLICTS" value="true" /> | ||
7 | + <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> | ||
8 | + <option name="LAST_RESOLUTION" value="IGNORE" /> | ||
9 | + </component> | ||
10 | + <component name="Git.Settings"> | ||
11 | + <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> | ||
12 | + </component> | ||
13 | + <component name="ProjectId" id="1wtiCZt9s9osC3izQmO4Etd3c5k" /> | ||
14 | + <component name="ProjectViewState"> | ||
15 | + <option name="hideEmptyMiddlePackages" value="true" /> | ||
16 | + <option name="showLibraryContents" value="true" /> | ||
17 | + </component> | ||
18 | + <component name="PropertiesComponent"> | ||
19 | + <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" /> | ||
20 | + <property name="RunOnceActivity.ShowReadmeOnStart" value="true" /> | ||
21 | + <property name="last_opened_file_path" value="$PROJECT_DIR$/flutter_application_1" /> | ||
22 | + <property name="project.structure.last.edited" value="Project" /> | ||
23 | + <property name="project.structure.proportion" value="0.0" /> | ||
24 | + <property name="project.structure.side.proportion" value="0.0" /> | ||
25 | + </component> | ||
26 | + <component name="SvnConfiguration"> | ||
27 | + <configuration /> | ||
28 | + </component> | ||
29 | + <component name="TaskManager"> | ||
30 | + <task active="true" id="Default" summary="Default task"> | ||
31 | + <changelist id="147dc7b8-1063-4e12-b6bb-adb3717b8080" name="Default Changelist" comment="" /> | ||
32 | + <created>1629284158268</created> | ||
33 | + <option name="number" value="Default" /> | ||
34 | + <option name="presentableId" value="Default" /> | ||
35 | + <updated>1629284158268</updated> | ||
36 | + </task> | ||
37 | + <servers /> | ||
38 | + </component> | ||
39 | + <component name="WindowStateProjectService"> | ||
40 | + <state x="740" y="278" key="FileChooserDialogImpl" timestamp="1629284197342"> | ||
41 | + <screen x="0" y="0" width="1920" height="1040" /> | ||
42 | + </state> | ||
43 | + <state x="740" y="278" key="FileChooserDialogImpl/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1629284197342" /> | ||
44 | + <state x="440" y="98" key="SettingsEditor" timestamp="1629284186082"> | ||
45 | + <screen x="0" y="0" width="1920" height="1040" /> | ||
46 | + </state> | ||
47 | + <state x="440" y="98" key="SettingsEditor/-1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1629284186082" /> | ||
48 | + </component> | ||
49 | +</project> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
15 | <application | 15 | <application |
16 | android:name="io.flutter.app.FlutterApplication" | 16 | android:name="io.flutter.app.FlutterApplication" |
17 | android:label="Smart_Medicine_Box" | 17 | android:label="Smart_Medicine_Box" |
18 | + android:requestLegacyExternalStorage="true" | ||
18 | android:icon="@mipmap/ic_launcher"> | 19 | android:icon="@mipmap/ic_launcher"> |
19 | <activity | 20 | <activity |
20 | android:name=".MainActivity" | 21 | android:name=".MainActivity" | ... | ... |
... | @@ -2,3 +2,4 @@ org.gradle.jvmargs=-Xmx1536M | ... | @@ -2,3 +2,4 @@ org.gradle.jvmargs=-Xmx1536M |
2 | android.useAndroidX=true | 2 | android.useAndroidX=true |
3 | android.enableJetifier=true | 3 | android.enableJetifier=true |
4 | android.enableR8=true | 4 | android.enableR8=true |
5 | +org.gradle.jvmargs=-Xmx4608m | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | import 'dart:convert'; | 1 | import 'dart:convert'; |
2 | +import 'package:Smart_Medicine_Box/src/screens/Register/DoctorRequest.dart'; | ||
2 | import 'package:flutter/material.dart'; | 3 | import 'package:flutter/material.dart'; |
3 | import 'package:flutter/services.dart'; | 4 | import 'package:flutter/services.dart'; |
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 | -import '../models/Bottle.dart'; | 7 | +import 'models/Bottle.dart'; |
7 | -import '../DashBoard.dart'; | 8 | +import 'DashBoard.dart'; |
8 | -import '../../utils/user_secure_stoarge.dart'; | 9 | +import '../utils/user_secure_stoarge.dart'; |
9 | 10 | ||
10 | class BottleList extends StatefulWidget { | 11 | class BottleList extends StatefulWidget { |
11 | BottleList({Key key}) : super(key: key); | 12 | BottleList({Key key}) : super(key: key); |
... | @@ -15,9 +16,12 @@ class BottleList extends StatefulWidget { | ... | @@ -15,9 +16,12 @@ class BottleList extends StatefulWidget { |
15 | } | 16 | } |
16 | 17 | ||
17 | class _BottleListState extends State<BottleList> { | 18 | class _BottleListState extends State<BottleList> { |
19 | + int newalarm = 0; | ||
20 | + | ||
18 | String valueText; | 21 | String valueText; |
19 | List<Bottle> _bottleList = new List<Bottle>(); | 22 | List<Bottle> _bottleList = new List<Bottle>(); |
20 | TextEditingController _textFieldController = TextEditingController(); | 23 | TextEditingController _textFieldController = TextEditingController(); |
24 | + | ||
21 | Future<String> getBottleList() async { | 25 | Future<String> getBottleList() async { |
22 | String hubid = await UserSecureStorage.getHubId(); | 26 | String hubid = await UserSecureStorage.getHubId(); |
23 | String usertoken = await UserSecureStorage.getUserToken(); | 27 | String usertoken = await UserSecureStorage.getUserToken(); |
... | @@ -90,7 +94,7 @@ class _BottleListState extends State<BottleList> { | ... | @@ -90,7 +94,7 @@ class _BottleListState extends State<BottleList> { |
90 | width: size.width, | 94 | width: size.width, |
91 | child: Center( | 95 | child: Center( |
92 | child: Text( | 96 | child: Text( |
93 | - '등록된 약병 리스트', | 97 | + 'BOTTLE LIST', |
94 | textScaleFactor: 1.0, | 98 | textScaleFactor: 1.0, |
95 | style: TextStyle( | 99 | style: TextStyle( |
96 | fontSize: 28, | 100 | fontSize: 28, |
... | @@ -133,13 +137,13 @@ class _BottleListState extends State<BottleList> { | ... | @@ -133,13 +137,13 @@ class _BottleListState extends State<BottleList> { |
133 | style: BorderStyle.solid), | 137 | style: BorderStyle.solid), |
134 | ), | 138 | ), |
135 | ), | 139 | ), |
136 | - height: 40, | 140 | + height: 30, |
137 | child: Row( | 141 | child: Row( |
138 | mainAxisAlignment: | 142 | mainAxisAlignment: |
139 | MainAxisAlignment.spaceBetween, | 143 | MainAxisAlignment.spaceBetween, |
140 | children: [ | 144 | children: [ |
141 | Container( | 145 | Container( |
142 | - height: 40, | 146 | + height: 30, |
143 | child: Center( | 147 | child: Center( |
144 | child: Text( | 148 | child: Text( |
145 | '${_bottleList[index].bottleId}', | 149 | '${_bottleList[index].bottleId}', |
... | @@ -151,35 +155,29 @@ class _BottleListState extends State<BottleList> { | ... | @@ -151,35 +155,29 @@ class _BottleListState extends State<BottleList> { |
151 | ), | 155 | ), |
152 | ), | 156 | ), |
153 | ), | 157 | ), |
154 | - Container( | ||
155 | - child: IconButton( | ||
156 | - alignment: Alignment(0.9, 0), | ||
157 | - icon: Icon( | ||
158 | - Icons.create_sharp, | ||
159 | - color: Colors.black, | ||
160 | - ), | ||
161 | - onPressed: () {}, | ||
162 | - ), | ||
163 | - ), | ||
164 | ], | 158 | ], |
165 | ), | 159 | ), |
166 | ), | 160 | ), |
167 | - SizedBox(height: 10), | 161 | + SizedBox(height: 5), |
168 | Container( | 162 | Container( |
169 | - height: 90, | 163 | + height: 70, |
170 | child: Icon( | 164 | child: Icon( |
171 | Icons.medical_services_outlined, | 165 | Icons.medical_services_outlined, |
172 | - size: 100, | 166 | + size: 70, |
173 | ), | 167 | ), |
174 | ) | 168 | ) |
175 | ], | 169 | ], |
176 | ), | 170 | ), |
177 | ), | 171 | ), |
178 | onTap: () { | 172 | onTap: () { |
173 | + if (_bottleList[index].medicineId == null) { | ||
174 | + //약병에 약이 없는 경우 | ||
175 | + } else { | ||
179 | UserSecureStorage.setBottleId( | 176 | UserSecureStorage.setBottleId( |
180 | _bottleList[index].bottleId.toString()); | 177 | _bottleList[index].bottleId.toString()); |
181 | UserSecureStorage.setMedicineId( | 178 | UserSecureStorage.setMedicineId( |
182 | _bottleList[index].medicineId.toString()); | 179 | _bottleList[index].medicineId.toString()); |
180 | + } | ||
183 | Navigator.push( | 181 | Navigator.push( |
184 | context, | 182 | context, |
185 | MaterialPageRoute( | 183 | MaterialPageRoute( |
... | @@ -199,6 +197,53 @@ class _BottleListState extends State<BottleList> { | ... | @@ -199,6 +197,53 @@ class _BottleListState extends State<BottleList> { |
199 | } | 197 | } |
200 | }, | 198 | }, |
201 | ), | 199 | ), |
200 | + floatingActionButton: Container( | ||
201 | + child: FittedBox( | ||
202 | + child: Stack( | ||
203 | + alignment: Alignment(1.4, -1.5), | ||
204 | + children: [ | ||
205 | + FloatingActionButton( | ||
206 | + onPressed: () { | ||
207 | + //여기 누르면 넘어가는데 아마 숫자가 있을 경우만 넘어가도록 하기 | ||
208 | + Navigator.push( | ||
209 | + context, | ||
210 | + MaterialPageRoute( | ||
211 | + builder: (BuildContext context) => DoctorRequest(), | ||
212 | + ), | ||
213 | + ); | ||
214 | + }, | ||
215 | + child: Icon(Icons.email_outlined), | ||
216 | + backgroundColor: Colors.blue, | ||
217 | + ), | ||
218 | + newalarm != 0 | ||
219 | + ? Container( | ||
220 | + // This is your Badge | ||
221 | + child: Center( | ||
222 | + // child 문을 ? : 를 이용하여 구분하자 | ||
223 | + child: Text(newalarm.toString(), | ||
224 | + style: TextStyle(color: Colors.white)), | ||
225 | + ), | ||
226 | + padding: EdgeInsets.all(8), | ||
227 | + constraints: | ||
228 | + BoxConstraints(minHeight: 32, minWidth: 32), | ||
229 | + decoration: BoxDecoration( | ||
230 | + // This controls the shadow | ||
231 | + boxShadow: [ | ||
232 | + BoxShadow( | ||
233 | + spreadRadius: 1, | ||
234 | + blurRadius: 5, | ||
235 | + color: Colors.black.withAlpha(50)) | ||
236 | + ], | ||
237 | + borderRadius: BorderRadius.circular(16), | ||
238 | + color: | ||
239 | + Colors.blue, // This would be color of the Badge | ||
240 | + ), | ||
241 | + ) | ||
242 | + : new Container() | ||
243 | + ], | ||
244 | + ), | ||
245 | + ), | ||
246 | + ), | ||
202 | ), | 247 | ), |
203 | onWillPop: () { | 248 | onWillPop: () { |
204 | SystemNavigator.pop(); | 249 | SystemNavigator.pop(); | ... | ... |
... | @@ -8,9 +8,9 @@ import '../utils/user_secure_stoarge.dart'; | ... | @@ -8,9 +8,9 @@ import '../utils/user_secure_stoarge.dart'; |
8 | import 'models/Bottle.dart'; | 8 | import 'models/Bottle.dart'; |
9 | import 'models/Medicine.dart'; | 9 | import 'models/Medicine.dart'; |
10 | import 'package:Smart_Medicine_Box/src/screens/SettingPage.dart'; | 10 | import 'package:Smart_Medicine_Box/src/screens/SettingPage.dart'; |
11 | -import 'Register/BottleList.dart'; | 11 | +import 'BottleList.dart'; |
12 | +import 'MainPage.dart'; | ||
12 | import 'Register/SearchMedicine.dart'; | 13 | import 'Register/SearchMedicine.dart'; |
13 | -import 'package:intl/date_symbol_data_local.dart'; | ||
14 | 14 | ||
15 | class DashBoard extends StatefulWidget { | 15 | class DashBoard extends StatefulWidget { |
16 | int pageNumber; | 16 | int pageNumber; |
... | @@ -59,8 +59,8 @@ class _DashBoardState extends State<DashBoard> { | ... | @@ -59,8 +59,8 @@ class _DashBoardState extends State<DashBoard> { |
59 | _selectedIndex = widget.pageNumber; | 59 | _selectedIndex = widget.pageNumber; |
60 | var _tabs = [ | 60 | var _tabs = [ |
61 | ineerInformationpage(context), | 61 | ineerInformationpage(context), |
62 | - mainpage(context), | 62 | + MainPage(), |
63 | - outerInformationpage(context), | 63 | + feedBackPage(context), |
64 | ]; | 64 | ]; |
65 | 65 | ||
66 | return WillPopScope( | 66 | return WillPopScope( |
... | @@ -131,8 +131,8 @@ class _DashBoardState extends State<DashBoard> { | ... | @@ -131,8 +131,8 @@ class _DashBoardState extends State<DashBoard> { |
131 | icon: Icon(Icons.device_thermostat), label: 'In'), | 131 | icon: Icon(Icons.device_thermostat), label: 'In'), |
132 | BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'), | 132 | BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'), |
133 | BottomNavigationBarItem( | 133 | BottomNavigationBarItem( |
134 | - label: 'Out', | 134 | + label: 'Feedback', |
135 | - icon: Icon(Icons.access_time), | 135 | + icon: Icon(Icons.feedback), |
136 | ) | 136 | ) |
137 | ], | 137 | ], |
138 | ), | 138 | ), |
... | @@ -155,233 +155,6 @@ class _DashBoardState extends State<DashBoard> { | ... | @@ -155,233 +155,6 @@ class _DashBoardState extends State<DashBoard> { |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | -Widget mainpage(BuildContext context) { | ||
159 | - Medicine _medicineInformation = new Medicine(); | ||
160 | - | ||
161 | - Future<Medicine> _getmedicine() async { | ||
162 | - String usertoken = await UserSecureStorage.getUserToken(); | ||
163 | - String medicineid = await UserSecureStorage.getMedicineId(); | ||
164 | - | ||
165 | - http.Response medicineresponse = await http.get( | ||
166 | - Uri.encodeFull( | ||
167 | - DotEnv().env['SERVER_URL'] + 'medicine/' + medicineid.toString()), | ||
168 | - headers: {"authorization": usertoken}, | ||
169 | - ); | ||
170 | - | ||
171 | - if (medicineresponse.statusCode == 200) { | ||
172 | - Map<String, dynamic> data = jsonDecode(medicineresponse.body); | ||
173 | - _medicineInformation = Medicine.fromJson(data); | ||
174 | - } | ||
175 | - return _medicineInformation; | ||
176 | - } | ||
177 | - | ||
178 | - final Size size = MediaQuery.of(context).size; | ||
179 | - return Scaffold( | ||
180 | - backgroundColor: Colors.white, | ||
181 | - body: SingleChildScrollView( | ||
182 | - child: FutureBuilder( | ||
183 | - future: _getmedicine(), | ||
184 | - builder: (BuildContext context, AsyncSnapshot snapshot) { | ||
185 | - if (snapshot.hasData == false) { | ||
186 | - return CircularProgressIndicator(); | ||
187 | - } else if (snapshot.hasError) { | ||
188 | - return Padding( | ||
189 | - padding: const EdgeInsets.all(8.0), | ||
190 | - child: Text( | ||
191 | - 'Error: ${snapshot.error}', | ||
192 | - style: TextStyle(fontSize: 15), | ||
193 | - ), | ||
194 | - ); | ||
195 | - } else { | ||
196 | - return Container( | ||
197 | - margin: EdgeInsets.fromLTRB(0, 30, 0, 0), | ||
198 | - padding: EdgeInsets.fromLTRB(5, 0, 5, 5), | ||
199 | - child: Column( | ||
200 | - crossAxisAlignment: CrossAxisAlignment.center, | ||
201 | - children: <Widget>[ | ||
202 | - SizedBox(height: 20), | ||
203 | - Container( | ||
204 | - width: size.width, | ||
205 | - padding: EdgeInsets.fromLTRB(5, 0, 5, 5), | ||
206 | - margin: EdgeInsets.all(15), | ||
207 | - decoration: BoxDecoration( | ||
208 | - border: Border.all(), | ||
209 | - borderRadius: BorderRadius.all(Radius.circular( | ||
210 | - 25.0) // <--- border radius here | ||
211 | - ), | ||
212 | - ), | ||
213 | - child: Column( | ||
214 | - children: [ | ||
215 | - SizedBox(height: 30), | ||
216 | - Container( | ||
217 | - child: Center( | ||
218 | - child: Text( | ||
219 | - '${snapshot.data.name}' == null | ||
220 | - ? '-' | ||
221 | - : '${snapshot.data.name}', | ||
222 | - style: TextStyle( | ||
223 | - color: Colors.black, | ||
224 | - fontSize: 24, | ||
225 | - fontFamily: 'NotoSansKR', | ||
226 | - fontWeight: FontWeight.w700)), | ||
227 | - ), | ||
228 | - ), | ||
229 | - SizedBox(height: 30), | ||
230 | - Container( | ||
231 | - width: size.width, | ||
232 | - alignment: Alignment(0.9, 0), | ||
233 | - child: Wrap( | ||
234 | - children: [ | ||
235 | - Text( | ||
236 | - '제조사: ', | ||
237 | - style: TextStyle( | ||
238 | - color: Colors.grey, | ||
239 | - fontSize: 14, | ||
240 | - ), | ||
241 | - ), | ||
242 | - Text( | ||
243 | - _medicineInformation.company == null | ||
244 | - ? '-' | ||
245 | - : _medicineInformation.company, | ||
246 | - style: TextStyle( | ||
247 | - color: Colors.grey, | ||
248 | - fontSize: 14, | ||
249 | - ), | ||
250 | - ), | ||
251 | - ], | ||
252 | - ), | ||
253 | - ), | ||
254 | - SizedBox(height: 30), | ||
255 | - Container( | ||
256 | - width: size.width, | ||
257 | - padding: EdgeInsets.fromLTRB(5, 0, 5, 0), | ||
258 | - alignment: Alignment(-1, 0), | ||
259 | - child: Wrap( | ||
260 | - children: [ | ||
261 | - Text( | ||
262 | - '타겟 층 : ', | ||
263 | - style: TextStyle( | ||
264 | - color: Colors.grey, | ||
265 | - fontSize: 14, | ||
266 | - ), | ||
267 | - ), | ||
268 | - Text( | ||
269 | - _medicineInformation.target == null | ||
270 | - ? '-' | ||
271 | - : _medicineInformation.target, | ||
272 | - style: TextStyle( | ||
273 | - color: Colors.grey, | ||
274 | - fontSize: 14, | ||
275 | - ), | ||
276 | - ), | ||
277 | - ], | ||
278 | - ), | ||
279 | - ), | ||
280 | - SizedBox(height: 15), | ||
281 | - Container( | ||
282 | - width: size.width, | ||
283 | - padding: EdgeInsets.fromLTRB(5, 0, 5, 0), | ||
284 | - alignment: Alignment(-1, 0), | ||
285 | - child: Wrap( | ||
286 | - children: [ | ||
287 | - Text( | ||
288 | - '복약 정보 : ', | ||
289 | - style: TextStyle( | ||
290 | - color: Colors.grey, | ||
291 | - fontSize: 14, | ||
292 | - ), | ||
293 | - ), | ||
294 | - Text( | ||
295 | - _medicineInformation.dosage == null | ||
296 | - ? '-' | ||
297 | - : _medicineInformation.dosage, | ||
298 | - style: TextStyle( | ||
299 | - color: Colors.grey, | ||
300 | - fontSize: 14, | ||
301 | - ), | ||
302 | - ), | ||
303 | - ], | ||
304 | - ), | ||
305 | - ), | ||
306 | - SizedBox(height: 10), | ||
307 | - Container( | ||
308 | - width: size.width, | ||
309 | - padding: EdgeInsets.fromLTRB(5, 10, 5, 10), | ||
310 | - alignment: Alignment(-1, 0), | ||
311 | - child: Column( | ||
312 | - children: [ | ||
313 | - SizedBox( | ||
314 | - height: 12, | ||
315 | - ), | ||
316 | - Container( | ||
317 | - width: size.width, | ||
318 | - child: Text( | ||
319 | - '경고', | ||
320 | - style: TextStyle( | ||
321 | - color: Colors.redAccent, fontSize: 14), | ||
322 | - ), | ||
323 | - ), | ||
324 | - SizedBox(height: 12), | ||
325 | - Container( | ||
326 | - width: size.width, | ||
327 | - child: Text( | ||
328 | - _medicineInformation.warn == null | ||
329 | - ? '-' | ||
330 | - : _medicineInformation.warn, | ||
331 | - style: TextStyle( | ||
332 | - color: Colors.redAccent, fontSize: 14), | ||
333 | - ), | ||
334 | - ), | ||
335 | - ], | ||
336 | - ), | ||
337 | - ), | ||
338 | - ], | ||
339 | - ), | ||
340 | - ), | ||
341 | - GestureDetector( | ||
342 | - child: Container( | ||
343 | - width: size.width * 0.8, | ||
344 | - height: 46, | ||
345 | - margin: EdgeInsets.only(bottom: 0), | ||
346 | - child: FlatButton( | ||
347 | - padding: EdgeInsets.fromLTRB(0, 5, 0, 5), | ||
348 | - onPressed: () async { | ||
349 | - String bottleid = | ||
350 | - await UserSecureStorage.getBottleId(); | ||
351 | - Navigator.push( | ||
352 | - context, | ||
353 | - MaterialPageRoute( | ||
354 | - builder: (BuildContext context) => SearchMedicine( | ||
355 | - bottleId: bottleid, | ||
356 | - ), | ||
357 | - ), | ||
358 | - ); | ||
359 | - }, | ||
360 | - child: Text( | ||
361 | - '약 검색', | ||
362 | - textScaleFactor: 1.0, | ||
363 | - style: TextStyle( | ||
364 | - color: Colors.white, | ||
365 | - fontSize: 16, | ||
366 | - fontFamily: 'Noto', | ||
367 | - fontWeight: FontWeight.bold), | ||
368 | - ), | ||
369 | - color: Color(0xff1674f6), | ||
370 | - shape: RoundedRectangleBorder( | ||
371 | - borderRadius: BorderRadius.circular(50)), | ||
372 | - ), | ||
373 | - ), | ||
374 | - ), | ||
375 | - ], | ||
376 | - ), | ||
377 | - ); | ||
378 | - } | ||
379 | - }, | ||
380 | - ), | ||
381 | - ), | ||
382 | - ); | ||
383 | -} | ||
384 | - | ||
385 | Widget ineerInformationpage(BuildContext context) { | 158 | Widget ineerInformationpage(BuildContext context) { |
386 | //get bottle | 159 | //get bottle |
387 | Future<Bottle> _getbottle() async { | 160 | Future<Bottle> _getbottle() async { |
... | @@ -473,7 +246,7 @@ Widget ineerInformationpage(BuildContext context) { | ... | @@ -473,7 +246,7 @@ Widget ineerInformationpage(BuildContext context) { |
473 | textScaleFactor: 1.0, | 246 | textScaleFactor: 1.0, |
474 | style: TextStyle( | 247 | style: TextStyle( |
475 | color: Colors.white, | 248 | color: Colors.white, |
476 | - fontSize: 24, | 249 | + fontSize: 20, |
477 | fontFamily: 'NotoSansKR', | 250 | fontFamily: 'NotoSansKR', |
478 | fontWeight: FontWeight.w800), | 251 | fontWeight: FontWeight.w800), |
479 | ), | 252 | ), |
... | @@ -538,7 +311,7 @@ Widget ineerInformationpage(BuildContext context) { | ... | @@ -538,7 +311,7 @@ Widget ineerInformationpage(BuildContext context) { |
538 | textScaleFactor: 1.0, | 311 | textScaleFactor: 1.0, |
539 | style: TextStyle( | 312 | style: TextStyle( |
540 | color: Colors.white, | 313 | color: Colors.white, |
541 | - fontSize: 24, | 314 | + fontSize: 20, |
542 | fontFamily: 'NotoSansKR', | 315 | fontFamily: 'NotoSansKR', |
543 | fontWeight: FontWeight.w800), | 316 | fontWeight: FontWeight.w800), |
544 | ), | 317 | ), |
... | @@ -621,7 +394,7 @@ Widget ineerInformationpage(BuildContext context) { | ... | @@ -621,7 +394,7 @@ Widget ineerInformationpage(BuildContext context) { |
621 | textScaleFactor: 1.0, | 394 | textScaleFactor: 1.0, |
622 | style: TextStyle( | 395 | style: TextStyle( |
623 | color: Colors.white, | 396 | color: Colors.white, |
624 | - fontSize: 24, | 397 | + fontSize: 20, |
625 | fontFamily: 'NotoSansKR', | 398 | fontFamily: 'NotoSansKR', |
626 | fontWeight: FontWeight.w800), | 399 | fontWeight: FontWeight.w800), |
627 | ), | 400 | ), |
... | @@ -687,7 +460,7 @@ Widget ineerInformationpage(BuildContext context) { | ... | @@ -687,7 +460,7 @@ Widget ineerInformationpage(BuildContext context) { |
687 | textScaleFactor: 1.0, | 460 | textScaleFactor: 1.0, |
688 | style: TextStyle( | 461 | style: TextStyle( |
689 | color: Colors.white, | 462 | color: Colors.white, |
690 | - fontSize: 24, | 463 | + fontSize: 20, |
691 | fontFamily: 'NotoSansKR', | 464 | fontFamily: 'NotoSansKR', |
692 | fontWeight: FontWeight.w800), | 465 | fontWeight: FontWeight.w800), |
693 | ), | 466 | ), |
... | @@ -706,7 +479,7 @@ Widget ineerInformationpage(BuildContext context) { | ... | @@ -706,7 +479,7 @@ Widget ineerInformationpage(BuildContext context) { |
706 | textScaleFactor: 1.0, | 479 | textScaleFactor: 1.0, |
707 | style: TextStyle( | 480 | style: TextStyle( |
708 | color: Colors.white, | 481 | color: Colors.white, |
709 | - fontSize: 60, | 482 | + fontSize: 40, |
710 | fontFamily: 'NotoSansKR', | 483 | fontFamily: 'NotoSansKR', |
711 | fontWeight: FontWeight.w800), | 484 | fontWeight: FontWeight.w800), |
712 | ), | 485 | ), |
... | @@ -730,7 +503,7 @@ Widget ineerInformationpage(BuildContext context) { | ... | @@ -730,7 +503,7 @@ Widget ineerInformationpage(BuildContext context) { |
730 | ); | 503 | ); |
731 | } | 504 | } |
732 | 505 | ||
733 | -Widget outerInformationpage(BuildContext context) { | 506 | +Widget feedBackPage(BuildContext context) { |
734 | Bottle _bottleinformation = new Bottle(); | 507 | Bottle _bottleinformation = new Bottle(); |
735 | //get bottle | 508 | //get bottle |
736 | Future<Bottle> _getbottle() async { | 509 | Future<Bottle> _getbottle() async { | ... | ... |
File mode changed
1 | +import 'package:flutter/material.dart'; | ||
2 | +import 'dart:convert'; | ||
3 | +import 'package:http/http.dart' as http; | ||
4 | +import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
5 | + | ||
6 | +import '../utils/user_secure_stoarge.dart'; | ||
7 | + | ||
8 | +import 'models/Medicine.dart'; | ||
9 | + | ||
10 | +import 'Register/SearchMedicine.dart'; | ||
11 | +//import 'package:flutter_material_pickers/flutter_material_pickers.dart'; | ||
12 | + | ||
13 | +class MainPage extends StatefulWidget { | ||
14 | + @override | ||
15 | + _MainPageState createState() => _MainPageState(); | ||
16 | +} | ||
17 | + | ||
18 | +class _MainPageState extends State<MainPage> { | ||
19 | + Widget build(BuildContext context) { | ||
20 | + Medicine _medicineInformation = new Medicine(); | ||
21 | + List<String> doctorlist = ['temp1', 'temp2', 'temp3', 'temp4']; | ||
22 | + | ||
23 | + String seletedDoctor = ''; | ||
24 | + Future<Medicine> _getmedicine() async { | ||
25 | + String usertoken = await UserSecureStorage.getUserToken(); | ||
26 | + String medicineid = await UserSecureStorage.getMedicineId(); | ||
27 | + | ||
28 | + http.Response medicineresponse = await http.get( | ||
29 | + Uri.encodeFull( | ||
30 | + DotEnv().env['SERVER_URL'] + 'medicine/' + medicineid.toString()), | ||
31 | + headers: {"authorization": usertoken}, | ||
32 | + ); | ||
33 | + | ||
34 | + if (medicineresponse.statusCode == 200) { | ||
35 | + Map<String, dynamic> data = jsonDecode(medicineresponse.body); | ||
36 | + _medicineInformation = Medicine.fromJson(data); | ||
37 | + } | ||
38 | + return _medicineInformation; | ||
39 | + } | ||
40 | + | ||
41 | + final Size size = MediaQuery.of(context).size; | ||
42 | + return Scaffold( | ||
43 | + backgroundColor: Colors.white, | ||
44 | + body: SingleChildScrollView( | ||
45 | + child: FutureBuilder( | ||
46 | + future: _getmedicine(), | ||
47 | + builder: (BuildContext context, AsyncSnapshot snapshot) { | ||
48 | + if (snapshot.hasData == false) { | ||
49 | + return CircularProgressIndicator(); | ||
50 | + } else if (snapshot.hasError) { | ||
51 | + return Padding( | ||
52 | + padding: const EdgeInsets.all(8.0), | ||
53 | + child: Text( | ||
54 | + 'Error: ${snapshot.error}', | ||
55 | + style: TextStyle(fontSize: 15), | ||
56 | + ), | ||
57 | + ); | ||
58 | + } else { | ||
59 | + return Container( | ||
60 | + margin: EdgeInsets.fromLTRB(0, 30, 0, 0), | ||
61 | + padding: EdgeInsets.fromLTRB(5, 0, 5, 5), | ||
62 | + child: Column( | ||
63 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
64 | + children: <Widget>[ | ||
65 | + SizedBox(height: 10), | ||
66 | + Container( | ||
67 | + width: size.width, | ||
68 | + padding: EdgeInsets.fromLTRB(5, 0, 5, 5), | ||
69 | + margin: EdgeInsets.all(15), | ||
70 | + decoration: BoxDecoration( | ||
71 | + border: Border.all(), | ||
72 | + borderRadius: BorderRadius.all(Radius.circular( | ||
73 | + 25.0) // <--- border radius here | ||
74 | + ), | ||
75 | + ), | ||
76 | + child: Column( | ||
77 | + children: [ | ||
78 | + SizedBox(height: 20), | ||
79 | + Container( | ||
80 | + child: Center( | ||
81 | + child: Text( | ||
82 | + '${snapshot.data.name}' == null | ||
83 | + ? '-' | ||
84 | + : '${snapshot.data.name}', | ||
85 | + style: TextStyle( | ||
86 | + color: Colors.black, | ||
87 | + fontSize: 24, | ||
88 | + fontFamily: 'NotoSansKR', | ||
89 | + fontWeight: FontWeight.w700)), | ||
90 | + ), | ||
91 | + ), | ||
92 | + SizedBox(height: 10), | ||
93 | + Container( | ||
94 | + width: size.width, | ||
95 | + alignment: Alignment(0.9, 0), | ||
96 | + child: Wrap( | ||
97 | + children: [ | ||
98 | + Text( | ||
99 | + '처방의: ', | ||
100 | + style: TextStyle( | ||
101 | + color: Colors.black, | ||
102 | + fontSize: 16, | ||
103 | + fontFamily: 'NotoSansKR', | ||
104 | + fontWeight: FontWeight.w700), | ||
105 | + ), | ||
106 | + Text( | ||
107 | + _medicineInformation.company == null | ||
108 | + ? '-' | ||
109 | + : '대강 처방의 이름', | ||
110 | + style: TextStyle( | ||
111 | + color: Colors.black, | ||
112 | + fontSize: 16, | ||
113 | + fontFamily: 'NotoSansKR', | ||
114 | + fontWeight: FontWeight.w700), | ||
115 | + ), | ||
116 | + ], | ||
117 | + ), | ||
118 | + ), | ||
119 | + SizedBox(height: 20), | ||
120 | + Container( | ||
121 | + width: size.width, | ||
122 | + alignment: Alignment(0.9, 0), | ||
123 | + child: Wrap( | ||
124 | + children: [ | ||
125 | + Text( | ||
126 | + '제조사: ', | ||
127 | + style: TextStyle( | ||
128 | + color: Colors.grey, | ||
129 | + fontSize: 14, | ||
130 | + ), | ||
131 | + ), | ||
132 | + Text( | ||
133 | + _medicineInformation.company == null | ||
134 | + ? '-' | ||
135 | + : _medicineInformation.company, | ||
136 | + style: TextStyle( | ||
137 | + color: Colors.grey, | ||
138 | + fontSize: 14, | ||
139 | + ), | ||
140 | + ), | ||
141 | + ], | ||
142 | + ), | ||
143 | + ), | ||
144 | + SizedBox(height: 30), | ||
145 | + Container( | ||
146 | + width: size.width, | ||
147 | + padding: EdgeInsets.fromLTRB(5, 0, 5, 0), | ||
148 | + alignment: Alignment(-1, 0), | ||
149 | + child: Wrap( | ||
150 | + children: [ | ||
151 | + Text( | ||
152 | + '타겟 층 : ', | ||
153 | + style: TextStyle( | ||
154 | + color: Colors.grey, | ||
155 | + fontSize: 14, | ||
156 | + ), | ||
157 | + ), | ||
158 | + Text( | ||
159 | + _medicineInformation.target == null | ||
160 | + ? '-' | ||
161 | + : _medicineInformation.target, | ||
162 | + style: TextStyle( | ||
163 | + color: Colors.grey, | ||
164 | + fontSize: 14, | ||
165 | + ), | ||
166 | + ), | ||
167 | + ], | ||
168 | + ), | ||
169 | + ), | ||
170 | + SizedBox(height: 15), | ||
171 | + Container( | ||
172 | + width: size.width, | ||
173 | + padding: EdgeInsets.fromLTRB(5, 0, 5, 0), | ||
174 | + alignment: Alignment(-1, 0), | ||
175 | + child: Wrap( | ||
176 | + children: [ | ||
177 | + Text( | ||
178 | + '복약 정보 : ', | ||
179 | + style: TextStyle( | ||
180 | + color: Colors.grey, | ||
181 | + fontSize: 14, | ||
182 | + ), | ||
183 | + ), | ||
184 | + Text( | ||
185 | + _medicineInformation.dosage == null | ||
186 | + ? '-' | ||
187 | + : _medicineInformation.dosage, | ||
188 | + style: TextStyle( | ||
189 | + color: Colors.grey, | ||
190 | + fontSize: 14, | ||
191 | + ), | ||
192 | + ), | ||
193 | + ], | ||
194 | + ), | ||
195 | + ), | ||
196 | + SizedBox(height: 10), | ||
197 | + Container( | ||
198 | + width: size.width, | ||
199 | + padding: EdgeInsets.fromLTRB(5, 10, 5, 10), | ||
200 | + alignment: Alignment(-1, 0), | ||
201 | + child: Column( | ||
202 | + children: [ | ||
203 | + SizedBox( | ||
204 | + height: 12, | ||
205 | + ), | ||
206 | + Container( | ||
207 | + width: size.width, | ||
208 | + child: Text( | ||
209 | + '경고', | ||
210 | + style: TextStyle( | ||
211 | + color: Colors.redAccent, fontSize: 14), | ||
212 | + ), | ||
213 | + ), | ||
214 | + SizedBox(height: 12), | ||
215 | + Container( | ||
216 | + width: size.width, | ||
217 | + child: Text( | ||
218 | + _medicineInformation.warn == null | ||
219 | + ? '-' | ||
220 | + : _medicineInformation.warn, | ||
221 | + style: TextStyle( | ||
222 | + color: Colors.redAccent, fontSize: 14), | ||
223 | + ), | ||
224 | + ), | ||
225 | + ], | ||
226 | + ), | ||
227 | + ), | ||
228 | + ], | ||
229 | + ), | ||
230 | + ), | ||
231 | + GestureDetector( | ||
232 | + child: Container( | ||
233 | + width: size.width * 0.8, | ||
234 | + height: 46, | ||
235 | + margin: EdgeInsets.only(bottom: 0), | ||
236 | + child: FlatButton( | ||
237 | + padding: EdgeInsets.fromLTRB(0, 5, 0, 5), | ||
238 | + onPressed: () async { | ||
239 | + String bottleid = | ||
240 | + await UserSecureStorage.getBottleId(); | ||
241 | + Navigator.push( | ||
242 | + context, | ||
243 | + MaterialPageRoute( | ||
244 | + builder: (BuildContext context) => | ||
245 | + SearchMedicine( | ||
246 | + bottleId: bottleid, | ||
247 | + ), | ||
248 | + ), | ||
249 | + ); | ||
250 | + }, | ||
251 | + child: Text( | ||
252 | + '약 검색', | ||
253 | + textScaleFactor: 1.0, | ||
254 | + style: TextStyle( | ||
255 | + color: Colors.white, | ||
256 | + fontSize: 16, | ||
257 | + fontFamily: 'Noto', | ||
258 | + fontWeight: FontWeight.bold), | ||
259 | + ), | ||
260 | + color: Color(0xff1674f6), | ||
261 | + shape: RoundedRectangleBorder( | ||
262 | + borderRadius: BorderRadius.circular(50)), | ||
263 | + ), | ||
264 | + ), | ||
265 | + ), | ||
266 | + SizedBox(height: 20), | ||
267 | + GestureDetector( | ||
268 | + child: Container( | ||
269 | + width: size.width * 0.8, | ||
270 | + height: 46, | ||
271 | + margin: EdgeInsets.only(bottom: 0), | ||
272 | + child: FlatButton( | ||
273 | + padding: EdgeInsets.fromLTRB(0, 5, 0, 5), | ||
274 | + onPressed: () async { | ||
275 | + /*showMaterialScrollPicker( | ||
276 | + context: context, | ||
277 | + title: '처방의', | ||
278 | + items: doctorlist, | ||
279 | + selectedItem: seletedDoctor, | ||
280 | + onChanged: (value) => | ||
281 | + setState(() => seletedDoctor = value), | ||
282 | + );*/ | ||
283 | + }, | ||
284 | + child: Text( | ||
285 | + '처방의 변경', | ||
286 | + textScaleFactor: 1.0, | ||
287 | + style: TextStyle( | ||
288 | + color: Colors.white, | ||
289 | + fontSize: 16, | ||
290 | + fontFamily: 'Noto', | ||
291 | + fontWeight: FontWeight.bold), | ||
292 | + ), | ||
293 | + color: Color(0xff1674f6), | ||
294 | + shape: RoundedRectangleBorder( | ||
295 | + borderRadius: BorderRadius.circular(50)), | ||
296 | + ), | ||
297 | + ), | ||
298 | + ), | ||
299 | + ], | ||
300 | + ), | ||
301 | + ); | ||
302 | + } | ||
303 | + }, | ||
304 | + ), | ||
305 | + ), | ||
306 | + ); | ||
307 | + } | ||
308 | +} |
1 | +import 'dart:convert'; | ||
2 | +import 'package:flutter/cupertino.dart'; | ||
3 | +import 'package:flutter/material.dart'; | ||
4 | +import 'package:http/http.dart' as http; | ||
5 | +import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
6 | +import '../../utils/user_secure_stoarge.dart'; | ||
7 | + | ||
8 | +class DoctorRequest extends StatefulWidget { | ||
9 | + @override | ||
10 | + _DoctorRequestState createState() => _DoctorRequestState(); | ||
11 | +} | ||
12 | + | ||
13 | +class _DoctorRequestState extends State<DoctorRequest> { | ||
14 | + List<int> _doctorlist = new List<int>(); | ||
15 | + | ||
16 | + Future<String> getDoctorRequestList() async { | ||
17 | + String usertoken = await UserSecureStorage.getUserToken(); | ||
18 | + http.Response response = await http.get( | ||
19 | + Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'hub'), | ||
20 | + headers: {"authorization": usertoken}, | ||
21 | + ); | ||
22 | + List<dynamic> values = new List<dynamic>(); | ||
23 | + if (_doctorlist.length != 0) { | ||
24 | + _doctorlist.clear(); | ||
25 | + } | ||
26 | + if (response.statusCode == 200) { | ||
27 | + values = json.decode(response.body); | ||
28 | + for (int i = 0; i < values.length; i++) { | ||
29 | + _doctorlist.add(values[i]['hubId']); | ||
30 | + } | ||
31 | + return "get완료"; | ||
32 | + } else if (response.statusCode == 404) { | ||
33 | + return "Not Found"; | ||
34 | + } else { | ||
35 | + return "Error"; | ||
36 | + } | ||
37 | + } | ||
38 | + | ||
39 | + Widget build(BuildContext context) { | ||
40 | + final Size size = MediaQuery.of(context).size; | ||
41 | + return Scaffold( | ||
42 | + appBar: AppBar( | ||
43 | + backgroundColor: Colors.white, | ||
44 | + leading: new Icon(Icons.medical_services_rounded, | ||
45 | + color: Colors.black, size: 45.0), | ||
46 | + title: Text( | ||
47 | + 'Smart Medicine Box', | ||
48 | + style: TextStyle( | ||
49 | + color: Colors.black, | ||
50 | + fontSize: 23, | ||
51 | + fontFamily: 'Noto', | ||
52 | + fontWeight: FontWeight.bold), | ||
53 | + ), | ||
54 | + ), | ||
55 | + body: FutureBuilder( | ||
56 | + future: getDoctorRequestList(), | ||
57 | + builder: (BuildContext context, AsyncSnapshot snapshot) { | ||
58 | + if (snapshot.hasData == false) { | ||
59 | + return CircularProgressIndicator(); | ||
60 | + } else if (snapshot.hasError) { | ||
61 | + return Padding( | ||
62 | + padding: const EdgeInsets.all(8.0), | ||
63 | + child: Text( | ||
64 | + 'Error: ${snapshot.error}', | ||
65 | + style: TextStyle(fontSize: 15), | ||
66 | + ), | ||
67 | + ); | ||
68 | + } else { | ||
69 | + return Container( | ||
70 | + height: size.height, | ||
71 | + child: Column( | ||
72 | + mainAxisAlignment: MainAxisAlignment.center, | ||
73 | + children: <Widget>[ | ||
74 | + Container( | ||
75 | + height: size.height * 0.1, | ||
76 | + width: size.width, | ||
77 | + child: Center( | ||
78 | + child: Text( | ||
79 | + '담당의 등록 요청', | ||
80 | + textScaleFactor: 1.0, | ||
81 | + style: TextStyle( | ||
82 | + fontSize: 24, | ||
83 | + fontFamily: 'Noto', | ||
84 | + fontWeight: FontWeight.bold), | ||
85 | + ), | ||
86 | + ), | ||
87 | + decoration: | ||
88 | + BoxDecoration(border: Border.all(), color: Colors.blue), | ||
89 | + ), | ||
90 | + SizedBox(height: 30), | ||
91 | + Expanded( | ||
92 | + child: ListView.separated( | ||
93 | + padding: const EdgeInsets.all(30), | ||
94 | + itemCount: _doctorlist.length, | ||
95 | + itemBuilder: (BuildContext context, int index) { | ||
96 | + return Container( | ||
97 | + padding: EdgeInsets.all(8.0), | ||
98 | + decoration: BoxDecoration( | ||
99 | + border: Border.all(), | ||
100 | + borderRadius: | ||
101 | + BorderRadius.all(Radius.circular(25.0)), | ||
102 | + ), | ||
103 | + child: ListTile( | ||
104 | + title: Text( | ||
105 | + 'DoctorID: ' + '${_doctorlist[index]}', | ||
106 | + style: TextStyle( | ||
107 | + color: Colors.black, | ||
108 | + fontSize: 20, | ||
109 | + fontFamily: 'Noto', | ||
110 | + fontWeight: FontWeight.bold), | ||
111 | + ), | ||
112 | + trailing: Icon(Icons.check), | ||
113 | + onTap: () async { | ||
114 | + await showDialog( | ||
115 | + context: context, | ||
116 | + builder: (BuildContext context) { | ||
117 | + return AlertDialog( | ||
118 | + title: new Text('담당의 등록'), | ||
119 | + content: new Text('담당의 등록이 완료 되었습니다.'), | ||
120 | + actions: <Widget>[ | ||
121 | + new FlatButton( | ||
122 | + child: new Text('Close'), | ||
123 | + onPressed: () { | ||
124 | + Navigator.of(context).pop(); | ||
125 | + }, | ||
126 | + ), | ||
127 | + ], | ||
128 | + ); | ||
129 | + }, | ||
130 | + ); | ||
131 | + Navigator.of(context).pop(); | ||
132 | + }, | ||
133 | + ), | ||
134 | + ); | ||
135 | + }, | ||
136 | + separatorBuilder: (BuildContext contetx, int index) => | ||
137 | + const Divider(), | ||
138 | + ), | ||
139 | + ) | ||
140 | + ], | ||
141 | + ), | ||
142 | + ); | ||
143 | + } | ||
144 | + }, | ||
145 | + ), | ||
146 | + ); | ||
147 | + } | ||
148 | +} |
1 | +import 'dart:convert'; | ||
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 'package:flutter/services.dart'; |
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 'RegisterBottle.dart'; | ||
8 | import '../models/Bottle.dart'; | 8 | import '../models/Bottle.dart'; |
9 | -import 'BottleList.dart'; | 9 | +import 'RegisterBottle.dart'; |
10 | +import '../BottleList.dart'; | ||
10 | import '../../utils/user_secure_stoarge.dart'; | 11 | import '../../utils/user_secure_stoarge.dart'; |
11 | 12 | ||
12 | class HubList extends StatefulWidget { | 13 | class HubList extends StatefulWidget { |
... | @@ -19,6 +20,7 @@ class HubList extends StatefulWidget { | ... | @@ -19,6 +20,7 @@ class HubList extends StatefulWidget { |
19 | 20 | ||
20 | class _HubListState extends State<HubList> { | 21 | class _HubListState extends State<HubList> { |
21 | List<Bottle> _bottleList = new List<Bottle>(); | 22 | List<Bottle> _bottleList = new List<Bottle>(); |
23 | + List<int> _hublist = new List<int>(); | ||
22 | //Get BottleList | 24 | //Get BottleList |
23 | Future<String> getBottleList(int hubid) async { | 25 | Future<String> getBottleList(int hubid) async { |
24 | String usertoken = await UserSecureStorage.getUserToken(); | 26 | String usertoken = await UserSecureStorage.getUserToken(); |
... | @@ -48,9 +50,33 @@ class _HubListState extends State<HubList> { | ... | @@ -48,9 +50,33 @@ class _HubListState extends State<HubList> { |
48 | return "Error"; | 50 | return "Error"; |
49 | } | 51 | } |
50 | 52 | ||
53 | + Future<String> getHubList() async { | ||
54 | + String usertoken = await UserSecureStorage.getUserToken(); | ||
55 | + http.Response response = await http.get( | ||
56 | + Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'hub'), | ||
57 | + headers: {"authorization": usertoken}, | ||
58 | + ); | ||
59 | + List<dynamic> values = new List<dynamic>(); | ||
60 | + if (_hublist.length != 0) { | ||
61 | + _hublist.clear(); | ||
62 | + } | ||
63 | + if (response.statusCode == 200) { | ||
64 | + values = json.decode(response.body); | ||
65 | + for (int i = 0; i < values.length; i++) { | ||
66 | + _hublist.add(values[i]['hubId']); | ||
67 | + } | ||
68 | + return "get완료"; | ||
69 | + } else if (response.statusCode == 404) { | ||
70 | + return "Not Found"; | ||
71 | + } else { | ||
72 | + return "Error"; | ||
73 | + } | ||
74 | + } | ||
75 | + | ||
51 | Widget build(BuildContext context) { | 76 | Widget build(BuildContext context) { |
52 | final Size size = MediaQuery.of(context).size; | 77 | final Size size = MediaQuery.of(context).size; |
53 | - return Scaffold( | 78 | + return WillPopScope( |
79 | + child: Scaffold( | ||
54 | appBar: AppBar( | 80 | appBar: AppBar( |
55 | backgroundColor: Colors.white, | 81 | backgroundColor: Colors.white, |
56 | leading: new Icon(Icons.medical_services_rounded, | 82 | leading: new Icon(Icons.medical_services_rounded, |
... | @@ -64,7 +90,21 @@ class _HubListState extends State<HubList> { | ... | @@ -64,7 +90,21 @@ class _HubListState extends State<HubList> { |
64 | fontWeight: FontWeight.bold), | 90 | fontWeight: FontWeight.bold), |
65 | ), | 91 | ), |
66 | ), | 92 | ), |
67 | - body: Container( | 93 | + body: FutureBuilder( |
94 | + future: getHubList(), | ||
95 | + builder: (BuildContext context, AsyncSnapshot snapshot) { | ||
96 | + if (snapshot.hasData == false) { | ||
97 | + return CircularProgressIndicator(); | ||
98 | + } else if (snapshot.hasError) { | ||
99 | + return Padding( | ||
100 | + padding: const EdgeInsets.all(8.0), | ||
101 | + child: Text( | ||
102 | + 'Error: ${snapshot.error}', | ||
103 | + style: TextStyle(fontSize: 15), | ||
104 | + ), | ||
105 | + ); | ||
106 | + } else { | ||
107 | + return Container( | ||
68 | height: size.height, | 108 | height: size.height, |
69 | child: Column( | 109 | child: Column( |
70 | mainAxisAlignment: MainAxisAlignment.center, | 110 | mainAxisAlignment: MainAxisAlignment.center, |
... | @@ -88,17 +128,18 @@ class _HubListState extends State<HubList> { | ... | @@ -88,17 +128,18 @@ class _HubListState extends State<HubList> { |
88 | Expanded( | 128 | Expanded( |
89 | child: ListView.separated( | 129 | child: ListView.separated( |
90 | padding: const EdgeInsets.all(30), | 130 | padding: const EdgeInsets.all(30), |
91 | - itemCount: widget.hublist.length, | 131 | + itemCount: _hublist.length, |
92 | itemBuilder: (BuildContext context, int index) { | 132 | itemBuilder: (BuildContext context, int index) { |
93 | return Container( | 133 | return Container( |
94 | padding: EdgeInsets.all(8.0), | 134 | padding: EdgeInsets.all(8.0), |
95 | decoration: BoxDecoration( | 135 | decoration: BoxDecoration( |
96 | border: Border.all(), | 136 | border: Border.all(), |
97 | - borderRadius: BorderRadius.all(Radius.circular(25.0)), | 137 | + borderRadius: |
138 | + BorderRadius.all(Radius.circular(25.0)), | ||
98 | ), | 139 | ), |
99 | child: ListTile( | 140 | child: ListTile( |
100 | title: Text( | 141 | title: Text( |
101 | - 'HUB ID: ' + '${widget.hublist[index]}', | 142 | + 'HUB ID: ' + '${_hublist[index]}', |
102 | style: TextStyle( | 143 | style: TextStyle( |
103 | color: Colors.black, | 144 | color: Colors.black, |
104 | fontSize: 20, | 145 | fontSize: 20, |
... | @@ -109,10 +150,10 @@ class _HubListState extends State<HubList> { | ... | @@ -109,10 +150,10 @@ class _HubListState extends State<HubList> { |
109 | onTap: () async { | 150 | onTap: () async { |
110 | //허브 id로 가져와서 있으면 바로 넘기기 | 151 | //허브 id로 가져와서 있으면 바로 넘기기 |
111 | var result = | 152 | var result = |
112 | - await getBottleList(widget.hublist[index]); | 153 | + await getBottleList(_hublist[index]); |
113 | if (result == "GET") { | 154 | if (result == "GET") { |
114 | UserSecureStorage.setHubId( | 155 | UserSecureStorage.setHubId( |
115 | - widget.hublist[index].toString()); | 156 | + _hublist[index].toString()); |
116 | Navigator.push( | 157 | Navigator.push( |
117 | context, | 158 | context, |
118 | MaterialPageRoute( | 159 | MaterialPageRoute( |
... | @@ -131,12 +172,12 @@ class _HubListState extends State<HubList> { | ... | @@ -131,12 +172,12 @@ class _HubListState extends State<HubList> { |
131 | child: new Text('등록'), | 172 | child: new Text('등록'), |
132 | onPressed: () { | 173 | onPressed: () { |
133 | UserSecureStorage.setHubId( | 174 | UserSecureStorage.setHubId( |
134 | - widget.hublist[index].toString()); | 175 | + _hublist[index].toString()); |
135 | Navigator.push( | 176 | Navigator.push( |
136 | context, | 177 | context, |
137 | MaterialPageRoute( | 178 | MaterialPageRoute( |
138 | - builder: | 179 | + builder: (BuildContext |
139 | - (BuildContext context) => | 180 | + context) => |
140 | RegisterBottle(), | 181 | RegisterBottle(), |
141 | )); | 182 | )); |
142 | }) | 183 | }) |
... | @@ -154,7 +195,15 @@ class _HubListState extends State<HubList> { | ... | @@ -154,7 +195,15 @@ class _HubListState extends State<HubList> { |
154 | ), | 195 | ), |
155 | ) | 196 | ) |
156 | ], | 197 | ], |
157 | - )), | 198 | + ), |
199 | + ); | ||
200 | + } | ||
201 | + }, | ||
202 | + ), | ||
203 | + ), | ||
204 | + onWillPop: () { | ||
205 | + SystemNavigator.pop(); | ||
206 | + }, | ||
158 | ); | 207 | ); |
159 | } | 208 | } |
160 | } | 209 | } | ... | ... |
1 | -import 'package:Smart_Medicine_Box/src/screens/DashBoard.dart'; | ||
2 | -import 'package:Smart_Medicine_Box/src/screens/Register/BottleList.dart'; | ||
3 | import 'package:flutter/cupertino.dart'; | 1 | import 'package:flutter/cupertino.dart'; |
4 | import 'dart:convert'; | 2 | import 'dart:convert'; |
5 | import 'package:flutter/material.dart'; | 3 | import 'package:flutter/material.dart'; |
... | @@ -7,6 +5,7 @@ import 'package:http/http.dart' as http; | ... | @@ -7,6 +5,7 @@ import 'package:http/http.dart' as http; |
7 | import 'package:flutter_dotenv/flutter_dotenv.dart'; | 5 | import 'package:flutter_dotenv/flutter_dotenv.dart'; |
8 | 6 | ||
9 | import 'SearchMedicine.dart'; | 7 | import 'SearchMedicine.dart'; |
8 | +import '../BottleList.dart'; | ||
10 | import '../../utils/user_secure_stoarge.dart'; | 9 | import '../../utils/user_secure_stoarge.dart'; |
11 | 10 | ||
12 | class RegisterBottle extends StatefulWidget { | 11 | class RegisterBottle extends StatefulWidget { |
... | @@ -139,7 +138,6 @@ class _RegisterBottleState extends State<RegisterBottle> { | ... | @@ -139,7 +138,6 @@ class _RegisterBottleState extends State<RegisterBottle> { |
139 | ); | 138 | ); |
140 | } else if (saveMessage == "등록 완료" && | 139 | } else if (saveMessage == "등록 완료" && |
141 | widget.modify_bottle == true) { | 140 | widget.modify_bottle == true) { |
142 | - print('asdg'); | ||
143 | await showDialog( | 141 | await showDialog( |
144 | context: context, | 142 | context: context, |
145 | builder: (BuildContext context) { | 143 | builder: (BuildContext context) { | ... | ... |
... | @@ -8,6 +8,13 @@ packages: | ... | @@ -8,6 +8,13 @@ packages: |
8 | url: "https://pub.dartlang.org" | 8 | url: "https://pub.dartlang.org" |
9 | source: hosted | 9 | source: hosted |
10 | version: "2.5.0-nullsafety.1" | 10 | version: "2.5.0-nullsafety.1" |
11 | + badges: | ||
12 | + dependency: "direct main" | ||
13 | + description: | ||
14 | + name: badges | ||
15 | + url: "https://pub.dartlang.org" | ||
16 | + source: hosted | ||
17 | + version: "1.2.0" | ||
11 | boolean_selector: | 18 | boolean_selector: |
12 | dependency: transitive | 19 | dependency: transitive |
13 | description: | 20 | description: |
... | @@ -125,6 +132,13 @@ packages: | ... | @@ -125,6 +132,13 @@ packages: |
125 | url: "https://pub.dartlang.org" | 132 | url: "https://pub.dartlang.org" |
126 | source: hosted | 133 | source: hosted |
127 | version: "1.0.1" | 134 | version: "1.0.1" |
135 | + flutter_picker: | ||
136 | + dependency: "direct main" | ||
137 | + description: | ||
138 | + name: flutter_picker | ||
139 | + url: "https://pub.dartlang.org" | ||
140 | + source: hosted | ||
141 | + version: "1.1.5" | ||
128 | flutter_screenutil: | 142 | flutter_screenutil: |
129 | dependency: "direct main" | 143 | dependency: "direct main" |
130 | description: | 144 | description: | ... | ... |
... | @@ -41,6 +41,9 @@ dependencies: | ... | @@ -41,6 +41,9 @@ dependencies: |
41 | flutter_secure_storage: ^3.3.5 | 41 | flutter_secure_storage: ^3.3.5 |
42 | sqflite: ^1.1.6 | 42 | sqflite: ^1.1.6 |
43 | path_provider: ^1.2.0 | 43 | path_provider: ^1.2.0 |
44 | + badges: ^1.1.1 | ||
45 | + flutter_picker: ^1.1.5 | ||
46 | + | ||
44 | 47 | ||
45 | dev_dependencies: | 48 | dev_dependencies: |
46 | flutter_test: | 49 | flutter_test: | ... | ... |
-
Please register or login to post a comment