고원빈

[frontend] app 뒤로가기 설정 변경

...@@ -86,4 +86,7 @@ appbar 관련 디자인은 추후 구현 예정 ...@@ -86,4 +86,7 @@ appbar 관련 디자인은 추후 구현 예정
86 + 로그인 권한 문제 해결 86 + 로그인 권한 문제 해결
87 87
88 ### 2021-05-26 88 ### 2021-05-26
89 -+ future buillder 변경
...\ No newline at end of file ...\ No newline at end of file
89 ++ future buillder 변경
90 +
91 +### 2021-05-27
92 ++ app 뒤로가기 설정 변경
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -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,82 +63,93 @@ class _DashBoardState extends State<DashBoard> { ...@@ -33,82 +63,93 @@ class _DashBoardState extends State<DashBoard> {
33 outerInformationpage(context), 63 outerInformationpage(context),
34 ]; 64 ];
35 65
36 - return Scaffold( 66 + return WillPopScope(
37 - backgroundColor: Color(0xffe5f4ff), 67 + child: Scaffold(
38 - appBar: AppBar( 68 + backgroundColor: Color(0xffe5f4ff),
39 - iconTheme: IconThemeData(color: Colors.black), 69 + appBar: AppBar(
40 - backgroundColor: Colors.white, 70 + iconTheme: IconThemeData(color: Colors.black),
41 - title: Text( 71 + backgroundColor: Colors.white,
42 - 'Smart Medicine Box', 72 + title: Text(
43 - style: TextStyle( 73 + 'Smart Medicine Box',
44 - color: Colors.black, 74 + style: TextStyle(
45 - fontSize: 20, 75 + color: Colors.black,
46 - fontFamily: 'Noto', 76 + fontSize: 20,
47 - fontWeight: FontWeight.bold), 77 + fontFamily: 'Noto',
78 + fontWeight: FontWeight.bold),
79 + ),
80 + actions: [
81 + IconButton(
82 + icon: Icon(
83 + Icons.settings,
84 + color: Colors.black,
85 + ),
86 + onPressed: () {
87 + Navigator.push(
88 + context,
89 + MaterialPageRoute(
90 + builder: (BuildContext context) => SettingPage(),
91 + ));
92 + },
93 + )
94 + ],
48 ), 95 ),
49 - actions: [ 96 + drawer: Drawer(
50 - IconButton( 97 + child: ListView(
51 - icon: Icon( 98 + children: [
52 - Icons.settings, 99 + DrawerHeader(
53 - color: Colors.black, 100 + child: Text('Drawer Header'),
54 - ), 101 + decoration: BoxDecoration(
55 - onPressed: () { 102 + color: Colors.blue,
56 - Navigator.push( 103 + ),
57 - context,
58 - MaterialPageRoute(
59 - builder: (BuildContext context) => SettingPage(),
60 - ));
61 - },
62 - )
63 - ],
64 - ),
65 - drawer: Drawer(
66 - child: ListView(
67 - children: [
68 - DrawerHeader(
69 - child: Text('Drawer Header'),
70 - decoration: BoxDecoration(
71 - color: Colors.blue,
72 ), 104 ),
73 - ), 105 + ListTile(
74 - ListTile( 106 + title: Text('Test 1'),
75 - title: Text('Test 1'), 107 + onTap: () {},
76 - onTap: () {}, 108 + ),
77 - ), 109 + ListTile(
78 - ListTile( 110 + title: Text('Test 2'),
79 - title: Text('Test 2'), 111 + onTap: () {},
80 - onTap: () {}, 112 + ),
81 - ), 113 + ListTile(
82 - ListTile( 114 + title: Text('Test 3'),
83 - title: Text('Test 3'), 115 + onTap: () {},
84 - onTap: () {}, 116 + ),
85 - ), 117 + ],
118 + ),
119 + ),
120 + body: _tabs[_selectedIndex],
121 + bottomNavigationBar: BottomNavigationBar(
122 + type: BottomNavigationBarType.fixed,
123 + backgroundColor: Colors.grey,
124 + selectedItemColor: Colors.blue,
125 + unselectedItemColor: Colors.white.withOpacity(.60),
126 + selectedFontSize: 14,
127 + unselectedFontSize: 14,
128 + currentIndex: _selectedIndex,
129 + onTap: (int index) => {
130 + setState(() {
131 + _onItemTapped(index);
132 + })
133 + },
134 + items: [
135 + BottomNavigationBarItem(icon: Icon(Icons.favorite), label: 'In'),
136 + BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
137 + BottomNavigationBarItem(
138 + label: 'Out',
139 + icon: Icon(Icons.favorite),
140 + )
86 ], 141 ],
87 ), 142 ),
88 ), 143 ),
89 - body: _tabs[_selectedIndex], 144 + onWillPop: () async {
90 - bottomNavigationBar: BottomNavigationBar( 145 + await getBottleList();
91 - type: BottomNavigationBarType.fixed, 146 + Navigator.push(
92 - backgroundColor: Colors.grey, 147 + context,
93 - selectedItemColor: Colors.blue, 148 + MaterialPageRoute(
94 - unselectedItemColor: Colors.white.withOpacity(.60), 149 + builder: (BuildContext context) =>
95 - selectedFontSize: 14, 150 + BottleList(bottlelist: _bottleList),
96 - unselectedFontSize: 14, 151 + ));
97 - currentIndex: _selectedIndex, 152 + },
98 - onTap: (int index) => {
99 - setState(() {
100 - _onItemTapped(index);
101 - })
102 - },
103 - items: [
104 - BottomNavigationBarItem(icon: Icon(Icons.favorite), label: 'In'),
105 - BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
106 - BottomNavigationBarItem(
107 - label: 'Out',
108 - icon: Icon(Icons.favorite),
109 - )
110 - ],
111 - ),
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,73 +19,78 @@ class BottleList extends StatefulWidget { ...@@ -19,73 +19,78 @@ 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 - body: Container( 23 + child: Scaffold(
24 - height: size.height, 24 + body: Container(
25 - child: Column( 25 + height: size.height,
26 - mainAxisAlignment: MainAxisAlignment.center, 26 + child: Column(
27 - children: <Widget>[ 27 + mainAxisAlignment: MainAxisAlignment.center,
28 - SizedBox(height: 70), 28 + children: <Widget>[
29 - Container( 29 + SizedBox(height: 70),
30 - height: size.height * 0.1, 30 + Container(
31 - width: size.width, 31 + height: size.height * 0.1,
32 - child: Center( 32 + width: size.width,
33 - child: Text( 33 + child: Center(
34 - '등록된 약병 리스트', 34 + child: Text(
35 - textScaleFactor: 1.0, 35 + '등록된 약병 리스트',
36 - style: TextStyle( 36 + textScaleFactor: 1.0,
37 - fontSize: 28, 37 + style: TextStyle(
38 - fontFamily: 'Noto', 38 + fontSize: 28,
39 - fontWeight: FontWeight.bold), 39 + fontFamily: 'Noto',
40 + fontWeight: FontWeight.bold),
41 + ),
40 ), 42 ),
43 + decoration: BoxDecoration(border: Border.all()),
41 ), 44 ),
42 - decoration: BoxDecoration(border: Border.all()), 45 + SizedBox(height: 30),
43 - ), 46 + Expanded(
44 - SizedBox(height: 30), 47 + child: ListView.separated(
45 - Expanded( 48 + padding: const EdgeInsets.all(30),
46 - child: ListView.separated( 49 + itemCount: widget.bottlelist.length == null
47 - padding: const EdgeInsets.all(30), 50 + ? 0
48 - itemCount: widget.bottlelist.length == null 51 + : widget.bottlelist.length,
49 - ? 0 52 + itemBuilder: (BuildContext context, int index) {
50 - : widget.bottlelist.length, 53 + return Container(
51 - itemBuilder: (BuildContext context, int index) { 54 + padding: EdgeInsets.all(8.0),
52 - return Container( 55 + decoration: BoxDecoration(border: Border.all()),
53 - padding: EdgeInsets.all(8.0), 56 + child: ListTile(
54 - decoration: BoxDecoration(border: Border.all()), 57 + title: Text(
55 - child: ListTile( 58 + 'BOTTLE ID : ' +
56 - title: Text( 59 + '${widget.bottlelist[index].bottleId}',
57 - 'BOTTLE ID : ' + 60 + style: TextStyle(
58 - '${widget.bottlelist[index].bottleId}', 61 + color: Colors.black,
59 - style: TextStyle( 62 + fontSize: 20,
60 - color: Colors.black, 63 + fontFamily: 'Noto',
61 - fontSize: 20, 64 + fontWeight: FontWeight.bold),
62 - fontFamily: 'Noto', 65 + ),
63 - fontWeight: FontWeight.bold), 66 + trailing: Icon(Icons.arrow_forward),
64 - ), 67 + onTap: () async {
65 - trailing: Icon(Icons.arrow_forward), 68 + UserSecureStorage.setBottleId(
66 - onTap: () async { 69 + widget.bottlelist[index].bottleId.toString());
67 - UserSecureStorage.setBottleId( 70 + UserSecureStorage.setMedicineId(
68 - widget.bottlelist[index].bottleId.toString()); 71 + widget.bottlelist[index].medicineId.toString());
69 - UserSecureStorage.setMedicineId( 72 + Navigator.push(
70 - widget.bottlelist[index].medicineId.toString()); 73 + context,
71 - Navigator.push( 74 + MaterialPageRoute(
72 - context, 75 + builder: (BuildContext context) => DashBoard(
73 - MaterialPageRoute( 76 + pageNumber: 1,
74 - builder: (BuildContext context) => DashBoard( 77 + ),
75 - pageNumber: 1,
76 ), 78 ),
77 - ), 79 + );
78 - ); 80 + },
79 - }, 81 + ),
80 - ), 82 + );
81 - ); 83 + },
82 - }, 84 + separatorBuilder: (BuildContext contetx, int index) =>
83 - separatorBuilder: (BuildContext contetx, int index) => 85 + const Divider(),
84 - const Divider(), 86 + ),
85 - ), 87 + )
86 - ) 88 + ],
87 - ], 89 + )),
88 - )), 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(
......