고원빈

[frontend] 2021-05-23

...@@ -67,3 +67,5 @@ appbar 관련 디자인은 추후 구현 예정 ...@@ -67,3 +67,5 @@ appbar 관련 디자인은 추후 구현 예정
67 ### 2021-05-21 67 ### 2021-05-21
68 + 약병 ,허브 리스트 출력 구현 68 + 약병 ,허브 리스트 출력 구현
69 69
70 +### 2021-05-22
71 ++ 약병 검색 기능 구현 중
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -16,6 +16,7 @@ class BottleList extends StatefulWidget { ...@@ -16,6 +16,7 @@ class BottleList extends StatefulWidget {
16 16
17 class _BottleListState extends State<BottleList> { 17 class _BottleListState extends State<BottleList> {
18 Widget build(BuildContext context) { 18 Widget build(BuildContext context) {
19 + print(widget.bottlelist);
19 final Size size = MediaQuery.of(context).size; 20 final Size size = MediaQuery.of(context).size;
20 return Scaffold( 21 return Scaffold(
21 body: Container( 22 body: Container(
......
...@@ -5,6 +5,8 @@ import 'package:flutter/material.dart'; ...@@ -5,6 +5,8 @@ import 'package:flutter/material.dart';
5 import 'package:http/http.dart' as http; 5 import 'package:http/http.dart' as http;
6 import 'package:flutter_dotenv/flutter_dotenv.dart'; 6 import 'package:flutter_dotenv/flutter_dotenv.dart';
7 7
8 +import 'SearchMedicine.dart';
9 +
8 class RegisterBottle extends StatefulWidget { 10 class RegisterBottle extends StatefulWidget {
9 final String hubid; 11 final String hubid;
10 RegisterBottle({Key key, this.hubid}) : super(key: key); 12 RegisterBottle({Key key, this.hubid}) : super(key: key);
...@@ -117,9 +119,7 @@ class _RegisterBottleState extends State<RegisterBottle> { ...@@ -117,9 +119,7 @@ class _RegisterBottleState extends State<RegisterBottle> {
117 context, 119 context,
118 MaterialPageRoute( 120 MaterialPageRoute(
119 builder: (BuildContext context) => 121 builder: (BuildContext context) =>
120 - DashBoard( 122 + SearchMedicine()));
121 - pageNumber: 1,
122 - )));
123 }) 123 })
124 ], 124 ],
125 ); 125 );
...@@ -129,19 +129,13 @@ class _RegisterBottleState extends State<RegisterBottle> { ...@@ -129,19 +129,13 @@ class _RegisterBottleState extends State<RegisterBottle> {
129 context: context, 129 context: context,
130 builder: (BuildContext context) { 130 builder: (BuildContext context) {
131 return AlertDialog( 131 return AlertDialog(
132 - title: new Text('약병 등록'), 132 + title: new Text('오류'),
133 content: new Text(saveMessage), 133 content: new Text(saveMessage),
134 actions: <Widget>[ 134 actions: <Widget>[
135 new FlatButton( 135 new FlatButton(
136 child: new Text('Close'), 136 child: new Text('Close'),
137 onPressed: () { 137 onPressed: () {
138 - Navigator.push( 138 + Navigator.of(context).pop();
139 - context,
140 - MaterialPageRoute(
141 - builder: (BuildContext context) =>
142 - DashBoard(
143 - pageNumber: 1,
144 - )));
145 }) 139 })
146 ], 140 ],
147 ); 141 );
......
...@@ -50,7 +50,7 @@ class _RegisterHubState extends State<RegisterHub> { ...@@ -50,7 +50,7 @@ class _RegisterHubState extends State<RegisterHub> {
50 child: Row( 50 child: Row(
51 children: <Widget>[ 51 children: <Widget>[
52 Text( 52 Text(
53 - '약병 등록', 53 + '허브 등록',
54 textScaleFactor: 1.0, 54 textScaleFactor: 1.0,
55 style: TextStyle(fontSize: 34), 55 style: TextStyle(fontSize: 34),
56 ) 56 )
...@@ -62,7 +62,7 @@ class _RegisterHubState extends State<RegisterHub> { ...@@ -62,7 +62,7 @@ class _RegisterHubState extends State<RegisterHub> {
62 child: Row( 62 child: Row(
63 children: <Widget>[ 63 children: <Widget>[
64 Text( 64 Text(
65 - 'SmartMedicine 회원가입', 65 + 'SmartMedicine 허브 등록',
66 textScaleFactor: 1.0, 66 textScaleFactor: 1.0,
67 style: TextStyle(fontSize: 16), 67 style: TextStyle(fontSize: 16),
68 ) 68 )
......
1 +import 'dart:convert';
2 +import 'package:flutter/material.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 'models/Bottle.dart';
7 +import 'DashBoard.dart';
8 +
9 +class SearchMedicine extends StatefulWidget {
10 + @override
11 + _SearchMedicineState createState() => _SearchMedicineState();
12 +}
13 +
14 +class _SearchMedicineState extends State<SearchMedicine> {
15 + final medicineNameController = TextEditingController();
16 + final medicineFactureController = TextEditingController();
17 +
18 + Widget build(BuildContext context) {
19 + bool isForward = false;
20 + final Size size = MediaQuery.of(context).size;
21 + // int goals = 60;
22 + // int points = 75;
23 +
24 + return Scaffold(
25 + appBar: AppBar(
26 + backgroundColor: Colors.white,
27 + leading: new Icon(Icons.medical_services_rounded,
28 + color: Colors.black, size: 45.0),
29 + title: Text(
30 + 'Smart Medicine Box',
31 + style: TextStyle(
32 + color: Colors.black,
33 + fontSize: 23,
34 + fontFamily: 'Noto',
35 + fontWeight: FontWeight.bold),
36 + ),
37 + ),
38 + body: Container(
39 + height: size.height,
40 + padding: const EdgeInsets.all(10),
41 + decoration: BoxDecoration(
42 + border: Border.all(),
43 + ),
44 + child: Column(
45 + crossAxisAlignment: CrossAxisAlignment.center,
46 + children: <Widget>[
47 + SizedBox(height: 20),
48 + Container(
49 + height: size.height * 0.13,
50 + decoration: BoxDecoration(
51 + border: Border.all(),
52 + color: Colors.white,
53 + borderRadius: BorderRadius.circular(25),
54 + ),
55 + child: Row(
56 + children: [
57 + Column(
58 + children: [
59 + Container(
60 + height: size.height * 0.0635,
61 + width: size.width * 0.75,
62 + child: Row(
63 + children: [
64 + Container(
65 + width: size.width * 0.16,
66 + padding: const EdgeInsets.fromLTRB(10, 0, 0, 0),
67 + child: Text('약이름:',
68 + textAlign: TextAlign.center,
69 + style: TextStyle(
70 + fontSize: 16,
71 + fontFamily: 'NotoSansKR',
72 + fontWeight: FontWeight.w600)),
73 + ),
74 + Container(
75 + padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
76 + width: size.width * 0.55,
77 + child: TextFormField(
78 + keyboardType: TextInputType.text,
79 + controller: medicineNameController,
80 + decoration: InputDecoration(
81 + border: InputBorder.none,
82 + focusedBorder: InputBorder.none,
83 + enabledBorder: InputBorder.none,
84 + errorBorder: InputBorder.none,
85 + disabledBorder: InputBorder.none,
86 + hintText: '약 이름을 입력하세요',
87 + ),
88 + style: TextStyle(
89 + fontSize: 16,
90 + fontFamily: 'NotoSansKR',
91 + fontWeight: FontWeight.w600)),
92 + )
93 + ],
94 + ),
95 + decoration: BoxDecoration(
96 + border: Border(
97 + bottom: BorderSide(
98 + color: Colors.black,
99 + width: 1,
100 + style: BorderStyle.solid),
101 + right: BorderSide(
102 + color: Colors.black,
103 + width: 1,
104 + style: BorderStyle.solid),
105 + ),
106 + ),
107 + ),
108 + Container(
109 + height: size.height * 0.0635,
110 + width: size.width * 0.75,
111 + child: Row(
112 + children: [
113 + Container(
114 + width: size.width * 0.16,
115 + padding: const EdgeInsets.fromLTRB(5, 0, 0, 3),
116 + child: Text('제조사:',
117 + textAlign: TextAlign.center,
118 + style: TextStyle(
119 + fontSize: 16,
120 + fontFamily: 'NotoSansKR',
121 + fontWeight: FontWeight.w600)),
122 + ),
123 + Container(
124 + padding: const EdgeInsets.fromLTRB(6, 0, 0, 0),
125 + width: size.width * 0.50,
126 + child: TextFormField(
127 + keyboardType: TextInputType.text,
128 + controller: medicineFactureController,
129 + decoration: InputDecoration(
130 + border: InputBorder.none,
131 + focusedBorder: InputBorder.none,
132 + enabledBorder: InputBorder.none,
133 + errorBorder: InputBorder.none,
134 + disabledBorder: InputBorder.none,
135 + hintText: '약 제조사 이름을 입력하세요',
136 + ),
137 + style: TextStyle(
138 + fontSize: 16,
139 + fontFamily: 'NotoSansKR',
140 + fontWeight: FontWeight.w600)),
141 + )
142 + ],
143 + ),
144 + decoration: BoxDecoration(
145 + border: Border(
146 + right: BorderSide(
147 + color: Colors.black,
148 + width: 1,
149 + style: BorderStyle.solid),
150 + ),
151 + ),
152 + ),
153 + ],
154 + ),
155 + Container(
156 + height: size.height * 0.0635 * 2,
157 + width: size.width * 0.14,
158 + padding: const EdgeInsets.fromLTRB(10, 0, 0, 0),
159 + child: IconButton(
160 + icon: Icon(Icons.search, size: 40),
161 + onPressed: () {
162 + //검색 함수를 여기다가
163 + },
164 + ),
165 + ),
166 + ],
167 + ),
168 + ),
169 + SizedBox(height: 20),
170 + Expanded(
171 + child: ListView.separated(
172 + itemBuilder: (BuildContext context, int index) {},
173 + separatorBuilder: (BuildContext contetx, int index) =>
174 + const Divider(),
175 + itemCount: 0))
176 + ],
177 + ),
178 + ),
179 + );
180 + }
181 +}
...@@ -48,14 +48,15 @@ class _SignInPageState extends State<SignInPage> { ...@@ -48,14 +48,15 @@ class _SignInPageState extends State<SignInPage> {
48 await http.get(Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'hub')); 48 await http.get(Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'hub'));
49 49
50 List<dynamic> values = new List<dynamic>(); 50 List<dynamic> values = new List<dynamic>();
51 - values = json.decode(response.body); 51 +
52 if (_hublist.length != 0) { 52 if (_hublist.length != 0) {
53 _hublist.clear(); 53 _hublist.clear();
54 } 54 }
55 - for (int i = 0; i < values.length; i++) {
56 - _hublist.add(values[i]['hubId']);
57 - }
58 if (response.statusCode == 200) { 55 if (response.statusCode == 200) {
56 + values = json.decode(response.body);
57 + for (int i = 0; i < values.length; i++) {
58 + _hublist.add(values[i]['hubId']);
59 + }
59 return "get완료"; 60 return "get완료";
60 } else if (response.statusCode == 404) { 61 } else if (response.statusCode == 404) {
61 return "Not Found"; 62 return "Not Found";
......
...@@ -19,8 +19,6 @@ class Bottle { ...@@ -19,8 +19,6 @@ class Bottle {
19 this.dosage}); 19 this.dosage});
20 20
21 factory Bottle.fromJson(Map<String, dynamic> parsedJson) { 21 factory Bottle.fromJson(Map<String, dynamic> parsedJson) {
22 - var list = parsedJson['data'] as List;
23 -
24 return Bottle( 22 return Bottle(
25 bottleId: parsedJson['bottleId'], 23 bottleId: parsedJson['bottleId'],
26 temperature: parsedJson['temperature'], 24 temperature: parsedJson['temperature'],
......
1 +class Medicine {
2 + final int medicineId;
3 + final String antiEffect;
4 + final String company;
5 + final String dosage;
6 + final String name;
7 + final String target;
8 + final String warn;
9 +
10 + Medicine(
11 + {this.medicineId,
12 + this.antiEffect,
13 + this.company,
14 + this.dosage,
15 + this.name,
16 + this.target,
17 + this.warn});
18 +
19 + factory Medicine.fromJson(Map<String, dynamic> parsedJson) {
20 + return Medicine(
21 + medicineId: parsedJson['medicineId'],
22 + antiEffect: parsedJson['antiEffect'],
23 + company: parsedJson['company'],
24 + dosage: parsedJson['dosage'],
25 + name: parsedJson['name'],
26 + target: parsedJson['target'],
27 + warn: parsedJson['warn'],
28 + );
29 + }
30 +
31 + Map<String, dynamic> toJson() => {
32 + "medicineId": medicineId,
33 + "antiEffect": antiEffect,
34 + "company": company,
35 + "dosage": dosage,
36 + "name": name,
37 + "target": target,
38 + "warn": warn,
39 + };
40 +}