Showing
11 changed files
with
725 additions
and
623 deletions
| ... | @@ -83,4 +83,7 @@ appbar 관련 디자인은 추후 구현 예정 | ... | @@ -83,4 +83,7 @@ appbar 관련 디자인은 추후 구현 예정 |
| 83 | 83 | ||
| 84 | 84 | ||
| 85 | ### 2021-05-25 | 85 | ### 2021-05-25 |
| 86 | -+ 로그인 권한 문제 해결 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 86 | ++ 로그인 권한 문제 해결 | ||
| 87 | + | ||
| 88 | +### 2021-05-26 | ||
| 89 | ++ future buillder 변경 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -5,39 +5,32 @@ import 'package:http/http.dart' as http; | ... | @@ -5,39 +5,32 @@ 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 'package:intl/intl.dart'; | 6 | import 'package:intl/intl.dart'; |
| 7 | 7 | ||
| 8 | +import '../utils/user_secure_stoarge.dart'; | ||
| 8 | import 'models/Bottle.dart'; | 9 | import 'models/Bottle.dart'; |
| 9 | import 'models/Medicine.dart'; | 10 | import 'models/Medicine.dart'; |
| 10 | import 'package:Smart_Medicine_Box/src/screens/SettingPage.dart'; | 11 | import 'package:Smart_Medicine_Box/src/screens/SettingPage.dart'; |
| 11 | 12 | ||
| 12 | class DashBoard extends StatefulWidget { | 13 | class DashBoard extends StatefulWidget { |
| 13 | int pageNumber; | 14 | int pageNumber; |
| 14 | - Bottle bottleInformation; | ||
| 15 | - Medicine medicineInformation; | ||
| 16 | 15 | ||
| 17 | - DashBoard( | 16 | + DashBoard({ |
| 18 | - {Key key, | 17 | + Key key, |
| 19 | - this.pageNumber, | 18 | + this.pageNumber, |
| 20 | - this.bottleInformation, | 19 | + }) : super(key: key); |
| 21 | - this.medicineInformation}) | ||
| 22 | - : super(key: key); | ||
| 23 | 20 | ||
| 24 | @override | 21 | @override |
| 25 | _DashBoardState createState() => _DashBoardState(); | 22 | _DashBoardState createState() => _DashBoardState(); |
| 26 | } | 23 | } |
| 27 | 24 | ||
| 28 | class _DashBoardState extends State<DashBoard> { | 25 | class _DashBoardState extends State<DashBoard> { |
| 29 | - Bottle _bottleinformation = new Bottle(); | ||
| 30 | int _selectedIndex = 0; | 26 | int _selectedIndex = 0; |
| 31 | - Medicine _medicineInformation = new Medicine(); | ||
| 32 | 27 | ||
| 33 | Widget build(BuildContext context) { | 28 | Widget build(BuildContext context) { |
| 34 | _selectedIndex = widget.pageNumber; | 29 | _selectedIndex = widget.pageNumber; |
| 35 | - _medicineInformation = widget.medicineInformation; | ||
| 36 | - _bottleinformation = widget.bottleInformation; | ||
| 37 | var _tabs = [ | 30 | var _tabs = [ |
| 38 | - ineerInformationpage(context, _bottleinformation), | 31 | + ineerInformationpage(context), |
| 39 | - mainpage(context, _medicineInformation), | 32 | + mainpage(context), |
| 40 | - outerInformationpage(context, _bottleinformation), | 33 | + outerInformationpage(context), |
| 41 | ]; | 34 | ]; |
| 42 | 35 | ||
| 43 | return Scaffold( | 36 | return Scaffold( |
| ... | @@ -126,148 +119,185 @@ class _DashBoardState extends State<DashBoard> { | ... | @@ -126,148 +119,185 @@ class _DashBoardState extends State<DashBoard> { |
| 126 | } | 119 | } |
| 127 | } | 120 | } |
| 128 | 121 | ||
| 129 | -Widget mainpage(BuildContext context, Medicine medicineInformation) { | 122 | +Widget mainpage(BuildContext context) { |
| 123 | + Medicine _medicineInformation = new Medicine(); | ||
| 124 | + | ||
| 125 | + Future<Medicine> _getmedicine() async { | ||
| 126 | + String usertoken = await UserSecureStorage.getUserToken(); | ||
| 127 | + String medicineid = await UserSecureStorage.getMedicineId(); | ||
| 128 | + http.Response medicineresponse = await http.get( | ||
| 129 | + Uri.encodeFull( | ||
| 130 | + DotEnv().env['SERVER_URL'] + 'medicine/' + medicineid.toString()), | ||
| 131 | + headers: {"authorization": usertoken}, | ||
| 132 | + ); | ||
| 133 | + | ||
| 134 | + if (medicineresponse.statusCode == 200) { | ||
| 135 | + Map<String, dynamic> data = jsonDecode(medicineresponse.body); | ||
| 136 | + _medicineInformation = Medicine.fromJson(data); | ||
| 137 | + } | ||
| 138 | + print(1); | ||
| 139 | + print(_medicineInformation.company); | ||
| 140 | + return _medicineInformation; | ||
| 141 | + } | ||
| 142 | + | ||
| 130 | final Size size = MediaQuery.of(context).size; | 143 | final Size size = MediaQuery.of(context).size; |
| 131 | return Scaffold( | 144 | return Scaffold( |
| 132 | backgroundColor: Colors.white, | 145 | backgroundColor: Colors.white, |
| 133 | body: SingleChildScrollView( | 146 | body: SingleChildScrollView( |
| 134 | - child: Container( | 147 | + child: FutureBuilder( |
| 135 | - margin: EdgeInsets.fromLTRB(0, 30, 0, 0), | 148 | + future: _getmedicine(), |
| 136 | - padding: EdgeInsets.fromLTRB(5, 0, 5, 5), | 149 | + builder: (BuildContext context, AsyncSnapshot snapshot) { |
| 137 | - child: Column( | 150 | + if (snapshot.hasData == false) { |
| 138 | - crossAxisAlignment: CrossAxisAlignment.center, | 151 | + return CircularProgressIndicator(); |
| 139 | - children: <Widget>[ | 152 | + } else if (snapshot.hasError) { |
| 140 | - SizedBox(height: 20), | 153 | + return Padding( |
| 141 | - Container( | 154 | + padding: const EdgeInsets.all(8.0), |
| 142 | - width: size.width, | 155 | + child: Text( |
| 143 | - padding: EdgeInsets.fromLTRB(5, 0, 5, 5), | 156 | + 'Error: ${snapshot.error}', |
| 144 | - margin: EdgeInsets.all(15), | 157 | + style: TextStyle(fontSize: 15), |
| 145 | - decoration: BoxDecoration( | ||
| 146 | - border: Border.all(), | ||
| 147 | - borderRadius: BorderRadius.all( | ||
| 148 | - Radius.circular(25.0) // <--- border radius here | ||
| 149 | - ), | ||
| 150 | ), | 158 | ), |
| 159 | + ); | ||
| 160 | + } else { | ||
| 161 | + return Container( | ||
| 162 | + margin: EdgeInsets.fromLTRB(0, 30, 0, 0), | ||
| 163 | + padding: EdgeInsets.fromLTRB(5, 0, 5, 5), | ||
| 151 | child: Column( | 164 | child: Column( |
| 152 | - children: [ | 165 | + crossAxisAlignment: CrossAxisAlignment.center, |
| 153 | - SizedBox(height: 30), | 166 | + children: <Widget>[ |
| 154 | - Container( | 167 | + SizedBox(height: 20), |
| 155 | - child: Center( | ||
| 156 | - child: Text( | ||
| 157 | - medicineInformation.name == null | ||
| 158 | - ? '-' | ||
| 159 | - : medicineInformation.name, | ||
| 160 | - style: TextStyle( | ||
| 161 | - color: Colors.black, | ||
| 162 | - fontSize: 24, | ||
| 163 | - fontFamily: 'NotoSansKR', | ||
| 164 | - fontWeight: FontWeight.w700)), | ||
| 165 | - ), | ||
| 166 | - ), | ||
| 167 | - SizedBox(height: 30), | ||
| 168 | Container( | 168 | Container( |
| 169 | width: size.width, | 169 | width: size.width, |
| 170 | - alignment: Alignment(0.9, 0), | 170 | + padding: EdgeInsets.fromLTRB(5, 0, 5, 5), |
| 171 | - child: Wrap( | 171 | + margin: EdgeInsets.all(15), |
| 172 | - children: [ | 172 | + decoration: BoxDecoration( |
| 173 | - Text( | 173 | + border: Border.all(), |
| 174 | - '제조사: ', | 174 | + borderRadius: BorderRadius.all(Radius.circular( |
| 175 | - style: TextStyle( | 175 | + 25.0) // <--- border radius here |
| 176 | - color: Colors.grey, | ||
| 177 | - fontSize: 14, | ||
| 178 | - ), | ||
| 179 | - ), | ||
| 180 | - Text( | ||
| 181 | - medicineInformation.company == null | ||
| 182 | - ? '-' | ||
| 183 | - : medicineInformation.company, | ||
| 184 | - style: TextStyle( | ||
| 185 | - color: Colors.grey, | ||
| 186 | - fontSize: 14, | ||
| 187 | ), | 176 | ), |
| 188 | - ), | ||
| 189 | - ], | ||
| 190 | ), | 177 | ), |
| 191 | - ), | 178 | + child: Column( |
| 192 | - SizedBox(height: 30), | ||
| 193 | - Container( | ||
| 194 | - width: size.width, | ||
| 195 | - padding: EdgeInsets.fromLTRB(5, 0, 5, 0), | ||
| 196 | - alignment: Alignment(-1, 0), | ||
| 197 | - child: Wrap( | ||
| 198 | children: [ | 179 | children: [ |
| 199 | - Text( | 180 | + SizedBox(height: 30), |
| 200 | - '타겟 층 : ', | 181 | + Container( |
| 201 | - style: TextStyle( | 182 | + child: Center( |
| 202 | - color: Colors.grey, | 183 | + child: Text( |
| 203 | - fontSize: 14, | 184 | + '${snapshot.data.name}' == null |
| 204 | - ), | 185 | + ? '-' |
| 205 | - ), | 186 | + : '${snapshot.data.name}', |
| 206 | - Text( | 187 | + style: TextStyle( |
| 207 | - medicineInformation.target == null | 188 | + color: Colors.black, |
| 208 | - ? '-' | 189 | + fontSize: 24, |
| 209 | - : medicineInformation.target, | 190 | + fontFamily: 'NotoSansKR', |
| 210 | - style: TextStyle( | 191 | + fontWeight: FontWeight.w700)), |
| 211 | - color: Colors.grey, | ||
| 212 | - fontSize: 14, | ||
| 213 | ), | 192 | ), |
| 214 | ), | 193 | ), |
| 215 | - ], | 194 | + SizedBox(height: 30), |
| 216 | - ), | 195 | + Container( |
| 217 | - ), | 196 | + width: size.width, |
| 218 | - SizedBox(height: 15), | 197 | + alignment: Alignment(0.9, 0), |
| 219 | - Container( | 198 | + child: Wrap( |
| 220 | - width: size.width, | 199 | + children: [ |
| 221 | - padding: EdgeInsets.fromLTRB(5, 0, 5, 0), | 200 | + Text( |
| 222 | - alignment: Alignment(-1, 0), | 201 | + '제조사: ', |
| 223 | - child: Wrap( | 202 | + style: TextStyle( |
| 224 | - children: [ | 203 | + color: Colors.grey, |
| 225 | - Text( | 204 | + fontSize: 14, |
| 226 | - '복약 정보 : ', | 205 | + ), |
| 227 | - style: TextStyle( | 206 | + ), |
| 228 | - color: Colors.grey, | 207 | + Text( |
| 229 | - fontSize: 14, | 208 | + _medicineInformation.company == null |
| 209 | + ? '-' | ||
| 210 | + : _medicineInformation.company, | ||
| 211 | + style: TextStyle( | ||
| 212 | + color: Colors.grey, | ||
| 213 | + fontSize: 14, | ||
| 214 | + ), | ||
| 215 | + ), | ||
| 216 | + ], | ||
| 230 | ), | 217 | ), |
| 231 | ), | 218 | ), |
| 232 | - Text( | 219 | + SizedBox(height: 30), |
| 233 | - medicineInformation.dosage == null | 220 | + Container( |
| 234 | - ? '-' | 221 | + width: size.width, |
| 235 | - : medicineInformation.dosage, | 222 | + padding: EdgeInsets.fromLTRB(5, 0, 5, 0), |
| 236 | - style: TextStyle( | 223 | + alignment: Alignment(-1, 0), |
| 237 | - color: Colors.grey, | 224 | + child: Wrap( |
| 238 | - fontSize: 14, | 225 | + children: [ |
| 226 | + Text( | ||
| 227 | + '타겟 층 : ', | ||
| 228 | + style: TextStyle( | ||
| 229 | + color: Colors.grey, | ||
| 230 | + fontSize: 14, | ||
| 231 | + ), | ||
| 232 | + ), | ||
| 233 | + Text( | ||
| 234 | + _medicineInformation.target == null | ||
| 235 | + ? '-' | ||
| 236 | + : _medicineInformation.target, | ||
| 237 | + style: TextStyle( | ||
| 238 | + color: Colors.grey, | ||
| 239 | + fontSize: 14, | ||
| 240 | + ), | ||
| 241 | + ), | ||
| 242 | + ], | ||
| 239 | ), | 243 | ), |
| 240 | ), | 244 | ), |
| 241 | - ], | 245 | + SizedBox(height: 15), |
| 242 | - ), | ||
| 243 | - ), | ||
| 244 | - SizedBox(height: 10), | ||
| 245 | - Container( | ||
| 246 | - width: size.width, | ||
| 247 | - padding: EdgeInsets.fromLTRB(5, 10, 5, 10), | ||
| 248 | - alignment: Alignment(-1, 0), | ||
| 249 | - child: Column( | ||
| 250 | - children: [ | ||
| 251 | - SizedBox( | ||
| 252 | - height: 12, | ||
| 253 | - ), | ||
| 254 | Container( | 246 | Container( |
| 255 | width: size.width, | 247 | width: size.width, |
| 256 | - child: Text( | 248 | + padding: EdgeInsets.fromLTRB(5, 0, 5, 0), |
| 257 | - '경고', | 249 | + alignment: Alignment(-1, 0), |
| 258 | - style: TextStyle( | 250 | + child: Wrap( |
| 259 | - color: Colors.redAccent, fontSize: 14), | 251 | + children: [ |
| 252 | + Text( | ||
| 253 | + '복약 정보 : ', | ||
| 254 | + style: TextStyle( | ||
| 255 | + color: Colors.grey, | ||
| 256 | + fontSize: 14, | ||
| 257 | + ), | ||
| 258 | + ), | ||
| 259 | + Text( | ||
| 260 | + _medicineInformation.dosage == null | ||
| 261 | + ? '-' | ||
| 262 | + : _medicineInformation.dosage, | ||
| 263 | + style: TextStyle( | ||
| 264 | + color: Colors.grey, | ||
| 265 | + fontSize: 14, | ||
| 266 | + ), | ||
| 267 | + ), | ||
| 268 | + ], | ||
| 260 | ), | 269 | ), |
| 261 | ), | 270 | ), |
| 262 | - SizedBox(height: 12), | 271 | + SizedBox(height: 10), |
| 263 | Container( | 272 | Container( |
| 264 | width: size.width, | 273 | width: size.width, |
| 265 | - child: Text( | 274 | + padding: EdgeInsets.fromLTRB(5, 10, 5, 10), |
| 266 | - medicineInformation.warn == null | 275 | + alignment: Alignment(-1, 0), |
| 267 | - ? '-' | 276 | + child: Column( |
| 268 | - : medicineInformation.warn, | 277 | + children: [ |
| 269 | - style: TextStyle( | 278 | + SizedBox( |
| 270 | - color: Colors.redAccent, fontSize: 14), | 279 | + height: 12, |
| 280 | + ), | ||
| 281 | + Container( | ||
| 282 | + width: size.width, | ||
| 283 | + child: Text( | ||
| 284 | + '경고', | ||
| 285 | + style: TextStyle( | ||
| 286 | + color: Colors.redAccent, fontSize: 14), | ||
| 287 | + ), | ||
| 288 | + ), | ||
| 289 | + SizedBox(height: 12), | ||
| 290 | + Container( | ||
| 291 | + width: size.width, | ||
| 292 | + child: Text( | ||
| 293 | + _medicineInformation.warn == null | ||
| 294 | + ? '-' | ||
| 295 | + : _medicineInformation.warn, | ||
| 296 | + style: TextStyle( | ||
| 297 | + color: Colors.redAccent, fontSize: 14), | ||
| 298 | + ), | ||
| 299 | + ), | ||
| 300 | + ], | ||
| 271 | ), | 301 | ), |
| 272 | ), | 302 | ), |
| 273 | ], | 303 | ], |
| ... | @@ -275,179 +305,214 @@ Widget mainpage(BuildContext context, Medicine medicineInformation) { | ... | @@ -275,179 +305,214 @@ Widget mainpage(BuildContext context, Medicine medicineInformation) { |
| 275 | ), | 305 | ), |
| 276 | ], | 306 | ], |
| 277 | ), | 307 | ), |
| 278 | - ), | 308 | + ); |
| 279 | - ], | 309 | + } |
| 280 | - ), | 310 | + }, |
| 281 | ), | 311 | ), |
| 282 | ), | 312 | ), |
| 283 | ); | 313 | ); |
| 284 | } | 314 | } |
| 285 | 315 | ||
| 286 | -Widget ineerInformationpage(BuildContext context, Bottle bottleinformation) { | 316 | +Widget ineerInformationpage(BuildContext context) { |
| 317 | + Bottle _bottleinformation = new Bottle(); | ||
| 318 | + //get bottle | ||
| 319 | + Future<Bottle> _getbottle() async { | ||
| 320 | + String usertoken = await UserSecureStorage.getUserToken(); | ||
| 321 | + String bottleid = await UserSecureStorage.getBottleId(); | ||
| 322 | + Bottle _bottleinformation = new Bottle(); | ||
| 323 | + http.Response response = await http.get( | ||
| 324 | + Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'bottle/' + bottleid), | ||
| 325 | + headers: {"authorization": usertoken}); | ||
| 326 | + | ||
| 327 | + if (response.statusCode == 200) { | ||
| 328 | + Map<String, dynamic> jsonData = jsonDecode(response.body); | ||
| 329 | + _bottleinformation = Bottle.fromJson(jsonData); | ||
| 330 | + } | ||
| 331 | + return _bottleinformation; | ||
| 332 | + } | ||
| 333 | + | ||
| 287 | final Size size = MediaQuery.of(context).size; | 334 | final Size size = MediaQuery.of(context).size; |
| 335 | + | ||
| 288 | return Scaffold( | 336 | return Scaffold( |
| 289 | backgroundColor: Colors.white, | 337 | backgroundColor: Colors.white, |
| 290 | - body: Container( | 338 | + body: FutureBuilder( |
| 291 | - height: size.height * 0.9, | 339 | + future: _getbottle(), |
| 292 | - margin: EdgeInsets.fromLTRB(0, 30, 0, 0), | 340 | + builder: (BuildContext context, AsyncSnapshot snapshot) { |
| 293 | - padding: EdgeInsets.fromLTRB(5, 0, 5, 5), | 341 | + if (snapshot.hasData == false) { |
| 294 | - child: Column( | 342 | + return CircularProgressIndicator(); |
| 295 | - crossAxisAlignment: CrossAxisAlignment.center, | 343 | + } else if (snapshot.hasError) { |
| 296 | - children: <Widget>[ | 344 | + return Padding( |
| 297 | - Container( | 345 | + padding: const EdgeInsets.all(8.0), |
| 298 | - padding: EdgeInsets.fromLTRB(5, 5, 5, 5), | 346 | + child: Text( |
| 299 | - height: size.height * 0.08, | 347 | + 'Error: ${snapshot.error}', |
| 300 | - width: size.width, | 348 | + style: TextStyle(fontSize: 15), |
| 301 | - child: Center( | ||
| 302 | - child: Text( | ||
| 303 | - 'Inside Information', | ||
| 304 | - textAlign: TextAlign.center, | ||
| 305 | - textScaleFactor: 1.0, | ||
| 306 | - style: TextStyle( | ||
| 307 | - color: Colors.black, | ||
| 308 | - fontSize: 32, | ||
| 309 | - fontFamily: 'NotoSansKR', | ||
| 310 | - fontWeight: FontWeight.w700), | ||
| 311 | - ), | ||
| 312 | ), | 349 | ), |
| 313 | - ), | 350 | + ); |
| 314 | - Container( | 351 | + } else { |
| 352 | + return Container( | ||
| 353 | + height: size.height * 0.9, | ||
| 354 | + margin: EdgeInsets.fromLTRB(0, 30, 0, 0), | ||
| 315 | padding: EdgeInsets.fromLTRB(5, 0, 5, 5), | 355 | padding: EdgeInsets.fromLTRB(5, 0, 5, 5), |
| 316 | - margin: EdgeInsets.fromLTRB(0, 10, 0, 0), | ||
| 317 | - height: size.height * 0.25, | ||
| 318 | - width: size.width, | ||
| 319 | child: Column( | 356 | child: Column( |
| 357 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
| 320 | children: <Widget>[ | 358 | children: <Widget>[ |
| 321 | - Flexible( | 359 | + Container( |
| 322 | - child: Row( | 360 | + padding: EdgeInsets.fromLTRB(5, 5, 5, 5), |
| 323 | - mainAxisAlignment: MainAxisAlignment.center, | 361 | + height: size.height * 0.08, |
| 362 | + width: size.width, | ||
| 363 | + child: Center( | ||
| 364 | + child: Text( | ||
| 365 | + 'Inside Information', | ||
| 366 | + textAlign: TextAlign.center, | ||
| 367 | + textScaleFactor: 1.0, | ||
| 368 | + style: TextStyle( | ||
| 369 | + color: Colors.black, | ||
| 370 | + fontSize: 32, | ||
| 371 | + fontFamily: 'NotoSansKR', | ||
| 372 | + fontWeight: FontWeight.w700), | ||
| 373 | + ), | ||
| 374 | + ), | ||
| 375 | + ), | ||
| 376 | + Container( | ||
| 377 | + padding: EdgeInsets.fromLTRB(5, 0, 5, 5), | ||
| 378 | + margin: EdgeInsets.fromLTRB(0, 10, 0, 0), | ||
| 379 | + height: size.height * 0.25, | ||
| 380 | + width: size.width, | ||
| 381 | + child: Column( | ||
| 324 | children: <Widget>[ | 382 | children: <Widget>[ |
| 325 | - Container( | 383 | + Flexible( |
| 326 | - width: size.width * 0.43, | 384 | + child: Row( |
| 327 | - height: size.width * 0.45, | 385 | + mainAxisAlignment: MainAxisAlignment.center, |
| 328 | - margin: const EdgeInsets.all(5.0), | 386 | + children: <Widget>[ |
| 329 | - padding: const EdgeInsets.fromLTRB(10, 5, 10, 10), | ||
| 330 | - decoration: BoxDecoration( | ||
| 331 | - color: Color(0xff8E97FD), | ||
| 332 | - borderRadius: BorderRadius.circular(10.0), | ||
| 333 | - ), | ||
| 334 | - child: Column( | ||
| 335 | - children: [ | ||
| 336 | Container( | 387 | Container( |
| 337 | - width: size.width, | 388 | + width: size.width * 0.43, |
| 338 | - height: size.height * 0.05, | 389 | + height: size.width * 0.45, |
| 339 | - child: Center( | 390 | + margin: const EdgeInsets.all(5.0), |
| 340 | - child: Text( | 391 | + padding: const EdgeInsets.fromLTRB(10, 5, 10, 10), |
| 341 | - '약병 내부 온도', | 392 | + decoration: BoxDecoration( |
| 342 | - textAlign: TextAlign.center, | 393 | + color: Color(0xff8E97FD), |
| 343 | - textScaleFactor: 1.0, | 394 | + borderRadius: BorderRadius.circular(10.0), |
| 344 | - style: TextStyle( | ||
| 345 | - color: Colors.white, | ||
| 346 | - fontSize: 24, | ||
| 347 | - fontFamily: 'NotoSansKR', | ||
| 348 | - fontWeight: FontWeight.w800), | ||
| 349 | - ), | ||
| 350 | ), | 395 | ), |
| 351 | - ), | 396 | + child: Column( |
| 352 | - Container( | 397 | + children: [ |
| 353 | - width: size.width, | 398 | + Container( |
| 354 | - height: size.height * 0.145, | 399 | + width: size.width, |
| 355 | - child: Center( | 400 | + height: size.height * 0.05, |
| 356 | - child: Row( | 401 | + child: Center( |
| 357 | - mainAxisAlignment: MainAxisAlignment.center, | 402 | + child: Text( |
| 358 | - children: [ | 403 | + '약병 내부 온도', |
| 359 | - Text( | 404 | + textAlign: TextAlign.center, |
| 360 | - bottleinformation.temperature | 405 | + textScaleFactor: 1.0, |
| 361 | - .toString() == | 406 | + style: TextStyle( |
| 362 | - null | 407 | + color: Colors.white, |
| 363 | - ? '-' | 408 | + fontSize: 24, |
| 364 | - : bottleinformation.temperature | 409 | + fontFamily: 'NotoSansKR', |
| 365 | - .toString(), | 410 | + fontWeight: FontWeight.w800), |
| 366 | - textAlign: TextAlign.center, | 411 | + ), |
| 367 | - textScaleFactor: 1.0, | ||
| 368 | - style: TextStyle( | ||
| 369 | - color: Colors.white, | ||
| 370 | - fontSize: 76, | ||
| 371 | - fontFamily: 'NotoSansKR', | ||
| 372 | - fontWeight: FontWeight.w800), | ||
| 373 | ), | 412 | ), |
| 374 | - Text( | 413 | + ), |
| 375 | - '℃', | 414 | + Container( |
| 376 | - textAlign: TextAlign.center, | 415 | + width: size.width, |
| 377 | - textScaleFactor: 1.0, | 416 | + height: size.height * 0.145, |
| 378 | - style: TextStyle( | 417 | + child: Center( |
| 379 | - color: Colors.white, | 418 | + child: Row( |
| 380 | - fontSize: 60, | 419 | + mainAxisAlignment: |
| 381 | - fontFamily: 'NotoSansKR', | 420 | + MainAxisAlignment.center, |
| 382 | - fontWeight: FontWeight.w800), | 421 | + children: [ |
| 383 | - ) | 422 | + Text( |
| 384 | - ], | 423 | + '${snapshot.data.temperature}' == |
| 385 | - ), | 424 | + null |
| 425 | + ? '-' | ||
| 426 | + : '${snapshot.data.temperature}', | ||
| 427 | + textAlign: TextAlign.center, | ||
| 428 | + textScaleFactor: 1.0, | ||
| 429 | + style: TextStyle( | ||
| 430 | + color: Colors.white, | ||
| 431 | + fontSize: 76, | ||
| 432 | + fontFamily: 'NotoSansKR', | ||
| 433 | + fontWeight: FontWeight.w800), | ||
| 434 | + ), | ||
| 435 | + Text( | ||
| 436 | + '℃', | ||
| 437 | + textAlign: TextAlign.center, | ||
| 438 | + textScaleFactor: 1.0, | ||
| 439 | + style: TextStyle( | ||
| 440 | + color: Colors.white, | ||
| 441 | + fontSize: 60, | ||
| 442 | + fontFamily: 'NotoSansKR', | ||
| 443 | + fontWeight: FontWeight.w800), | ||
| 444 | + ) | ||
| 445 | + ], | ||
| 446 | + ), | ||
| 447 | + ), | ||
| 448 | + ), | ||
| 449 | + ], | ||
| 386 | ), | 450 | ), |
| 387 | ), | 451 | ), |
| 388 | - ], | ||
| 389 | - ), | ||
| 390 | - ), | ||
| 391 | - Container( | ||
| 392 | - width: size.width * 0.43, | ||
| 393 | - height: size.width * 0.45, | ||
| 394 | - margin: const EdgeInsets.all(5.0), | ||
| 395 | - padding: const EdgeInsets.fromLTRB(10, 5, 10, 10), | ||
| 396 | - decoration: BoxDecoration( | ||
| 397 | - color: Color(0xff8E97FD), | ||
| 398 | - borderRadius: BorderRadius.circular(10.0), | ||
| 399 | - ), | ||
| 400 | - child: Column( | ||
| 401 | - children: [ | ||
| 402 | Container( | 452 | Container( |
| 403 | - width: size.width, | 453 | + width: size.width * 0.43, |
| 404 | - height: size.height * 0.05, | 454 | + height: size.width * 0.45, |
| 405 | - child: Center( | 455 | + margin: const EdgeInsets.all(5.0), |
| 406 | - child: Text( | 456 | + padding: const EdgeInsets.fromLTRB(10, 5, 10, 10), |
| 407 | - '약병 내부 습도', | 457 | + decoration: BoxDecoration( |
| 408 | - textAlign: TextAlign.center, | 458 | + color: Color(0xff8E97FD), |
| 409 | - textScaleFactor: 1.0, | 459 | + borderRadius: BorderRadius.circular(10.0), |
| 410 | - style: TextStyle( | ||
| 411 | - color: Colors.white, | ||
| 412 | - fontSize: 24, | ||
| 413 | - fontFamily: 'NotoSansKR', | ||
| 414 | - fontWeight: FontWeight.w800), | ||
| 415 | - ), | ||
| 416 | ), | 460 | ), |
| 417 | - ), | 461 | + child: Column( |
| 418 | - Container( | 462 | + children: [ |
| 419 | - width: size.width, | 463 | + Container( |
| 420 | - height: size.height * 0.14, | 464 | + width: size.width, |
| 421 | - child: Center( | 465 | + height: size.height * 0.05, |
| 422 | - child: Row( | 466 | + child: Center( |
| 423 | - mainAxisAlignment: MainAxisAlignment.center, | 467 | + child: Text( |
| 424 | - children: [ | 468 | + '약병 내부 습도', |
| 425 | - Text( | 469 | + textAlign: TextAlign.center, |
| 426 | - bottleinformation.humidity.toString() == | 470 | + textScaleFactor: 1.0, |
| 427 | - null | 471 | + style: TextStyle( |
| 428 | - ? '-' | 472 | + color: Colors.white, |
| 429 | - : bottleinformation.humidity | 473 | + fontSize: 24, |
| 430 | - .toString(), | 474 | + fontFamily: 'NotoSansKR', |
| 431 | - textAlign: TextAlign.center, | 475 | + fontWeight: FontWeight.w800), |
| 432 | - textScaleFactor: 1.0, | 476 | + ), |
| 433 | - style: TextStyle( | ||
| 434 | - color: Colors.white, | ||
| 435 | - fontSize: 80, | ||
| 436 | - fontFamily: 'NotoSansKR', | ||
| 437 | - fontWeight: FontWeight.w800), | ||
| 438 | ), | 477 | ), |
| 439 | - Text( | 478 | + ), |
| 440 | - '%', | 479 | + Container( |
| 441 | - textAlign: TextAlign.center, | 480 | + width: size.width, |
| 442 | - textScaleFactor: 1.0, | 481 | + height: size.height * 0.14, |
| 443 | - style: TextStyle( | 482 | + child: Center( |
| 444 | - color: Colors.white, | 483 | + child: Row( |
| 445 | - fontSize: 60, | 484 | + mainAxisAlignment: |
| 446 | - fontFamily: 'NotoSansKR', | 485 | + MainAxisAlignment.center, |
| 447 | - fontWeight: FontWeight.w800), | 486 | + children: [ |
| 448 | - ) | 487 | + Text( |
| 449 | - ], | 488 | + snapshot.data.humidity.toString() == |
| 450 | - ), | 489 | + null |
| 490 | + ? '-' | ||
| 491 | + : snapshot.data.humidity | ||
| 492 | + .toString(), | ||
| 493 | + textAlign: TextAlign.center, | ||
| 494 | + textScaleFactor: 1.0, | ||
| 495 | + style: TextStyle( | ||
| 496 | + color: Colors.white, | ||
| 497 | + fontSize: 80, | ||
| 498 | + fontFamily: 'NotoSansKR', | ||
| 499 | + fontWeight: FontWeight.w800), | ||
| 500 | + ), | ||
| 501 | + Text( | ||
| 502 | + '%', | ||
| 503 | + textAlign: TextAlign.center, | ||
| 504 | + textScaleFactor: 1.0, | ||
| 505 | + style: TextStyle( | ||
| 506 | + color: Colors.white, | ||
| 507 | + fontSize: 60, | ||
| 508 | + fontFamily: 'NotoSansKR', | ||
| 509 | + fontWeight: FontWeight.w800), | ||
| 510 | + ) | ||
| 511 | + ], | ||
| 512 | + ), | ||
| 513 | + ), | ||
| 514 | + ), | ||
| 515 | + ], | ||
| 451 | ), | 516 | ), |
| 452 | ), | 517 | ), |
| 453 | ], | 518 | ], |
| ... | @@ -456,129 +521,130 @@ Widget ineerInformationpage(BuildContext context, Bottle bottleinformation) { | ... | @@ -456,129 +521,130 @@ Widget ineerInformationpage(BuildContext context, Bottle bottleinformation) { |
| 456 | ], | 521 | ], |
| 457 | ), | 522 | ), |
| 458 | ), | 523 | ), |
| 459 | - ], | 524 | + Container( |
| 460 | - ), | 525 | + padding: EdgeInsets.fromLTRB(5, 0, 5, 5), |
| 461 | - ), | 526 | + margin: EdgeInsets.fromLTRB(0, 0, 0, 0), |
| 462 | - Container( | 527 | + height: size.height * 0.3, |
| 463 | - padding: EdgeInsets.fromLTRB(5, 0, 5, 5), | 528 | + width: size.width, |
| 464 | - margin: EdgeInsets.fromLTRB(0, 0, 0, 0), | 529 | + child: Column( |
| 465 | - height: size.height * 0.3, | ||
| 466 | - width: size.width, | ||
| 467 | - child: Column( | ||
| 468 | - children: <Widget>[ | ||
| 469 | - Flexible( | ||
| 470 | - child: Row( | ||
| 471 | - mainAxisAlignment: MainAxisAlignment.center, | ||
| 472 | children: <Widget>[ | 530 | children: <Widget>[ |
| 473 | - Container( | 531 | + Flexible( |
| 474 | - width: size.width * 0.43, | 532 | + child: Row( |
| 475 | - height: size.width * 0.45, | 533 | + mainAxisAlignment: MainAxisAlignment.center, |
| 476 | - margin: const EdgeInsets.all(5.0), | 534 | + children: <Widget>[ |
| 477 | - padding: const EdgeInsets.fromLTRB(10, 5, 10, 10), | ||
| 478 | - decoration: BoxDecoration( | ||
| 479 | - color: Color(0xff8E97FD), | ||
| 480 | - borderRadius: BorderRadius.circular(10.0), | ||
| 481 | - ), | ||
| 482 | - child: Column( | ||
| 483 | - children: [ | ||
| 484 | Container( | 535 | Container( |
| 485 | - width: size.width, | 536 | + width: size.width * 0.43, |
| 486 | - height: size.height * 0.05, | 537 | + height: size.width * 0.45, |
| 487 | - child: Center( | 538 | + margin: const EdgeInsets.all(5.0), |
| 488 | - child: Text( | 539 | + padding: const EdgeInsets.fromLTRB(10, 5, 10, 10), |
| 489 | - '약병 내부 잔량', | 540 | + decoration: BoxDecoration( |
| 490 | - textAlign: TextAlign.center, | 541 | + color: Color(0xff8E97FD), |
| 491 | - textScaleFactor: 1.0, | 542 | + borderRadius: BorderRadius.circular(10.0), |
| 492 | - style: TextStyle( | ||
| 493 | - color: Colors.white, | ||
| 494 | - fontSize: 24, | ||
| 495 | - fontFamily: 'NotoSansKR', | ||
| 496 | - fontWeight: FontWeight.w800), | ||
| 497 | - ), | ||
| 498 | ), | 543 | ), |
| 499 | - ), | 544 | + child: Column( |
| 500 | - Container( | 545 | + children: [ |
| 501 | - width: size.width, | 546 | + Container( |
| 502 | - height: size.height * 0.14, | 547 | + width: size.width, |
| 503 | - child: Center( | 548 | + height: size.height * 0.05, |
| 504 | - child: Row( | 549 | + child: Center( |
| 505 | - mainAxisAlignment: MainAxisAlignment.center, | 550 | + child: Text( |
| 506 | - children: [ | 551 | + '약병 내부 잔량', |
| 507 | - Text( | 552 | + textAlign: TextAlign.center, |
| 508 | - bottleinformation.balance.toString() == | 553 | + textScaleFactor: 1.0, |
| 509 | - null | 554 | + style: TextStyle( |
| 510 | - ? '-' | 555 | + color: Colors.white, |
| 511 | - : bottleinformation.balance | 556 | + fontSize: 24, |
| 512 | - .toString(), | 557 | + fontFamily: 'NotoSansKR', |
| 513 | - textAlign: TextAlign.center, | 558 | + fontWeight: FontWeight.w800), |
| 514 | - textScaleFactor: 1.0, | 559 | + ), |
| 515 | - style: TextStyle( | ||
| 516 | - color: Colors.white, | ||
| 517 | - fontSize: 80, | ||
| 518 | - fontFamily: 'NotoSansKR', | ||
| 519 | - fontWeight: FontWeight.w800), | ||
| 520 | ), | 560 | ), |
| 521 | - Text( | 561 | + ), |
| 522 | - '%', | 562 | + Container( |
| 523 | - textAlign: TextAlign.center, | 563 | + width: size.width, |
| 524 | - textScaleFactor: 1.0, | 564 | + height: size.height * 0.14, |
| 525 | - style: TextStyle( | 565 | + child: Center( |
| 526 | - color: Colors.white, | 566 | + child: Row( |
| 527 | - fontSize: 60, | 567 | + mainAxisAlignment: |
| 528 | - fontFamily: 'NotoSansKR', | 568 | + MainAxisAlignment.center, |
| 529 | - fontWeight: FontWeight.w800), | 569 | + children: [ |
| 530 | - ) | 570 | + Text( |
| 531 | - ], | 571 | + snapshot.data.balance.toString() == |
| 532 | - ), | 572 | + null |
| 573 | + ? '-' | ||
| 574 | + : snapshot.data.balance | ||
| 575 | + .toString(), | ||
| 576 | + textAlign: TextAlign.center, | ||
| 577 | + textScaleFactor: 1.0, | ||
| 578 | + style: TextStyle( | ||
| 579 | + color: Colors.white, | ||
| 580 | + fontSize: 80, | ||
| 581 | + fontFamily: 'NotoSansKR', | ||
| 582 | + fontWeight: FontWeight.w800), | ||
| 583 | + ), | ||
| 584 | + Text( | ||
| 585 | + '%', | ||
| 586 | + textAlign: TextAlign.center, | ||
| 587 | + textScaleFactor: 1.0, | ||
| 588 | + style: TextStyle( | ||
| 589 | + color: Colors.white, | ||
| 590 | + fontSize: 60, | ||
| 591 | + fontFamily: 'NotoSansKR', | ||
| 592 | + fontWeight: FontWeight.w800), | ||
| 593 | + ) | ||
| 594 | + ], | ||
| 595 | + ), | ||
| 596 | + ), | ||
| 597 | + ), | ||
| 598 | + ], | ||
| 533 | ), | 599 | ), |
| 534 | ), | 600 | ), |
| 535 | - ], | ||
| 536 | - ), | ||
| 537 | - ), | ||
| 538 | - Container( | ||
| 539 | - width: size.width * 0.43, | ||
| 540 | - height: size.width * 0.45, | ||
| 541 | - margin: const EdgeInsets.all(5.0), | ||
| 542 | - padding: const EdgeInsets.fromLTRB(10, 5, 10, 10), | ||
| 543 | - decoration: BoxDecoration( | ||
| 544 | - color: Color(0xff8E97FD), | ||
| 545 | - borderRadius: BorderRadius.circular(10.0), | ||
| 546 | - ), | ||
| 547 | - child: Column( | ||
| 548 | - children: [ | ||
| 549 | Container( | 601 | Container( |
| 550 | - width: size.width, | 602 | + width: size.width * 0.43, |
| 551 | - height: size.height * 0.05, | 603 | + height: size.width * 0.45, |
| 552 | - child: Center( | 604 | + margin: const EdgeInsets.all(5.0), |
| 553 | - child: Text( | 605 | + padding: const EdgeInsets.fromLTRB(10, 5, 10, 10), |
| 554 | - '최근 개폐 시간', | 606 | + decoration: BoxDecoration( |
| 555 | - textAlign: TextAlign.center, | 607 | + color: Color(0xff8E97FD), |
| 556 | - textScaleFactor: 1.0, | 608 | + borderRadius: BorderRadius.circular(10.0), |
| 557 | - style: TextStyle( | ||
| 558 | - color: Colors.white, | ||
| 559 | - fontSize: 24, | ||
| 560 | - fontFamily: 'NotoSansKR', | ||
| 561 | - fontWeight: FontWeight.w800), | ||
| 562 | - ), | ||
| 563 | ), | 609 | ), |
| 564 | - ), | 610 | + child: Column( |
| 565 | - Container( | 611 | + children: [ |
| 566 | - width: size.width, | 612 | + Container( |
| 567 | - height: size.height * 0.14, | 613 | + width: size.width, |
| 568 | - child: Center( | 614 | + height: size.height * 0.05, |
| 569 | - child: Text( | 615 | + child: Center( |
| 570 | - bottleinformation.recentOpen == null | 616 | + child: Text( |
| 571 | - ? '-' | 617 | + '최근 개폐 시간', |
| 572 | - : DateFormat.Hm() | 618 | + textAlign: TextAlign.center, |
| 573 | - .format(bottleinformation.recentOpen), | 619 | + textScaleFactor: 1.0, |
| 574 | - textAlign: TextAlign.center, | 620 | + style: TextStyle( |
| 575 | - textScaleFactor: 1.0, | 621 | + color: Colors.white, |
| 576 | - style: TextStyle( | 622 | + fontSize: 24, |
| 577 | - color: Colors.white, | 623 | + fontFamily: 'NotoSansKR', |
| 578 | - fontSize: 60, | 624 | + fontWeight: FontWeight.w800), |
| 579 | - fontFamily: 'NotoSansKR', | 625 | + ), |
| 580 | - fontWeight: FontWeight.w800), | 626 | + ), |
| 581 | - ), | 627 | + ), |
| 628 | + Container( | ||
| 629 | + width: size.width, | ||
| 630 | + height: size.height * 0.14, | ||
| 631 | + child: Center( | ||
| 632 | + child: Text( | ||
| 633 | + snapshot.data.recentOpen == null | ||
| 634 | + ? '-' | ||
| 635 | + : DateFormat.Hm().format( | ||
| 636 | + snapshot.data.recentOpen), | ||
| 637 | + textAlign: TextAlign.center, | ||
| 638 | + textScaleFactor: 1.0, | ||
| 639 | + style: TextStyle( | ||
| 640 | + color: Colors.white, | ||
| 641 | + fontSize: 60, | ||
| 642 | + fontFamily: 'NotoSansKR', | ||
| 643 | + fontWeight: FontWeight.w800), | ||
| 644 | + ), | ||
| 645 | + ), | ||
| 646 | + ), | ||
| 647 | + ], | ||
| 582 | ), | 648 | ), |
| 583 | ), | 649 | ), |
| 584 | ], | 650 | ], |
| ... | @@ -589,190 +655,220 @@ Widget ineerInformationpage(BuildContext context, Bottle bottleinformation) { | ... | @@ -589,190 +655,220 @@ Widget ineerInformationpage(BuildContext context, Bottle bottleinformation) { |
| 589 | ), | 655 | ), |
| 590 | ], | 656 | ], |
| 591 | ), | 657 | ), |
| 592 | - ), | 658 | + ); |
| 593 | - ], | 659 | + } |
| 594 | - ), | 660 | + }, |
| 595 | ), | 661 | ), |
| 596 | ); | 662 | ); |
| 597 | } | 663 | } |
| 598 | 664 | ||
| 599 | -Widget outerInformationpage(BuildContext context, Bottle bottleinformation) { | 665 | +Widget outerInformationpage(BuildContext context) { |
| 666 | + Bottle _bottleinformation = new Bottle(); | ||
| 667 | + //get bottle | ||
| 668 | + Future<Bottle> _getbottle() async { | ||
| 669 | + String usertoken = await UserSecureStorage.getUserToken(); | ||
| 670 | + String bottleid = await UserSecureStorage.getBottleId(); | ||
| 671 | + Bottle _bottleinformation = new Bottle(); | ||
| 672 | + http.Response response = await http.get( | ||
| 673 | + Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'bottle/' + bottleid), | ||
| 674 | + headers: {"authorization": usertoken}); | ||
| 675 | + | ||
| 676 | + if (response.statusCode == 200) { | ||
| 677 | + Map<String, dynamic> jsonData = jsonDecode(response.body); | ||
| 678 | + print(jsonData); | ||
| 679 | + _bottleinformation = Bottle.fromJson(jsonData); | ||
| 680 | + } | ||
| 681 | + print(1); | ||
| 682 | + print(_bottleinformation.toJson()); | ||
| 683 | + return _bottleinformation; | ||
| 684 | + } | ||
| 685 | + | ||
| 600 | final Size size = MediaQuery.of(context).size; | 686 | final Size size = MediaQuery.of(context).size; |
| 601 | return Scaffold( | 687 | return Scaffold( |
| 602 | backgroundColor: Colors.white, | 688 | backgroundColor: Colors.white, |
| 603 | - body: Container( | 689 | + body: FutureBuilder( |
| 604 | - height: size.height * 0.9, | 690 | + future: _getbottle(), |
| 605 | - margin: EdgeInsets.fromLTRB(0, 30, 0, 0), | 691 | + builder: (BuildContext context, AsyncSnapshot snapshot) { |
| 606 | - padding: EdgeInsets.fromLTRB(5, 0, 5, 5), | 692 | + if (snapshot.hasData == false) { |
| 607 | - child: Column( | 693 | + return CircularProgressIndicator(); |
| 608 | - crossAxisAlignment: CrossAxisAlignment.center, | 694 | + } else if (snapshot.hasError) { |
| 609 | - children: <Widget>[ | 695 | + return Padding( |
| 610 | - Container( | 696 | + padding: const EdgeInsets.all(8.0), |
| 611 | - padding: EdgeInsets.fromLTRB(5, 5, 5, 5), | ||
| 612 | - height: size.height * 0.08, | ||
| 613 | - width: size.width, | ||
| 614 | - child: Center( | ||
| 615 | child: Text( | 697 | child: Text( |
| 616 | - 'Outside Information', | 698 | + 'Error: ${snapshot.error}', |
| 617 | - textAlign: TextAlign.center, | 699 | + style: TextStyle(fontSize: 15), |
| 618 | - textScaleFactor: 1.0, | ||
| 619 | - style: TextStyle( | ||
| 620 | - color: Colors.black, | ||
| 621 | - fontSize: 32, | ||
| 622 | - fontFamily: 'NotoSansKR', | ||
| 623 | - fontWeight: FontWeight.w700), | ||
| 624 | ), | 700 | ), |
| 625 | - ), | 701 | + ); |
| 626 | - ), | 702 | + } else { |
| 627 | - Container( | 703 | + print(123412); |
| 628 | - padding: EdgeInsets.fromLTRB(5, 0, 5, 5), | 704 | + print(snapshot.data.dosage); |
| 629 | - margin: EdgeInsets.fromLTRB(0, 10, 0, 0), | 705 | + return Container( |
| 630 | - height: size.height * 0.20, | 706 | + height: size.height * 0.9, |
| 631 | - width: size.width, | 707 | + margin: EdgeInsets.fromLTRB(0, 30, 0, 0), |
| 632 | - child: Column( | 708 | + padding: EdgeInsets.fromLTRB(5, 0, 5, 5), |
| 633 | - children: <Widget>[ | 709 | + child: Column( |
| 634 | - Flexible( | 710 | + crossAxisAlignment: CrossAxisAlignment.center, |
| 635 | - child: Column( | 711 | + children: <Widget>[ |
| 636 | - mainAxisAlignment: MainAxisAlignment.center, | 712 | + Container( |
| 637 | - children: <Widget>[ | 713 | + padding: EdgeInsets.fromLTRB(5, 5, 5, 5), |
| 638 | - Container( | 714 | + height: size.height * 0.08, |
| 639 | - padding: EdgeInsets.fromLTRB(5, 5, 5, 0), | 715 | + width: size.width, |
| 640 | - width: size.width * 0.9, | 716 | + child: Center( |
| 641 | - height: size.height * 0.18, | 717 | + child: Text( |
| 642 | - decoration: BoxDecoration( | 718 | + 'Outside Information', |
| 643 | - color: Color(0xff8E97FD), | 719 | + textAlign: TextAlign.center, |
| 644 | - borderRadius: BorderRadius.circular(10.0), | 720 | + textScaleFactor: 1.0, |
| 645 | - ), | 721 | + style: TextStyle( |
| 646 | - child: Column( | 722 | + color: Colors.black, |
| 647 | - children: [ | 723 | + fontSize: 32, |
| 648 | - Container( | 724 | + fontFamily: 'NotoSansKR', |
| 649 | - width: size.width, | 725 | + fontWeight: FontWeight.w700), |
| 650 | - height: size.height * 0.05, | 726 | + ), |
| 651 | - child: Center( | 727 | + ), |
| 652 | - child: Text( | 728 | + ), |
| 653 | - '권장 약 복용량', | 729 | + Container( |
| 654 | - textAlign: TextAlign.center, | 730 | + padding: EdgeInsets.fromLTRB(5, 0, 5, 5), |
| 655 | - textScaleFactor: 1.0, | 731 | + margin: EdgeInsets.fromLTRB(0, 10, 0, 0), |
| 656 | - style: TextStyle( | 732 | + height: size.height * 0.20, |
| 657 | - color: Colors.white, | 733 | + width: size.width, |
| 658 | - fontSize: 28, | 734 | + child: Column( |
| 659 | - fontFamily: 'NotoSansKR', | 735 | + children: <Widget>[ |
| 660 | - fontWeight: FontWeight.w800), | 736 | + Flexible( |
| 737 | + child: Column( | ||
| 738 | + mainAxisAlignment: MainAxisAlignment.center, | ||
| 739 | + children: <Widget>[ | ||
| 740 | + Container( | ||
| 741 | + padding: EdgeInsets.fromLTRB(5, 5, 5, 0), | ||
| 742 | + width: size.width * 0.9, | ||
| 743 | + height: size.height * 0.18, | ||
| 744 | + decoration: BoxDecoration( | ||
| 745 | + color: Color(0xff8E97FD), | ||
| 746 | + borderRadius: BorderRadius.circular(10.0), | ||
| 747 | + ), | ||
| 748 | + child: Column( | ||
| 749 | + children: [ | ||
| 750 | + Container( | ||
| 751 | + width: size.width, | ||
| 752 | + height: size.height * 0.05, | ||
| 753 | + child: Center( | ||
| 754 | + child: Text( | ||
| 755 | + '권장 약 복용량', | ||
| 756 | + textAlign: TextAlign.center, | ||
| 757 | + textScaleFactor: 1.0, | ||
| 758 | + style: TextStyle( | ||
| 759 | + color: Colors.white, | ||
| 760 | + fontSize: 28, | ||
| 761 | + fontFamily: 'NotoSansKR', | ||
| 762 | + fontWeight: FontWeight.w800), | ||
| 763 | + ), | ||
| 764 | + ), | ||
| 765 | + ), | ||
| 766 | + Container( | ||
| 767 | + width: size.width, | ||
| 768 | + height: size.height * 0.12, | ||
| 769 | + child: Row( | ||
| 770 | + mainAxisAlignment: | ||
| 771 | + MainAxisAlignment.center, | ||
| 772 | + children: [ | ||
| 773 | + Text( | ||
| 774 | + snapshot.data.dosage == null | ||
| 775 | + ? '-' | ||
| 776 | + : snapshot.data.dosage | ||
| 777 | + .toString(), | ||
| 778 | + textAlign: TextAlign.center, | ||
| 779 | + textScaleFactor: 1.0, | ||
| 780 | + style: TextStyle( | ||
| 781 | + color: Colors.white, | ||
| 782 | + fontSize: 80, | ||
| 783 | + fontFamily: 'NotoSansKR', | ||
| 784 | + fontWeight: FontWeight.w800), | ||
| 785 | + ), | ||
| 786 | + Text( | ||
| 787 | + ' 개', | ||
| 788 | + textScaleFactor: 1.0, | ||
| 789 | + style: TextStyle( | ||
| 790 | + color: Colors.white, | ||
| 791 | + fontSize: 64, | ||
| 792 | + fontFamily: 'NotoSansKR', | ||
| 793 | + fontWeight: FontWeight.w800), | ||
| 794 | + ) | ||
| 795 | + ], | ||
| 796 | + ), | ||
| 797 | + ), | ||
| 798 | + ], | ||
| 661 | ), | 799 | ), |
| 662 | ), | 800 | ), |
| 663 | - ), | 801 | + ], |
| 664 | - Container( | 802 | + ), |
| 665 | - width: size.width, | ||
| 666 | - height: size.height * 0.12, | ||
| 667 | - child: Row( | ||
| 668 | - mainAxisAlignment: MainAxisAlignment.center, | ||
| 669 | - children: [ | ||
| 670 | - Text( | ||
| 671 | - bottleinformation.dosage == null | ||
| 672 | - ? '-' | ||
| 673 | - : bottleinformation.dosage.toString(), | ||
| 674 | - textAlign: TextAlign.center, | ||
| 675 | - textScaleFactor: 1.0, | ||
| 676 | - style: TextStyle( | ||
| 677 | - color: Colors.white, | ||
| 678 | - fontSize: 80, | ||
| 679 | - fontFamily: 'NotoSansKR', | ||
| 680 | - fontWeight: FontWeight.w800), | ||
| 681 | - ), | ||
| 682 | - Text( | ||
| 683 | - ' 개', | ||
| 684 | - textScaleFactor: 1.0, | ||
| 685 | - style: TextStyle( | ||
| 686 | - color: Colors.white, | ||
| 687 | - fontSize: 64, | ||
| 688 | - fontFamily: 'NotoSansKR', | ||
| 689 | - fontWeight: FontWeight.w800), | ||
| 690 | - ) | ||
| 691 | - ], | ||
| 692 | - ), | ||
| 693 | - ), | ||
| 694 | - ], | ||
| 695 | ), | 803 | ), |
| 696 | - ), | 804 | + ], |
| 697 | - ], | 805 | + ), |
| 698 | ), | 806 | ), |
| 699 | - ), | 807 | + Container( |
| 700 | - ], | 808 | + margin: EdgeInsets.fromLTRB(0, 0, 0, 0), |
| 701 | - ), | 809 | + height: size.height * 0.20, |
| 702 | - ), | 810 | + width: size.width, |
| 703 | - Container( | 811 | + child: Column( |
| 704 | - margin: EdgeInsets.fromLTRB(0, 0, 0, 0), | 812 | + children: <Widget>[ |
| 705 | - height: size.height * 0.20, | 813 | + Flexible( |
| 706 | - width: size.width, | 814 | + child: Column( |
| 707 | - child: Column( | 815 | + mainAxisAlignment: MainAxisAlignment.center, |
| 708 | - children: <Widget>[ | 816 | + children: <Widget>[ |
| 709 | - Flexible( | 817 | + Container( |
| 710 | - child: Column( | 818 | + padding: EdgeInsets.fromLTRB(5, 5, 5, 0), |
| 711 | - mainAxisAlignment: MainAxisAlignment.center, | 819 | + width: size.width * 0.9, |
| 712 | - children: <Widget>[ | 820 | + height: size.height * 0.18, |
| 713 | - Container( | 821 | + decoration: BoxDecoration( |
| 714 | - padding: EdgeInsets.fromLTRB(5, 5, 5, 0), | 822 | + color: Color(0xff8E97FD), |
| 715 | - width: size.width * 0.9, | 823 | + borderRadius: BorderRadius.circular(10.0), |
| 716 | - height: size.height * 0.18, | ||
| 717 | - decoration: BoxDecoration( | ||
| 718 | - color: Color(0xff8E97FD), | ||
| 719 | - borderRadius: BorderRadius.circular(10.0), | ||
| 720 | - ), | ||
| 721 | - child: Column( | ||
| 722 | - children: [ | ||
| 723 | - Container( | ||
| 724 | - width: size.width, | ||
| 725 | - height: size.height * 0.05, | ||
| 726 | - child: Center( | ||
| 727 | - child: Text( | ||
| 728 | - '약 복용 시간', | ||
| 729 | - textAlign: TextAlign.center, | ||
| 730 | - textScaleFactor: 1.0, | ||
| 731 | - style: TextStyle( | ||
| 732 | - color: Colors.white, | ||
| 733 | - fontSize: 28, | ||
| 734 | - fontFamily: 'NotoSansKR', | ||
| 735 | - fontWeight: FontWeight.w800), | ||
| 736 | ), | 824 | ), |
| 737 | - ), | 825 | + child: Column( |
| 738 | - ), | 826 | + children: [ |
| 739 | - Container( | 827 | + Container( |
| 740 | - width: size.width, | 828 | + width: size.width, |
| 741 | - height: size.height * 0.12, | 829 | + height: size.height * 0.05, |
| 742 | - child: Center( | 830 | + child: Center( |
| 743 | - child: Text( | 831 | + child: Text( |
| 744 | - '15:57', | 832 | + '약 복용 시간', |
| 745 | - textAlign: TextAlign.center, | 833 | + textAlign: TextAlign.center, |
| 746 | - textScaleFactor: 1.0, | 834 | + textScaleFactor: 1.0, |
| 747 | - style: TextStyle( | 835 | + style: TextStyle( |
| 748 | - color: Colors.white, | 836 | + color: Colors.white, |
| 749 | - fontSize: 70, | 837 | + fontSize: 28, |
| 750 | - fontFamily: 'NotoSansKR', | 838 | + fontFamily: 'NotoSansKR', |
| 751 | - fontWeight: FontWeight.w800), | 839 | + fontWeight: FontWeight.w800), |
| 840 | + ), | ||
| 841 | + ), | ||
| 842 | + ), | ||
| 843 | + Container( | ||
| 844 | + width: size.width, | ||
| 845 | + height: size.height * 0.12, | ||
| 846 | + child: Center( | ||
| 847 | + child: Text( | ||
| 848 | + '15:57', | ||
| 849 | + textAlign: TextAlign.center, | ||
| 850 | + textScaleFactor: 1.0, | ||
| 851 | + style: TextStyle( | ||
| 852 | + color: Colors.white, | ||
| 853 | + fontSize: 70, | ||
| 854 | + fontFamily: 'NotoSansKR', | ||
| 855 | + fontWeight: FontWeight.w800), | ||
| 856 | + ), | ||
| 857 | + ), | ||
| 858 | + ), | ||
| 859 | + ], | ||
| 752 | ), | 860 | ), |
| 753 | ), | 861 | ), |
| 754 | - ), | 862 | + ], |
| 755 | - ], | 863 | + ), |
| 756 | ), | 864 | ), |
| 757 | - ), | 865 | + ], |
| 758 | - ], | 866 | + ), |
| 759 | ), | 867 | ), |
| 760 | - ), | 868 | + ], |
| 761 | - ], | 869 | + ), |
| 762 | - ), | 870 | + ); |
| 763 | - ), | 871 | + } |
| 764 | - ], | 872 | + }), |
| 765 | - ), | ||
| 766 | - ), | ||
| 767 | ); | 873 | ); |
| 768 | } | 874 | } |
| 769 | - | ||
| 770 | -/* | ||
| 771 | -bottom navbar로 이동 | ||
| 772 | -appbar로는 저거 만들어서 사용 | ||
| 773 | -설정 smartmedicine box를 app bar 로 구현 | ||
| 774 | -이건 우선 작업 후 추후 작업 | ||
| 775 | - | ||
| 776 | - | ||
| 777 | - | ||
| 778 | -*/ | ... | ... |
| ... | @@ -10,46 +10,13 @@ import '../../utils/user_secure_stoarge.dart'; | ... | @@ -10,46 +10,13 @@ import '../../utils/user_secure_stoarge.dart'; |
| 10 | 10 | ||
| 11 | class BottleList extends StatefulWidget { | 11 | class BottleList extends StatefulWidget { |
| 12 | List<Bottle> bottlelist; | 12 | List<Bottle> bottlelist; |
| 13 | - String hubid; | 13 | + BottleList({Key key, this.bottlelist}) : super(key: key); |
| 14 | - BottleList({Key key, this.bottlelist, this.hubid}) : super(key: key); | ||
| 15 | 14 | ||
| 16 | @override | 15 | @override |
| 17 | _BottleListState createState() => _BottleListState(); | 16 | _BottleListState createState() => _BottleListState(); |
| 18 | } | 17 | } |
| 19 | 18 | ||
| 20 | class _BottleListState extends State<BottleList> { | 19 | class _BottleListState extends State<BottleList> { |
| 21 | - Bottle _bottleinformation = new Bottle(); | ||
| 22 | - Medicine _medicineinformation = new Medicine(); | ||
| 23 | - | ||
| 24 | - Future<Bottle> getbottle(int index) async { | ||
| 25 | - String usertoken = await UserSecureStorage.getUserToken(); | ||
| 26 | - http.Response response = await http.get( | ||
| 27 | - Uri.encodeFull(DotEnv().env['SERVER_URL'] + | ||
| 28 | - 'bottle/' + | ||
| 29 | - widget.bottlelist[index].bottleId.toString()), | ||
| 30 | - headers: {"authorization": usertoken}); | ||
| 31 | - | ||
| 32 | - if (response.statusCode == 200) { | ||
| 33 | - Map<String, dynamic> jsonData = jsonDecode(response.body); | ||
| 34 | - print(jsonData); | ||
| 35 | - _bottleinformation = Bottle.fromJson(jsonData); | ||
| 36 | - } | ||
| 37 | - } | ||
| 38 | - | ||
| 39 | - Future<Bottle> getmedicine(int index) async { | ||
| 40 | - String usertoken = await UserSecureStorage.getUserToken(); | ||
| 41 | - http.Response medicineresponse = await http.get( | ||
| 42 | - Uri.encodeFull(DotEnv().env['SERVER_URL'] + | ||
| 43 | - 'medicine/' + | ||
| 44 | - widget.bottlelist[index].medicineId.toString()), | ||
| 45 | - headers: {"authorization": usertoken}, | ||
| 46 | - ); | ||
| 47 | - if (medicineresponse.statusCode == 200) { | ||
| 48 | - Map<String, dynamic> data = jsonDecode(medicineresponse.body); | ||
| 49 | - _medicineinformation = Medicine.fromJson(data); | ||
| 50 | - } | ||
| 51 | - } | ||
| 52 | - | ||
| 53 | Widget build(BuildContext context) { | 20 | Widget build(BuildContext context) { |
| 54 | final Size size = MediaQuery.of(context).size; | 21 | final Size size = MediaQuery.of(context).size; |
| 55 | return Scaffold( | 22 | return Scaffold( |
| ... | @@ -97,15 +64,15 @@ class _BottleListState extends State<BottleList> { | ... | @@ -97,15 +64,15 @@ class _BottleListState extends State<BottleList> { |
| 97 | ), | 64 | ), |
| 98 | trailing: Icon(Icons.arrow_forward), | 65 | trailing: Icon(Icons.arrow_forward), |
| 99 | onTap: () async { | 66 | onTap: () async { |
| 100 | - await getbottle(index); | 67 | + UserSecureStorage.setBottleId( |
| 101 | - await getmedicine(index); | 68 | + widget.bottlelist[index].bottleId.toString()); |
| 69 | + UserSecureStorage.setMedicineId( | ||
| 70 | + widget.bottlelist[index].medicineId.toString()); | ||
| 102 | Navigator.push( | 71 | Navigator.push( |
| 103 | context, | 72 | context, |
| 104 | MaterialPageRoute( | 73 | MaterialPageRoute( |
| 105 | builder: (BuildContext context) => DashBoard( | 74 | builder: (BuildContext context) => DashBoard( |
| 106 | pageNumber: 1, | 75 | pageNumber: 1, |
| 107 | - bottleInformation: _bottleinformation, | ||
| 108 | - medicineInformation: _medicineinformation, | ||
| 109 | ), | 76 | ), |
| 110 | ), | 77 | ), |
| 111 | ); | 78 | ); | ... | ... |
| ... | @@ -215,7 +215,9 @@ class _DetailMedicineState extends State<DetailMedicine> { | ... | @@ -215,7 +215,9 @@ class _DetailMedicineState extends State<DetailMedicine> { |
| 215 | context, | 215 | context, |
| 216 | MaterialPageRoute( | 216 | MaterialPageRoute( |
| 217 | builder: (BuildContext context) => | 217 | builder: (BuildContext context) => |
| 218 | - HomePage(), | 218 | + DashBoard( |
| 219 | + pageNumber: 1, | ||
| 220 | + ), | ||
| 219 | ), | 221 | ), |
| 220 | ); | 222 | ); |
| 221 | }) | 223 | }) | ... | ... |
| ... | @@ -45,6 +45,7 @@ class _HubListState extends State<HubList> { | ... | @@ -45,6 +45,7 @@ class _HubListState extends State<HubList> { |
| 45 | } else { | 45 | } else { |
| 46 | return "Error"; | 46 | return "Error"; |
| 47 | } | 47 | } |
| 48 | + return "Error"; | ||
| 48 | } | 49 | } |
| 49 | 50 | ||
| 50 | Widget build(BuildContext context) { | 51 | Widget build(BuildContext context) { |
| ... | @@ -95,14 +96,15 @@ class _HubListState extends State<HubList> { | ... | @@ -95,14 +96,15 @@ class _HubListState extends State<HubList> { |
| 95 | var result = | 96 | var result = |
| 96 | await getBottleList(widget.hublist[index]); | 97 | await getBottleList(widget.hublist[index]); |
| 97 | if (result == "GET") { | 98 | if (result == "GET") { |
| 99 | + UserSecureStorage.setHubId( | ||
| 100 | + widget.hublist[index].toString()); | ||
| 98 | Navigator.push( | 101 | Navigator.push( |
| 99 | context, | 102 | context, |
| 100 | MaterialPageRoute( | 103 | MaterialPageRoute( |
| 101 | builder: (BuildContext context) => | 104 | builder: (BuildContext context) => |
| 102 | BottleList( | 105 | BottleList( |
| 103 | - bottlelist: _bottleList, | 106 | + bottlelist: _bottleList, |
| 104 | - hubid: widget.hublist[index] | 107 | + ), |
| 105 | - .toString()), | ||
| 106 | )); | 108 | )); |
| 107 | } else if (result == "Not Found") { | 109 | } else if (result == "Not Found") { |
| 108 | showDialog( | 110 | showDialog( |
| ... | @@ -115,15 +117,15 @@ class _HubListState extends State<HubList> { | ... | @@ -115,15 +117,15 @@ class _HubListState extends State<HubList> { |
| 115 | new FlatButton( | 117 | new FlatButton( |
| 116 | child: new Text('등록'), | 118 | child: new Text('등록'), |
| 117 | onPressed: () { | 119 | onPressed: () { |
| 120 | + UserSecureStorage.setHubId(widget | ||
| 121 | + .hublist[index] | ||
| 122 | + .toString()); | ||
| 118 | Navigator.push( | 123 | Navigator.push( |
| 119 | context, | 124 | context, |
| 120 | MaterialPageRoute( | 125 | MaterialPageRoute( |
| 121 | builder: (BuildContext | 126 | builder: (BuildContext |
| 122 | context) => | 127 | context) => |
| 123 | - RegisterBottle( | 128 | + RegisterBottle(), |
| 124 | - hubid: widget | ||
| 125 | - .hublist[index] | ||
| 126 | - .toString()), | ||
| 127 | )); | 129 | )); |
| 128 | }) | 130 | }) |
| 129 | ], | 131 | ], | ... | ... |
| ... | @@ -20,16 +20,16 @@ class _RegisterBottleState extends State<RegisterBottle> { | ... | @@ -20,16 +20,16 @@ class _RegisterBottleState extends State<RegisterBottle> { |
| 20 | 20 | ||
| 21 | Future<String> registerhub_Validate() async { | 21 | Future<String> registerhub_Validate() async { |
| 22 | String usertoken = await UserSecureStorage.getUserToken(); | 22 | String usertoken = await UserSecureStorage.getUserToken(); |
| 23 | + String hubid = await UserSecureStorage.getHubId(); | ||
| 24 | + print(hubid); | ||
| 23 | http.Response bottleresponse = await http.post( | 25 | http.Response bottleresponse = await http.post( |
| 24 | Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'bottle'), | 26 | Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'bottle'), |
| 25 | headers: { | 27 | headers: { |
| 26 | "Content-Type": "application/json", | 28 | "Content-Type": "application/json", |
| 27 | "authorization": usertoken | 29 | "authorization": usertoken |
| 28 | }, | 30 | }, |
| 29 | - body: jsonEncode({ | 31 | + body: jsonEncode( |
| 30 | - 'bottleId': medicineBottleIDController.text, | 32 | + {'bottleId': medicineBottleIDController.text, 'hubId': hubid})); |
| 31 | - 'hubId': widget.hubid | ||
| 32 | - })); | ||
| 33 | 33 | ||
| 34 | if (bottleresponse.statusCode == 201) { | 34 | if (bottleresponse.statusCode == 201) { |
| 35 | return "등록 완료"; | 35 | return "등록 완료"; | ... | ... |
| ... | @@ -120,6 +120,7 @@ class _RegisterHubState extends State<RegisterHub> { | ... | @@ -120,6 +120,7 @@ class _RegisterHubState extends State<RegisterHub> { |
| 120 | String saveMessage = await registerhub_Validate(); | 120 | String saveMessage = await registerhub_Validate(); |
| 121 | print(saveMessage); | 121 | print(saveMessage); |
| 122 | if (saveMessage == "허브 등록 완료") { | 122 | if (saveMessage == "허브 등록 완료") { |
| 123 | + UserSecureStorage.setHubId(medicineHubIDController.text); | ||
| 123 | Navigator.push( | 124 | Navigator.push( |
| 124 | context, | 125 | context, |
| 125 | MaterialPageRoute( | 126 | MaterialPageRoute( | ... | ... |
| ... | @@ -28,6 +28,7 @@ class _SignInPageState extends State<SignInPage> { | ... | @@ -28,6 +28,7 @@ class _SignInPageState extends State<SignInPage> { |
| 28 | 28 | ||
| 29 | //Login 함수 | 29 | //Login 함수 |
| 30 | Future<String> login(String _email, String _password) async { | 30 | Future<String> login(String _email, String _password) async { |
| 31 | + print(Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'auth/login')); | ||
| 31 | http.Response response = await http.post( | 32 | http.Response response = await http.post( |
| 32 | Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'auth/login'), | 33 | Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'auth/login'), |
| 33 | headers: {"Content-Type": "application/json"}, | 34 | headers: {"Content-Type": "application/json"}, |
| ... | @@ -38,6 +39,7 @@ class _SignInPageState extends State<SignInPage> { | ... | @@ -38,6 +39,7 @@ class _SignInPageState extends State<SignInPage> { |
| 38 | }, | 39 | }, |
| 39 | ), | 40 | ), |
| 40 | ); | 41 | ); |
| 42 | + print(response.statusCode); | ||
| 41 | 43 | ||
| 42 | if (response.statusCode == 200) { | 44 | if (response.statusCode == 200) { |
| 43 | Map<String, dynamic> data = jsonDecode(response.body); | 45 | Map<String, dynamic> data = jsonDecode(response.body); |
| ... | @@ -51,7 +53,7 @@ class _SignInPageState extends State<SignInPage> { | ... | @@ -51,7 +53,7 @@ class _SignInPageState extends State<SignInPage> { |
| 51 | } | 53 | } |
| 52 | } | 54 | } |
| 53 | 55 | ||
| 54 | - //Get Bottle List 함수 | 56 | + //Get Hub List 함수 |
| 55 | Future<String> getHubList() async { | 57 | Future<String> getHubList() async { |
| 56 | String usertoken = await UserSecureStorage.getUserToken(); | 58 | String usertoken = await UserSecureStorage.getUserToken(); |
| 57 | http.Response response = await http.get( | 59 | http.Response response = await http.get( |
| ... | @@ -207,6 +209,7 @@ class _SignInPageState extends State<SignInPage> { | ... | @@ -207,6 +209,7 @@ class _SignInPageState extends State<SignInPage> { |
| 207 | String saveMessage = await login( | 209 | String saveMessage = await login( |
| 208 | emailController.text, | 210 | emailController.text, |
| 209 | passwordController.text); | 211 | passwordController.text); |
| 212 | + print(saveMessage); | ||
| 210 | if (emailController.text.isEmpty || | 213 | if (emailController.text.isEmpty || |
| 211 | passwordController.text.isEmpty) { | 214 | passwordController.text.isEmpty) { |
| 212 | showDialog( | 215 | showDialog( |
| ... | @@ -227,7 +230,6 @@ class _SignInPageState extends State<SignInPage> { | ... | @@ -227,7 +230,6 @@ class _SignInPageState extends State<SignInPage> { |
| 227 | ); | 230 | ); |
| 228 | }); | 231 | }); |
| 229 | } else { | 232 | } else { |
| 230 | - saveMessage = "로그인 성공"; | ||
| 231 | if (saveMessage == "로그인 성공") { | 233 | if (saveMessage == "로그인 성공") { |
| 232 | var result = await getHubList(); | 234 | var result = await getHubList(); |
| 233 | print(result); | 235 | print(result); |
| ... | @@ -242,6 +244,9 @@ class _SignInPageState extends State<SignInPage> { | ... | @@ -242,6 +244,9 @@ class _SignInPageState extends State<SignInPage> { |
| 242 | } else if (result == "get완료") { | 244 | } else if (result == "get완료") { |
| 243 | UserSecureStorage.setUserToken( | 245 | UserSecureStorage.setUserToken( |
| 244 | user.token); | 246 | user.token); |
| 247 | + UserSecureStorage.setUserId( | ||
| 248 | + user.userId); | ||
| 249 | + print('asdg'); | ||
| 245 | Navigator.push( | 250 | Navigator.push( |
| 246 | context, | 251 | context, |
| 247 | MaterialPageRoute( | 252 | MaterialPageRoute( |
| ... | @@ -250,6 +255,8 @@ class _SignInPageState extends State<SignInPage> { | ... | @@ -250,6 +255,8 @@ class _SignInPageState extends State<SignInPage> { |
| 250 | HubList(hublist: _hublist), | 255 | HubList(hublist: _hublist), |
| 251 | )); | 256 | )); |
| 252 | } else {} | 257 | } else {} |
| 258 | + } else { | ||
| 259 | + print('Error'); | ||
| 253 | } | 260 | } |
| 254 | } | 261 | } |
| 255 | }, | 262 | }, | ... | ... |
| 1 | import 'dart:convert'; | 1 | import 'dart:convert'; |
| 2 | +import 'package:Smart_Medicine_Box/src/screens/Homepage.dart'; | ||
| 2 | import 'package:flutter/material.dart'; | 3 | import 'package:flutter/material.dart'; |
| 3 | import 'package:http/http.dart' as http; | 4 | import 'package:http/http.dart' as http; |
| 4 | import 'package:flutter_dotenv/flutter_dotenv.dart'; | 5 | import 'package:flutter_dotenv/flutter_dotenv.dart'; |
| ... | @@ -182,7 +183,7 @@ class _SignUpLocalState extends State<SignUpLocal> { | ... | @@ -182,7 +183,7 @@ class _SignUpLocalState extends State<SignUpLocal> { |
| 182 | context, | 183 | context, |
| 183 | MaterialPageRoute( | 184 | MaterialPageRoute( |
| 184 | builder: (BuildContext context) => | 185 | builder: (BuildContext context) => |
| 185 | - RegisterHub())); | 186 | + HomePage())); |
| 186 | }) | 187 | }) |
| 187 | ], | 188 | ], |
| 188 | ); | 189 | ); | ... | ... |
| ... | @@ -7,6 +7,12 @@ class UserSecureStorage { | ... | @@ -7,6 +7,12 @@ class UserSecureStorage { |
| 7 | 7 | ||
| 8 | static const _keyUserId = 'userid'; | 8 | static const _keyUserId = 'userid'; |
| 9 | 9 | ||
| 10 | + static const _keyBottleId = 'bottleid'; | ||
| 11 | + | ||
| 12 | + static const _keyMedicineId = 'medicineid'; | ||
| 13 | + | ||
| 14 | + static const _keyhubId = 'hubid'; | ||
| 15 | + | ||
| 10 | static Future setUserId(String userid) async => | 16 | static Future setUserId(String userid) async => |
| 11 | await _storage.write(key: _keyUserId, value: userid); | 17 | await _storage.write(key: _keyUserId, value: userid); |
| 12 | 18 | ||
| ... | @@ -18,4 +24,21 @@ class UserSecureStorage { | ... | @@ -18,4 +24,21 @@ class UserSecureStorage { |
| 18 | 24 | ||
| 19 | static Future<String> getUserToken() async => | 25 | static Future<String> getUserToken() async => |
| 20 | await _storage.read(key: _keyToken); | 26 | await _storage.read(key: _keyToken); |
| 27 | + | ||
| 28 | + static Future setBottleId(String bottleid) async => | ||
| 29 | + await _storage.write(key: _keyBottleId, value: bottleid); | ||
| 30 | + | ||
| 31 | + static Future<String> getBottleId() async => | ||
| 32 | + await _storage.read(key: _keyBottleId); | ||
| 33 | + | ||
| 34 | + static Future setMedicineId(String medicineid) async => | ||
| 35 | + await _storage.write(key: _keyMedicineId, value: medicineid); | ||
| 36 | + | ||
| 37 | + static Future<String> getMedicineId() async => | ||
| 38 | + await _storage.read(key: _keyMedicineId); | ||
| 39 | + | ||
| 40 | + static Future setHubId(String hubid) async => | ||
| 41 | + await _storage.write(key: _keyhubId, value: hubid); | ||
| 42 | + | ||
| 43 | + static Future<String> getHubId() async => await _storage.read(key: _keyhubId); | ||
| 21 | } | 44 | } | ... | ... |
-
Please register or login to post a comment