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'] : '', userName: item['user'] != null ? item['user']['name'] : '',
status: item['status'], status: item['status'],
udi: item['udi'], 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, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Container( Container(
width: 40 * _deviceBlockSize, width: 50 * _deviceBlockSize,
child: Text( child: Row(
children: [
Text(
item!.name, item!.name,
style: TextStyle( style: TextStyle(
fontSize: 3 * _deviceBlockSize, fontSize: 3 * _deviceBlockSize,
fontWeight: FontWeight.w700, 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( Container(
width: 30 * _deviceBlockSize, width: 30 * _deviceBlockSize,
child: Row( child: Row(
children: [ children: [
Text( Text(
'Udi: ', 'UDI: ',
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
fontSize: 3 * _deviceBlockSize, fontSize: 3 * _deviceBlockSize,
@@ -140,10 +165,11 @@ class ItemItemBox extends StatelessWidget {
// width: 5.0, // width: 5.0,
// ), // ),
if (userData['roles']?.contains('Admin') || if (userData['roles']?.contains('Admin') ||
(userData['roles']?.contains('Supervisor') && userData['roles']?.contains('Supervisor'))
item!.packageId != null)) item?.status == "pending"
item?.status == "pending" || item?.status == "rejected" ? Row(
? InkWell( children: [
InkWell(
customBorder: CircleBorder(), customBorder: CircleBorder(),
onTap: () { onTap: () {
showDialog( showDialog(
@@ -156,7 +182,8 @@ class ItemItemBox extends StatelessWidget {
actions: <Widget>[ actions: <Widget>[
Consumer<ItemProvider>(builder: Consumer<ItemProvider>(builder:
(context, itemProvider, _) { (context, itemProvider, _) {
return itemProvider.isloadingButton return itemProvider
.isloadingButton
? CircularProgressIndicator( ? CircularProgressIndicator(
color: Colors.black, color: Colors.black,
) )
@@ -176,9 +203,11 @@ class ItemItemBox extends StatelessWidget {
if (value) { if (value) {
print('true'); print('true');
} }
Navigator.of(context) Navigator.of(
context)
.pop(); .pop();
Navigator.of(context) Navigator.of(
context)
.popAndPushNamed( .popAndPushNamed(
Routes Routes
.itemResultScreen); .itemResultScreen);
@@ -224,16 +253,19 @@ class ItemItemBox extends StatelessWidget {
color: Colors.white, color: Colors.white,
), ),
), ),
) ),
: InkWell( SizedBox(
width: 5.0,
),
InkWell(
customBorder: CircleBorder(), customBorder: CircleBorder(),
onTap: () { onTap: () {
showDialog( showDialog(
context: context, context: context,
builder: (context) { builder: (context) {
return AlertDialog( return AlertDialog(
title: title: Text(
Text('Are you Reject this item?'), 'Are you Reject this item?'),
actions: <Widget>[ actions: <Widget>[
Consumer<ItemProvider>( Consumer<ItemProvider>(
builder: builder:
@@ -250,7 +282,8 @@ class ItemItemBox extends StatelessWidget {
await Provider.of< await Provider.of<
ItemProvider>( ItemProvider>(
context, context,
listen: false) listen:
false)
.changeStatus( .changeStatus(
item!.id, item!.id,
"rejected") "rejected")
@@ -310,274 +343,101 @@ class ItemItemBox extends StatelessWidget {
), ),
), ),
), ),
// item?.status == "pending" || item?.status == "rejected" ],
// ? userData['roles']?.contains('Admin') ?? false )
// ? InkWell( : item?.status == "rejected"
// customBorder: CircleBorder(), ? InkWell(
// onTap: () { customBorder: CircleBorder(),
// showDialog( onTap: () {
// context: context, showDialog(
// builder: (context) { context: context,
// return AlertDialog( builder: (context) {
// title: Text( return AlertDialog(
// 'Are you Confirm this item?', title: Text(
// ), 'Are you Confirm this item?',
// actions: <Widget>[ ),
// Consumer<ItemProvider>(builder: actions: <Widget>[
// (context, itemProvider, _) { Consumer<ItemProvider>(builder:
// return itemProvider (context, itemProvider, _) {
// .isloadingButton return itemProvider
// ? CircularProgressIndicator( .isloadingButton
// color: Colors.black, ? CircularProgressIndicator(
// ) color: Colors.black,
// : TextButton( )
// onPressed: () async { : TextButton(
// itemProvider onPressed: () async {
// .setLoadingButton(); itemProvider
// await Provider.of< .setLoadingButton();
// ItemProvider>( await Provider.of<
// context, ItemProvider>(
// listen: false) context,
// .changeStatus( listen: false)
// item!.id, .changeStatus(
// "approved") item!.id,
// .then( "approved")
// (value) { .then(
// if (value) { (value) {
// print('true'); if (value) {
// } print('true');
// Navigator.of( }
// context) Navigator.of(
// .pop(); context)
// Navigator.of( .pop();
// context) Navigator.of(
// .popAndPushNamed( context)
// Routes .popAndPushNamed(
// .itemResultScreen); Routes
// Fluttertoast .itemResultScreen);
// .showToast( Fluttertoast
// msg: .showToast(
// "Item is Approved.", msg:
// toastLength: Toast "Item is Approved.",
// .LENGTH_SHORT, toastLength: Toast
// gravity: .LENGTH_SHORT,
// ToastGravity gravity:
// .BOTTOM, ToastGravity
// ); .BOTTOM,
// itemProvider );
// .resetLoadingButton(); itemProvider
// }, .resetLoadingButton();
// ); },
// }, );
// child: Text('Yes'), },
// ); child: Text('Yes'),
// }), );
// TextButton( }),
// onPressed: () { TextButton(
// Navigator.of(context).pop(); onPressed: () {
// }, Navigator.of(context).pop();
// child: Text('No'), },
// ), child: Text('No'),
// ], ),
// ); ],
// }, );
// ); },
// }, );
// child: Container( },
// padding: EdgeInsets.all(7), child: Container(
// width: 8 * _deviceBlockSize, padding: EdgeInsets.all(7),
// decoration: BoxDecoration( width: 8 * _deviceBlockSize,
// shape: BoxShape.circle, decoration: BoxDecoration(
// color: kLightBlue, shape: BoxShape.circle,
// ), color: kLightBlue,
// child: Icon( ),
// Icons.check, child: Icon(
// size: 4 * _deviceBlockSize, Icons.check,
// color: Colors.white, size: 4 * _deviceBlockSize,
// ), color: Colors.white,
// ), ),
// ) ),
// : userData['roles']?.contains('Supervisor') )
// ? item!.packageId != null : Container(),
// ? 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,
// ),
// ),
// ),
SizedBox( SizedBox(
width: 5.0, width: 5.0,
), ),
userData['roles']?.contains('Admin') ?? false if (userData['roles']?.contains('Admin') ||
userData['roles']?.contains('Supervisor'))
item!.packageId == ""
? InkWell( ? InkWell(
onTap: () { onTap: () {
showDialog( 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(), : 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( SizedBox(
width: 5.0, width: 5.0,
), ),