고원빈

[frontend] DashBoard 1차 작업 완료

......@@ -70,7 +70,15 @@ appbar 관련 디자인은 추후 구현 예정
### 2021-05-22
+ 약병 검색 기능 구현 중
### 2021-0523
### 2021-05-23
+ 로그인 하여 메인페이지 과정 구현 완료
+ 폴더 정리
### 2021-05-24
회원 가입 --> 허브 등록 --> 약병 등록 -->로그인 페이지로
로그인 --> 허브 리스트 --> 약병 리스트 --> 메인 페이지
+ 시나리오 수정 완료
+ 메인 페이지 데이터 출력 완료
......
import 'package:flutter/material.dart';
import 'package:Smart_Medicine_Box/src/screens/SettingPage.dart';
import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:http/http.dart' as http;
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'models/Bottle.dart';
import 'models/Medicine.dart';
import 'package:Smart_Medicine_Box/src/screens/SettingPage.dart';
class DashBoard extends StatefulWidget {
int pageNumber;
int bottleID;
DashBoard({Key key, this.pageNumber, this.bottleID}) : super(key: key);
Bottle bottleInformation;
Medicine medicineInformation;
DashBoard(
{Key key,
this.pageNumber,
this.bottleInformation,
this.medicineInformation})
: super(key: key);
@override
_DashBoardState createState() => _DashBoardState();
}
class _DashBoardState extends State<DashBoard> {
Bottle _bottleinformation = new Bottle();
int _selectedIndex = 0;
Medicine _medicineInformation = new Medicine();
Widget build(BuildContext context) {
_selectedIndex = widget.pageNumber;
_medicineInformation = widget.medicineInformation;
_bottleinformation = widget.bottleInformation;
var _tabs = [
ineerInformationpage(context),
mainpage(context),
outerInformationpage(context),
ineerInformationpage(context, _bottleinformation),
mainpage(context, _medicineInformation),
outerInformationpage(context, _bottleinformation),
];
return Scaffold(
......@@ -112,7 +124,7 @@ class _DashBoardState extends State<DashBoard> {
}
}
Widget mainpage(BuildContext context) {
Widget mainpage(BuildContext context, Medicine medicineInformation) {
Future<String> getHubList() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
......@@ -122,117 +134,165 @@ Widget mainpage(BuildContext context) {
print(response.statusCode);
}
//현재 접속 중인 허브 리스트 id와 약병 리스트 id 출력
//약 상세 정보 가져오기 --> 이건 Detail Medicine에서 가져 오면 됨
final Size size = MediaQuery.of(context).size;
/*
Main 화면
약의 정보를 가져와서 출력을 하는 곳
유저 이메일
약 이름
약 제조사
*/
return Scaffold(
backgroundColor: Colors.white,
body: Container(
height: size.height * 0.6,
body: SingleChildScrollView(
child: Container(
margin: EdgeInsets.fromLTRB(0, 30, 0, 0),
padding: EdgeInsets.fromLTRB(5, 0, 5, 5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
SizedBox(height: 20),
Container(
padding: EdgeInsets.fromLTRB(5, 0, 5, 5),
margin: EdgeInsets.fromLTRB(0, 30, 0, 0),
height: size.height * 0.15,
width: size.width,
padding: EdgeInsets.fromLTRB(5, 0, 5, 5),
margin: EdgeInsets.all(15),
decoration: BoxDecoration(
border: Border.all(),
borderRadius: BorderRadius.all(
Radius.circular(4.0) // <--- border radius here
Radius.circular(25.0) // <--- border radius here
),
),
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
child: Column(
children: [
Text(
'약 이름:',
SizedBox(height: 30),
Container(
child: Center(
child: Text(
medicineInformation.name == null
? '-'
: medicineInformation.name,
style: TextStyle(
color: Colors.black,
fontSize: 24,
fontFamily: 'NotoSansKR',
fontWeight: FontWeight.w700),
fontWeight: FontWeight.w700)),
),
),
SizedBox(height: 30),
Container(
width: size.width,
alignment: Alignment(0.9, 0),
child: Wrap(
children: [
Text(
'제조사: ',
style: TextStyle(
color: Colors.grey,
fontSize: 14,
),
),
Text(
'무슨 무슨 비타민 ',
medicineInformation.company == null
? '-'
: medicineInformation.company,
style: TextStyle(
color: Colors.black,
fontSize: 36,
fontFamily: 'NotoSansKR',
fontWeight: FontWeight.w700),
color: Colors.grey,
fontSize: 14,
),
),
],
),
),
SizedBox(height: 30),
Container(
padding: EdgeInsets.fromLTRB(5, 0, 5, 5),
margin: EdgeInsets.fromLTRB(0, 30, 0, 0),
height: size.height * 0.15,
width: size.width,
decoration: BoxDecoration(
border: Border.all(),
borderRadius: BorderRadius.all(
Radius.circular(4.0) // <--- border radius here
padding: EdgeInsets.fromLTRB(5, 0, 5, 0),
alignment: Alignment(-1, 0),
child: Wrap(
children: [
Text(
'타겟 층 : ',
style: TextStyle(
color: Colors.grey,
fontSize: 14,
),
),
Text(
medicineInformation.target == null
? '-'
: medicineInformation.target,
style: TextStyle(
color: Colors.grey,
fontSize: 14,
),
),
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
],
),
),
SizedBox(height: 15),
Container(
width: size.width,
padding: EdgeInsets.fromLTRB(5, 0, 5, 0),
alignment: Alignment(-1, 0),
child: Wrap(
children: [
Text(
'약 제조사:',
'복약 정보 : ',
style: TextStyle(
color: Colors.black,
fontSize: 24,
fontFamily: 'NotoSansKR',
fontWeight: FontWeight.w700),
color: Colors.grey,
fontSize: 14,
),
),
Text(
'Test123',
medicineInformation.dosage == null
? '-'
: medicineInformation.dosage,
style: TextStyle(
color: Colors.black,
fontSize: 32,
fontFamily: 'NotoSansKR',
fontWeight: FontWeight.w700),
color: Colors.grey,
fontSize: 14,
),
),
],
),
),
SizedBox(height: 10),
Container(
height: 80,
padding: const EdgeInsets.fromLTRB(20, 20, 20, 20),
child: RaisedButton(
onPressed: () async {
String saveMessage = await getHubList();
},
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(18.0),
side: BorderSide(color: Colors.blue)),
color: Color(0xff1674f6),
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(
'회원 가입',
textScaleFactor: 1.0,
'경고',
style: TextStyle(
fontSize: 16,
color: Colors.white,
fontWeight: FontWeight.bold),
color: Colors.redAccent, fontSize: 14),
),
),
SizedBox(height: 12),
Container(
width: size.width,
child: Text(
medicineInformation.warn == null
? '-'
: medicineInformation.warn,
style: TextStyle(
color: Colors.redAccent, fontSize: 14),
),
),
],
),
),
)
],
),
),
],
),
),
),
);
}
Widget ineerInformationpage(BuildContext context) {
Widget ineerInformationpage(BuildContext context, Bottle bottleinformation) {
final Size size = MediaQuery.of(context).size;
return Scaffold(
backgroundColor: Colors.white,
......@@ -306,7 +366,12 @@ Widget ineerInformationpage(BuildContext context) {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'14',
bottleinformation.temperature
.toString() ==
null
? '-'
: bottleinformation.temperature
.toString(),
textAlign: TextAlign.center,
textScaleFactor: 1.0,
style: TextStyle(
......@@ -367,7 +432,11 @@ Widget ineerInformationpage(BuildContext context) {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'57',
bottleinformation.humidity.toString() ==
null
? '-'
: bottleinformation.humidity
.toString(),
textAlign: TextAlign.center,
textScaleFactor: 1.0,
style: TextStyle(
......@@ -445,7 +514,11 @@ Widget ineerInformationpage(BuildContext context) {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'57',
bottleinformation.balance.toString() ==
null
? '-'
: bottleinformation.balance
.toString(),
textAlign: TextAlign.center,
textScaleFactor: 1.0,
style: TextStyle(
......@@ -503,7 +576,9 @@ Widget ineerInformationpage(BuildContext context) {
height: size.height * 0.14,
child: Center(
child: Text(
'15:57',
bottleinformation.recentOpen == null
? '-'
: bottleinformation.recentOpen,
textAlign: TextAlign.center,
textScaleFactor: 1.0,
style: TextStyle(
......@@ -529,7 +604,7 @@ Widget ineerInformationpage(BuildContext context) {
);
}
Widget outerInformationpage(BuildContext context) {
Widget outerInformationpage(BuildContext context, Bottle bottleinformation) {
final Size size = MediaQuery.of(context).size;
return Scaffold(
backgroundColor: Colors.white,
......@@ -601,7 +676,9 @@ Widget outerInformationpage(BuildContext context) {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'2',
bottleinformation.toString() == null
? '-'
: bottleinformation.toString(),
textAlign: TextAlign.center,
textScaleFactor: 1.0,
style: TextStyle(
......
......@@ -5,18 +5,46 @@ 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';
class BottleList extends StatefulWidget {
List<Bottle> bottlelist;
BottleList({Key key, this.bottlelist}) : super(key: key);
String hubid;
BottleList({Key key, this.bottlelist, this.hubid}) : super(key: key);
@override
_BottleListState createState() => _BottleListState();
}
class _BottleListState extends State<BottleList> {
Bottle _bottleinformation = new Bottle();
Medicine _medicineinformation = new Medicine();
Future<Bottle> getbottle(int index) async {
http.Response response = await http.get(Uri.encodeFull(
DotEnv().env['SERVER_URL'] +
'bottle/' +
widget.bottlelist[index].bottleId.toString()));
if (response.statusCode == 200) {
Map<String, dynamic> jsonData = jsonDecode(response.body);
print(jsonData);
_bottleinformation = Bottle.fromJson(jsonData);
}
}
Future<Bottle> getmedicine(int index) async {
http.Response medicineresponse = await http.get(Uri.encodeFull(
DotEnv().env['SERVER_URL'] +
'medicine/' +
widget.bottlelist[index].medicineId.toString()));
if (medicineresponse.statusCode == 200) {
Map<String, dynamic> data = jsonDecode(medicineresponse.body);
_medicineinformation = Medicine.fromJson(data);
}
}
Widget build(BuildContext context) {
print(widget.bottlelist);
final Size size = MediaQuery.of(context).size;
return Scaffold(
body: Container(
......@@ -62,13 +90,19 @@ class _BottleListState extends State<BottleList> {
fontWeight: FontWeight.bold),
),
trailing: Icon(Icons.arrow_forward),
onTap: () {
onTap: () async {
getbottle(index);
getmedicine(index);
print(_bottleinformation);
print(_medicineinformation);
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => DashBoard(
pageNumber: 1,
bottleID: widget.bottlelist[index].bottleId,
bottleInformation: _bottleinformation,
medicineInformation: _medicineinformation,
),
));
}),
......
import 'package:Smart_Medicine_Box/src/screens/DashBoard.dart';
import 'package:Smart_Medicine_Box/src/screens/Homepage.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'dart:convert';
......@@ -28,7 +29,6 @@ class _DetailMedicineState extends State<DetailMedicine> {
'dosage': medicineDosageController.text
}));
print(response.statusCode);
if (response.statusCode == 200) {
return "Complete";
} else if (response.statusCode == 404) {
......@@ -210,11 +210,9 @@ class _DetailMedicineState extends State<DetailMedicine> {
context,
MaterialPageRoute(
builder: (BuildContext context) =>
DashBoard(
pageNumber: 1,
bottleID: int.parse(
widget.bottleId),
)));
HomePage(),
),
);
})
],
);
......
......@@ -95,7 +95,8 @@ class _HubListState extends State<HubList> {
builder: (BuildContext context) =>
BottleList(
bottlelist: _bottleList,
),
hubid: widget.hublist[index]
.toString()),
));
} else if (result == "Not Found") {
showDialog(
......
......@@ -117,11 +117,12 @@ class _RegisterBottleState extends State<RegisterBottle> {
MaterialPageRoute(
builder: (BuildContext context) =>
SearchMedicine(
bottleId:
medicineBottleIDController
.text,
)));
})
bottleId: medicineBottleIDController.text,
),
),
);
},
),
],
);
});
......
......@@ -8,7 +8,6 @@ import 'DetailMedicine.dart';
class SearchMedicine extends StatefulWidget {
String bottleId;
SearchMedicine({Key key, this.bottleId}) : super(key: key);
@override
_SearchMedicineState createState() => _SearchMedicineState();
......
......@@ -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 'RegsiterHub.dart';
class SignUpLocal extends StatefulWidget {
@override
......@@ -182,7 +182,7 @@ class _SignUpLocalState extends State<SignUpLocal> {
context,
MaterialPageRoute(
builder: (BuildContext context) =>
HomePage()));
RegisterHub()));
})
],
);
......
......@@ -156,6 +156,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.4"
infinite_listview:
dependency: transitive
description:
name: infinite_listview
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1+1"
intl:
dependency: "direct main"
description:
......@@ -198,6 +205,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.7"
numberpicker:
dependency: "direct main"
description:
name: numberpicker
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
page_transition:
dependency: "direct main"
description:
......
......@@ -37,6 +37,7 @@ dependencies:
cupertino_icons: ^0.1.3
http: ^0.12.0+4
flutter_dotenv: ^2.1.0
numberpicker: ^1.3.0
dev_dependencies:
flutter_test:
......