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(
height: 20,
),
if (datas.repair == 0)
(userData['roles']?.contains('Admin') ||
(userData['roles']?.contains('Supervisor') &&
datas.packageId == null &&
@@ -457,9 +458,11 @@ class MyItemsDetailsDataBox extends StatelessWidget {
},
)
: Container(),
if (datas.repair == 0)
SizedBox(
height: 10.0,
),
if (datas.repair == 0)
(userData['roles']?.contains('Admin') ||
(userData['roles']?.contains('Supervisor') &&
datas.status != 1))
@@ -507,7 +510,8 @@ class MyItemsDetailsDataBox extends StatelessWidget {
itemProvider.isloadingButton,
onTap: () async {
itemProvider.setLoadingButton();
await Provider.of<ItemProvider>(context,
await Provider.of<ItemProvider>(
context,
listen: false)
.removeItems(datas.id)
.then(
@@ -596,7 +600,8 @@ class MyItemsDetailsDataBox extends StatelessWidget {
.then(
(value) {
Navigator.of(context).pop();
Navigator.pushReplacementNamed(
Navigator
.pushReplacementNamed(
context,
Routes.myItemsResultScreen,
);
@@ -625,6 +630,7 @@ class MyItemsDetailsDataBox extends StatelessWidget {
)
: Container()
: Container(),
if (datas.repair == 0)
SizedBox(
height: 10.0,
),
@@ -634,14 +640,16 @@ class MyItemsDetailsDataBox extends StatelessWidget {
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',
);
},
),