mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-10 19:38:56 +03:30
disable buttons in repair mode
This commit is contained in:
@@ -431,217 +431,225 @@ class MyItemsDetailsDataBox extends StatelessWidget {
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
(userData['roles']?.contains('Admin') ||
|
||||
(userData['roles']?.contains('Supervisor') &&
|
||||
datas.packageId == null &&
|
||||
datas.hospital.contains(userData['medical_center'])) ||
|
||||
(userData['roles']?.contains('User') &&
|
||||
datas.packageId == null))
|
||||
? 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('Admin') ||
|
||||
(userData['roles']?.contains('Supervisor') &&
|
||||
datas.status != 1))
|
||||
? TransferDestroyButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
firstColor: Colors.black,
|
||||
secondColor: Colors.black87,
|
||||
text: 'Destroy',
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text(
|
||||
'Are you sure to destroy this Item?',
|
||||
style: TextStyle(
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
if (datas.repair == 0)
|
||||
(userData['roles']?.contains('Admin') ||
|
||||
(userData['roles']?.contains('Supervisor') &&
|
||||
datas.packageId == null &&
|
||||
datas.hospital.contains(userData['medical_center'])) ||
|
||||
(userData['roles']?.contains('User') &&
|
||||
datas.packageId == null))
|
||||
? 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(),
|
||||
if (datas.repair == 0)
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
if (datas.repair == 0)
|
||||
(userData['roles']?.contains('Admin') ||
|
||||
(userData['roles']?.contains('Supervisor') &&
|
||||
datas.status != 1))
|
||||
? TransferDestroyButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
firstColor: Colors.black,
|
||||
secondColor: Colors.black87,
|
||||
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,
|
||||
),
|
||||
Consumer<ItemProvider>(
|
||||
builder: (context, itemProvider, child) {
|
||||
return TransferDestroyButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
firstColor: Colors.black,
|
||||
secondColor: Colors.black87,
|
||||
isLoadingButton:
|
||||
itemProvider.isloadingButton,
|
||||
onTap: () async {
|
||||
itemProvider.setLoadingButton();
|
||||
await Provider.of<ItemProvider>(context,
|
||||
listen: false)
|
||||
.removeItems(datas.id)
|
||||
.then(
|
||||
(value) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
Navigator.pushReplacementNamed(
|
||||
context,
|
||||
Routes.myItemsResultScreen,
|
||||
);
|
||||
itemProvider.resetLoadingButton();
|
||||
Fluttertoast.showToast(
|
||||
msg: "The item is destroyed.",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
text: 'Destroy',
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 5.0,
|
||||
),
|
||||
CancelTransferButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
color: kDarkBlue,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
)
|
||||
: userData['roles'].contains('Supervisor')
|
||||
? datas.packageId != null
|
||||
? TransferDestroyButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
firstColor: Colors.black,
|
||||
secondColor: Colors.black87,
|
||||
text: 'Destroy',
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text(
|
||||
'Are you sure to destroy this Item?',
|
||||
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: 4 * _deviceBlockSize,
|
||||
fontSize: 3 * _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: Colors.black,
|
||||
secondColor: Colors.black87,
|
||||
onTap: () {
|
||||
Provider.of<ItemProvider>(context,
|
||||
listen: false)
|
||||
.removeItems(datas.id)
|
||||
.then(
|
||||
(value) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.pushReplacementNamed(
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
ItemCard(_deviceBlockSize),
|
||||
SizedBox(
|
||||
height: 20.0,
|
||||
),
|
||||
Consumer<ItemProvider>(
|
||||
builder: (context, itemProvider, child) {
|
||||
return TransferDestroyButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
firstColor: Colors.black,
|
||||
secondColor: Colors.black87,
|
||||
isLoadingButton:
|
||||
itemProvider.isloadingButton,
|
||||
onTap: () async {
|
||||
itemProvider.setLoadingButton();
|
||||
await Provider.of<ItemProvider>(
|
||||
context,
|
||||
Routes.myItemsResultScreen,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
text: 'Destroy',
|
||||
),
|
||||
SizedBox(
|
||||
height: 5.0,
|
||||
),
|
||||
CancelTransferButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
color: kDarkBlue,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
listen: false)
|
||||
.removeItems(datas.id)
|
||||
.then(
|
||||
(value) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
Navigator.pushReplacementNamed(
|
||||
context,
|
||||
Routes.myItemsResultScreen,
|
||||
);
|
||||
itemProvider.resetLoadingButton();
|
||||
Fluttertoast.showToast(
|
||||
msg: "The item is destroyed.",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
text: 'Destroy',
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
)
|
||||
: Container()
|
||||
: Container(),
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
SizedBox(
|
||||
height: 5.0,
|
||||
),
|
||||
CancelTransferButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
color: kDarkBlue,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
)
|
||||
: userData['roles'].contains('Supervisor')
|
||||
? datas.packageId != null
|
||||
? TransferDestroyButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
firstColor: Colors.black,
|
||||
secondColor: Colors.black87,
|
||||
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: Colors.black,
|
||||
secondColor: Colors.black87,
|
||||
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(),
|
||||
if (datas.repair == 0)
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
(userData['roles']?.contains('Admin') ||
|
||||
userData['roles']?.contains('Supervisor'))
|
||||
? TransferDestroyButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
firstColor: datas.repair == 1 ? kPink : Colors.green,
|
||||
secondColor: datas.repair == 1 ? kPinkSub : Colors.lightGreen,
|
||||
text: 'Repair',
|
||||
text: datas.repair == 1 ? 'Exit repair mode' : 'Repair',
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text(
|
||||
'Are you sure to repair this Item?',
|
||||
datas.repair == 1
|
||||
? 'Are you sure you want to exit repair mode for this item?'
|
||||
: 'Are you sure to repair this Item?',
|
||||
style: TextStyle(
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
@@ -652,7 +660,9 @@ class MyItemsDetailsDataBox extends StatelessWidget {
|
||||
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.',
|
||||
datas.repair == 1
|
||||
? 'By approving, your item will come out of repair mode and will be usable again unless you enable repair mode.'
|
||||
: '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,
|
||||
),
|
||||
@@ -695,7 +705,9 @@ class MyItemsDetailsDataBox extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
},
|
||||
text: 'Repair',
|
||||
text: datas.repair == 1
|
||||
? 'Exit repair mode'
|
||||
: 'Repair',
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user