This commit is contained in:
erfan hayat'bakhsh
2020-08-01 14:16:20 +04:30
parent 30f10dca2e
commit e4d29c4e3c
71 changed files with 5018 additions and 2319 deletions
+287 -238
View File
@@ -1,18 +1,17 @@
import 'package:cssd/config/routes.dart';
import 'package:cssd/models/test_result_models.dart';
// import 'package:cssd/providers/test_result.dart';
import 'package:cssd/providers/test_results.dart';
import 'package:cssd/widgets/TestResultScreens/Main/filter_chip_box.dart';
import 'package:cssd/widgets/TestResultScreens/Main/search_box.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import '../config/routes.dart';
import '../models/test_result_models.dart';
import '../providers/auth.dart';
class TestVerifyScreen extends StatefulWidget {
// static const route = '/TestVerifyScreen';
final bool isAdmin;
// final bool isAdmin;
TestVerifyScreen({this.isAdmin});
// TestVerifyScreen({this.isAdmin});
@override
_TestVerifyScreenState createState() => _TestVerifyScreenState();
@@ -41,6 +40,7 @@ class _TestVerifyScreenState extends State<TestVerifyScreen> {
var testResults =
Provider.of<TestResultsProvider>(context, listen: false);
testResults.setLoading();
testResults.resetFilters();
testResults.resetPageNumber();
testResults.getTestResults().then((_) {
testResults.resetLoading();
@@ -64,6 +64,8 @@ class _TestVerifyScreenState extends State<TestVerifyScreen> {
@override
Widget build(BuildContext context) {
final userData = Provider.of<Auth>(context, listen: false).user;
final _media = MediaQuery.of(context);
// final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5);
final double _devicewidth = _media.size.width;
@@ -101,153 +103,153 @@ class _TestVerifyScreenState extends State<TestVerifyScreen> {
),
),
),
Spacer(),
InkWell(
onTap: () {
Navigator.of(context)
.popAndPushNamed(Routes.testFilterScreen);
},
child: Container(
padding: EdgeInsets.all(7),
child: Icon(
FontAwesomeIcons.filter,
size: 7 * _deviceBlockSize,
),
),
),
// Spacer(),
// InkWell(
// onTap: () {
// Navigator.of(context)
// .popAndPushNamed(Routes.testFilterScreen);
// },
// child: Container(
// padding: EdgeInsets.all(7),
// child: Icon(
// FontAwesomeIcons.filter,
// size: 7 * _deviceBlockSize,
// ),
// ),
// ),
],
),
SizedBox(
height: 20,
),
Consumer<TestResultsProvider>(
builder: (context, testResult, _) {
return Container(
height: 50,
child: ListView(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
children: <Widget>[
InkWell(
onTap: () {
Navigator.of(context)
.popAndPushNamed(Routes.testFilterScreen);
},
child: Chip(
backgroundColor: Colors.black,
label: Text(
'Filters',
style: TextStyle(
color: Colors.white,
),
),
deleteIcon: Icon(
FontAwesomeIcons.filter,
color: Colors.white,
size: 4 * _deviceBlockSize,
),
onDeleted: () {
Navigator.of(context)
.popAndPushNamed(Routes.testFilterScreen);
},
),
),
testResult.filters.id != ''
? TestResultChip(
deviceBlockSize: _deviceBlockSize,
label: 'ID',
id: '',
labelID: testResult.filters.labelID,
testType: testResult.filters.testType,
hospital: testResult.filters.hospital,
username: testResult.filters.userName,
fDate: testResult.filters.fDate,
uDate: testResult.filters.uDate,
)
: Container(),
testResult.filters.labelID != ''
? TestResultChip(
deviceBlockSize: _deviceBlockSize,
label: 'Label ID',
id: testResult.filters.id,
labelID: '',
testType: testResult.filters.testType,
hospital: testResult.filters.hospital,
username: testResult.filters.userName,
fDate: testResult.filters.fDate,
uDate: testResult.filters.uDate,
)
: Container(),
testResult.filters.testType != ''
? TestResultChip(
deviceBlockSize: _deviceBlockSize,
label: 'Test Type',
id: testResult.filters.id,
labelID: testResult.filters.labelID,
testType: '',
hospital: testResult.filters.hospital,
username: testResult.filters.userName,
fDate: testResult.filters.fDate,
uDate: testResult.filters.uDate,
)
: Container(),
testResult.filters.hospital != ''
? TestResultChip(
deviceBlockSize: _deviceBlockSize,
label: 'Hospital',
id: testResult.filters.id,
labelID: testResult.filters.labelID,
testType: testResult.filters.testType,
hospital: '',
username: testResult.filters.userName,
fDate: testResult.filters.fDate,
uDate: testResult.filters.uDate,
)
: Container(),
testResult.filters.userName != ''
? TestResultChip(
deviceBlockSize: _deviceBlockSize,
label: 'Username',
id: testResult.filters.id,
labelID: testResult.filters.labelID,
testType: testResult.filters.testType,
hospital: testResult.filters.hospital,
username: '',
fDate: testResult.filters.fDate,
uDate: testResult.filters.uDate,
)
: Container(),
testResult.filters.fDate != ''
? TestResultChip(
deviceBlockSize: _deviceBlockSize,
label: 'From Date',
id: testResult.filters.id,
labelID: testResult.filters.labelID,
testType: testResult.filters.testType,
hospital: testResult.filters.hospital,
username: testResult.filters.userName,
fDate: '',
uDate: testResult.filters.uDate,
)
: Container(),
testResult.filters.uDate != ''
? TestResultChip(
deviceBlockSize: _deviceBlockSize,
label: 'Until Date',
id: testResult.filters.id,
labelID: testResult.filters.labelID,
testType: testResult.filters.testType,
hospital: testResult.filters.hospital,
username: testResult.filters.userName,
fDate: testResult.filters.fDate,
uDate: '',
)
: Container(),
],
),
);
},
),
// Consumer<TestResultsProvider>(
// builder: (context, testResult, _) {
// return Container(
// height: 50,
// child: ListView(
// scrollDirection: Axis.horizontal,
// shrinkWrap: true,
// children: <Widget>[
// InkWell(
// onTap: () {
// Navigator.of(context)
// .popAndPushNamed(Routes.testFilterScreen);
// },
// child: Chip(
// backgroundColor: Colors.black,
// label: Text(
// 'Filters',
// style: TextStyle(
// color: Colors.white,
// ),
// ),
// deleteIcon: Icon(
// FontAwesomeIcons.filter,
// color: Colors.white,
// size: 4 * _deviceBlockSize,
// ),
// onDeleted: () {
// Navigator.of(context)
// .popAndPushNamed(Routes.testFilterScreen);
// },
// ),
// ),
// testResult.filters.id != ''
// ? TestResultChip(
// deviceBlockSize: _deviceBlockSize,
// label: 'ID',
// id: '',
// labelID: testResult.filters.labelID,
// testType: testResult.filters.testType,
// hospital: testResult.filters.hospital,
// username: testResult.filters.userName,
// fDate: testResult.filters.fDate,
// uDate: testResult.filters.uDate,
// )
// : Container(),
// testResult.filters.labelID != ''
// ? TestResultChip(
// deviceBlockSize: _deviceBlockSize,
// label: 'Label ID',
// id: testResult.filters.id,
// labelID: '',
// testType: testResult.filters.testType,
// hospital: testResult.filters.hospital,
// username: testResult.filters.userName,
// fDate: testResult.filters.fDate,
// uDate: testResult.filters.uDate,
// )
// : Container(),
// testResult.filters.testType != ''
// ? TestResultChip(
// deviceBlockSize: _deviceBlockSize,
// label: 'Test Type',
// id: testResult.filters.id,
// labelID: testResult.filters.labelID,
// testType: '',
// hospital: testResult.filters.hospital,
// username: testResult.filters.userName,
// fDate: testResult.filters.fDate,
// uDate: testResult.filters.uDate,
// )
// : Container(),
// testResult.filters.hospital != ''
// ? TestResultChip(
// deviceBlockSize: _deviceBlockSize,
// label: 'Hospital',
// id: testResult.filters.id,
// labelID: testResult.filters.labelID,
// testType: testResult.filters.testType,
// hospital: '',
// username: testResult.filters.userName,
// fDate: testResult.filters.fDate,
// uDate: testResult.filters.uDate,
// )
// : Container(),
// testResult.filters.userName != ''
// ? TestResultChip(
// deviceBlockSize: _deviceBlockSize,
// label: 'Username',
// id: testResult.filters.id,
// labelID: testResult.filters.labelID,
// testType: testResult.filters.testType,
// hospital: testResult.filters.hospital,
// username: '',
// fDate: testResult.filters.fDate,
// uDate: testResult.filters.uDate,
// )
// : Container(),
// testResult.filters.fDate != ''
// ? TestResultChip(
// deviceBlockSize: _deviceBlockSize,
// label: 'From Date',
// id: testResult.filters.id,
// labelID: testResult.filters.labelID,
// testType: testResult.filters.testType,
// hospital: testResult.filters.hospital,
// username: testResult.filters.userName,
// fDate: '',
// uDate: testResult.filters.uDate,
// )
// : Container(),
// testResult.filters.uDate != ''
// ? TestResultChip(
// deviceBlockSize: _deviceBlockSize,
// label: 'Until Date',
// id: testResult.filters.id,
// labelID: testResult.filters.labelID,
// testType: testResult.filters.testType,
// hospital: testResult.filters.hospital,
// username: testResult.filters.userName,
// fDate: testResult.filters.fDate,
// uDate: '',
// )
// : Container(),
// ],
// ),
// );
// },
// ),
TestResultSearchBox(
searchCTRL: searchCTRL,
deviceBlockSize: _deviceBlockSize,
@@ -264,11 +266,18 @@ class _TestVerifyScreenState extends State<TestVerifyScreen> {
)
: ListView.builder(
controller: sc,
itemBuilder: (context, index) => TestItemBox(
deviceBlockSize: _deviceBlockSize,
item: testResults.items[index],
id: testResults.items[index].id,
),
itemBuilder: (context, index) =>
(testResults.items[index].verified == 'None' &&
userData['roles']
.contains('Supervisor')) ||
userData['roles'].contains('Admin')
? TestItemBox(
deviceBlockSize: _deviceBlockSize,
item: testResults.items[index],
id: testResults.items[index].id,
userData: userData,
)
: Container(),
// Column(
// children: <Widget>[
// Text(testResults.items[index].name),
@@ -303,11 +312,12 @@ class TestItemBox extends StatelessWidget {
Key key,
@required String id,
@required double deviceBlockSize,
this.item,
@required this.item,
@required this.userData,
}) : _deviceBlockSize = deviceBlockSize,
// _id = id,
super(key: key);
final Map<String, dynamic> userData;
final double _deviceBlockSize;
// final String _id;
@@ -348,17 +358,24 @@ class TestItemBox extends StatelessWidget {
SizedBox(
height: 15,
),
item.result == 'Verified'
item.verified == 'None'
? Text(
'Verified',
style: TextStyle(color: Colors.blueAccent),
)
: Text(
'Awaiting Verification',
style: TextStyle(
color: Colors.orange,
),
),
style: TextStyle(color: Colors.orange),
)
: item.verified == 'Verified'
? Text(
'Verified',
style: TextStyle(
color: Colors.blueAccent,
),
)
: Text(
'Rejected',
style: TextStyle(
color: Colors.red,
),
),
],
),
Spacer(),
@@ -372,85 +389,117 @@ class TestItemBox extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
item.result != 'Verified'
? InkWell(
onTap: () {
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: Text('Verify'),
content: Text(
'Are you sure for verify this test?'),
actions: <Widget>[
FlatButton(
onPressed: () {
// TestResultsProvider.updateTestResult(
// _id,
// {})
// .then((_) {
// Navigator.of(context).pop();
// });
// Provider.of<TestResultsProvider>(
// context)
// .removeTestResult(
// item.id.toString())
// .then((_) {
// Navigator.of(ctx).pop();
// });
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
InkWell(
onTap: () {
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: Text('Verify'),
content: Text(
'Are you sure for verify this test?'),
actions: <Widget>[
FlatButton(
onPressed: () async {
Provider.of<TestResultsProvider>(
context)
.changeVerification(
item.id, 'Verified')
.then((result) {
if (result) {
print('true');
}
Navigator.of(ctx).pop();
},
child: Text('Yes'),
),
FlatButton(
onPressed: () {
Navigator.of(ctx).pop();
},
child: Text('No'),
),
],
),
);
},
child: Container(
padding: EdgeInsets.all(7),
width: 10 * _deviceBlockSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Color.fromRGBO(0, 190, 190, 1),
),
child: Icon(
Icons.check,
size: 6 * _deviceBlockSize,
color: Colors.white,
Navigator.of(context).popAndPushNamed(
Routes.testVerifyScreen);
});
},
child: Text('Yes'),
),
FlatButton(
onPressed: () {
Navigator.of(ctx).pop();
},
child: Text('No'),
),
],
),
);
},
child: Container(
padding: EdgeInsets.all(7),
width: 10 * _deviceBlockSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Color.fromRGBO(0, 190, 190, 1),
),
)
: Container(),
child: Icon(
Icons.check,
size: 6 * _deviceBlockSize,
color: Colors.white,
),
),
),
SizedBox(
width: 3,
),
InkWell(
onTap: () {
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: Text('Reject'),
content: Text(
'Are you sure for reject this test?'),
actions: <Widget>[
FlatButton(
onPressed: () async {
await Provider.of<TestResultsProvider>(
context)
.changeVerification(
item.id, 'NotVerified')
.then((result) {
if (result) {
print('true');
}
Navigator.of(ctx).pop();
Navigator.of(context).popAndPushNamed(
Routes.testVerifyScreen);
});
},
child: Text('Yes'),
),
FlatButton(
onPressed: () {
Navigator.of(ctx).pop();
},
child: Text('No'),
),
],
),
);
},
child: Container(
padding: EdgeInsets.all(7),
width: 10 * _deviceBlockSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.red,
),
child: Icon(
Icons.close,
size: 6 * _deviceBlockSize,
color: Colors.white,
),
),
),
],
),
SizedBox(
width: _deviceBlockSize,
),
InkWell(
onTap: () {
Navigator.of(context).pushNamed(
Routes.testDetailsScreen,
arguments: item.id,
);
// TestDetail(testResultId: item.id.toString());
},
child: Container(
padding: EdgeInsets.all(7),
width: 10 * _deviceBlockSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.black,
),
child: Icon(
FontAwesomeIcons.fileAlt,
size: 6 * _deviceBlockSize,
color: Colors.white,
),
),
),
],
)
],