This commit is contained in:
unknown
2023-12-09 17:52:53 +03:30
parent 6464557956
commit ede10a2efe
36 changed files with 2252 additions and 1821 deletions
+19 -19
View File
@@ -108,25 +108,25 @@ class CycleItemBox extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
userData['roles']?.contains('User') ?? false
? Container()
: InkWell(
customBorder: CircleBorder(),
onTap: () {
Navigator.of(context).pushNamed(
Routes.cycleUpdateScreen,
arguments: item!.id,
);
},
child: Icon(
Icons.edit,
size: 5 * _deviceBlockSize,
color: Colors.black,
),
),
SizedBox(
width: 5.0,
),
// userData['roles']?.contains('User') ?? false
// ? Container()
// : InkWell(
// customBorder: CircleBorder(),
// onTap: () {
// Navigator.of(context).pushNamed(
// Routes.cycleUpdateScreen,
// arguments: item!.id,
// );
// },
// child: Icon(
// Icons.edit,
// size: 5 * _deviceBlockSize,
// color: Colors.black,
// ),
// ),
// SizedBox(
// width: 5.0,
// ),
userData['roles']?.contains('User') ?? false
? Container()
: InkWell(
@@ -159,7 +159,7 @@ class ItemDetailsDataBox extends StatelessWidget {
Container(
width: 35 * _deviceBlockSize,
child: Text(
'User',
'Owner',
style: TextStyle(
color: Colors.grey,
),
@@ -181,6 +181,33 @@ class ItemDetailsDataBox extends StatelessWidget {
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Container(
width: 35 * _deviceBlockSize,
child: Text(
'Creator',
style: TextStyle(
color: Colors.grey,
),
),
),
Container(
width: 45 * _deviceBlockSize,
child: Text(
datas.userCreator.toString(),
style: TextStyle(
fontWeight: FontWeight.w700,
),
overflow: TextOverflow.clip,
),
),
],
),
Divider(),
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Container(
@@ -163,14 +163,14 @@ class ItemItemBox extends StatelessWidget {
},
child: Container(
padding: EdgeInsets.all(7),
width: 6 * _deviceBlockSize,
width: 8 * _deviceBlockSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: item!.status == 1 ? kPink : kBlue,
),
child: Icon(
item!.status == 1 ? Icons.close : Icons.check,
size: 2 * _deviceBlockSize,
size: 4 * _deviceBlockSize,
color: Colors.white,
),
),
@@ -178,27 +178,26 @@ class ItemItemBox extends StatelessWidget {
SizedBox(
width: 5.0,
),
userData['roles']?.contains('User') ?? false
? Container()
: InkWell(
onTap: () {
Navigator.of(context).pushNamed(
Routes.itemUpdateScreen,
arguments: item!.id,
);
},
child: Icon(
Icons.edit,
size: 5 * _deviceBlockSize,
color: Colors.black,
),
),
SizedBox(
width: 5.0,
),
userData['roles']?.contains('User') ?? false
? Container()
: InkWell(
// userData['roles']?.contains('User') ?? false
// ? Container()
// : InkWell(
// onTap: () {
// Navigator.of(context).pushNamed(
// Routes.itemUpdateScreen,
// arguments: item!.id,
// );
// },
// child: Icon(
// Icons.edit,
// size: 5 * _deviceBlockSize,
// color: Colors.black,
// ),
// ),
// SizedBox(
// width: 5.0,
// ),
userData['roles']?.contains('Admin') ?? false
? InkWell(
onTap: () {
showDialog(
context: context,
@@ -206,7 +205,7 @@ class ItemItemBox extends StatelessWidget {
return AlertDialog(
title: Text('Delete'),
content: Text(
'Are you sure you want delete this Item?'),
'Are you sure you want delete this Item?',),
actions: <Widget>[
TextButton(
child: Text('Yes'),
@@ -233,7 +232,49 @@ class ItemItemBox extends StatelessWidget {
size: 5 * _deviceBlockSize,
color: Colors.black,
),
),
)
: userData['roles']?.contains('Supervisor')
? item!.packageId != null
? InkWell(
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('Delete'),
content: Text(
'Are you sure you want delete this Item?',
),
actions: <Widget>[
TextButton(
child: Text('Yes'),
onPressed: () {
Navigator.of(context).pop();
Provider.of<ItemProvider>(
context,
listen: false)
.removeItems(item!.id);
},
),
TextButton(
child: Text('No'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
},
child: Icon(
Icons.delete,
size: 5 * _deviceBlockSize,
color: Colors.black,
),
)
: Container()
: Container(),
SizedBox(
width: 5.0,
),
+19 -19
View File
@@ -100,25 +100,25 @@ class LabelItemBox extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
userData['roles']?.contains('User') ?? false
? Container()
: InkWell(
customBorder: CircleBorder(),
onTap: () {
Navigator.of(context).pushNamed(
Routes.labelUpdateScreen,
arguments: item!.id,
);
},
child: Icon(
Icons.edit,
size: 5 * _deviceBlockSize,
color: Colors.black,
),
),
SizedBox(
width: 5.0,
),
// userData['roles']?.contains('User') ?? false
// ? Container()
// : InkWell(
// customBorder: CircleBorder(),
// onTap: () {
// Navigator.of(context).pushNamed(
// Routes.labelUpdateScreen,
// arguments: item!.id,
// );
// },
// child: Icon(
// Icons.edit,
// size: 5 * _deviceBlockSize,
// color: Colors.black,
// ),
// ),
// SizedBox(
// width: 5.0,
// ),
userData['roles']?.contains('User') ?? false
? Container()
: InkWell(
@@ -168,7 +168,7 @@ class MyItemsDetailsDataBox extends StatelessWidget {
Container(
width: 35 * _deviceBlockSize,
child: Text(
'User',
'Owner',
style: TextStyle(
color: Colors.grey,
),
@@ -190,6 +190,33 @@ class MyItemsDetailsDataBox extends StatelessWidget {
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Container(
width: 35 * _deviceBlockSize,
child: Text(
'Creator',
style: TextStyle(
color: Colors.grey,
),
),
),
Container(
width: 45 * _deviceBlockSize,
child: Text(
datas.userCreator.toString(),
style: TextStyle(
fontWeight: FontWeight.w700,
),
overflow: TextOverflow.clip,
),
),
],
),
Divider(),
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Container(
@@ -332,21 +359,32 @@ class MyItemsDetailsDataBox extends StatelessWidget {
SizedBox(
height: 20,
),
TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: kDarkBlue,
secondColor: kDarkBlueSub,
text: 'Transfer',
onTap: () {
push();
},
),
userData['roles']?.contains('Admin') ?? false
? TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: kDarkBlue,
secondColor: kDarkBlueSub,
text: 'Transfer',
onTap: () {
push();
},
)
: datas.packageId != null
? TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: kDarkBlue,
secondColor: kDarkBlueSub,
text: 'Transfer',
onTap: () {
push();
},
)
: Container(),
SizedBox(
height: 10.0,
),
userData['roles']?.contains('User') ?? false
? Container()
: TransferDestroyButton(
userData['roles']?.contains('Admin') ?? false
? TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: kPink,
secondColor: kPinkSub,
@@ -417,13 +455,88 @@ class MyItemsDetailsDataBox extends StatelessWidget {
},
);
},
),
)
: userData['roles'].contains('Supervisor')
? datas.packageId != null
? TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: kPink,
secondColor: kPinkSub,
text: 'Destroy',
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you sure to destroy this Item?',
style: TextStyle(
fontSize: 4 * _deviceBlockSize,
),
),
content: SizedBox(
width: _deviceBlockSize,
height: 220,
child: Column(
children: [
Text(
'By approving, your item will be removed and it can not be used any more.',
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
),
),
SizedBox(
height: 10.0,
),
ItemCard(_deviceBlockSize),
SizedBox(
height: 20.0,
),
TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: kPink,
secondColor: kPinkSub,
onTap: () {
Provider.of<ItemProvider>(context,
listen: false)
.removeItems(datas.id)
.then(
(value) {
Navigator.of(context).pop();
Navigator.pushReplacementNamed(
context,
Routes.myItemsResultScreen,
);
},
);
},
text: 'Destroy',
),
SizedBox(
height: 5.0,
),
CancelTransferButton(
deviceBlockSize: _deviceBlockSize,
color: kDarkBlue,
onTap: () {
Navigator.pop(context);
},
),
],
),
),
);
},
);
},
)
: Container()
: Container(),
SizedBox(
height: 10.0,
),
userData['roles']?.contains('User') ?? false
? Container()
: TransferDestroyButton(
userData['roles']?.contains('Admin') ?? false
? TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: Colors.black,
secondColor: Colors.black87,
@@ -494,7 +607,84 @@ class MyItemsDetailsDataBox extends StatelessWidget {
},
);
},
),
)
: userData['roles'].contains('Supervisor')
? datas.packageId != null
? TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: Colors.black,
secondColor: Colors.black87,
text: 'Repair',
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you sure to repair this Item?',
style: TextStyle(
fontSize: 4 * _deviceBlockSize,
),
),
content: SizedBox(
width: _deviceBlockSize,
height: 220,
child: Column(
children: [
Text(
'By approving, your item will be set in repair mode and it can be use anymore unless you disable repair mode.',
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
),
),
SizedBox(
height: 10.0,
),
ItemCard(_deviceBlockSize),
SizedBox(
height: 20.0,
),
TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: Colors.black,
secondColor: Colors.black87,
onTap: () {
Provider.of<MyItemProvider>(context,
listen: false)
.repairItems(
datas.id, 'approved')
.then(
(value) {
Navigator.of(context).pop();
Navigator.pushReplacementNamed(
context,
Routes.myItemsResultScreen,
);
},
);
},
text: 'Repair',
),
SizedBox(
height: 5.0,
),
CancelTransferButton(
deviceBlockSize: _deviceBlockSize,
color: kDarkBlue,
onTap: () {
Navigator.pop(context);
},
),
],
),
),
);
},
);
},
)
: Container()
: Container(),
SizedBox(
height: 20.0,
),
@@ -8,6 +8,7 @@ class TransferDestroyButton extends StatelessWidget {
required this.secondColor,
required this.onTap,
required this.text,
this.fontSize = 5.0,
}) : _deviceBlockSize = deviceBlockSize,
super(key: key);
final double _deviceBlockSize;
@@ -15,6 +16,7 @@ class TransferDestroyButton extends StatelessWidget {
final Color secondColor;
final String text;
final VoidCallback onTap;
final double fontSize;
@override
Widget build(BuildContext context) {
@@ -37,7 +39,7 @@ class TransferDestroyButton extends StatelessWidget {
text,
style: TextStyle(
color: Colors.white,
fontSize: 5 * _deviceBlockSize,
fontSize: fontSize * _deviceBlockSize,
),
),
),
@@ -1,4 +1,3 @@
import 'package:cssd/providers/auth.dart';
import 'package:cssd/providers/my_items.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
@@ -32,7 +31,6 @@ class MyItemFilterChip extends StatelessWidget {
@override
Widget build(BuildContext context) {
final userData = Provider.of<Auth>(context, listen: false).user;
return Row(
children: <Widget>[
SizedBox(
@@ -61,19 +59,11 @@ class MyItemFilterChip extends StatelessWidget {
_specific,
);
itemProvider.setLoading();
if (userData['roles']?.contains('User')) {
itemProvider.getMyItems().then(
(_) {
itemProvider.resetLoading();
},
);
} else {
itemProvider.getHospitalItems().then(
(_) {
itemProvider.resetLoading();
},
);
}
itemProvider.getMyItems().then(
(_) {
itemProvider.resetLoading();
},
);
},
),
],
@@ -1,8 +1,13 @@
import 'package:cssd/config/colors.dart';
import 'package:cssd/config/routes.dart';
import 'package:cssd/models/package_model.dart';
import 'package:cssd/providers/auth.dart';
import 'package:cssd/providers/packages.dart';
import 'package:cssd/widgets/MyItemsScreens/Detail/cancel_transfer_button.dart';
import 'package:cssd/widgets/MyItemsScreens/Detail/transfer_destroy_button.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';
class MyPackageDetailsDataBox extends StatelessWidget {
@@ -20,7 +25,7 @@ class MyPackageDetailsDataBox extends StatelessWidget {
@override
Widget build(BuildContext context) {
// final userData = Provider.of<Auth>(context, listen: false).user;
final userData = Provider.of<Auth>(context, listen: false).user;
return Padding(
padding: EdgeInsets.all(20),
child: ListView(
@@ -129,6 +134,64 @@ class MyPackageDetailsDataBox extends StatelessWidget {
),
],
),
Divider(),
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Container(
width: 35 * _deviceBlockSize,
child: Text(
'Owner',
style: TextStyle(
color: Colors.grey,
),
),
),
Container(
width: 45 * _deviceBlockSize,
child: Text(
datas.userName.toString(),
style: TextStyle(
fontWeight: FontWeight.w700,
),
overflow: TextOverflow.clip,
),
),
],
),
Divider(),
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Container(
width: 35 * _deviceBlockSize,
child: Text(
'Creator',
style: TextStyle(
color: Colors.grey,
),
),
),
Container(
width: 45 * _deviceBlockSize,
child: Text(
datas.userCreator.toString(),
style: TextStyle(
fontWeight: FontWeight.w700,
),
overflow: TextOverflow.clip,
),
),
],
),
Divider(),
SizedBox(
height: 5,
),
// Divider(),
// SizedBox(
// height: 5,
@@ -271,83 +334,83 @@ class MyPackageDetailsDataBox extends StatelessWidget {
push();
},
),
// SizedBox(
// height: 10.0,
// ),
// userData['roles']?.contains('User') ?? false
// ? Container()
// : TransferDestroyButton(
// deviceBlockSize: _deviceBlockSize,
// firstColor: kPink,
// secondColor: kPinkSub,
// text: 'Destroy',
// onTap: () {
// showDialog(
// context: context,
// builder: (context) {
// return AlertDialog(
// title: Text(
// 'Are you sure to destroy this Package?',
// style: TextStyle(
// fontSize: 4 * _deviceBlockSize,
// ),
// ),
// content: SizedBox(
// width: _deviceBlockSize,
// height: 220,
// child: Column(
// children: [
// Text(
// 'By approving, your package will be removed and it can not be used any more.',
// style: TextStyle(
// fontSize: 3 * _deviceBlockSize,
// ),
// ),
// SizedBox(
// height: 10.0,
// ),
// PackageCard(_deviceBlockSize),
// SizedBox(
// height: 20.0,
// ),
// TransferDestroyButton(
// deviceBlockSize: _deviceBlockSize,
// firstColor: kPink,
// secondColor: kPinkSub,
// onTap: () {
// Provider.of<PackageProvider>(context,
// listen: false)
// .removePackages(datas.id)
// .then(
// (value) {
// Navigator.of(context).pop();
// Navigator.pushReplacementNamed(
// context,
// Routes.myPackagesResultScreen,
// );
// },
// );
// },
// text: 'Destroy',
// ),
// SizedBox(
// height: 5.0,
// ),
// CancelTransferButton(
// deviceBlockSize: _deviceBlockSize,
// color: kDarkPurple,
// onTap: () {
// Navigator.pop(context);
// },
// ),
// ],
// ),
// ),
// );
// },
// );
// },
// ),
SizedBox(
height: 10.0,
),
userData['roles']?.contains('User') ?? false
? Container()
: TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: kPink,
secondColor: kPinkSub,
text: 'Back Items to Item List',
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you sure to destroy this Package?',
style: TextStyle(
fontSize: 4 * _deviceBlockSize,
),
),
content: SizedBox(
width: _deviceBlockSize,
height: 220,
child: Column(
children: [
Text(
'By approving, your package will be removed and it can not be used any more.',
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
),
),
SizedBox(
height: 10.0,
),
PackageCard(_deviceBlockSize),
SizedBox(
height: 20.0,
),
TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: kPink,
secondColor: kPinkSub,
onTap: () {
Provider.of<PackageProvider>(context,
listen: false)
.removePackages(datas.id)
.then(
(value) {
Navigator.of(context).pop();
Navigator.pushReplacementNamed(
context,
Routes.myPackagesResultScreen,
);
},
);
},
text: 'Destroy',
),
SizedBox(
height: 5.0,
),
CancelTransferButton(
deviceBlockSize: _deviceBlockSize,
color: kDarkPurple,
onTap: () {
Navigator.pop(context);
},
),
],
),
),
);
},
);
},
),
SizedBox(
height: 20,
),
@@ -1,4 +1,3 @@
import 'package:cssd/providers/auth.dart';
import 'package:cssd/providers/my_packages.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
@@ -26,7 +25,6 @@ class MyPackageFilterChip extends StatelessWidget {
@override
Widget build(BuildContext context) {
final userData = Provider.of<Auth>(context, listen: false).user;
return Row(
children: <Widget>[
SizedBox(
@@ -53,19 +51,11 @@ class MyPackageFilterChip extends StatelessWidget {
// _udi,
);
packageProvider.setLoading();
if (userData['roles']?.contains('User')) {
packageProvider.getMyPackages().then(
packageProvider.getMyPackages().then(
(_) {
packageProvider.resetLoading();
},
);
} else {
packageProvider.getHospitalPackages().then(
(_) {
packageProvider.resetLoading();
},
);
}
},
),
],
@@ -132,6 +132,60 @@ class PackageDetailsDataBox extends StatelessWidget {
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Container(
width: 35 * _deviceBlockSize,
child: Text(
'Owner',
style: TextStyle(
color: Colors.grey,
),
),
),
Container(
width: 45 * _deviceBlockSize,
child: Text(
datas.userName.toString(),
style: TextStyle(
fontWeight: FontWeight.w700,
),
overflow: TextOverflow.clip,
),
),
],
),
Divider(),
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Container(
width: 35 * _deviceBlockSize,
child: Text(
'Creator',
style: TextStyle(
color: Colors.grey,
),
),
),
Container(
width: 45 * _deviceBlockSize,
child: Text(
datas.userCreator.toString(),
style: TextStyle(
fontWeight: FontWeight.w700,
),
overflow: TextOverflow.clip,
),
),
],
),
Divider(),
SizedBox(
height: 5,
),
// Row(
// children: <Widget>[
// Container(
@@ -264,6 +318,7 @@ class PackageDetailsDataBox extends StatelessWidget {
secondColor: kPurpleSub,
onTap: goToAddLabelPage,
text: 'Make a Label For Package',
fontSize: 4.0,
),
SizedBox(
height: 5.0,
@@ -106,25 +106,25 @@ class PackageItemBox extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
userData['roles']?.contains('User') ?? false
? Container()
: InkWell(
customBorder: CircleBorder(),
onTap: () {
Navigator.of(context).pushNamed(
Routes.packageUpdateScreen,
arguments: item!.id,
);
},
child: Icon(
Icons.edit,
size: 5 * _deviceBlockSize,
color: Colors.black,
),
),
SizedBox(
width: 5.0,
),
// userData['roles']?.contains('User') ?? false
// ? Container()
// : InkWell(
// customBorder: CircleBorder(),
// onTap: () {
// Navigator.of(context).pushNamed(
// Routes.packageUpdateScreen,
// arguments: item!.id,
// );
// },
// child: Icon(
// Icons.edit,
// size: 5 * _deviceBlockSize,
// color: Colors.black,
// ),
// ),
// SizedBox(
// width: 5.0,
// ),
userData['roles']?.contains('User') ?? false
? Container()
: InkWell(