Fix status of package in detail screens

This commit is contained in:
fhkhd
2024-01-31 19:55:57 +03:30
parent 2dc4c6b416
commit 86feef9a38
8 changed files with 415 additions and 161 deletions
+122 -57
View File
@@ -31,7 +31,7 @@ class ItemItemBox extends StatelessWidget {
child: Card(
elevation: 1,
child: Container(
padding: EdgeInsets.all(8),
padding: EdgeInsets.symmetric(vertical: 8),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
@@ -51,6 +51,7 @@ class ItemItemBox extends StatelessWidget {
// width: 3 * _deviceBlockSize,
// ),
// Spacer(),
SizedBox(width: 4,),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
@@ -144,7 +145,8 @@ 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'),
@@ -172,7 +174,7 @@ class ItemItemBox extends StatelessWidget {
color: Colors.black,
),
)
: userData['roles']?.contains('Supervisor')
: userData['roles']?.contains('Supervisor')
? item!.packageId != null
? InkWell(
onTap: () {
@@ -213,68 +215,130 @@ class ItemItemBox extends StatelessWidget {
),
)
: Container()
: Container(),
: Container(),
SizedBox(
width: 5.0,
),
userData['roles']?.contains('User') ?? false
? Container()
: InkWell(
customBorder: CircleBorder(),
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
item!.status == 1
? 'Are you Reject this item?'
: 'Are you Confirm this item?',
: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
InkWell(
customBorder: CircleBorder(),
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you Reject this item?'
),
actions: <Widget>[
TextButton(
onPressed: () {
Provider.of<ItemProvider>(context,
listen: false)
.changeStatus(item!.id, "rejected")
.then(
(value) {
if (value) {
print('true');
}
Navigator.of(context).pop();
// Navigator.of(context)
// .popAndPushNamed(Routes
// .itemResultScreen);
},
);
},
child: Text('Yes'),
),
actions: <Widget>[
TextButton(
onPressed: () {
Provider.of<ItemProvider>(context,
listen: false)
.changeStatus(item!.id)
.then(
(value) {
if (value) {
print('true');
}
Navigator.of(context)
.popAndPushNamed(Routes
.itemResultScreen);
},
);
},
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: item!.status == 1 ? kPink : kBlue,
),
child: Icon(
item!.status == 1 ? Icons.close : Icons.check,
size: 4 * _deviceBlockSize,
color: Colors.white,
),
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text('No'),
),
],
);
},
);
},
child: Container(
padding: EdgeInsets.all(7),
width: 8 * _deviceBlockSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: kPink
),
child: Icon(
Icons.close ,
size: 4 * _deviceBlockSize,
color: Colors.white,
),
),
),
SizedBox(
width: 5,
),
InkWell(
customBorder: CircleBorder(),
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you Confirm this item?',
),
actions: <Widget>[
TextButton(
onPressed: () {
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);
},
);
},
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: kBlue,
),
child: Icon(
Icons.check,
size: 4 * _deviceBlockSize,
color: Colors.white,
),
),
),
],
),
SizedBox(
width: 5.0,
),
@@ -304,6 +368,7 @@ class ItemItemBox extends StatelessWidget {
),
],
),
SizedBox(width: 4,)
],
),
),