Improve Item Data box widget ui

This commit is contained in:
hanie.khodkari
2025-04-22 20:02:46 +03:30
parent 156f2a7c69
commit 00e727a793
2 changed files with 324 additions and 700 deletions
+2 -1
View File
@@ -313,7 +313,8 @@ class ItemProvider extends ChangeNotifier {
userName: item['user'] != null ? item['user']['name'] : '',
status: item['status'],
udi: item['udi'],
packageId: item['package_id'].toString(),
packageId:
item['package_id'] != null ? item['package_id'].toString() : "",
),
);
}
+140 -517
View File
@@ -59,21 +59,46 @@ class ItemItemBox extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
width: 40 * _deviceBlockSize,
child: Text(
width: 50 * _deviceBlockSize,
child: Row(
children: [
Text(
item!.name,
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
fontWeight: FontWeight.w700,
),
),
if (item!.status != "approved")
Container(
margin: EdgeInsets.only(left: 5.0),
padding: EdgeInsets.symmetric(
vertical: 1, horizontal: 10),
decoration: BoxDecoration(
color: item!.status == "pending"
? Colors.grey.withOpacity(0.2)
: kPink.withOpacity(0.05),
borderRadius: BorderRadius.circular(2)),
alignment: Alignment.center,
child: Text(
item!.status,
style: TextStyle(
fontSize: 2 * _deviceBlockSize,
color: item!.status == "pending"
? Colors.black.withOpacity(0.5)
: kPink,
),
),
)
],
),
),
Container(
width: 30 * _deviceBlockSize,
child: Row(
children: [
Text(
'Udi: ',
'UDI: ',
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
@@ -140,10 +165,11 @@ class ItemItemBox extends StatelessWidget {
// width: 5.0,
// ),
if (userData['roles']?.contains('Admin') ||
(userData['roles']?.contains('Supervisor') &&
item!.packageId != null))
item?.status == "pending" || item?.status == "rejected"
? InkWell(
userData['roles']?.contains('Supervisor'))
item?.status == "pending"
? Row(
children: [
InkWell(
customBorder: CircleBorder(),
onTap: () {
showDialog(
@@ -156,7 +182,8 @@ class ItemItemBox extends StatelessWidget {
actions: <Widget>[
Consumer<ItemProvider>(builder:
(context, itemProvider, _) {
return itemProvider.isloadingButton
return itemProvider
.isloadingButton
? CircularProgressIndicator(
color: Colors.black,
)
@@ -176,9 +203,11 @@ class ItemItemBox extends StatelessWidget {
if (value) {
print('true');
}
Navigator.of(context)
Navigator.of(
context)
.pop();
Navigator.of(context)
Navigator.of(
context)
.popAndPushNamed(
Routes
.itemResultScreen);
@@ -224,16 +253,19 @@ class ItemItemBox extends StatelessWidget {
color: Colors.white,
),
),
)
: InkWell(
),
SizedBox(
width: 5.0,
),
InkWell(
customBorder: CircleBorder(),
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title:
Text('Are you Reject this item?'),
title: Text(
'Are you Reject this item?'),
actions: <Widget>[
Consumer<ItemProvider>(
builder:
@@ -250,7 +282,8 @@ class ItemItemBox extends StatelessWidget {
await Provider.of<
ItemProvider>(
context,
listen: false)
listen:
false)
.changeStatus(
item!.id,
"rejected")
@@ -310,274 +343,101 @@ class ItemItemBox extends StatelessWidget {
),
),
),
// item?.status == "pending" || item?.status == "rejected"
// ? 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 Approved.",
// 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 Approved.",
// 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(),
// onTap: () {
// showDialog(
// context: context,
// builder: (context) {
// return AlertDialog(
// title: Text('Are you Reject 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,
// "rejected")
// .then(
// (value) {
// if (value) {
// print('true');
// }
// Navigator.of(context)
// .pop();
// Navigator.of(context)
// .popAndPushNamed(
// Routes
// .itemResultScreen);
// Fluttertoast
// .showToast(
// msg:
// "Item is rejected.",
// 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: Colors.black),
// child: Icon(
// Icons.close,
// size: 4 * _deviceBlockSize,
// color: Colors.white,
// ),
// ),
// ),
],
)
: item?.status == "rejected"
? 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 Approved.",
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(),
SizedBox(
width: 5.0,
),
userData['roles']?.contains('Admin') ?? false
if (userData['roles']?.contains('Admin') ||
userData['roles']?.contains('Supervisor'))
item!.packageId == ""
? InkWell(
onTap: () {
showDialog(
@@ -623,244 +483,7 @@ class ItemItemBox extends StatelessWidget {
),
),
)
: userData['roles']?.contains('Supervisor')
? item!.packageId != null
? InkWell(
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('Delete'),
content: Text(
'Are you sure you want delete this Item?',
),
actions: <Widget>[
TextButton(
child: Text('Yes'),
onPressed: () {
Navigator.of(context).pop();
Provider.of<ItemProvider>(
context,
listen: false)
.removeItems(item!.id);
},
),
TextButton(
child: Text('No'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
},
child: Container(
padding: EdgeInsets.all(7),
width: 8 * _deviceBlockSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: kPink,
),
child: Icon(
Icons.delete_outlined,
size: 4 * _deviceBlockSize,
color: Colors.white,
),
),
)
: Container()
: Container(),
// (userData['roles']?.contains('User') ?? false)
// ? Container()
// : item?.status == "pending"
// ? 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>[
// 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,
// "rejected")
// .then(
// (value) {
// if (value) {
// print(
// 'true');
// }
// Navigator.of(
// context)
// .pop();
// Navigator.of(
// context)
// .popAndPushNamed(
// Routes
// .itemResultScreen);
// Fluttertoast
// .showToast(
// msg:
// "Item is rejected.",
// 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: 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>[
// 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 Approved.",
// 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(),
SizedBox(
width: 5.0,
),