disable buttons in repair mode

This commit is contained in:
fhkhd
2024-05-02 18:47:20 +04:30
parent d1b153b9c2
commit ec4da1359e
@@ -431,6 +431,7 @@ class MyItemsDetailsDataBox extends StatelessWidget {
SizedBox( SizedBox(
height: 20, height: 20,
), ),
if (datas.repair == 0)
(userData['roles']?.contains('Admin') || (userData['roles']?.contains('Admin') ||
(userData['roles']?.contains('Supervisor') && (userData['roles']?.contains('Supervisor') &&
datas.packageId == null && datas.packageId == null &&
@@ -457,9 +458,11 @@ class MyItemsDetailsDataBox extends StatelessWidget {
}, },
) )
: Container(), : Container(),
if (datas.repair == 0)
SizedBox( SizedBox(
height: 10.0, height: 10.0,
), ),
if (datas.repair == 0)
(userData['roles']?.contains('Admin') || (userData['roles']?.contains('Admin') ||
(userData['roles']?.contains('Supervisor') && (userData['roles']?.contains('Supervisor') &&
datas.status != 1)) datas.status != 1))
@@ -507,7 +510,8 @@ class MyItemsDetailsDataBox extends StatelessWidget {
itemProvider.isloadingButton, itemProvider.isloadingButton,
onTap: () async { onTap: () async {
itemProvider.setLoadingButton(); itemProvider.setLoadingButton();
await Provider.of<ItemProvider>(context, await Provider.of<ItemProvider>(
context,
listen: false) listen: false)
.removeItems(datas.id) .removeItems(datas.id)
.then( .then(
@@ -596,7 +600,8 @@ class MyItemsDetailsDataBox extends StatelessWidget {
.then( .then(
(value) { (value) {
Navigator.of(context).pop(); Navigator.of(context).pop();
Navigator.pushReplacementNamed( Navigator
.pushReplacementNamed(
context, context,
Routes.myItemsResultScreen, Routes.myItemsResultScreen,
); );
@@ -625,6 +630,7 @@ class MyItemsDetailsDataBox extends StatelessWidget {
) )
: Container() : Container()
: Container(), : Container(),
if (datas.repair == 0)
SizedBox( SizedBox(
height: 10.0, height: 10.0,
), ),
@@ -634,14 +640,16 @@ class MyItemsDetailsDataBox extends StatelessWidget {
deviceBlockSize: _deviceBlockSize, deviceBlockSize: _deviceBlockSize,
firstColor: datas.repair == 1 ? kPink : Colors.green, firstColor: datas.repair == 1 ? kPink : Colors.green,
secondColor: datas.repair == 1 ? kPinkSub : Colors.lightGreen, secondColor: datas.repair == 1 ? kPinkSub : Colors.lightGreen,
text: 'Repair', text: datas.repair == 1 ? 'Exit repair mode' : 'Repair',
onTap: () { onTap: () {
showDialog( showDialog(
context: context, context: context,
builder: (context) { builder: (context) {
return AlertDialog( return AlertDialog(
title: Text( 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( style: TextStyle(
fontSize: 4 * _deviceBlockSize, fontSize: 4 * _deviceBlockSize,
), ),
@@ -652,7 +660,9 @@ class MyItemsDetailsDataBox extends StatelessWidget {
child: Column( child: Column(
children: [ children: [
Text( 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( style: TextStyle(
fontSize: 3 * _deviceBlockSize, fontSize: 3 * _deviceBlockSize,
), ),
@@ -695,7 +705,9 @@ class MyItemsDetailsDataBox extends StatelessWidget {
}, },
); );
}, },
text: 'Repair', text: datas.repair == 1
? 'Exit repair mode'
: 'Repair',
); );
}, },
), ),