고원빈

[frontend]2021-05-24

......@@ -69,3 +69,8 @@ appbar 관련 디자인은 추후 구현 예정
### 2021-05-22
+ 약병 검색 기능 구현 중
### 2021-0523
+ 로그인 하여 메인페이지 과정 구현 완료
+ 폴더 정리
......
SERVER_URL=http://192.168.0.3:4000/api/
\ No newline at end of file
SERVER_URL=
\ No newline at end of file
......
......@@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../shared/colors.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import './SignInPage.dart';
import './SignUpLocal.dart';
import './Register/SignInPage.dart';
import 'Register/SignUpLocal.dart';
class HomePage extends StatefulWidget {
final String pageTitle;
......@@ -106,7 +106,8 @@ class _HomePageState extends State<HomePage> {
color: Color(0xff1674f6),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50)),
)),
),
),
),
GestureDetector(
child: Container(
......
......@@ -3,8 +3,8 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:http/http.dart' as http;
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'models/Bottle.dart';
import 'DashBoard.dart';
import '../models/Bottle.dart';
import '../DashBoard.dart';
class BottleList extends StatefulWidget {
List<Bottle> bottlelist;
......@@ -44,7 +44,9 @@ class _BottleListState extends State<BottleList> {
Expanded(
child: ListView.separated(
padding: const EdgeInsets.all(30),
itemCount: widget.bottlelist.length,
itemCount: widget.bottlelist.length == null
? 0
: widget.bottlelist.length,
itemBuilder: (BuildContext context, int index) {
return Container(
padding: EdgeInsets.all(8.0),
......
import 'package:Smart_Medicine_Box/src/screens/DashBoard.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:flutter_dotenv/flutter_dotenv.dart';
import '../models/Medicine.dart';
class DetailMedicine extends StatefulWidget {
Medicine searchMedicine;
String bottleId;
DetailMedicine({Key key, this.searchMedicine, this.bottleId})
: super(key: key);
@override
_DetailMedicineState createState() => _DetailMedicineState();
}
class _DetailMedicineState extends State<DetailMedicine> {
final medicineDosageController = TextEditingController();
//약 등록
Future<String> patchMedcine() async {
http.Response response = await http.patch(
Uri.encodeFull(
DotEnv().env['SERVER_URL'] + 'bottle/' + widget.bottleId),
headers: {"Content-Type": "application/json"},
body: jsonEncode({
'medicineId': widget.searchMedicine.medicineId,
'dosage': medicineDosageController.text
}));
print(response.statusCode);
if (response.statusCode == 200) {
return "Complete";
} else if (response.statusCode == 404) {
return "약병이 존재하지 않습니다.";
} else if (response.statusCode == 403) {
return "약병에 접근할 권한이 없습니다.";
} else {
return "알 수 없는 오류";
}
}
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
return MaterialApp(
home: Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
leading: new Icon(Icons.medical_services_rounded,
color: Colors.black, size: 45.0),
title: Text(
'Smart Medicine Box',
style: TextStyle(
color: Colors.black,
fontSize: 23,
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
),
body: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
SizedBox(height: 30),
Container(
padding: EdgeInsets.fromLTRB(5, 5, 5, 5),
height: size.height * 0.08,
width: size.width,
child: Center(
child: Text(
'세부 약 정보',
textAlign: TextAlign.center,
textScaleFactor: 1.0,
style: TextStyle(
color: Colors.black,
fontSize: 36,
fontFamily: 'NotoSansKR',
fontWeight: FontWeight.w700),
),
),
),
SizedBox(height: 5),
Container(
width: size.width,
padding: EdgeInsets.fromLTRB(5, 0, 5, 5),
margin: EdgeInsets.all(15),
decoration: BoxDecoration(
border: Border.all(),
borderRadius: BorderRadius.all(
Radius.circular(25.0) // <--- border radius here
),
),
child: Column(
children: [
SizedBox(height: 40),
Container(
child: Center(
child: Text(widget.searchMedicine.name,
style: TextStyle(
color: Colors.black,
fontSize: 24,
fontFamily: 'NotoSansKR',
fontWeight: FontWeight.w700)),
),
),
SizedBox(height: 15),
Container(
width: size.width,
alignment: Alignment(0.9, 0),
child: Text(
'제조사: ' + widget.searchMedicine.company,
style: TextStyle(
color: Colors.grey,
fontSize: 20,
),
),
),
SizedBox(height: 30),
Container(
width: size.width,
padding: EdgeInsets.fromLTRB(5, 0, 5, 0),
alignment: Alignment(-1, 0),
child: Text(
'타겟 층 : ' + widget.searchMedicine.target,
style: TextStyle(color: Colors.black, fontSize: 16),
),
),
SizedBox(height: 15),
Container(
width: size.width,
padding: EdgeInsets.fromLTRB(5, 0, 5, 0),
alignment: Alignment(-1, 0),
child: Text(
'복약 정보 : ' + widget.searchMedicine.dosage,
style: TextStyle(color: Colors.black, fontSize: 16),
),
),
SizedBox(height: 10),
Container(
width: size.width,
padding: EdgeInsets.fromLTRB(5, 10, 5, 10),
alignment: Alignment(-1, 0),
child: Column(
children: [
SizedBox(
height: 12,
),
Container(
width: size.width,
child: Text(
'경고',
style: TextStyle(
color: Colors.redAccent, fontSize: 14),
),
),
SizedBox(height: 12),
Container(
width: size.width,
child: Text(
widget.searchMedicine.warn,
style: TextStyle(
color: Colors.redAccent, fontSize: 14),
),
),
],
),
),
],
),
),
SizedBox(height: 12),
Container(
height: size.height * 0.1,
padding: const EdgeInsets.fromLTRB(20, 10, 20, 5),
child: TextFormField(
keyboardType: TextInputType.text,
controller: medicineDosageController,
decoration: InputDecoration(
border: OutlineInputBorder(),
errorBorder: InputBorder.none,
disabledBorder: InputBorder.none,
hintText: '하루에 섭취할 적정 복용량을 숫자만 입력하세요',
),
style: TextStyle(
fontSize: 16,
fontFamily: 'NotoSansKR',
fontWeight: FontWeight.w600)),
),
SizedBox(height: 12),
Container(
height: size.height * 0.07,
width: size.width * 0.8,
child: FlatButton(
padding: EdgeInsets.fromLTRB(0, 5, 0, 5),
onPressed: () async {
String saveMessage = await patchMedcine();
if (saveMessage == "Complete") {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: new Text('약 등록'),
content: new Text('약 등록이 완료 되었습니다.'),
actions: <Widget>[
new FlatButton(
child: new Text('Close'),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
DashBoard(
pageNumber: 1,
bottleID: int.parse(
widget.bottleId),
)));
})
],
);
});
}
},
child: Text(
'약 등록',
textScaleFactor: 1.0,
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
color: Color(0xff1674f6),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50)),
),
),
SizedBox(height: 30)
],
),
),
),
);
}
}
......@@ -5,7 +5,7 @@ import 'package:http/http.dart' as http;
import 'package:flutter_dotenv/flutter_dotenv.dart';
// Screen import
import 'RegisterBottle.dart';
import 'models/Bottle.dart';
import '../models/Bottle.dart';
import 'BottleList.dart';
class HubList extends StatefulWidget {
......@@ -89,8 +89,6 @@ class _HubListState extends State<HubList> {
var result =
await getBottleList(widget.hublist[index]);
if (result == "GET") {
print(0);
print(_bottleList);
Navigator.push(
context,
MaterialPageRoute(
......
......@@ -16,9 +16,6 @@ class RegisterBottle extends StatefulWidget {
class _RegisterBottleState extends State<RegisterBottle> {
final medicineBottleIDController = TextEditingController();
final medicineHubIDController = TextEditingController();
final medicineHubPortController = TextEditingController();
final medicineHubHostController = TextEditingController();
Future<String> registerhub_Validate() async {
http.Response bottleresponse = await http.post(
......@@ -119,7 +116,11 @@ class _RegisterBottleState extends State<RegisterBottle> {
context,
MaterialPageRoute(
builder: (BuildContext context) =>
SearchMedicine()));
SearchMedicine(
bottleId:
medicineBottleIDController
.text,
)));
})
],
);
......
......@@ -3,17 +3,46 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:http/http.dart' as http;
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'models/Bottle.dart';
import 'DashBoard.dart';
import '../models/Medicine.dart';
import 'DetailMedicine.dart';
class SearchMedicine extends StatefulWidget {
String bottleId;
SearchMedicine({Key key, this.bottleId}) : super(key: key);
@override
_SearchMedicineState createState() => _SearchMedicineState();
}
class _SearchMedicineState extends State<SearchMedicine> {
List<Medicine> _medicineList = new List<Medicine>();
final medicineNameController = TextEditingController();
final medicineFactureController = TextEditingController();
final medicineCompanyController = TextEditingController();
Future<String> postMeicineList() async {
http.Response response =
await http.post(Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'medicine'),
headers: {"Content-Type": "application/json"},
body: jsonEncode({
'name': medicineNameController.text,
'company': medicineCompanyController.text,
}));
if (_medicineList.length != 0) {
_medicineList.clear();
}
if (response.statusCode == 200) {
List<dynamic> values = new List<dynamic>();
values = json.decode(response.body);
for (int i = 0; i < values.length; i++) {
Map<String, dynamic> map = values[i];
_medicineList.add(Medicine.fromJson(map));
}
return "GET";
} else {
return "Not Found";
}
}
Widget build(BuildContext context) {
bool isForward = false;
......@@ -125,7 +154,7 @@ class _SearchMedicineState extends State<SearchMedicine> {
width: size.width * 0.50,
child: TextFormField(
keyboardType: TextInputType.text,
controller: medicineFactureController,
controller: medicineCompanyController,
decoration: InputDecoration(
border: InputBorder.none,
focusedBorder: InputBorder.none,
......@@ -158,7 +187,11 @@ class _SearchMedicineState extends State<SearchMedicine> {
padding: const EdgeInsets.fromLTRB(10, 0, 0, 0),
child: IconButton(
icon: Icon(Icons.search, size: 40),
onPressed: () {
onPressed: () async {
String saveMessage = await postMeicineList();
if (saveMessage == "GET") {
setState(() {});
}
//검색 함수를 여기다가
},
),
......@@ -169,10 +202,38 @@ class _SearchMedicineState extends State<SearchMedicine> {
SizedBox(height: 20),
Expanded(
child: ListView.separated(
itemBuilder: (BuildContext context, int index) {},
itemBuilder: (BuildContext context, int index) {
return Container(
padding: EdgeInsets.all(8.0),
decoration: BoxDecoration(border: Border.all()),
child: ListTile(
title: Text(
'Medicine: ' + _medicineList[index].name,
style: TextStyle(
color: Colors.black,
fontSize: 20,
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
trailing: Icon(Icons.arrow_forward),
onTap: () async {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
DetailMedicine(
searchMedicine: _medicineList[index],
bottleId: widget.bottleId,
),
));
}),
);
},
separatorBuilder: (BuildContext contetx, int index) =>
const Divider(),
itemCount: 0))
itemCount: _medicineList.length == null
? 0
: _medicineList.length))
],
),
),
......
......@@ -4,7 +4,7 @@ import 'package:flutter/services.dart';
import 'package:http/http.dart' as http;
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:shared_preferences/shared_preferences.dart';
import './DashBoard.dart';
import '../DashBoard.dart';
import 'HubList.dart';
import 'RegsiterHub.dart';
......
......@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'Homepage.dart';
import '../Homepage.dart';
class SignUpLocal extends StatefulWidget {
@override
......
import 'Medicine.dart';
class Data {
final int totalItem;
final List<Medicine> result;
Data({this.totalItem, this.result});
factory Data.fromJson(Map<String, dynamic> parsedJson) {
var list = parsedJson['result'] as List;
List<Medicine> resultList = list.map((i) => Medicine.fromJson(i)).toList();
return Data(
totalItem: parsedJson['totalItem'],
result: resultList,
);
}
Map<String, dynamic> toJson() => {
"totalItem": totalItem,
"result": result,
};
}
......@@ -32,7 +32,7 @@ dependencies:
flutter_datetime_picker: ^1.3.4
timezone: ^0.6.0
intl : ^0.16.1
shared_preferences: ^0.5.6+1
shared_preferences: ^0.5.12+2
flutter_blue: ^0.7.2
cupertino_icons: ^0.1.3
http: ^0.12.0+4
......