Files

430 lines
16 KiB
Dart
Executable File

// import 'package:cssd/pages/test_result_screen.dart';
import 'package:cssd/config/colors.dart';
import 'package:cssd/providers/auth.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../config/routes.dart';
import '../../pages/TestPages/test_filter_screen.dart';
class AppDrawer extends StatefulWidget {
@override
State<AppDrawer> createState() => _AppDrawerState();
}
class _AppDrawerState extends State<AppDrawer> {
Map<String, dynamic>? user;
@override
void didChangeDependencies() async {
var authObj = Provider.of<Auth>(context, listen: false);
user = await authObj.getUserData();
super.didChangeDependencies();
}
@override
Widget build(BuildContext context) {
final _media = MediaQuery.of(context);
final double _devicewidth = _media.size.width;
final double _deviceBlockSize = _devicewidth / 100;
return SafeArea(
child: SizedBox(
width: 250,
child: Drawer(
child: Container(
padding: EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.black,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'WELCOME',
style: TextStyle(
color: Colors.white,
),
),
SizedBox(
height: 5.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
user?['name'] != null ? user!['name'] : '',
style: TextStyle(
color: Colors.white,
),
),
],
),
Divider(
color: Colors.white,
),
Container(
padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15),
margin: EdgeInsets.only(top: 10),
decoration: BoxDecoration(
color: kLightBlue,
borderRadius: BorderRadius.circular(5),
),
child: Row(
children: <Widget>[
Icon(
Icons.dashboard,
color: Colors.white,
),
SizedBox(
width: 10,
),
Text(
'Dashboard',
style: TextStyle(
color: Colors.white,
),
)
],
),
),
InkWell(
onTap: () =>
Navigator.of(context).pushNamed(Routes.myInfoScreen),
child: Container(
padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15),
margin: EdgeInsets.only(top: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
),
child: Row(
children: <Widget>[
Icon(
Icons.person_outline,
color: Colors.white,
),
SizedBox(
width: 10,
),
Text(
'My Info',
style: TextStyle(
color: Colors.white,
),
)
],
),
),
),
InkWell(
onTap: () =>
Navigator.of(context).pushNamed(Routes.testResultScreen),
child: Container(
padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15),
margin: EdgeInsets.only(top: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
),
child: Row(
children: <Widget>[
Icon(
Icons.assignment,
color: Colors.white,
),
SizedBox(
width: 10,
),
Text(
'Test Results',
style: TextStyle(
color: Colors.white,
),
)
],
),
),
),
InkWell(
onTap: () {
Navigator.of(context).pushNamed(Routes.itemResultScreen);
},
child: Container(
padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15),
margin: EdgeInsets.only(top: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
),
child: Row(
children: <Widget>[
Icon(
Icons.book,
color: Colors.white,
),
SizedBox(
width: 10,
),
Text(
'Items',
style: TextStyle(
color: Colors.white,
),
)
],
),
),
),
InkWell(
onTap: () {
Navigator.of(context).pushNamed(Routes.myItemsResultScreen);
},
child: Container(
padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15),
margin: EdgeInsets.only(top: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
),
child: Row(
children: <Widget>[
Icon(
Icons.my_library_books,
color: Colors.white,
),
SizedBox(
width: 10,
),
Text(
'My Items',
style: TextStyle(
color: Colors.white,
),
)
],
),
),
),
InkWell(
onTap: () {
Navigator.of(context).pushNamed(Routes.packageResultScreen);
},
child: Container(
padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15),
margin: EdgeInsets.only(top: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
),
child: Row(
children: <Widget>[
Icon(
Icons.all_inbox_rounded,
color: Colors.white,
),
SizedBox(
width: 10,
),
Text(
'Packages',
style: TextStyle(
color: Colors.white,
),
)
],
),
),
),
InkWell(
onTap: () {
Navigator.of(context)
.pushNamed(Routes.myPackagesResultScreen);
},
child: Container(
padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15),
margin: EdgeInsets.only(top: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
),
child: Row(
children: <Widget>[
Icon(
Icons.inbox_rounded,
color: Colors.white,
),
SizedBox(
width: 10,
),
Text(
'My Packages',
style: TextStyle(
color: Colors.white,
),
)
],
),
),
),
InkWell(
onTap: () {
Navigator.of(context).pushNamed(Routes.labelResultScreen);
},
child: Container(
padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15),
margin: EdgeInsets.only(top: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
),
child: Row(
children: <Widget>[
Icon(
FontAwesomeIcons.tag,
color: Colors.white,
),
SizedBox(
width: 10,
),
Text(
'Labels',
style: TextStyle(
color: Colors.white,
),
)
],
),
),
),
InkWell(
onTap: () {
Navigator.of(context).pushNamed(Routes.cycleResultScreen);
},
child: Container(
padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15),
margin: EdgeInsets.only(top: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
),
child: Row(
children: <Widget>[
Icon(
Icons.refresh,
color: Colors.white,
),
SizedBox(
width: 10,
),
Text(
'Cycles',
style: TextStyle(
color: Colors.white,
),
)
],
),
),
),
InkWell(
onTap: () => scan().then(
(String result) {
if (result == 'cancel') {
print('cancel');
} else if (result == 'error') {
print('error');
} else if (result == 'access') {
print('access');
} else {
print(result);
showDialog(
context: context,
builder: (_) => AlertDialog(
title: Text(
'نتیجه ی اسکن',
textDirection: TextDirection.rtl,
textAlign: TextAlign.right,
style: TextStyle(
fontSize: 2.75 * _deviceBlockSize,
),
),
content: Text(
result,
textDirection: TextDirection.rtl,
style: TextStyle(
fontSize: 4 * _deviceBlockSize,
),
),
actions: <Widget>[
TextButton(
onPressed: () async {
await launch(result);
Navigator.of(context).pop();
},
child: Text(
'بازکردن در مرورگر',
style: TextStyle(
fontFamily: 'montserrat',
),
),
),
],
),
);
}
},
),
child: Container(
padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15),
margin: EdgeInsets.only(top: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
),
child: Row(
children: <Widget>[
Icon(
Icons.qr_code_scanner,
color: Colors.white,
),
SizedBox(
width: 10,
),
Text(
'Scanner',
style: TextStyle(
color: Colors.white,
),
)
],
),
),
),
// Container(
// margin: EdgeInsets.only(left: 20),
// child: ListTile(
// leading: Icon(Icons.phone_bluetooth_speaker),
// title: Text('All Test Result'),
// dense: true,
// ),
// ),
// Container(
// margin: EdgeInsets.only(left: 20),
// child: ListTile(
// leading: Icon(Icons.settings),
// title: Text('Manage Users'),
// dense: true,
// ),
// ),
// Container(
// margin: EdgeInsets.only(left: 20),
// child: ListTile(
// leading: Icon(Icons.label),
// title: Text('Manage Medical Center'),
// dense: true,
// ),
// ),
],
),
),
elevation: 0,
),
),
);
}
}