고원빈

[frontend] 새로 고침 + ui 변경

......@@ -89,4 +89,8 @@ appbar 관련 디자인은 추후 구현 예정
+ future buillder 변경
### 2021-05-27
+ app 뒤로가기 설정 변경
\ No newline at end of file
+ app 뒤로가기 설정 변경
### 2021-05-29
+ 약병 리스트 ui 변경
+ DashBoard 새로고침
\ No newline at end of file
......
......@@ -118,6 +118,13 @@ class _DashBoardState extends State<DashBoard> {
),
),
body: _tabs[_selectedIndex],
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {});
},
child: const Icon(Icons.refresh_outlined),
backgroundColor: Colors.blue,
),
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
backgroundColor: Colors.grey,
......@@ -132,11 +139,12 @@ class _DashBoardState extends State<DashBoard> {
})
},
items: [
BottomNavigationBarItem(icon: Icon(Icons.favorite), label: 'In'),
BottomNavigationBarItem(
icon: Icon(Icons.device_thermostat), label: 'In'),
BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
BottomNavigationBarItem(
label: 'Out',
icon: Icon(Icons.favorite),
icon: Icon(Icons.access_time),
)
],
),
......@@ -146,8 +154,7 @@ class _DashBoardState extends State<DashBoard> {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
BottleList(bottlelist: _bottleList),
builder: (BuildContext context) => BottleList(),
));
},
);
......
......@@ -5,88 +5,199 @@ 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 '../../utils/user_secure_stoarge.dart';
class BottleList extends StatefulWidget {
List<Bottle> bottlelist;
BottleList({Key key, this.bottlelist}) : super(key: key);
BottleList({Key key}) : super(key: key);
@override
_BottleListState createState() => _BottleListState();
}
class _BottleListState extends State<BottleList> {
List<Bottle> _bottleList = new List<Bottle>();
Future<String> getBottleList() async {
String hubid = await UserSecureStorage.getHubId();
String usertoken = await UserSecureStorage.getUserToken();
http.Response response = await http.get(
Uri.encodeFull(
DotEnv().env['SERVER_URL'] + 'bottle/hub/' + hubid.toString()),
headers: {"authorization": usertoken},
);
print(response.body);
print(1);
if (_bottleList.length != 0) {
_bottleList.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];
_bottleList.add(Bottle.fromJson(map));
}
return "GET";
} else if (response.statusCode == 404) {
return "Not Found";
} else {
return "Error";
}
}
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
return WillPopScope(
child: Scaffold(
body: Container(
height: size.height,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(height: 70),
Container(
height: size.height * 0.1,
width: size.width,
child: Center(
child: Text(
'등록된 약병 리스트',
textScaleFactor: 1.0,
style: TextStyle(
fontSize: 28,
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
),
decoration: BoxDecoration(border: Border.all()),
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: FutureBuilder(
future: getBottleList(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasData == false) {
return CircularProgressIndicator();
} else if (snapshot.hasError) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Error: ${snapshot.error}',
style: TextStyle(fontSize: 15),
),
SizedBox(height: 30),
Expanded(
child: ListView.separated(
padding: const EdgeInsets.all(30),
itemCount: widget.bottlelist.length == null
? 0
: widget.bottlelist.length,
itemBuilder: (BuildContext context, int index) {
return Container(
padding: EdgeInsets.all(8.0),
decoration: BoxDecoration(border: Border.all()),
child: ListTile(
title: Text(
'BOTTLE ID : ' +
'${widget.bottlelist[index].bottleId}',
style: TextStyle(
color: Colors.black,
fontSize: 20,
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
trailing: Icon(Icons.arrow_forward),
onTap: () async {
UserSecureStorage.setBottleId(
widget.bottlelist[index].bottleId.toString());
UserSecureStorage.setMedicineId(
widget.bottlelist[index].medicineId.toString());
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => DashBoard(
pageNumber: 1,
);
} else {
return Container(
height: size.height,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(height: 10),
Container(
height: size.height * 0.07,
width: size.width,
child: Center(
child: Text(
'등록된 약병 리스트',
textScaleFactor: 1.0,
style: TextStyle(
fontSize: 28,
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
),
),
SizedBox(height: 10),
Expanded(
child: GridView.builder(
padding: const EdgeInsets.all(30),
itemCount:
_bottleList.length == null ? 0 : _bottleList.length,
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 200,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
),
itemBuilder: (BuildContext context, int index) {
return InkResponse(
splashColor: Colors.transparent,
child: Container(
height: 140,
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
border: Border.all(),
borderRadius: BorderRadius.all(
Radius.circular(16.0),
),
),
);
},
),
);
},
separatorBuilder: (BuildContext contetx, int index) =>
const Divider(),
),
)
],
)),
child: Column(
children: [
Container(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Colors.black,
width: 1,
style: BorderStyle.solid),
),
),
height: 40,
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Container(
height: 40,
child: Center(
child: Text(
'${_bottleList[index].bottleId}',
style: TextStyle(
color: Colors.black,
fontSize: 20,
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
),
),
Container(
child: IconButton(
alignment: Alignment(0.9, 0),
icon: Icon(
Icons.create_sharp,
color: Colors.black,
),
onPressed: () {
print("asdfg");
},
),
),
],
),
),
SizedBox(height: 10),
Container(
height: 90,
child: Icon(
Icons.medical_services_outlined,
size: 100,
),
)
],
),
),
onTap: () {
UserSecureStorage.setBottleId(
_bottleList[index].bottleId.toString());
UserSecureStorage.setMedicineId(
_bottleList[index].medicineId.toString());
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => DashBoard(
pageNumber: 1,
),
),
);
},
);
},
),
)
],
),
);
}
},
),
),
onWillPop: () {
SystemNavigator.pop();
......
......@@ -102,9 +102,7 @@ class _HubListState extends State<HubList> {
context,
MaterialPageRoute(
builder: (BuildContext context) =>
BottleList(
bottlelist: _bottleList,
),
BottleList(),
));
} else if (result == "Not Found") {
showDialog(
......
class UserBottle {
String bottleId;
String bottleName;
UserBottle({this.bottleId, this.bottleName});
}
......@@ -233,6 +233,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.1"
path_provider:
dependency: "direct main"
description:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.28"
path_provider_linux:
dependency: transitive
description:
......@@ -240,6 +247,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+2"
path_provider_macos:
dependency: transitive
description:
name: path_provider_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.4+8"
path_provider_platform_interface:
dependency: transitive
description:
......@@ -350,6 +364,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.2"
sqflite:
dependency: "direct main"
description:
name: sqflite
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.2+4"
sqflite_common:
dependency: transitive
description:
name: sqflite_common
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3+3"
stack_trace:
dependency: transitive
description:
......@@ -371,6 +399,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
synchronized:
dependency: transitive
description:
name: synchronized
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0+2"
term_glyph:
dependency: transitive
description:
......@@ -421,5 +456,5 @@ packages:
source: hosted
version: "0.1.2"
sdks:
dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.20.0 <2.0.0"
dart: ">=2.10.2 <2.11.0"
flutter: ">=1.22.2 <2.0.0"
......
......@@ -39,6 +39,8 @@ dependencies:
flutter_dotenv: ^2.1.0
numberpicker: ^1.3.0
flutter_secure_storage: ^3.3.5
sqflite: ^1.1.6
path_provider: ^1.2.0
dev_dependencies:
flutter_test:
......