고원빈

[frontend] app 뒤로가기 설정 변경

......@@ -86,4 +86,7 @@ appbar 관련 디자인은 추후 구현 예정
+ 로그인 권한 문제 해결
### 2021-05-26
+ future buillder 변경
\ No newline at end of file
+ future buillder 변경
### 2021-05-27
+ app 뒤로가기 설정 변경
\ No newline at end of file
......
......@@ -9,6 +9,7 @@ import '../utils/user_secure_stoarge.dart';
import 'models/Bottle.dart';
import 'models/Medicine.dart';
import 'package:Smart_Medicine_Box/src/screens/SettingPage.dart';
import 'Register/BottleList.dart';
class DashBoard extends StatefulWidget {
int pageNumber;
......@@ -24,6 +25,35 @@ class DashBoard extends StatefulWidget {
class _DashBoardState extends State<DashBoard> {
int _selectedIndex = 0;
List<Bottle> _bottleList = new List<Bottle>();
//Get BottleList
Future<String> getBottleList() async {
String usertoken = await UserSecureStorage.getUserToken();
String hubid = await UserSecureStorage.getHubId();
http.Response response = await http.get(
Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'bottle/hub/' + hubid),
headers: {"authorization": usertoken},
);
print(response.body);
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";
}
return "Error";
}
Widget build(BuildContext context) {
_selectedIndex = widget.pageNumber;
......@@ -33,82 +63,93 @@ class _DashBoardState extends State<DashBoard> {
outerInformationpage(context),
];
return Scaffold(
backgroundColor: Color(0xffe5f4ff),
appBar: AppBar(
iconTheme: IconThemeData(color: Colors.black),
backgroundColor: Colors.white,
title: Text(
'Smart Medicine Box',
style: TextStyle(
color: Colors.black,
fontSize: 20,
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
return WillPopScope(
child: Scaffold(
backgroundColor: Color(0xffe5f4ff),
appBar: AppBar(
iconTheme: IconThemeData(color: Colors.black),
backgroundColor: Colors.white,
title: Text(
'Smart Medicine Box',
style: TextStyle(
color: Colors.black,
fontSize: 20,
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
actions: [
IconButton(
icon: Icon(
Icons.settings,
color: Colors.black,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => SettingPage(),
));
},
)
],
),
actions: [
IconButton(
icon: Icon(
Icons.settings,
color: Colors.black,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => SettingPage(),
));
},
)
],
),
drawer: Drawer(
child: ListView(
children: [
DrawerHeader(
child: Text('Drawer Header'),
decoration: BoxDecoration(
color: Colors.blue,
drawer: Drawer(
child: ListView(
children: [
DrawerHeader(
child: Text('Drawer Header'),
decoration: BoxDecoration(
color: Colors.blue,
),
),
),
ListTile(
title: Text('Test 1'),
onTap: () {},
),
ListTile(
title: Text('Test 2'),
onTap: () {},
),
ListTile(
title: Text('Test 3'),
onTap: () {},
),
ListTile(
title: Text('Test 1'),
onTap: () {},
),
ListTile(
title: Text('Test 2'),
onTap: () {},
),
ListTile(
title: Text('Test 3'),
onTap: () {},
),
],
),
),
body: _tabs[_selectedIndex],
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
backgroundColor: Colors.grey,
selectedItemColor: Colors.blue,
unselectedItemColor: Colors.white.withOpacity(.60),
selectedFontSize: 14,
unselectedFontSize: 14,
currentIndex: _selectedIndex,
onTap: (int index) => {
setState(() {
_onItemTapped(index);
})
},
items: [
BottomNavigationBarItem(icon: Icon(Icons.favorite), label: 'In'),
BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
BottomNavigationBarItem(
label: 'Out',
icon: Icon(Icons.favorite),
)
],
),
),
body: _tabs[_selectedIndex],
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
backgroundColor: Colors.grey,
selectedItemColor: Colors.blue,
unselectedItemColor: Colors.white.withOpacity(.60),
selectedFontSize: 14,
unselectedFontSize: 14,
currentIndex: _selectedIndex,
onTap: (int index) => {
setState(() {
_onItemTapped(index);
})
},
items: [
BottomNavigationBarItem(icon: Icon(Icons.favorite), label: 'In'),
BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
BottomNavigationBarItem(
label: 'Out',
icon: Icon(Icons.favorite),
)
],
),
onWillPop: () async {
await getBottleList();
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
BottleList(bottlelist: _bottleList),
));
},
);
}
......@@ -314,7 +355,6 @@ Widget mainpage(BuildContext context) {
}
Widget ineerInformationpage(BuildContext context) {
Bottle _bottleinformation = new Bottle();
//get bottle
Future<Bottle> _getbottle() async {
String usertoken = await UserSecureStorage.getUserToken();
......
......@@ -55,7 +55,7 @@ class _HomePageState extends State<HomePage> {
textScaleFactor: 1.0,
style: TextStyle(
color: Color(0xff004ca2),
fontSize: 20,
fontSize: 30,
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
......
......@@ -19,73 +19,78 @@ class BottleList extends StatefulWidget {
class _BottleListState extends State<BottleList> {
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
return 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),
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()),
),
decoration: BoxDecoration(border: Border.all()),
),
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,
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,
),
),
),
);
},
),
);
},
separatorBuilder: (BuildContext contetx, int index) =>
const Divider(),
),
)
],
)),
);
},
),
);
},
separatorBuilder: (BuildContext contetx, int index) =>
const Divider(),
),
)
],
)),
),
onWillPop: () {
SystemNavigator.pop();
},
);
}
}
......
......@@ -117,6 +117,8 @@ class _RegisterBottleState extends State<RegisterBottle> {
new FlatButton(
child: new Text('Close'),
onPressed: () {
UserSecureStorage.setBottleId(
medicineBottleIDController.text);
Navigator.push(
context,
MaterialPageRoute(
......
......@@ -121,6 +121,7 @@ class _RegisterHubState extends State<RegisterHub> {
print(saveMessage);
if (saveMessage == "허브 등록 완료") {
UserSecureStorage.setHubId(medicineHubIDController.text);
print(UserSecureStorage.getHubId());
Navigator.push(
context,
MaterialPageRoute(
......