diff --git a/lib/widgets/ItemScreens/Result/item_data_box.dart b/lib/widgets/ItemScreens/Result/item_data_box.dart index fafe671..9f39286 100755 --- a/lib/widgets/ItemScreens/Result/item_data_box.dart +++ b/lib/widgets/ItemScreens/Result/item_data_box.dart @@ -141,186 +141,86 @@ class ItemItemBox extends StatelessWidget { // ), userData['roles']?.contains('Admin') ?? false ? InkWell( + customBorder: CircleBorder(), onTap: () { showDialog( context: context, builder: (context) { return AlertDialog( - title: Text('Delete'), - content: Text( - 'Are you sure you want delete this Item?', + title: Text( + 'Are you Confirm this item?', ), actions: [ + Consumer(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( - child: Text('Yes'), onPressed: () { Navigator.of(context).pop(); - Provider.of(context, - listen: false) - .removeItems(item!.id); }, - ), - TextButton( child: Text('No'), - onPressed: () { - Navigator.of(context).pop(); - }, ), ], ); }, ); }, - child: Icon( - Icons.delete, - size: 5 * _deviceBlockSize, - color: Colors.black, + 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( - onTap: () { - showDialog( - context: context, - builder: (context) { - return AlertDialog( - title: Text('Delete'), - content: Text( - 'Are you sure you want delete this Item?', - ), - actions: [ - TextButton( - child: Text('Yes'), - onPressed: () { - Navigator.of(context).pop(); - Provider.of( - context, - listen: false) - .removeItems(item!.id); - }, - ), - TextButton( - child: Text('No'), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ], - ); - }, - ); - }, - child: Icon( - Icons.delete, - size: 5 * _deviceBlockSize, - color: Colors.black, - ), - ) - : Container() - : Container(), - SizedBox( - width: 5.0, - ), - (userData['roles']?.contains('User') ?? false) - ? Container() - : item?.status == "suspended" - ? Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - InkWell( - customBorder: CircleBorder(), - onTap: () { - showDialog( - context: context, - builder: (context) { - return AlertDialog( - title: Text( - 'Are you Reject this item?'), - actions: [ - Consumer( - 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( @@ -397,7 +297,7 @@ class ItemItemBox extends StatelessWidget { width: 8 * _deviceBlockSize, decoration: BoxDecoration( shape: BoxShape.circle, - color: kBlue, + color: kLightBlue, ), child: Icon( Icons.check, @@ -405,35 +305,321 @@ class ItemItemBox extends StatelessWidget { color: Colors.white, ), ), - ), - ], - ) + ) + : Container() : Container(), SizedBox( width: 5.0, ), - InkWell( - customBorder: CircleBorder(), - onTap: () { - Navigator.of(context).pushNamed( - Routes.itemDetailScreen, - arguments: item!.id, - ); - }, - child: Container( - padding: EdgeInsets.all(7), - width: 9 * _deviceBlockSize, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - FontAwesomeIcons.fileAlt, - size: 5 * _deviceBlockSize, - color: Colors.white, - ), - ), + userData['roles']?.contains('Admin') ?? false + ? InkWell( + onTap: () { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text('Delete'), + content: Text( + 'Are you sure you want delete this Item?', + ), + actions: [ + TextButton( + child: Text('Yes'), + onPressed: () { + Navigator.of(context).pop(); + Provider.of(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, + ), + ), + ) + : 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: [ + TextButton( + child: Text('Yes'), + onPressed: () { + Navigator.of(context).pop(); + Provider.of( + 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 == "suspended" + // ? Row( + // mainAxisAlignment: MainAxisAlignment.end, + // children: [ + // InkWell( + // customBorder: CircleBorder(), + // onTap: () { + // showDialog( + // context: context, + // builder: (context) { + // return AlertDialog( + // title: Text( + // 'Are you Reject this item?'), + // actions: [ + // Consumer( + // 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: [ + // Consumer(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(), + SizedBox( + width: 5.0, ), + // InkWell( + // customBorder: CircleBorder(), + // onTap: () { + // Navigator.of(context).pushNamed( + // Routes.itemDetailScreen, + // arguments: item!.id, + // ); + // }, + // child: Container( + // padding: EdgeInsets.all(7), + // width: 9 * _deviceBlockSize, + // decoration: BoxDecoration( + // shape: BoxShape.circle, + // color: Colors.black, + // ), + // child: Icon( + // FontAwesomeIcons.fileAlt, + // size: 5 * _deviceBlockSize, + // color: Colors.white, + // ), + // ), + // ), ], ), ],