Showing
9 changed files
with
538 additions
and
56 deletions
1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
2 | import 'package:Smart_Medicine_Box/src/screens/SettingPage.dart'; | 2 | import 'package:Smart_Medicine_Box/src/screens/SettingPage.dart'; |
3 | +import 'dart:convert'; | ||
4 | +import 'package:shared_preferences/shared_preferences.dart'; | ||
5 | +import 'package:http/http.dart' as http; | ||
6 | +import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
3 | 7 | ||
4 | class DashBoard extends StatefulWidget { | 8 | class DashBoard extends StatefulWidget { |
5 | int pageNumber = 1; | 9 | int pageNumber = 1; |
... | @@ -108,6 +112,15 @@ class _DashBoardState extends State<DashBoard> { | ... | @@ -108,6 +112,15 @@ class _DashBoardState extends State<DashBoard> { |
108 | } | 112 | } |
109 | 113 | ||
110 | Widget mainpage(BuildContext context) { | 114 | Widget mainpage(BuildContext context) { |
115 | + Future<String> getHubList() async { | ||
116 | + SharedPreferences prefs = await SharedPreferences.getInstance(); | ||
117 | + | ||
118 | + http.Response response = | ||
119 | + await http.get(Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'hub')); | ||
120 | + | ||
121 | + print(response.statusCode); | ||
122 | + } | ||
123 | + | ||
111 | final Size size = MediaQuery.of(context).size; | 124 | final Size size = MediaQuery.of(context).size; |
112 | /* | 125 | /* |
113 | Main 화면 | 126 | Main 화면 |
... | @@ -191,6 +204,27 @@ Widget mainpage(BuildContext context) { | ... | @@ -191,6 +204,27 @@ Widget mainpage(BuildContext context) { |
191 | ], | 204 | ], |
192 | ), | 205 | ), |
193 | ), | 206 | ), |
207 | + Container( | ||
208 | + height: 80, | ||
209 | + padding: const EdgeInsets.fromLTRB(20, 20, 20, 20), | ||
210 | + child: RaisedButton( | ||
211 | + onPressed: () async { | ||
212 | + String saveMessage = await getHubList(); | ||
213 | + }, | ||
214 | + shape: RoundedRectangleBorder( | ||
215 | + borderRadius: new BorderRadius.circular(18.0), | ||
216 | + side: BorderSide(color: Colors.blue)), | ||
217 | + color: Color(0xff1674f6), | ||
218 | + child: Text( | ||
219 | + '회원 가입', | ||
220 | + textScaleFactor: 1.0, | ||
221 | + style: TextStyle( | ||
222 | + fontSize: 16, | ||
223 | + color: Colors.white, | ||
224 | + fontWeight: FontWeight.bold), | ||
225 | + ), | ||
226 | + ), | ||
227 | + ) | ||
194 | ], | 228 | ], |
195 | ), | 229 | ), |
196 | ), | 230 | ), | ... | ... |
1 | -import 'package:flutter/material.dart'; | ||
2 | -import 'package:flutter/services.dart'; | ||
3 | -import '../shared/colors.dart'; | ||
4 | -import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
5 | - | ||
6 | -class MainPage extends StatefulWidget { | ||
7 | - @override | ||
8 | - _MainPageState createState() => _MainPageState(); | ||
9 | -} | ||
10 | - | ||
11 | -class _MainPageState extends State<MainPage> { | ||
12 | - Widget build(BuildContext context) { | ||
13 | - return MaterialApp( | ||
14 | - title: 'Welcome to Flutter', | ||
15 | - home: Scaffold( | ||
16 | - appBar: AppBar( | ||
17 | - title: Text('Welcome to Flutter'), | ||
18 | - ), | ||
19 | - body: Center( | ||
20 | - child: Text('Main PAge 작업 영역'), | ||
21 | - ), | ||
22 | - ), | ||
23 | - ); | ||
24 | - } | ||
25 | -} |
1 | +import 'package:Smart_Medicine_Box/src/screens/DashBoard.dart'; | ||
2 | +import 'package:flutter/cupertino.dart'; | ||
3 | +import 'dart:convert'; | ||
4 | +import 'package:flutter/material.dart'; | ||
5 | +import 'package:http/http.dart' as http; | ||
6 | +import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
7 | + | ||
8 | +class RegsiterBottle extends StatefulWidget { | ||
9 | + final String hubid; | ||
10 | + RegsiterBottle({Key key, this.hubid}) : super(key: key); | ||
11 | + @override | ||
12 | + _RegsiterBottleState createState() => _RegsiterBottleState(); | ||
13 | +} | ||
14 | + | ||
15 | +class _RegsiterBottleState extends State<RegsiterBottle> { | ||
16 | + final medicineBottleIDController = TextEditingController(); | ||
17 | + final medicineHubIDController = TextEditingController(); | ||
18 | + final medicineHubPortController = TextEditingController(); | ||
19 | + final medicineHubHostController = TextEditingController(); | ||
20 | + | ||
21 | + Future<String> registerhub_Validate() async { | ||
22 | + http.Response bottleresponse = await http.post( | ||
23 | + Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'bottle'), | ||
24 | + headers: {"Content-Type": "application/json"}, | ||
25 | + body: jsonEncode({ | ||
26 | + 'bottleId': medicineBottleIDController.text, | ||
27 | + 'hubId': widget.hubid | ||
28 | + })); | ||
29 | + | ||
30 | + if (bottleresponse.statusCode == 201) { | ||
31 | + return "등록 완료"; | ||
32 | + } else if (bottleresponse.statusCode == 404) { | ||
33 | + return "Hub 없음"; | ||
34 | + } else if (bottleresponse.statusCode == 403) { | ||
35 | + return "유저 정보 없음 "; | ||
36 | + } else if (bottleresponse.statusCode == 404) { | ||
37 | + return "HOST 없음"; | ||
38 | + } else { | ||
39 | + return "오류"; | ||
40 | + } | ||
41 | + } | ||
42 | + | ||
43 | + Widget build(BuildContext context) { | ||
44 | + final Size size = MediaQuery.of(context).size; | ||
45 | + // int goals = 60; | ||
46 | + // int points = 75; | ||
47 | + | ||
48 | + return Scaffold( | ||
49 | + backgroundColor: Colors.white, | ||
50 | + body: ListView( | ||
51 | + children: <Widget>[ | ||
52 | + Padding( | ||
53 | + padding: const EdgeInsets.fromLTRB(20, 25, 20, 0), | ||
54 | + child: Row( | ||
55 | + children: <Widget>[ | ||
56 | + Text( | ||
57 | + '약병 등록', | ||
58 | + textScaleFactor: 1.0, | ||
59 | + style: TextStyle(fontSize: 34), | ||
60 | + ) | ||
61 | + ], | ||
62 | + ), | ||
63 | + ), | ||
64 | + Padding( | ||
65 | + padding: const EdgeInsets.fromLTRB(20, 10, 20, 0), | ||
66 | + child: Row( | ||
67 | + children: <Widget>[ | ||
68 | + Text( | ||
69 | + 'SmartMedicine 회원가입', | ||
70 | + textScaleFactor: 1.0, | ||
71 | + style: TextStyle(fontSize: 16), | ||
72 | + ) | ||
73 | + ], | ||
74 | + ), | ||
75 | + ), | ||
76 | + MediaQuery( | ||
77 | + data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0), | ||
78 | + child: Container( | ||
79 | + height: size.height * 0.6, | ||
80 | + child: Padding( | ||
81 | + padding: const EdgeInsets.fromLTRB(20, 5, 20, 20), | ||
82 | + child: new Column( | ||
83 | + mainAxisAlignment: MainAxisAlignment.center, | ||
84 | + children: <Widget>[ | ||
85 | + TextFormField( | ||
86 | + keyboardType: TextInputType.text, | ||
87 | + controller: medicineBottleIDController, | ||
88 | + decoration: InputDecoration( | ||
89 | + labelText: '약병 ID', | ||
90 | + helperText: '현재 사용하시는 약병의 고유번호를 입력하세요', | ||
91 | + ), | ||
92 | + ), | ||
93 | + ], | ||
94 | + ), | ||
95 | + ), | ||
96 | + ), | ||
97 | + ), | ||
98 | + Container( | ||
99 | + height: 80, | ||
100 | + padding: const EdgeInsets.fromLTRB(20, 20, 20, 20), | ||
101 | + child: RaisedButton( | ||
102 | + onPressed: () async { | ||
103 | + String saveMessage = await registerhub_Validate(); | ||
104 | + print(saveMessage); | ||
105 | + if (saveMessage == "등록 완료") { | ||
106 | + showDialog( | ||
107 | + context: context, | ||
108 | + builder: (BuildContext context) { | ||
109 | + return AlertDialog( | ||
110 | + title: new Text('약병 등록'), | ||
111 | + content: new Text('약병 등록이 완료 되었습니다.'), | ||
112 | + actions: <Widget>[ | ||
113 | + new FlatButton( | ||
114 | + child: new Text('Close'), | ||
115 | + onPressed: () { | ||
116 | + Navigator.push( | ||
117 | + context, | ||
118 | + MaterialPageRoute( | ||
119 | + builder: (BuildContext context) => | ||
120 | + DashBoard( | ||
121 | + pageNumber: 1, | ||
122 | + ))); | ||
123 | + }) | ||
124 | + ], | ||
125 | + ); | ||
126 | + }); | ||
127 | + } else { | ||
128 | + showDialog( | ||
129 | + context: context, | ||
130 | + builder: (BuildContext context) { | ||
131 | + return AlertDialog( | ||
132 | + title: new Text('약병 등록'), | ||
133 | + content: new Text(saveMessage), | ||
134 | + actions: <Widget>[ | ||
135 | + new FlatButton( | ||
136 | + child: new Text('Close'), | ||
137 | + onPressed: () { | ||
138 | + Navigator.push( | ||
139 | + context, | ||
140 | + MaterialPageRoute( | ||
141 | + builder: (BuildContext context) => | ||
142 | + DashBoard( | ||
143 | + pageNumber: 1, | ||
144 | + ))); | ||
145 | + }) | ||
146 | + ], | ||
147 | + ); | ||
148 | + }); | ||
149 | + } | ||
150 | + }, | ||
151 | + shape: RoundedRectangleBorder( | ||
152 | + borderRadius: new BorderRadius.circular(18.0), | ||
153 | + side: BorderSide(color: Colors.blue)), | ||
154 | + color: Color(0xff1674f6), | ||
155 | + child: Text( | ||
156 | + '약병 등록', | ||
157 | + textScaleFactor: 1.0, | ||
158 | + style: TextStyle( | ||
159 | + fontSize: 16, | ||
160 | + color: Colors.white, | ||
161 | + fontWeight: FontWeight.bold), | ||
162 | + ), | ||
163 | + ), | ||
164 | + ) | ||
165 | + ], | ||
166 | + ), | ||
167 | + bottomNavigationBar: BottomAppBar( | ||
168 | + elevation: 0, | ||
169 | + child: Container( | ||
170 | + height: 70, | ||
171 | + child: Column( | ||
172 | + mainAxisAlignment: MainAxisAlignment.start, | ||
173 | + children: <Widget>[ | ||
174 | + Padding( | ||
175 | + padding: const EdgeInsets.fromLTRB(70, 0, 70, 0), | ||
176 | + child: Text( | ||
177 | + '회원 가입시, 이용 약관 및 개인정보 처리 방침에 동의하는 것으로 간주합니다..', | ||
178 | + style: TextStyle(fontSize: 12, color: Color(0xff747474)), | ||
179 | + textAlign: TextAlign.center, | ||
180 | + ), | ||
181 | + ) | ||
182 | + ], | ||
183 | + ), | ||
184 | + ), | ||
185 | + ), | ||
186 | + ); | ||
187 | + } | ||
188 | +} |
1 | +import 'package:flutter/cupertino.dart'; | ||
2 | +import 'dart:convert'; | ||
3 | +import 'package:flutter/material.dart'; | ||
4 | +import 'package:http/http.dart' as http; | ||
5 | +import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
6 | + | ||
7 | +import 'RegisterBottle.dart'; | ||
8 | + | ||
9 | +class RegsiterHub extends StatefulWidget { | ||
10 | + @override | ||
11 | + _RegsiterHubState createState() => _RegsiterHubState(); | ||
12 | +} | ||
13 | + | ||
14 | +class _RegsiterHubState extends State<RegsiterHub> { | ||
15 | + final medicineBottleIDController = TextEditingController(); | ||
16 | + final medicineHubIDController = TextEditingController(); | ||
17 | + final medicineHubPortController = TextEditingController(); | ||
18 | + final medicineHubHostController = TextEditingController(); | ||
19 | + | ||
20 | + Future<String> registerhub_Validate() async { | ||
21 | + http.Response hubresponse = | ||
22 | + await http.post(Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'hub'), | ||
23 | + headers: {"Content-Type": "application/json"}, | ||
24 | + body: jsonEncode({ | ||
25 | + 'hubId': medicineHubIDController.text, | ||
26 | + 'host': medicineHubHostController.text, | ||
27 | + 'port': medicineHubPortController.text, | ||
28 | + })); | ||
29 | + | ||
30 | + if (hubresponse.statusCode == 201) { | ||
31 | + return "허브 등록 완료"; | ||
32 | + } else if (hubresponse.statusCode == 409) { | ||
33 | + return "이미 존재하는 hub"; | ||
34 | + } else { | ||
35 | + return "오류"; | ||
36 | + } | ||
37 | + } | ||
38 | + | ||
39 | + Widget build(BuildContext context) { | ||
40 | + final Size size = MediaQuery.of(context).size; | ||
41 | + // int goals = 60; | ||
42 | + // int points = 75; | ||
43 | + | ||
44 | + return Scaffold( | ||
45 | + backgroundColor: Colors.white, | ||
46 | + body: ListView( | ||
47 | + children: <Widget>[ | ||
48 | + Padding( | ||
49 | + padding: const EdgeInsets.fromLTRB(20, 25, 20, 0), | ||
50 | + child: Row( | ||
51 | + children: <Widget>[ | ||
52 | + Text( | ||
53 | + '약병 등록', | ||
54 | + textScaleFactor: 1.0, | ||
55 | + style: TextStyle(fontSize: 34), | ||
56 | + ) | ||
57 | + ], | ||
58 | + ), | ||
59 | + ), | ||
60 | + Padding( | ||
61 | + padding: const EdgeInsets.fromLTRB(20, 10, 20, 0), | ||
62 | + child: Row( | ||
63 | + children: <Widget>[ | ||
64 | + Text( | ||
65 | + 'SmartMedicine 회원가입', | ||
66 | + textScaleFactor: 1.0, | ||
67 | + style: TextStyle(fontSize: 16), | ||
68 | + ) | ||
69 | + ], | ||
70 | + ), | ||
71 | + ), | ||
72 | + MediaQuery( | ||
73 | + data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0), | ||
74 | + child: Container( | ||
75 | + height: size.height * 0.6, | ||
76 | + child: Padding( | ||
77 | + padding: const EdgeInsets.fromLTRB(20, 5, 20, 20), | ||
78 | + child: new Column( | ||
79 | + mainAxisAlignment: MainAxisAlignment.center, | ||
80 | + children: <Widget>[ | ||
81 | + TextFormField( | ||
82 | + keyboardType: TextInputType.text, | ||
83 | + controller: medicineHubIDController, | ||
84 | + decoration: InputDecoration( | ||
85 | + labelText: '허브 ID', | ||
86 | + helperText: '현자 등록하시는 허브의 고유 번호를 입력하세요', | ||
87 | + ), | ||
88 | + ), | ||
89 | + TextFormField( | ||
90 | + keyboardType: TextInputType.text, | ||
91 | + controller: medicineHubHostController, | ||
92 | + decoration: InputDecoration( | ||
93 | + labelText: 'Host', | ||
94 | + helperText: '현재 사용하시는 허브의 HOST를 입력하세요', | ||
95 | + ), | ||
96 | + ), | ||
97 | + TextFormField( | ||
98 | + keyboardType: TextInputType.text, | ||
99 | + controller: medicineHubPortController, | ||
100 | + decoration: InputDecoration( | ||
101 | + labelText: 'Port', | ||
102 | + helperText: '현재 사용하시는 허브의 PORT를 입력하세요', | ||
103 | + ), | ||
104 | + ), | ||
105 | + ], | ||
106 | + ), | ||
107 | + ), | ||
108 | + ), | ||
109 | + ), | ||
110 | + Container( | ||
111 | + height: 80, | ||
112 | + padding: const EdgeInsets.fromLTRB(20, 20, 20, 20), | ||
113 | + child: RaisedButton( | ||
114 | + onPressed: () async { | ||
115 | + String saveMessage = await registerhub_Validate(); | ||
116 | + print(saveMessage); | ||
117 | + if (saveMessage == "허브 등록 완료") { | ||
118 | + Navigator.push( | ||
119 | + context, | ||
120 | + MaterialPageRoute( | ||
121 | + builder: (BuildContext context) => | ||
122 | + RegsiterBottle(hubid: medicineHubIDController.text), | ||
123 | + )); | ||
124 | + } | ||
125 | + }, | ||
126 | + shape: RoundedRectangleBorder( | ||
127 | + borderRadius: new BorderRadius.circular(18.0), | ||
128 | + side: BorderSide(color: Colors.blue)), | ||
129 | + color: Color(0xff1674f6), | ||
130 | + child: Text( | ||
131 | + ' 허브 등록 ', | ||
132 | + textScaleFactor: 1.0, | ||
133 | + style: TextStyle( | ||
134 | + fontSize: 16, | ||
135 | + color: Colors.white, | ||
136 | + fontWeight: FontWeight.bold), | ||
137 | + ), | ||
138 | + ), | ||
139 | + ) | ||
140 | + ], | ||
141 | + ), | ||
142 | + bottomNavigationBar: BottomAppBar( | ||
143 | + elevation: 0, | ||
144 | + child: Container( | ||
145 | + height: 70, | ||
146 | + child: Column( | ||
147 | + mainAxisAlignment: MainAxisAlignment.start, | ||
148 | + children: <Widget>[ | ||
149 | + Padding( | ||
150 | + padding: const EdgeInsets.fromLTRB(70, 0, 70, 0), | ||
151 | + child: Text( | ||
152 | + '회원 가입시, 이용 약관 및 개인정보 처리 방침에 동의하는 것으로 간주합니다..', | ||
153 | + style: TextStyle(fontSize: 12, color: Color(0xff747474)), | ||
154 | + textAlign: TextAlign.center, | ||
155 | + ), | ||
156 | + ) | ||
157 | + ], | ||
158 | + ), | ||
159 | + ), | ||
160 | + ), | ||
161 | + ); | ||
162 | + } | ||
163 | +} |
1 | +import 'dart:convert'; | ||
1 | import 'package:flutter/material.dart'; | 2 | import 'package:flutter/material.dart'; |
2 | import 'package:flutter/services.dart'; | 3 | import 'package:flutter/services.dart'; |
4 | +import 'package:http/http.dart' as http; | ||
5 | +import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
6 | +import 'package:shared_preferences/shared_preferences.dart'; | ||
3 | import './DashBoard.dart'; | 7 | import './DashBoard.dart'; |
8 | +import 'RegsiterHub.dart'; | ||
4 | 9 | ||
5 | class SignInPage extends StatefulWidget { | 10 | class SignInPage extends StatefulWidget { |
6 | @override | 11 | @override |
... | @@ -15,6 +20,40 @@ class _SignInPageState extends State<SignInPage> { | ... | @@ -15,6 +20,40 @@ class _SignInPageState extends State<SignInPage> { |
15 | final emailController = TextEditingController(); | 20 | final emailController = TextEditingController(); |
16 | final passwordController = TextEditingController(); | 21 | final passwordController = TextEditingController(); |
17 | 22 | ||
23 | + //Login 함수 | ||
24 | + Future<String> login(String _email, String _password) async { | ||
25 | + http.Response response = await http.post( | ||
26 | + Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'auth/login'), | ||
27 | + headers: {"Content-Type": "application/json"}, | ||
28 | + body: jsonEncode({ | ||
29 | + 'userId': _email, | ||
30 | + 'password': _password, | ||
31 | + })); | ||
32 | + | ||
33 | + if (response.statusCode == 200) { | ||
34 | + return "로그인 성공"; | ||
35 | + } else if (response.statusCode == 400) { | ||
36 | + return "올바르지 않은 아이디 및 패스워드"; | ||
37 | + } else { | ||
38 | + return "존재하지 않는 아이디 이거나 비밀번호가 불일치 합니다."; | ||
39 | + } | ||
40 | + } | ||
41 | + | ||
42 | + //Get Bottle List 함수 | ||
43 | + Future<String> getHubList() async { | ||
44 | + SharedPreferences prefs = await SharedPreferences.getInstance(); | ||
45 | + | ||
46 | + http.Response response = | ||
47 | + await http.get(Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'hub')); | ||
48 | + if (response.statusCode == 200) { | ||
49 | + return "get완료"; | ||
50 | + } else if (response.statusCode == 404) { | ||
51 | + return "Not Found"; | ||
52 | + } else { | ||
53 | + return "Error"; | ||
54 | + } | ||
55 | + } | ||
56 | + | ||
18 | Widget build(BuildContext context) { | 57 | Widget build(BuildContext context) { |
19 | final Size size = MediaQuery.of(context).size; | 58 | final Size size = MediaQuery.of(context).size; |
20 | final mqData = MediaQuery.of(context); | 59 | final mqData = MediaQuery.of(context); |
... | @@ -142,7 +181,9 @@ class _SignInPageState extends State<SignInPage> { | ... | @@ -142,7 +181,9 @@ class _SignInPageState extends State<SignInPage> { |
142 | fontFamily: 'Noto', | 181 | fontFamily: 'Noto', |
143 | fontWeight: FontWeight.bold)), | 182 | fontWeight: FontWeight.bold)), |
144 | onPressed: () async { | 183 | onPressed: () async { |
145 | - String saveMessage; | 184 | + String saveMessage = await login( |
185 | + emailController.text, | ||
186 | + passwordController.text); | ||
146 | if (emailController.text.isEmpty || | 187 | if (emailController.text.isEmpty || |
147 | passwordController.text.isEmpty) { | 188 | passwordController.text.isEmpty) { |
148 | showDialog( | 189 | showDialog( |
... | @@ -163,18 +204,27 @@ class _SignInPageState extends State<SignInPage> { | ... | @@ -163,18 +204,27 @@ class _SignInPageState extends State<SignInPage> { |
163 | ); | 204 | ); |
164 | }); | 205 | }); |
165 | } else { | 206 | } else { |
166 | - emailController.text = | ||
167 | - emailController.text.trim(); | ||
168 | - passwordController.text = | ||
169 | - passwordController.text.trim(); | ||
170 | saveMessage = "로그인 성공"; | 207 | saveMessage = "로그인 성공"; |
171 | if (saveMessage == "로그인 성공") { | 208 | if (saveMessage == "로그인 성공") { |
209 | + var result = await getHubList(); | ||
210 | + print(result); | ||
211 | + if (result == "Not Found") { | ||
212 | + Navigator.push( | ||
213 | + context, | ||
214 | + MaterialPageRoute( | ||
215 | + builder: | ||
216 | + (BuildContext context) => | ||
217 | + RegsiterHub(), | ||
218 | + )); | ||
219 | + } else if (result == "get완료") { | ||
172 | Navigator.push( | 220 | Navigator.push( |
173 | context, | 221 | context, |
174 | MaterialPageRoute( | 222 | MaterialPageRoute( |
175 | - builder: (BuildContext context) => | 223 | + builder: (BuildContext |
224 | + context) => | ||
176 | DashBoard(pageNumber: 1), | 225 | DashBoard(pageNumber: 1), |
177 | )); | 226 | )); |
227 | + } else {} | ||
178 | } | 228 | } |
179 | } | 229 | } |
180 | }, | 230 | }, | ... | ... |
... | @@ -3,6 +3,8 @@ import 'package:flutter/material.dart'; | ... | @@ -3,6 +3,8 @@ import 'package:flutter/material.dart'; |
3 | import 'package:http/http.dart' as http; | 3 | import 'package:http/http.dart' as http; |
4 | import 'package:flutter_dotenv/flutter_dotenv.dart'; | 4 | import 'package:flutter_dotenv/flutter_dotenv.dart'; |
5 | 5 | ||
6 | +import 'Homepage.dart'; | ||
7 | + | ||
6 | class SignUpLocal extends StatefulWidget { | 8 | class SignUpLocal extends StatefulWidget { |
7 | @override | 9 | @override |
8 | _SignUpLocalState createState() => _SignUpLocalState(); | 10 | _SignUpLocalState createState() => _SignUpLocalState(); |
... | @@ -12,9 +14,6 @@ class _SignUpLocalState extends State<SignUpLocal> { | ... | @@ -12,9 +14,6 @@ class _SignUpLocalState extends State<SignUpLocal> { |
12 | final emailController = TextEditingController(); | 14 | final emailController = TextEditingController(); |
13 | final passwordController = TextEditingController(); | 15 | final passwordController = TextEditingController(); |
14 | final passwordValidController = TextEditingController(); | 16 | final passwordValidController = TextEditingController(); |
15 | - final medicineNameController = TextEditingController(); | ||
16 | - final medicineFactureController = TextEditingController(); | ||
17 | - | ||
18 | bool _validate = false; | 17 | bool _validate = false; |
19 | int userRole = 0; | 18 | int userRole = 0; |
20 | 19 | ||
... | @@ -31,6 +30,13 @@ class _SignUpLocalState extends State<SignUpLocal> { | ... | @@ -31,6 +30,13 @@ class _SignUpLocalState extends State<SignUpLocal> { |
31 | 'password': passwordController.text, | 30 | 'password': passwordController.text, |
32 | 'passwordCheck': passwordValidController.text | 31 | 'passwordCheck': passwordValidController.text |
33 | })); | 32 | })); |
33 | + | ||
34 | + print(response.statusCode); | ||
35 | + if (response.statusCode == 201) { | ||
36 | + return "정보 입력 완료"; | ||
37 | + } else { | ||
38 | + return "오류"; | ||
39 | + } | ||
34 | } | 40 | } |
35 | 41 | ||
36 | @override | 42 | @override |
... | @@ -150,22 +156,6 @@ class _SignUpLocalState extends State<SignUpLocal> { | ... | @@ -150,22 +156,6 @@ class _SignUpLocalState extends State<SignUpLocal> { |
150 | ), | 156 | ), |
151 | ), | 157 | ), |
152 | ), | 158 | ), |
153 | - TextFormField( | ||
154 | - keyboardType: TextInputType.text, | ||
155 | - controller: medicineNameController, | ||
156 | - decoration: InputDecoration( | ||
157 | - labelText: '약 이름', | ||
158 | - helperText: '약의 이름을 읿력하세요', | ||
159 | - ), | ||
160 | - ), | ||
161 | - TextFormField( | ||
162 | - keyboardType: TextInputType.text, | ||
163 | - controller: medicineFactureController, | ||
164 | - decoration: InputDecoration( | ||
165 | - labelText: '약 제조사 이름', | ||
166 | - helperText: '약 제조사의 이름을 읿력하세요', | ||
167 | - ), | ||
168 | - ), | ||
169 | ], | 159 | ], |
170 | ), | 160 | ), |
171 | ), | 161 | ), |
... | @@ -177,11 +167,43 @@ class _SignUpLocalState extends State<SignUpLocal> { | ... | @@ -177,11 +167,43 @@ class _SignUpLocalState extends State<SignUpLocal> { |
177 | child: RaisedButton( | 167 | child: RaisedButton( |
178 | onPressed: () async { | 168 | onPressed: () async { |
179 | String saveMessage = await signup_Validate(); | 169 | String saveMessage = await signup_Validate(); |
180 | - print('saveMessage'); | 170 | + if (saveMessage == "정보 입력 완료") { |
181 | - print(saveMessage); | 171 | + showDialog( |
182 | - print(emailController.text); | 172 | + context: context, |
183 | - print(passwordController.text); | 173 | + builder: (BuildContext context) { |
184 | - print(passwordValidController.text); | 174 | + return AlertDialog( |
175 | + title: new Text('회원 가입'), | ||
176 | + content: new Text('회원 가입이 완료 되었습니다.'), | ||
177 | + actions: <Widget>[ | ||
178 | + new FlatButton( | ||
179 | + child: new Text('Close'), | ||
180 | + onPressed: () { | ||
181 | + Navigator.push( | ||
182 | + context, | ||
183 | + MaterialPageRoute( | ||
184 | + builder: (BuildContext context) => | ||
185 | + HomePage())); | ||
186 | + }) | ||
187 | + ], | ||
188 | + ); | ||
189 | + }); | ||
190 | + } else { | ||
191 | + showDialog( | ||
192 | + context: context, | ||
193 | + builder: (BuildContext context) { | ||
194 | + return AlertDialog( | ||
195 | + title: new Text('회원 가입 오류'), | ||
196 | + content: new Text('정확한 이메일, 비밀번호를 입력해 주세요.'), | ||
197 | + actions: <Widget>[ | ||
198 | + new FlatButton( | ||
199 | + child: new Text('Close'), | ||
200 | + onPressed: () { | ||
201 | + Navigator.of(context).pop(); | ||
202 | + }) | ||
203 | + ], | ||
204 | + ); | ||
205 | + }); | ||
206 | + } | ||
185 | }, | 207 | }, |
186 | shape: RoundedRectangleBorder( | 208 | shape: RoundedRectangleBorder( |
187 | borderRadius: new BorderRadius.circular(18.0), | 209 | borderRadius: new BorderRadius.circular(18.0), | ... | ... |
1 | +class Bottle { | ||
2 | + final int bottleId; | ||
3 | + final int temperature; | ||
4 | + final int humidity; | ||
5 | + final int balance; | ||
6 | + final DateTime recentOpen; | ||
7 | + final int medicineId; | ||
8 | + final int hubId; | ||
9 | + final int dosage; | ||
10 | + | ||
11 | + Bottle( | ||
12 | + {this.bottleId, | ||
13 | + this.temperature, | ||
14 | + this.humidity, | ||
15 | + this.balance, | ||
16 | + this.recentOpen, | ||
17 | + this.medicineId, | ||
18 | + this.hubId, | ||
19 | + this.dosage}); | ||
20 | + | ||
21 | + factory Bottle.fromJson(Map<String, dynamic> parsedJson) { | ||
22 | + var list = parsedJson['data'] as List; | ||
23 | + | ||
24 | + return Bottle( | ||
25 | + bottleId: parsedJson['bottleId'], | ||
26 | + temperature: parsedJson['temperature'], | ||
27 | + humidity: parsedJson['humidity'], | ||
28 | + balance: parsedJson['balance'], | ||
29 | + recentOpen: parsedJson['recentOpen'], | ||
30 | + medicineId: parsedJson['medicineId'], | ||
31 | + hubId: parsedJson['hubId'], | ||
32 | + dosage: parsedJson['dosage'], | ||
33 | + ); | ||
34 | + } | ||
35 | + | ||
36 | + Map<String, dynamic> toJson() => { | ||
37 | + "bottleId": bottleId, | ||
38 | + "temperature": temperature, | ||
39 | + "humidity:": humidity, | ||
40 | + "balance": balance, | ||
41 | + "recentOpen": recentOpen, | ||
42 | + "medicineId": medicineId, | ||
43 | + "hubId": hubId, | ||
44 | + "dosage": dosage, | ||
45 | + }; | ||
46 | +} |
-
Please register or login to post a comment