Fix approve and reject in item result

This commit is contained in:
hanie.khodkari
2025-03-16 21:14:57 +03:30
parent 05f36c8a6a
commit 948f18d30f
+237 -142
View File
@@ -139,60 +139,246 @@ class ItemItemBox extends StatelessWidget {
// SizedBox( // SizedBox(
// width: 5.0, // width: 5.0,
// ), // ),
userData['roles']?.contains('Admin') ?? false item?.status == "suspended" || item?.status == "rejected"
? InkWell( ? userData['roles']?.contains('Admin') ?? false
? InkWell(
customBorder: CircleBorder(),
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you Confirm this item?',
),
actions: <Widget>[
Consumer<ItemProvider>(builder:
(context, itemProvider, _) {
return itemProvider
.isloadingButton
? CircularProgressIndicator(
color: Colors.black,
)
: TextButton(
onPressed: () async {
itemProvider
.setLoadingButton();
await Provider.of<
ItemProvider>(
context,
listen: false)
.changeStatus(
item!.id,
"approved")
.then(
(value) {
if (value) {
print('true');
}
Navigator.of(
context)
.pop();
Navigator.of(
context)
.popAndPushNamed(
Routes
.itemResultScreen);
Fluttertoast
.showToast(
msg:
"Item is Confirmed.",
toastLength: Toast
.LENGTH_SHORT,
gravity:
ToastGravity
.BOTTOM,
);
itemProvider
.resetLoadingButton();
},
);
},
child: Text('Yes'),
);
}),
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text('No'),
),
],
);
},
);
},
child: Container(
padding: EdgeInsets.all(7),
width: 8 * _deviceBlockSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: kLightBlue,
),
child: Icon(
Icons.check,
size: 4 * _deviceBlockSize,
color: Colors.white,
),
),
)
: userData['roles']?.contains('Supervisor')
? item!.packageId != null
? InkWell(
customBorder: CircleBorder(),
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you Confirm this item?',
),
actions: <Widget>[
Consumer<ItemProvider>(
builder: (context,
itemProvider, _) {
return itemProvider
.isloadingButton
? CircularProgressIndicator(
color:
Colors.black,
)
: TextButton(
onPressed:
() async {
itemProvider
.setLoadingButton();
await Provider.of<
ItemProvider>(
context,
listen:
false)
.changeStatus(
item!
.id,
"approved")
.then(
(value) {
if (value) {
print(
'true');
}
Navigator.of(
context)
.pop();
Navigator.of(
context)
.popAndPushNamed(
Routes.itemResultScreen);
Fluttertoast
.showToast(
msg:
"Item is Confirmed.",
toastLength:
Toast
.LENGTH_SHORT,
gravity:
ToastGravity
.BOTTOM,
);
itemProvider
.resetLoadingButton();
},
);
},
child:
Text('Yes'),
);
}),
TextButton(
onPressed: () {
Navigator.of(context)
.pop();
},
child: Text('No'),
),
],
);
},
);
},
child: Container(
padding: EdgeInsets.all(7),
width: 8 * _deviceBlockSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: kLightBlue,
),
child: Icon(
Icons.check,
size: 4 * _deviceBlockSize,
color: Colors.white,
),
),
)
: Container()
: Container()
: InkWell(
customBorder: CircleBorder(), customBorder: CircleBorder(),
onTap: () { onTap: () {
showDialog( showDialog(
context: context, context: context,
builder: (context) { builder: (context) {
return AlertDialog( return AlertDialog(
title: Text( title: Text('Are you Reject this item?'),
'Are you Confirm this item?',
),
actions: <Widget>[ actions: <Widget>[
Consumer<ItemProvider>(builder: Consumer<ItemProvider>(
(context, itemProvider, _) { builder: (context, itemProvider, _) {
return itemProvider.isloadingButton return itemProvider.isloadingButton
? CircularProgressIndicator( ? CircularProgressIndicator(
color: Colors.black, color: Colors.black,
) )
: TextButton( : TextButton(
onPressed: () async { onPressed: () async {
itemProvider itemProvider
.setLoadingButton(); .setLoadingButton();
await Provider.of< await Provider.of<
ItemProvider>( ItemProvider>(
context, context,
listen: false) listen: false)
.changeStatus(item!.id, .changeStatus(
"approved") item!.id,
.then( "rejected")
(value) { .then(
if (value) { (value) {
print('true'); if (value) {
} print('true');
Navigator.of(context) }
.pop(); Navigator.of(context)
Navigator.of(context) .pop();
.popAndPushNamed(Routes Navigator.of(context)
.itemResultScreen); .popAndPushNamed(
Fluttertoast.showToast( Routes
msg: .itemResultScreen);
"Item is Confirmed.", Fluttertoast
toastLength: Toast .showToast(
.LENGTH_SHORT, msg:
gravity: ToastGravity "Item is rejected.",
.BOTTOM, toastLength: Toast
); .LENGTH_SHORT,
itemProvider gravity:
.resetLoadingButton(); ToastGravity
}, .BOTTOM,
); );
}, itemProvider
child: Text('Yes'), .resetLoadingButton();
); },
}), );
},
child: Text('Yes'),
);
},
),
TextButton( TextButton(
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
@@ -208,106 +394,15 @@ class ItemItemBox extends StatelessWidget {
padding: EdgeInsets.all(7), padding: EdgeInsets.all(7),
width: 8 * _deviceBlockSize, width: 8 * _deviceBlockSize,
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.circle, shape: BoxShape.circle,
color: kLightBlue, color: Colors.black),
),
child: Icon( child: Icon(
Icons.check, Icons.close,
size: 4 * _deviceBlockSize, size: 4 * _deviceBlockSize,
color: Colors.white, color: Colors.white,
), ),
), ),
) ),
: userData['roles']?.contains('Supervisor')
? item!.packageId != null
? InkWell(
customBorder: CircleBorder(),
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you Confirm this item?',
),
actions: <Widget>[
Consumer<ItemProvider>(builder:
(context, itemProvider, _) {
return itemProvider
.isloadingButton
? CircularProgressIndicator(
color: Colors.black,
)
: TextButton(
onPressed: () async {
itemProvider
.setLoadingButton();
await Provider.of<
ItemProvider>(
context,
listen:
false)
.changeStatus(
item!.id,
"approved")
.then(
(value) {
if (value) {
print('true');
}
Navigator.of(
context)
.pop();
Navigator.of(
context)
.popAndPushNamed(
Routes
.itemResultScreen);
Fluttertoast
.showToast(
msg:
"Item is Confirmed.",
toastLength: Toast
.LENGTH_SHORT,
gravity:
ToastGravity
.BOTTOM,
);
itemProvider
.resetLoadingButton();
},
);
},
child: Text('Yes'),
);
}),
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text('No'),
),
],
);
},
);
},
child: Container(
padding: EdgeInsets.all(7),
width: 8 * _deviceBlockSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: kLightBlue,
),
child: Icon(
Icons.check,
size: 4 * _deviceBlockSize,
color: Colors.white,
),
),
)
: Container()
: Container(),
SizedBox( SizedBox(
width: 5.0, width: 5.0,
), ),