Showing
6 changed files
with
55 additions
and
4 deletions
| ... | @@ -9,6 +9,7 @@ import '../utils/user_secure_stoarge.dart'; | ... | @@ -9,6 +9,7 @@ import '../utils/user_secure_stoarge.dart'; |
| 9 | import 'models/Bottle.dart'; | 9 | import 'models/Bottle.dart'; |
| 10 | import 'models/Medicine.dart'; | 10 | import 'models/Medicine.dart'; |
| 11 | import 'package:Smart_Medicine_Box/src/screens/SettingPage.dart'; | 11 | import 'package:Smart_Medicine_Box/src/screens/SettingPage.dart'; |
| 12 | +import 'Register/BottleList.dart'; | ||
| 12 | 13 | ||
| 13 | class DashBoard extends StatefulWidget { | 14 | class DashBoard extends StatefulWidget { |
| 14 | int pageNumber; | 15 | int pageNumber; |
| ... | @@ -24,6 +25,35 @@ class DashBoard extends StatefulWidget { | ... | @@ -24,6 +25,35 @@ class DashBoard extends StatefulWidget { |
| 24 | 25 | ||
| 25 | class _DashBoardState extends State<DashBoard> { | 26 | class _DashBoardState extends State<DashBoard> { |
| 26 | int _selectedIndex = 0; | 27 | int _selectedIndex = 0; |
| 28 | + List<Bottle> _bottleList = new List<Bottle>(); | ||
| 29 | + //Get BottleList | ||
| 30 | + Future<String> getBottleList() async { | ||
| 31 | + String usertoken = await UserSecureStorage.getUserToken(); | ||
| 32 | + String hubid = await UserSecureStorage.getHubId(); | ||
| 33 | + http.Response response = await http.get( | ||
| 34 | + Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'bottle/hub/' + hubid), | ||
| 35 | + headers: {"authorization": usertoken}, | ||
| 36 | + ); | ||
| 37 | + print(response.body); | ||
| 38 | + if (_bottleList.length != 0) { | ||
| 39 | + _bottleList.clear(); | ||
| 40 | + } | ||
| 41 | + if (response.statusCode == 200) { | ||
| 42 | + List<dynamic> values = new List<dynamic>(); | ||
| 43 | + values = json.decode(response.body); | ||
| 44 | + | ||
| 45 | + for (int i = 0; i < values.length; i++) { | ||
| 46 | + Map<String, dynamic> map = values[i]; | ||
| 47 | + _bottleList.add(Bottle.fromJson(map)); | ||
| 48 | + return "GET"; | ||
| 49 | + } | ||
| 50 | + } else if (response.statusCode == 404) { | ||
| 51 | + return "Not Found"; | ||
| 52 | + } else { | ||
| 53 | + return "Error"; | ||
| 54 | + } | ||
| 55 | + return "Error"; | ||
| 56 | + } | ||
| 27 | 57 | ||
| 28 | Widget build(BuildContext context) { | 58 | Widget build(BuildContext context) { |
| 29 | _selectedIndex = widget.pageNumber; | 59 | _selectedIndex = widget.pageNumber; |
| ... | @@ -33,7 +63,8 @@ class _DashBoardState extends State<DashBoard> { | ... | @@ -33,7 +63,8 @@ class _DashBoardState extends State<DashBoard> { |
| 33 | outerInformationpage(context), | 63 | outerInformationpage(context), |
| 34 | ]; | 64 | ]; |
| 35 | 65 | ||
| 36 | - return Scaffold( | 66 | + return WillPopScope( |
| 67 | + child: Scaffold( | ||
| 37 | backgroundColor: Color(0xffe5f4ff), | 68 | backgroundColor: Color(0xffe5f4ff), |
| 38 | appBar: AppBar( | 69 | appBar: AppBar( |
| 39 | iconTheme: IconThemeData(color: Colors.black), | 70 | iconTheme: IconThemeData(color: Colors.black), |
| ... | @@ -109,6 +140,16 @@ class _DashBoardState extends State<DashBoard> { | ... | @@ -109,6 +140,16 @@ class _DashBoardState extends State<DashBoard> { |
| 109 | ) | 140 | ) |
| 110 | ], | 141 | ], |
| 111 | ), | 142 | ), |
| 143 | + ), | ||
| 144 | + onWillPop: () async { | ||
| 145 | + await getBottleList(); | ||
| 146 | + Navigator.push( | ||
| 147 | + context, | ||
| 148 | + MaterialPageRoute( | ||
| 149 | + builder: (BuildContext context) => | ||
| 150 | + BottleList(bottlelist: _bottleList), | ||
| 151 | + )); | ||
| 152 | + }, | ||
| 112 | ); | 153 | ); |
| 113 | } | 154 | } |
| 114 | 155 | ||
| ... | @@ -314,7 +355,6 @@ Widget mainpage(BuildContext context) { | ... | @@ -314,7 +355,6 @@ Widget mainpage(BuildContext context) { |
| 314 | } | 355 | } |
| 315 | 356 | ||
| 316 | Widget ineerInformationpage(BuildContext context) { | 357 | Widget ineerInformationpage(BuildContext context) { |
| 317 | - Bottle _bottleinformation = new Bottle(); | ||
| 318 | //get bottle | 358 | //get bottle |
| 319 | Future<Bottle> _getbottle() async { | 359 | Future<Bottle> _getbottle() async { |
| 320 | String usertoken = await UserSecureStorage.getUserToken(); | 360 | String usertoken = await UserSecureStorage.getUserToken(); | ... | ... |
| ... | @@ -55,7 +55,7 @@ class _HomePageState extends State<HomePage> { | ... | @@ -55,7 +55,7 @@ class _HomePageState extends State<HomePage> { |
| 55 | textScaleFactor: 1.0, | 55 | textScaleFactor: 1.0, |
| 56 | style: TextStyle( | 56 | style: TextStyle( |
| 57 | color: Color(0xff004ca2), | 57 | color: Color(0xff004ca2), |
| 58 | - fontSize: 20, | 58 | + fontSize: 30, |
| 59 | fontFamily: 'Noto', | 59 | fontFamily: 'Noto', |
| 60 | fontWeight: FontWeight.bold), | 60 | fontWeight: FontWeight.bold), |
| 61 | ), | 61 | ), | ... | ... |
| ... | @@ -19,7 +19,8 @@ class BottleList extends StatefulWidget { | ... | @@ -19,7 +19,8 @@ class BottleList extends StatefulWidget { |
| 19 | class _BottleListState extends State<BottleList> { | 19 | class _BottleListState extends State<BottleList> { |
| 20 | Widget build(BuildContext context) { | 20 | Widget build(BuildContext context) { |
| 21 | final Size size = MediaQuery.of(context).size; | 21 | final Size size = MediaQuery.of(context).size; |
| 22 | - return Scaffold( | 22 | + return WillPopScope( |
| 23 | + child: Scaffold( | ||
| 23 | body: Container( | 24 | body: Container( |
| 24 | height: size.height, | 25 | height: size.height, |
| 25 | child: Column( | 26 | child: Column( |
| ... | @@ -86,6 +87,10 @@ class _BottleListState extends State<BottleList> { | ... | @@ -86,6 +87,10 @@ class _BottleListState extends State<BottleList> { |
| 86 | ) | 87 | ) |
| 87 | ], | 88 | ], |
| 88 | )), | 89 | )), |
| 90 | + ), | ||
| 91 | + onWillPop: () { | ||
| 92 | + SystemNavigator.pop(); | ||
| 93 | + }, | ||
| 89 | ); | 94 | ); |
| 90 | } | 95 | } |
| 91 | } | 96 | } | ... | ... |
| ... | @@ -117,6 +117,8 @@ class _RegisterBottleState extends State<RegisterBottle> { | ... | @@ -117,6 +117,8 @@ class _RegisterBottleState extends State<RegisterBottle> { |
| 117 | new FlatButton( | 117 | new FlatButton( |
| 118 | child: new Text('Close'), | 118 | child: new Text('Close'), |
| 119 | onPressed: () { | 119 | onPressed: () { |
| 120 | + UserSecureStorage.setBottleId( | ||
| 121 | + medicineBottleIDController.text); | ||
| 120 | Navigator.push( | 122 | Navigator.push( |
| 121 | context, | 123 | context, |
| 122 | MaterialPageRoute( | 124 | MaterialPageRoute( | ... | ... |
| ... | @@ -121,6 +121,7 @@ class _RegisterHubState extends State<RegisterHub> { | ... | @@ -121,6 +121,7 @@ class _RegisterHubState extends State<RegisterHub> { |
| 121 | print(saveMessage); | 121 | print(saveMessage); |
| 122 | if (saveMessage == "허브 등록 완료") { | 122 | if (saveMessage == "허브 등록 완료") { |
| 123 | UserSecureStorage.setHubId(medicineHubIDController.text); | 123 | UserSecureStorage.setHubId(medicineHubIDController.text); |
| 124 | + print(UserSecureStorage.getHubId()); | ||
| 124 | Navigator.push( | 125 | Navigator.push( |
| 125 | context, | 126 | context, |
| 126 | MaterialPageRoute( | 127 | MaterialPageRoute( | ... | ... |
-
Please register or login to post a comment