From f07167e734a352bf2920a3fd96d00a29aeab83c8 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 18 Oct 2022 14:06:28 +0300 Subject: [PATCH] Leave balance fix, Items for sale fix --- lib/ui/leave_balance/add_leave_balance_screen.dart | 8 ++++---- .../fragments/add_details_fragment.dart | 12 ++++++------ lib/ui/work_list/work_list_screen.dart | 1 + lib/widgets/bottom_sheets/attachment_options.dart | 5 +++-- lib/widgets/image_picker.dart | 3 ++- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index 5fce5ec..eb8e493 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -109,14 +109,14 @@ class _AddLeaveBalanceScreenState extends State { } } await LeaveBalanceApiClient().validateAbsenceTransaction(selectedAbsenceType!.dESCFLEXCONTEXTCODE!, "HR_LOA_SS", selectedAbsenceType!.aBSENCEATTENDANCETYPEID!, - selectedReplacementEmployee!.userName!, DateUtil.getFormattedDate(startDateTime!, "MM/dd/yyyy"), DateUtil.getFormattedDate(endDateTime!, "MM/dd/yyyy"), -999, dffDataMap, + selectedReplacementEmployee != null ? selectedReplacementEmployee!.userName! : "", DateUtil.getFormattedDate(startDateTime!, "MM/dd/yyyy"), DateUtil.getFormattedDate(endDateTime!, "MM/dd/yyyy"), -999, dffDataMap, comments: comment); SumbitAbsenceTransactionList submit = await LeaveBalanceApiClient().submitAbsenceTransaction( selectedAbsenceType!.dESCFLEXCONTEXTCODE!, "HR_LOA_SS", selectedAbsenceType!.aBSENCEATTENDANCETYPEID!, - selectedReplacementEmployee!.userName!, + selectedReplacementEmployee != null ? selectedReplacementEmployee!.userName! : "", DateUtil.getFormattedDate(startDateTime!, "MM/dd/yyyy"), DateUtil.getFormattedDate(endDateTime!, "MM/dd/yyyy"), -999, @@ -126,9 +126,9 @@ class _AddLeaveBalanceScreenState extends State { Utils.hideLoading(context); await Navigator.pushNamed(context, AppRoutes.requestSubmitScreen, arguments: RequestSubmitScreenParams(LocaleKeys.submit.tr(), submit.pTRANSACTIONID!, "", "add_leave_balance")); - Utils.showLoading(context); + // Utils.showLoading(context); await LeaveBalanceApiClient().cancelHrTransaction(submit.pTRANSACTIONID!); - Utils.hideLoading(context); + // Utils.hideLoading(context); } catch (ex) { Utils.hideLoading(context); Utils.handleException(ex, context, null); diff --git a/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart b/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart index 8b2f24e..b2791ec 100644 --- a/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart +++ b/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart @@ -189,7 +189,7 @@ class _AddItemDetailsFragmentState extends State { title.toText16().expanded, 6.width, SimpleButton(LocaleKeys.add.tr(), () { - ImageOptions.showImageOptionsNew(context, (String image, File file) { + ImageOptions.showImageOptionsNew(context, false, (String image, File file) { setState(() { images.add(image); Navigator.of(context).pop(); @@ -272,15 +272,15 @@ class _AddItemDetailsFragmentState extends State { } void getRegions() async { - // try { + try { Utils.showLoading(context); getRegionsList = await ItemsForSaleApiClient().getRegions(); await getAdDetails(); Utils.hideLoading(context); setState(() {}); - // } catch (ex) { - // Utils.hideLoading(context); - // Utils.handleException(ex, context, null); - // } + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } } } diff --git a/lib/ui/work_list/work_list_screen.dart b/lib/ui/work_list/work_list_screen.dart index de0815c..a19d6a5 100644 --- a/lib/ui/work_list/work_list_screen.dart +++ b/lib/ui/work_list/work_list_screen.dart @@ -182,6 +182,7 @@ class _WorkListScreenState extends State { getWorkList(showLoading: false), ]); calculateCounter(); + Utils.hideLoading(context); setState(() {}); } catch (ex) { Utils.hideLoading(context); diff --git a/lib/widgets/bottom_sheets/attachment_options.dart b/lib/widgets/bottom_sheets/attachment_options.dart index 83b6d3d..30189a0 100644 --- a/lib/widgets/bottom_sheets/attachment_options.dart +++ b/lib/widgets/bottom_sheets/attachment_options.dart @@ -8,8 +8,9 @@ class AttachmentOptions extends StatelessWidget { VoidCallback onCameraTap; VoidCallback onGalleryTap; VoidCallback onFilesTap; + bool showFilesOption; - AttachmentOptions({Key? key, required this.onCameraTap, required this.onGalleryTap, required this.onFilesTap}) : super(key: key); + AttachmentOptions({Key? key, required this.onCameraTap, required this.onGalleryTap, required this.onFilesTap, this.showFilesOption = true}) : super(key: key); @override Widget build(BuildContext context) { @@ -28,7 +29,7 @@ class AttachmentOptions extends StatelessWidget { children: [ itemView("open_camera.svg", "Open\nCamera", onCameraTap), itemView("gallery.svg", "Upload from\nGallery", onGalleryTap), - itemView("files.svg", "Upload from\nFiles", onFilesTap), + if (showFilesOption) itemView("files.svg", "Upload from\nFiles", onFilesTap), ], ) ], diff --git a/lib/widgets/image_picker.dart b/lib/widgets/image_picker.dart index 4c17250..4a99577 100644 --- a/lib/widgets/image_picker.dart +++ b/lib/widgets/image_picker.dart @@ -10,10 +10,11 @@ import 'package:mohem_flutter_app/widgets/bottom_sheet.dart'; import 'package:mohem_flutter_app/widgets/bottom_sheets/attachment_options.dart'; class ImageOptions { - static void showImageOptionsNew(BuildContext context, Function(String, File) image) { + static void showImageOptionsNew(BuildContext context, bool showFilesOption, Function(String, File) image) { showMyBottomSheet( context, child: AttachmentOptions( + showFilesOption: showFilesOption, onCameraTap: () async { if (Platform.isAndroid) { cameraImageAndroid(image);