From c92aae904804a1a0b1f534f6869d4acdaff22784 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 8 Jul 2025 15:15:58 +0300 Subject: [PATCH] improvements --- lib/extensions/context_extension.dart | 12 +- lib/extensions/widget_extensions.dart | 69 +++++--- .../action_button/footer_action_button.dart | 10 +- .../service_request_bottomsheet.dart | 20 +-- .../service_request_detail_view.dart | 3 +- .../maintenance_request_main.dart | 4 +- .../pm_module/ppm_wo/ppm_details_page.dart | 138 +++++++-------- .../ppm_wo/update_ppm/update_ppm.dart | 138 +++++++-------- .../components/room_tabs_widget.dart | 1 + .../recurrent_work_order_view.dart | 7 +- .../tasks_wo/task_request_detail_view.dart | 157 +++++++++--------- .../tasks_wo/update_task_request_view.dart | 142 ++++++++-------- .../update_device_transfer.dart | 148 ++++++++--------- .../user/gas_refill/gas_refill_details.dart | 81 ++++----- .../gas_refill/update_gas_refill_request.dart | 150 +++++++++-------- lib/views/pages/user/profile_page.dart | 14 +- .../update_user_contact_info_bottomsheet.dart | 6 - .../selection_fullscreen_dialog.dart | 41 ++--- .../widgets/images/multi_image_picker.dart | 121 ++++++-------- 19 files changed, 626 insertions(+), 636 deletions(-) diff --git a/lib/extensions/context_extension.dart b/lib/extensions/context_extension.dart index bab455de..655a67d4 100644 --- a/lib/extensions/context_extension.dart +++ b/lib/extensions/context_extension.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:provider/provider.dart'; import 'package:test_sa/controllers/providers/api/user_provider.dart'; +import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/new_views/swipe_module/dialoge/confirm_dialog.dart'; -import '../controllers/providers/settings/setting_provider.dart'; import '../controllers/providers/settings/setting_provider.dart'; extension BuildContextExtension on BuildContext { @@ -17,6 +17,7 @@ extension BuildContextExtension on BuildContext { bool get isAr => Provider.of(this).language == "ar"; SettingProvider get settingProvider => Provider.of(this, listen: false); + UserProvider get userProvider => Provider.of(this, listen: false); void showConfirmDialog(String message, {String? title, VoidCallback? onTap}) => showDialog( @@ -26,4 +27,13 @@ extension BuildContextExtension on BuildContext { onTap: onTap, ), ); + + void showBottomSheet(Widget childWidget, {bool? isDismissible, String? title}) => showModalBottomSheet( + context: this, + useSafeArea: true, + isScrollControlled: true, + isDismissible: true, + backgroundColor: Colors.transparent, + builder: (context) => SingleChildScrollView(padding: const EdgeInsets.all(0), child: childWidget.bottomSafeArea).bottomSheetContainerNew(context, title: title), + ); } diff --git a/lib/extensions/widget_extensions.dart b/lib/extensions/widget_extensions.dart index f13316a2..bea487f4 100644 --- a/lib/extensions/widget_extensions.dart +++ b/lib/extensions/widget_extensions.dart @@ -21,8 +21,10 @@ extension WidgetExtensions on Widget { Widget paddingAll(double value) => Padding(padding: EdgeInsets.all(value), child: this); + Widget get bottomSafeArea => SafeArea(bottom: true, top: false, right: false, left: false, child: this); + Widget indicatorWidget({double? height, double? width, Color? color}) => Container( - width: height ?? 40.toScreenWidth, + width: height ?? 50.toScreenWidth, height: width ?? 5.toScreenHeight, decoration: BoxDecoration(color: color ?? AppColor.white50, borderRadius: BorderRadius.circular(30)), child: this, @@ -55,24 +57,26 @@ extension WidgetExtensions on Widget { Widget toExpanded({int flex = 1}) => Expanded(flex: flex, child: this); - Widget handlePopScope({required BuildContext cxt, required VoidCallback onSave, bool? showPopUp =true}) { - return showPopUp! ? PopScope( - canPop: false, - onPopInvokedWithResult: (didPop, result) { - if (didPop) { - return; - } - showDialog( - context: cxt, - builder: (BuildContext cxt) => AcknowledgeWorkDialog( - onSave: () => onSave(), - onDiscard: () { - Navigator.of(cxt).pop(); - }, - ), - ); - }, - child: this): this; + Widget handlePopScope({required BuildContext cxt, required VoidCallback onSave, bool? showPopUp = true}) { + return showPopUp! + ? PopScope( + canPop: false, + onPopInvokedWithResult: (didPop, result) { + if (didPop) { + return; + } + showDialog( + context: cxt, + builder: (BuildContext cxt) => AcknowledgeWorkDialog( + onSave: () => onSave(), + onDiscard: () { + Navigator.of(cxt).pop(); + }, + ), + ); + }, + child: this) + : this; } Widget toShimmer({bool isShow = true, double radius = 20}) => isShow @@ -128,6 +132,33 @@ extension WidgetExtensions on Widget { child: this, ); + Widget bottomSheetContainerNew(BuildContext context, {EdgeInsets? padding, String? title}) => Container( + clipBehavior: Clip.antiAlias, + margin: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), + decoration: BoxDecoration( + color: AppColor.background(context), + borderRadius: const BorderRadius.only(topRight: Radius.circular(30), topLeft: Radius.circular(30)), + ), + padding: padding ?? EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 12.toScreenHeight), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 50.toScreenWidth, + height: 6.toScreenHeight, + decoration: BoxDecoration(color: AppColor.white50, borderRadius: BorderRadius.circular(30)), + ).center, + 16.height, + if (title != null) ...[ + title.bottomSheetHeadingTextStyle(context), + 16.height, + ], + this + ], + ), + ); + Widget toShadowCircleContainer(BuildContext context, {bool showShadow = true, double padding = 16}) => showShadow ? Container( padding: EdgeInsets.all(padding), diff --git a/lib/modules/cm_module/views/components/action_button/footer_action_button.dart b/lib/modules/cm_module/views/components/action_button/footer_action_button.dart index 4853cf43..fe9ccc46 100644 --- a/lib/modules/cm_module/views/components/action_button/footer_action_button.dart +++ b/lib/modules/cm_module/views/components/action_button/footer_action_button.dart @@ -24,13 +24,11 @@ import 'package:test_sa/providers/service_request_providers/reject_reason_provid class FooterActionButton { static Widget footerContainer({required Widget child}) { - return Align( + return Container( alignment: Alignment.bottomCenter, - child: Container( - padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 16.toScreenHeight), - color: AppColor.white10, - child: child, - ), + padding: const EdgeInsets.only(left: 16, right: 16, top: 12,bottom: 8), + color: AppColor.white10, + child: SafeArea(child: child), ); } diff --git a/lib/modules/cm_module/views/components/bottom_sheets/service_request_bottomsheet.dart b/lib/modules/cm_module/views/components/bottom_sheets/service_request_bottomsheet.dart index 46a99403..24835b82 100644 --- a/lib/modules/cm_module/views/components/bottom_sheets/service_request_bottomsheet.dart +++ b/lib/modules/cm_module/views/components/bottom_sheets/service_request_bottomsheet.dart @@ -41,7 +41,7 @@ class ServiceRequestBottomSheet { isDismissible: isDismissible ?? true, backgroundColor: Colors.transparent, builder: (context) => SingleChildScrollView( - child: childWidget, + child: SafeArea(child: childWidget), ).bottomSheetContainer(context), ); } @@ -636,13 +636,8 @@ class ServiceRequestBottomSheet { {'heading': context.translation.requestSparePart, 'subHeading': context.translation.requestSparePartForYourAsset, 'icon': AppAsset.sparePartIcon}, {'heading': context.translation.addNewActivity, 'subHeading': context.translation.addNewActivityToYourWorkOrder, 'icon': AppAsset.maintenanceIcon}, ]; - Widget customListItem({ - required BuildContext context, - required String icon, - required String heading, - required String subHeading, - required VoidCallback onTap, - }) { + + Widget customListItem({required BuildContext context, required String icon, required String heading, required String subHeading, required VoidCallback onTap}) { return GestureDetector( onTap: onTap, // Handles the tap child: Card( @@ -654,13 +649,7 @@ class ServiceRequestBottomSheet { crossAxisAlignment: CrossAxisAlignment.start, // Align items at the top children: [ // Icon Section - icon - .toSvgAsset( - width: 26, - color: AppColor.neutral120, - height: 29, - ) - .paddingOnly(top: 8), + icon.toSvgAsset(width: 26, color: AppColor.neutral120, height: 29).paddingOnly(top: 8), 14.width, Expanded( child: Column( @@ -725,6 +714,7 @@ class ServiceRequestBottomSheet { shrinkWrap: true, padding: EdgeInsets.zero, itemCount: items.length, + physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) { final item = items[index]; return customListItem( diff --git a/lib/modules/cm_module/views/components/service_request_detail_view.dart b/lib/modules/cm_module/views/components/service_request_detail_view.dart index 247b0af7..cc7eef0e 100644 --- a/lib/modules/cm_module/views/components/service_request_detail_view.dart +++ b/lib/modules/cm_module/views/components/service_request_detail_view.dart @@ -346,8 +346,9 @@ class _ServiceRequestDetailViewState extends State { files: _userAttachments, buttonColor: AppColor.primary10, onlyImages: false, + // showAsGrid: true, buttonIcon: 'quotation_icon'.toSvgAsset(color: AppColor.primary10), - onChange: (attachment) { + onChange: () { requestProvider.addWorkOrderAttachment(woId: workOrder.requestId!, attachments: _userAttachments, otherAttachment: _attachments); }, ), diff --git a/lib/modules/cm_module/views/forms/maintenance_request/maintenance_request_main.dart b/lib/modules/cm_module/views/forms/maintenance_request/maintenance_request_main.dart index 0dc286d8..4a9ce491 100644 --- a/lib/modules/cm_module/views/forms/maintenance_request/maintenance_request_main.dart +++ b/lib/modules/cm_module/views/forms/maintenance_request/maintenance_request_main.dart @@ -58,7 +58,7 @@ class _MaintenanceRequestFormState extends State with Si save(requestDetailProvider); }, ), - body: Stack( + body: Column( children: [ DefaultTabController( length: 2, @@ -99,7 +99,7 @@ class _MaintenanceRequestFormState extends State with Si ).expanded, ], ), - ), + ).expanded, if (!requestDetailProvider.isReadOnlyRequest) FooterActionButton.footerContainer( child: AppFilledButton( diff --git a/lib/modules/pm_module/ppm_wo/ppm_details_page.dart b/lib/modules/pm_module/ppm_wo/ppm_details_page.dart index 78d8cefe..50df7af0 100644 --- a/lib/modules/pm_module/ppm_wo/ppm_details_page.dart +++ b/lib/modules/pm_module/ppm_wo/ppm_details_page.dart @@ -7,6 +7,7 @@ import 'package:test_sa/extensions/string_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/plan_preventive_visit/plan_preventive_visit_model.dart'; +import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart'; import 'package:test_sa/new_views/common_widgets/default_app_bar.dart'; import 'package:test_sa/views/widgets/loaders/app_loading.dart'; import 'package:test_sa/views/widgets/loaders/no_data_found.dart'; @@ -60,74 +61,77 @@ class _PpmDetailsPageState extends State { // ppmProvider!.getPlanPreventiveVisitById(widget.request.id!); return Scaffold( appBar: DefaultAppBar(title: context.translation.preventiveMaintenance), - body: SafeArea( - child: Consumer(builder: (context, ppmProvider, child) { - PlanPreventiveVisit? planPreventiveVisit = ppmProvider.planPreventiveVisit; - return ppmProvider.isLoading - ? const ALoading() - :planPreventiveVisit!=null? Column(children: [ - SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - // if (widget.request.priority != null) - // StatusLabel( - // label: widget.request.priority, - // textColor: AppColor.getRequestStatusTextColorByName(context, widget.request.priority!), - // backgroundColor: AppColor.getRequestStatusColorByName(context, widget.request.priority!), - // ), - // if (planPreventiveVisit?.visitStatus != null) 8.width, - StatusLabel( - label: planPreventiveVisit?.visitStatus!.name!, - id: planPreventiveVisit?.visitStatus?.id??0, - textColor: AppColor.getRequestStatusTextColorByName(context, planPreventiveVisit.visitStatus!.name!), - backgroundColor: AppColor.getRequestStatusColorByName(context, planPreventiveVisit.visitStatus!.name!), - ), - // 1.width.expanded, - ], + body: Consumer(builder: (context, ppmProvider, child) { + PlanPreventiveVisit? planPreventiveVisit = ppmProvider.planPreventiveVisit; + return ppmProvider.isLoading + ? const ALoading() + : planPreventiveVisit != null + ? Column(children: [ + SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + // if (widget.request.priority != null) + // StatusLabel( + // label: widget.request.priority, + // textColor: AppColor.getRequestStatusTextColorByName(context, widget.request.priority!), + // backgroundColor: AppColor.getRequestStatusColorByName(context, widget.request.priority!), + // ), + // if (planPreventiveVisit?.visitStatus != null) 8.width, + StatusLabel( + label: planPreventiveVisit?.visitStatus!.name!, + id: planPreventiveVisit?.visitStatus?.id ?? 0, + textColor: AppColor.getRequestStatusTextColorByName(context, planPreventiveVisit.visitStatus!.name!), + backgroundColor: AppColor.getRequestStatusColorByName(context, planPreventiveVisit.visitStatus!.name!), + ), + // 1.width.expanded, + ], + ), + 8.height, + planPreventiveVisit.assetName!.cleanupWhitespace.capitalizeFirstOfEach.heading5(context), + 8.height, + '${context.translation.assetNumber}: ${planPreventiveVisit.asset!.assetNumber}'.bodyText(context), + '${context.translation.assetSN}: ${planPreventiveVisit.asset!.assetSerialNo}'.bodyText(context), + '${context.translation.requestNo}: ${planPreventiveVisit.visitNo}'.bodyText(context), + const Divider().defaultStyle(context), + // '${context.translation.expectDate}: ${planPreventiveVisit.expectedDate?.toAssetDetailsFormat ?? ""}'.bodyText(context), //todo @baha, + '${context.translation.actualDate}: ${planPreventiveVisit.acutalDateOfVisit?.toIso8601String().toAssetDetailsFormat ?? ""}'.bodyText(context), //todo @baha, + const Divider().defaultStyle(context), + '${context.translation.assignedEmployee}: ${planPreventiveVisit.assignedEmployee?.userName ?? ""}'.bodyText(context), //todo @baha, + '${context.translation.site}: ${planPreventiveVisit.siteName?.cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context), //todo @baha, + '${context.translation.building}: ${planPreventiveVisit.buildingName?.cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context), //todo @baha, + '${context.translation.floor}: ${planPreventiveVisit.floorName?.cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context), //todo @baha, + '${context.translation.department}: ${planPreventiveVisit.departmentName?.cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context), //todo @baha, + '${context.translation.room}: ${(planPreventiveVisit.roomName ?? "").cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context), //todo @baha, + ], + ).toShadowContainer(context).paddingAll(16), + ).expanded, + if (userProvider!.user!.type == UsersTypes.engineer && (!ppmProvider.isReadOnly)) ...[ + FooterActionButton.footerContainer( + child: AppFilledButton( + onPressed: () async { + await Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdatePpm(ppm: null, planPreventiveVisit: planPreventiveVisit))); + getVisitData(); + }, + label: context.translation.updateWorkOrder, ), - 8.height, - planPreventiveVisit.assetName!.cleanupWhitespace.capitalizeFirstOfEach.heading5(context), - 8.height, - '${context.translation.assetNumber}: ${planPreventiveVisit.asset!.assetNumber}'.bodyText(context), - '${context.translation.assetSN}: ${planPreventiveVisit.asset!.assetSerialNo}'.bodyText(context), - '${context.translation.requestNo}: ${planPreventiveVisit.visitNo}'.bodyText(context), - const Divider().defaultStyle(context), - // '${context.translation.expectDate}: ${planPreventiveVisit.expectedDate?.toAssetDetailsFormat ?? ""}'.bodyText(context), //todo @baha, - '${context.translation.actualDate}: ${planPreventiveVisit.acutalDateOfVisit?.toIso8601String().toAssetDetailsFormat ?? ""}'.bodyText(context), //todo @baha, - const Divider().defaultStyle(context), - '${context.translation.assignedEmployee}: ${planPreventiveVisit.assignedEmployee?.userName ?? ""}'.bodyText(context), //todo @baha, - '${context.translation.site}: ${planPreventiveVisit.siteName?.cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context), //todo @baha, - '${context.translation.building}: ${planPreventiveVisit.buildingName?.cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context), //todo @baha, - '${context.translation.floor}: ${planPreventiveVisit.floorName?.cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context), //todo @baha, - '${context.translation.department}: ${planPreventiveVisit.departmentName?.cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context), //todo @baha, - '${context.translation.room}: ${(planPreventiveVisit.roomName ?? "").cleanupWhitespace.capitalizeFirstOfEach}'.bodyText(context), //todo @baha, - ], - ).toShadowContainer(context).paddingAll(16), - ).expanded, - if (userProvider!.user!.type == UsersTypes.engineer && (!ppmProvider.isReadOnly))...[ - AppFilledButton( - onPressed: () async { - await Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdatePpm(ppm: null, planPreventiveVisit: planPreventiveVisit))); - getVisitData(); - }, - label: context.translation.updateWorkOrder, - ).paddingAll(16) - ] - else ...[ - AppFilledButton( - onPressed: () async { - await Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdatePpm(ppm: null, planPreventiveVisit: planPreventiveVisit))); - getVisitData(); - }, - label: context.translation.viewDetails, - ).paddingAll(16) - ] - ]):const Center(child: NoDataFound()); - }), - ), + ) + ] else ...[ + FooterActionButton.footerContainer( + child: AppFilledButton( + onPressed: () async { + await Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdatePpm(ppm: null, planPreventiveVisit: planPreventiveVisit))); + getVisitData(); + }, + label: context.translation.viewDetails, + ), + ) + ] + ]) + : const Center(child: NoDataFound()); + }), ); } } diff --git a/lib/modules/pm_module/ppm_wo/update_ppm/update_ppm.dart b/lib/modules/pm_module/ppm_wo/update_ppm/update_ppm.dart index 20a66f47..4b38f990 100644 --- a/lib/modules/pm_module/ppm_wo/update_ppm/update_ppm.dart +++ b/lib/modules/pm_module/ppm_wo/update_ppm/update_ppm.dart @@ -12,10 +12,12 @@ import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/plan_preventive_visit/plan_preventive_visit_model.dart'; import 'package:test_sa/models/ppm/ppm.dart'; import 'package:test_sa/modules/cm_module/utilities/service_request_utils.dart'; +import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; import 'package:test_sa/new_views/common_widgets/app_lazy_loading.dart'; import 'package:test_sa/new_views/common_widgets/default_app_bar.dart'; + import 'ppm_calibration_tools_form.dart'; import 'ppm_external_details_form.dart'; import 'ppm_pm_check_list_form.dart'; @@ -132,74 +134,74 @@ class _UpdatePpmState extends State with TickerProviderStateMixin { }, ), key: _scaffoldKey, - body: SafeArea( - child: Column( - children: [ - DefaultTabController( - length: 2, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Container( - margin: EdgeInsets.only(left: 16.toScreenWidth, right: 16.toScreenWidth, top: 16.toScreenHeight, bottom: 8), - decoration: BoxDecoration( - color: context.isDark ? AppColor.neutral50 : AppColor.white10, - borderRadius: BorderRadius.circular(10), - ), - child: TabBar( - padding: EdgeInsets.symmetric(vertical: 4.toScreenHeight, horizontal: 4.toScreenWidth), - labelColor: context.isDark ? AppColor.neutral30 : AppColor.black20, - unselectedLabelColor: context.isDark ? AppColor.neutral30 : AppColor.black20, - unselectedLabelStyle: AppTextStyles.bodyText, - labelStyle: AppTextStyles.bodyText, - indicatorPadding: EdgeInsets.zero, - indicatorSize: TabBarIndicatorSize.tab, - dividerColor: Colors.transparent, - indicator: BoxDecoration( - color: context.isDark ? AppColor.neutral60 : AppColor.neutral110, - borderRadius: BorderRadius.circular(7), - ), - onTap: (index) { - tabIndex = index; - if (tabIndex == 0) { - _tabController?.animateTo(0); - } - setState(() {}); - }, - tabs: [ - Tab(text: "WO Info".addTranslation, height: 57.toScreenHeight), - Tab(text: "WO Inspection".addTranslation, height: 57.toScreenHeight), - ], + body: Column( + children: [ + DefaultTabController( + length: 2, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + margin: EdgeInsets.only(left: 16.toScreenWidth, right: 16.toScreenWidth, top: 16.toScreenHeight, bottom: 8), + decoration: BoxDecoration( + color: context.isDark ? AppColor.neutral50 : AppColor.white10, + borderRadius: BorderRadius.circular(10), + ), + child: TabBar( + padding: EdgeInsets.symmetric(vertical: 4.toScreenHeight, horizontal: 4.toScreenWidth), + labelColor: context.isDark ? AppColor.neutral30 : AppColor.black20, + unselectedLabelColor: context.isDark ? AppColor.neutral30 : AppColor.black20, + unselectedLabelStyle: AppTextStyles.bodyText, + labelStyle: AppTextStyles.bodyText, + indicatorPadding: EdgeInsets.zero, + indicatorSize: TabBarIndicatorSize.tab, + dividerColor: Colors.transparent, + indicator: BoxDecoration( + color: context.isDark ? AppColor.neutral60 : AppColor.neutral110, + borderRadius: BorderRadius.circular(7), ), + onTap: (index) { + tabIndex = index; + if (tabIndex == 0) { + _tabController?.animateTo(0); + } + setState(() {}); + }, + tabs: [ + Tab(text: "WO Info".addTranslation, height: 57.toScreenHeight), + Tab(text: "WO Inspection".addTranslation, height: 57.toScreenHeight), + ], ), - TabBarView( - physics: const NeverScrollableScrollPhysics(), - children: [ - WoInfoForm( - planPreventiveVisit: _planPreventiveVisit, - onTypeOfServiceChange: (selectedTypeOfService) { - initTabs(selectedTypeOfService); - }), - TabBarView( - physics: const NeverScrollableScrollPhysics(), - controller: _tabController, - children: [ - if (ppmProvider.totalTabs == 4) ...[ - PpmExternalDetailsForm( - models: _planPreventiveVisit.preventiveVisitSuppliers, - ), - ], - PpmCalibrationToolsForm(models: _planPreventiveVisit.preventiveVisitCalibrations), - PpmPMKitsForm(models: _planPreventiveVisit.preventiveVisitKits, assetId: _planPreventiveVisit.asset?.id), - PpmPmChecklistForm(checkList: _planPreventiveVisit.preventiveVisitChecklists), + ), + TabBarView( + physics: const NeverScrollableScrollPhysics(), + children: [ + WoInfoForm( + planPreventiveVisit: _planPreventiveVisit, + onTypeOfServiceChange: (selectedTypeOfService) { + initTabs(selectedTypeOfService); + }), + TabBarView( + physics: const NeverScrollableScrollPhysics(), + controller: _tabController, + children: [ + if (ppmProvider.totalTabs == 4) ...[ + PpmExternalDetailsForm( + models: _planPreventiveVisit.preventiveVisitSuppliers, + ), ], - ) - ], - ).expanded, - ], - ), - ).expanded, - Row( + PpmCalibrationToolsForm(models: _planPreventiveVisit.preventiveVisitCalibrations), + PpmPMKitsForm(models: _planPreventiveVisit.preventiveVisitKits, assetId: _planPreventiveVisit.asset?.id), + PpmPmChecklistForm(checkList: _planPreventiveVisit.preventiveVisitChecklists), + ], + ) + ], + ).expanded, + ], + ), + ).expanded, + FooterActionButton.footerContainer( + child: Row( children: [ if (tabIndex == 1) ...[ AppFilledButton( @@ -261,9 +263,9 @@ class _UpdatePpmState extends State with TickerProviderStateMixin { ), ] ], - ).toShadowContainer(context, showShadow: false, borderRadius: 0), - ], - ), + ), + ), + ], ), ).handlePopScope( cxt: context, diff --git a/lib/modules/pm_module/recurrent_wo/components/room_tabs_widget.dart b/lib/modules/pm_module/recurrent_wo/components/room_tabs_widget.dart index d74ed962..c40db559 100644 --- a/lib/modules/pm_module/recurrent_wo/components/room_tabs_widget.dart +++ b/lib/modules/pm_module/recurrent_wo/components/room_tabs_widget.dart @@ -26,6 +26,7 @@ class _RoomTabsWidgetState extends State { Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, children: [ Container( padding: EdgeInsets.all(8.toScreenHeight), diff --git a/lib/modules/pm_module/recurrent_wo/recurrent_work_order_view.dart b/lib/modules/pm_module/recurrent_wo/recurrent_work_order_view.dart index fc9531f4..5920fff1 100644 --- a/lib/modules/pm_module/recurrent_wo/recurrent_work_order_view.dart +++ b/lib/modules/pm_module/recurrent_wo/recurrent_work_order_view.dart @@ -58,9 +58,10 @@ class _RecurrentWorkOrderViewState extends State { body: allRequestsProvider!.isLoading ? const ALoading() : requestProvider.recurrentWoData != null - ? Stack( + ? Column( children: [ SingleChildScrollView( + padding: EdgeInsets.all(16), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, @@ -75,8 +76,8 @@ class _RecurrentWorkOrderViewState extends State { ) : const SizedBox(), ], - ).paddingAll(12), - ).paddingOnly(bottom: 85), + ), + ).expanded, if (requestProvider.recurrentWoData?.status?.value != 1) ...[ FooterActionButton.footerContainer( child: Row( diff --git a/lib/modules/tm_module/tasks_wo/task_request_detail_view.dart b/lib/modules/tm_module/tasks_wo/task_request_detail_view.dart index 8c4153e1..d33bd9c8 100644 --- a/lib/modules/tm_module/tasks_wo/task_request_detail_view.dart +++ b/lib/modules/tm_module/tasks_wo/task_request_detail_view.dart @@ -8,6 +8,7 @@ import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/all_requests_and_count_model.dart'; import 'package:test_sa/models/new_models/task_request/task_request_model.dart'; +import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart'; import 'package:test_sa/new_views/common_widgets/default_app_bar.dart'; import 'package:test_sa/providers/task_request_provider/task_request_provider.dart'; import 'package:test_sa/views/widgets/images/files_list.dart'; @@ -61,90 +62,90 @@ class _TaskRequestDetailsViewState extends State { userProvider ??= Provider.of(context, listen: false); return Scaffold( appBar: DefaultAppBar(title: context.translation.taskRequest), - body: SafeArea( - child: Consumer(builder: (context, taskProvider, child) { - TaskData? taskModel = taskProvider.taskRequestModel; - return taskProvider.isLoading - ? const ALoading() - : Column(children: [ - SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( + body: Consumer(builder: (context, taskProvider, child) { + TaskData? taskModel = taskProvider.taskRequestModel; + return taskProvider.isLoading + ? const ALoading() + : Column(children: [ + SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + StatusLabel( + label: widget.requestDetails?.priority!, + textColor: AppColor.getRequestStatusTextColorByName(context, widget.requestDetails?.priority!), + backgroundColor: AppColor.getRequestStatusColorByName(context, widget.requestDetails?.priority!), + ), + 8.width, + StatusLabel( + label: widget.requestDetails?.status!, + textColor: AppColor.getRequestStatusTextColorByName(context, widget.requestDetails?.status!), + backgroundColor: AppColor.getRequestStatusColorByName(context, widget.requestDetails?.status!), + ), + 1.width.expanded, + Text( + widget.requestDetails?.date?.toServiceRequestCardFormat ?? "-", + textAlign: TextAlign.end, + style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50), + ), + ], + ), + 8.height, + if (taskProvider.taskRequestModel?.taskType?.relatedTo?.value == 1) ...[ + assetDetails(taskModel: taskProvider.taskRequestModel!), + ], + if (taskProvider.taskRequestModel?.taskType?.isInstallation == true) ...[installationWidget(taskModel: taskProvider.taskRequestModel!)], + if (taskProvider.taskRequestModel?.taskType?.relatedTo?.value == 2) ...[ + linkWithLocationWidget(taskModel: taskProvider.taskRequestModel!), + ], + const Divider().defaultStyle(context), + Text( + "Task Details".addTranslation, + style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), + ), + '${context.translation.taskType}: ${taskModel?.taskType?.typeName ?? "-"}'.bodyText(context), + '${context.translation.taskNo}: ${taskModel?.taskJobNo ?? "-"}'.bodyText(context), + '${context.translation.createdBy}: ${taskModel?.userCreated?.userName ?? "-"}'.bodyText(context), + if (taskProvider.taskRequestModel?.taskType?.isRecallAndAlert == true) ...[ + recallAlertTypeWidget(taskModel: taskProvider.taskRequestModel!), + Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - StatusLabel( - label: widget.requestDetails?.priority!, - textColor: AppColor.getRequestStatusTextColorByName(context, widget.requestDetails?.priority!), - backgroundColor: AppColor.getRequestStatusColorByName(context, widget.requestDetails?.priority!), - ), - 8.width, - StatusLabel( - label: widget.requestDetails?.status!, - textColor: AppColor.getRequestStatusTextColorByName(context, widget.requestDetails?.status!), - backgroundColor: AppColor.getRequestStatusColorByName(context, widget.requestDetails?.status!), - ), - 1.width.expanded, - Text( - widget.requestDetails?.date?.toServiceRequestCardFormat ?? "-", - textAlign: TextAlign.end, - style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50), - ), + 'Type of alert: ${taskProvider.taskRequestModel?.typeOfAlert?.name ?? '-'}'.bodyText(context), + 'Risk Level: ${taskProvider.taskRequestModel?.riskLevel?.name ?? '-'}'.bodyText(context), + 'Resource: ${taskProvider.taskRequestModel?.resource?.name ?? '-'}'.bodyText(context), + 'Evaluator User: ${taskProvider.taskRequestModel?.evaluatorUser?.userName ?? '-'}'.bodyText(context) ], ), + ], + if (taskProvider.taskRequestModel?.callComment != null) ...[ + const Divider().defaultStyle(context), + Text( + context.translation.comment, + style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), + ), + 2.height, + taskProvider.taskRequestModel!.callComment!.bodyText(context), + ], + if (taskProvider.taskRequestModel?.taskJobAttachments?.isNotEmpty ?? false) ...[ 8.height, - if (taskProvider.taskRequestModel?.taskType?.relatedTo?.value == 1) ...[ - assetDetails(taskModel: taskProvider.taskRequestModel!), - ], - if (taskProvider.taskRequestModel?.taskType?.isInstallation == true) ...[installationWidget(taskModel: taskProvider.taskRequestModel!)], - if (taskProvider.taskRequestModel?.taskType?.relatedTo?.value == 2) ...[ - linkWithLocationWidget(taskModel: taskProvider.taskRequestModel!), - ], const Divider().defaultStyle(context), Text( - "Task Details".addTranslation, + "Attachments".addTranslation, style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), ), - '${context.translation.taskType}: ${taskModel?.taskType?.typeName ?? "-"}'.bodyText(context), - '${context.translation.taskNo}: ${taskModel?.taskJobNo ?? "-"}'.bodyText(context), - '${context.translation.createdBy}: ${taskModel?.userCreated?.userName ?? "-"}'.bodyText(context), - if (taskProvider.taskRequestModel?.taskType?.isRecallAndAlert == true) ...[ - recallAlertTypeWidget(taskModel: taskProvider.taskRequestModel!), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - 'Type of alert: ${taskProvider.taskRequestModel?.typeOfAlert?.name ?? '-'}'.bodyText(context), - 'Risk Level: ${taskProvider.taskRequestModel?.riskLevel?.name ?? '-'}'.bodyText(context), - 'Resource: ${taskProvider.taskRequestModel?.resource?.name ?? '-'}'.bodyText(context), - 'Evaluator User: ${taskProvider.taskRequestModel?.evaluatorUser?.userName ?? '-'}'.bodyText(context) - ], - ), - ], - if (taskProvider.taskRequestModel?.callComment != null) ...[ - const Divider().defaultStyle(context), - Text( - context.translation.comment, - style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), - ), - 2.height, - taskProvider.taskRequestModel!.callComment!.bodyText(context), - ], - if (taskProvider.taskRequestModel?.taskJobAttachments?.isNotEmpty ?? false) ...[ - 8.height, - const Divider().defaultStyle(context), - Text( - "Attachments".addTranslation, - style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), - ), - FilesList(images: taskProvider.taskRequestModel!.taskJobAttachments!.map((toElement) => URLs.getFileUrl(toElement.name ?? '') ?? '').toList()), - ], - buildTechnicalComments(taskModel: taskModel), + FilesList(images: taskProvider.taskRequestModel!.taskJobAttachments!.map((toElement) => URLs.getFileUrl(toElement.name ?? '') ?? '').toList()), ], - ).toShadowContainer(context).paddingAll(16), - ).expanded, - if (userProvider!.user!.type == UsersTypes.engineer && (taskModel?.taskJobStatus?.value != 4 && taskModel?.taskJobStatus?.value != 3)) - AppFilledButton( + buildTechnicalComments(taskModel: taskModel), + ], + ).toShadowContainer(context).paddingAll(16), + ).expanded, + if (userProvider!.user!.type == UsersTypes.engineer && (taskModel?.taskJobStatus?.value != 4 && taskModel?.taskJobStatus?.value != 3)) + FooterActionButton.footerContainer( + child: AppFilledButton( onPressed: () async { if (taskProvider.taskRequestModel?.taskType?.isInstallation == true) { taskProvider.getSiteData(siteId: taskProvider.taskRequestModel?.asset?.siteId); @@ -152,10 +153,10 @@ class _TaskRequestDetailsViewState extends State { Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdateTaskRequest(taskId: widget.taskId))); }, label: context.translation.updateRequest, - ).paddingAll(16) - ]); - }), - ), + ), + ) + ]); + }), ); } diff --git a/lib/modules/tm_module/tasks_wo/update_task_request_view.dart b/lib/modules/tm_module/tasks_wo/update_task_request_view.dart index 60a155bc..242bbe55 100644 --- a/lib/modules/tm_module/tasks_wo/update_task_request_view.dart +++ b/lib/modules/tm_module/tasks_wo/update_task_request_view.dart @@ -98,81 +98,79 @@ class _UpdateTaskRequestState extends State { body: taskProvider.isLoading ? const ALoading() : taskProvider.taskRequestModel != null - ? SafeArea( - child: Form( - key: _formKey, - child: Stack( - children: [ - SingleChildScrollView( - padding: EdgeInsets.all(12 * AppStyle.getScaleFactor(context)), - child: Column( + ? Form( + key: _formKey, + child: Column( + children: [ + SingleChildScrollView( + padding: EdgeInsets.all(12 * AppStyle.getScaleFactor(context)), + child: Column( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _timerWidget(context, true, taskProvider), - 8.height, - if (taskProvider.taskRequestModel?.taskType?.isInstallation == true) ...[installationWidget(taskModel: taskProvider.taskRequestModel!)], - if (taskProvider.taskRequestModel?.taskType?.isRecallAndAlert == true) ...[ - recallAlertTypeWidget(taskModel: taskProvider.taskRequestModel!), - ], - // if (previousComments.isNotEmpty) ...[ - // 'Previous Comments'.bodyText2(context).custom(color: AppColor.neutral50), - // 8.height, - buildPreviousComments(taskProvider: taskProvider), - // 8.height, - // ], - AppTextFormField( - initialValue: "", - labelText: context.translation.technicalComment, - textInputType: TextInputType.multiline, - backgroundColor: AppColor.neutral90, - showShadow: false, - alignLabelWithHint: true, - onChange: (value) { - comments = value; - setState(() {}); - }, - onSaved: (value) {}, - ), - 20.height, - MultiFilesPicker( - label: context.translation.attachFiles, - files: _files, - buttonColor: AppColor.black10, - onlyImages: false, - buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), - ), - ], - ).toShadowContainer(context), - 16.height, - const AssistantEmployeeCard().toShadowContainer(context, paddingObject: const EdgeInsets.symmetric(horizontal: 16)), + _timerWidget(context, true, taskProvider), + 8.height, + if (taskProvider.taskRequestModel?.taskType?.isInstallation == true) ...[installationWidget(taskModel: taskProvider.taskRequestModel!)], + if (taskProvider.taskRequestModel?.taskType?.isRecallAndAlert == true) ...[ + recallAlertTypeWidget(taskModel: taskProvider.taskRequestModel!), + ], + // if (previousComments.isNotEmpty) ...[ + // 'Previous Comments'.bodyText2(context).custom(color: AppColor.neutral50), + // 8.height, + buildPreviousComments(taskProvider: taskProvider), + // 8.height, + // ], + AppTextFormField( + initialValue: "", + labelText: context.translation.technicalComment, + textInputType: TextInputType.multiline, + backgroundColor: AppColor.neutral90, + showShadow: false, + alignLabelWithHint: true, + onChange: (value) { + comments = value; + setState(() {}); + }, + onSaved: (value) {}, + ), + 20.height, + MultiFilesPicker( + label: context.translation.attachFiles, + files: _files, + buttonColor: AppColor.black10, + onlyImages: false, + buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), + ), ], - ), - ).paddingOnly(bottom: 85), - FooterActionButton.footerContainer( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - AppFilledButton( - label: context.translation.save, - buttonColor: AppColor.white60, - textColor: AppColor.black10, - onPressed: () => _updateTask(context: context, status: 0), - ).expanded, - 12.width, - AppFilledButton( - label: context.translation.complete, - buttonColor: AppColor.primary10, - onPressed: () => _updateTask(context: context, status: 1), - ).expanded, - ], - ), - ), - ], + ).toShadowContainer(context), + 16.height, + const AssistantEmployeeCard().toShadowContainer(context, paddingObject: const EdgeInsets.symmetric(horizontal: 16)), + ], + ), + ).expanded, + FooterActionButton.footerContainer( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + AppFilledButton( + label: context.translation.save, + buttonColor: AppColor.white60, + textColor: AppColor.black10, + onPressed: () => _updateTask(context: context, status: 0), + ).expanded, + 12.width, + AppFilledButton( + label: context.translation.complete, + buttonColor: AppColor.primary10, + onPressed: () => _updateTask(context: context, status: 1), + ).expanded, + ], + ), ), - ), - ) + ], + ), + ) : NoDataFound(message: context.translation.noDataFound).center, ).handlePopScope( cxt: context, diff --git a/lib/views/pages/device_transfer/update_device_transfer.dart b/lib/views/pages/device_transfer/update_device_transfer.dart index 5270c36e..4a35c1f3 100644 --- a/lib/views/pages/device_transfer/update_device_transfer.dart +++ b/lib/views/pages/device_transfer/update_device_transfer.dart @@ -209,88 +209,86 @@ class _UpdateDeviceTransferState extends State { }, ), key: _scaffoldKey, - body: SafeArea( - child: LoadingManager( - isLoading: _isLoading, - isFailedLoading: false, - stateCode: 200, - onRefresh: () async {}, - child: Form( - key: _formKey, - child: Column( - children: [ - SingleChildScrollView( - padding: EdgeInsets.all(12 * AppStyle.getScaleFactor(context)), - child: Column( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - _timerWidget(context, totalWorkingHours, isTimerEnable), - 8.height, - AppTextFormField( - initialValue: widget.isSender ? _formModel.senderComment ?? "" : _formModel.receiverComment ?? "", - labelText: context.translation.technicalComment, - labelStyle: AppTextStyles.tinyFont.copyWith(color: AppColor.neutral20), - textInputType: TextInputType.multiline, - backgroundColor: AppColor.neutral100, - showShadow: false, - alignLabelWithHint: true, - onSaved: (value) { - widget.isSender ? _formModel.senderComment = value : _formModel.receiverComment = value; - }, - ), - 8.height, - MultiFilesPicker( - label: context.translation.attachFiles, - files: _files, - buttonColor: AppColor.black10, - onlyImages: false, - buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), - ), - 8.height, - ], - ).toShadowContainer(context), - 16.height, - AssistantEmployeeCard( - isSender: widget.isSender, - formModel: _formModel, - ).toShadowContainer(context, paddingObject: const EdgeInsets.symmetric(horizontal: 16)), - ], - ), - ).expanded, - FooterActionButton.footerContainer( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ + body: LoadingManager( + isLoading: _isLoading, + isFailedLoading: false, + stateCode: 200, + onRefresh: () async {}, + child: Form( + key: _formKey, + child: Column( + children: [ + SingleChildScrollView( + padding: EdgeInsets.all(12 * AppStyle.getScaleFactor(context)), + child: Column( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + _timerWidget(context, totalWorkingHours, isTimerEnable), + 8.height, + AppTextFormField( + initialValue: widget.isSender ? _formModel.senderComment ?? "" : _formModel.receiverComment ?? "", + labelText: context.translation.technicalComment, + labelStyle: AppTextStyles.tinyFont.copyWith(color: AppColor.neutral20), + textInputType: TextInputType.multiline, + backgroundColor: AppColor.neutral100, + showShadow: false, + alignLabelWithHint: true, + onSaved: (value) { + widget.isSender ? _formModel.senderComment = value : _formModel.receiverComment = value; + }, + ), + 8.height, + MultiFilesPicker( + label: context.translation.attachFiles, + files: _files, + buttonColor: AppColor.black10, + onlyImages: false, + buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), + ), + 8.height, + ], + ).toShadowContainer(context), + 16.height, + AssistantEmployeeCard( + isSender: widget.isSender, + formModel: _formModel, + ).toShadowContainer(context, paddingObject: const EdgeInsets.symmetric(horizontal: 16)), + ], + ), + ).expanded, + FooterActionButton.footerContainer( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + AppFilledButton( + label: context.translation.save, + buttonColor: AppColor.white60, + textColor: AppColor.black10, + onPressed: () => _update(status: 0), + ).expanded, + 12.width, + if (!widget.isSender && _formModel.senderMachineStatusValue == 3) ...[ AppFilledButton( - label: context.translation.save, - buttonColor: AppColor.white60, - textColor: AppColor.black10, - onPressed: () => _update(status: 0), - ).expanded, - 12.width, - if (!widget.isSender && _formModel.senderMachineStatusValue == 3) ...[ - AppFilledButton( - label: context.translation.complete, - buttonColor: AppColor.primary10, - onPressed: () { - _update(status: 1); - }).expanded, - ] else if (widget.isSender) ...[ - AppFilledButton( label: context.translation.complete, buttonColor: AppColor.primary10, onPressed: () { _update(status: 1); - }, - ).expanded, - ], + }).expanded, + ] else if (widget.isSender) ...[ + AppFilledButton( + label: context.translation.complete, + buttonColor: AppColor.primary10, + onPressed: () { + _update(status: 1); + }, + ).expanded, ], - ), + ], ), - ], - ), + ), + ], ), ), ), diff --git a/lib/views/pages/user/gas_refill/gas_refill_details.dart b/lib/views/pages/user/gas_refill/gas_refill_details.dart index 85cb9c2c..727dcf69 100644 --- a/lib/views/pages/user/gas_refill/gas_refill_details.dart +++ b/lib/views/pages/user/gas_refill/gas_refill_details.dart @@ -10,6 +10,7 @@ import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/string_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; +import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; import 'package:test_sa/views/pages/user/gas_refill/update_gas_refill_request.dart'; import 'package:test_sa/views/widgets/images/files_list.dart'; @@ -56,52 +57,52 @@ class _GasRefillDetailsPageState extends State { return Scaffold( appBar: DefaultAppBar(title: context.translation.gasRefillDetails), key: _scaffoldKey, - body: SafeArea( - child: FutureBuilder( - future: gasRefillProvider.getGasRefillObjectById(widget.model.id!), - builder: (context, snap) { - if (snap.connectionState == ConnectionState.waiting) { - return const ALoading(); - } else if (snap.hasData) { - _model = snap.data as GasRefillModel; - _attachments = _model.gasRefillAttachments?.map((e) => File(e.attachmentName ?? '')).toList() ?? []; + body: FutureBuilder( + future: gasRefillProvider.getGasRefillObjectById(widget.model.id!), + builder: (context, snap) { + if (snap.connectionState == ConnectionState.waiting) { + return const ALoading(); + } else if (snap.hasData) { + _model = snap.data as GasRefillModel; + _attachments = _model.gasRefillAttachments?.map((e) => File(e.attachmentName ?? '')).toList() ?? []; - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SingleChildScrollView( - padding: const EdgeInsets.all(16), - child: informationCard(_model), - ).expanded, - if (_userProvider.user!.type == UsersTypes.engineer && (_model.status!.value! != 2)) ...[ - AppFilledButton( + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SingleChildScrollView( + padding: const EdgeInsets.all(16), + child: informationCard(_model), + ).expanded, + if (_userProvider.user!.type == UsersTypes.engineer && (_model.status!.value! != 2)) ...[ + FooterActionButton.footerContainer( + child: AppFilledButton( onPressed: () async { await Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdateGasRefillRequest(gasRefillModel: _model))); // getVisitData(); }, label: context.translation.updateRequest, - ).paddingAll(16) - ] - //TODO need to uncomment this to enable nurse edit gas refill request. - // else if (_model.status!.value! == 0) ...[ - // AppFilledButton( - // onPressed: () async { - // await Navigator.of(context).push(MaterialPageRoute( - // builder: (_) => GasRefillRequestForm( - // gasModel: _model, - // gasRefillDetails: _model.gasRefillDetails?[0], - // ))); - // // getVisitData(); - // }, - // label: context.translation.updateRequest, - // ).paddingAll(16) - // ], - ], - ); - } - return NoDataFound(message: context.translation.noDataFound).center; - }, - ), + ), + ) + ] + //TODO need to uncomment this to enable nurse edit gas refill request. + // else if (_model.status!.value! == 0) ...[ + // AppFilledButton( + // onPressed: () async { + // await Navigator.of(context).push(MaterialPageRoute( + // builder: (_) => GasRefillRequestForm( + // gasModel: _model, + // gasRefillDetails: _model.gasRefillDetails?[0], + // ))); + // // getVisitData(); + // }, + // label: context.translation.updateRequest, + // ).paddingAll(16) + // ], + ], + ); + } + return NoDataFound(message: context.translation.noDataFound).center; + }, ), ); } diff --git a/lib/views/pages/user/gas_refill/update_gas_refill_request.dart b/lib/views/pages/user/gas_refill/update_gas_refill_request.dart index b92133b6..5f5884b0 100644 --- a/lib/views/pages/user/gas_refill/update_gas_refill_request.dart +++ b/lib/views/pages/user/gas_refill/update_gas_refill_request.dart @@ -211,83 +211,81 @@ class _UpdateGasRefillRequestState extends State { key: _scaffoldKey, body: Form( key: _formKey, - child: SafeArea( - child: LoadingManager( - isLoading: _isLoading, - isFailedLoading: false, - stateCode: 200, - onRefresh: () async {}, - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - SingleChildScrollView( - padding: const EdgeInsets.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - 8.height, - SingleItemDropDownMenu( - context: context, - title: context.translation.quantity, - backgroundColor: AppColor.neutral100, - showShadow: false, - showAsBottomSheet: true, - initialValue: _deliveredQuantity, - staticData: deliveredQuantity, - onSelect: (value) { - _deliveredQuantity = value; - _currentDetails.deliverdQty = value!.value; - }, - ), - 8.height, - _timerWidget(context, totalWorkingHours), - 8.height, - AppTextFormField( - labelText: context.translation.technicalComment, - textInputType: TextInputType.multiline, - alignLabelWithHint: true, - backgroundColor: AppColor.neutral100, - showShadow: false, - controller: _commentController, - onChange: (value) { - _formModel.techComment = value; - }, - onSaved: (value) {}, - ), - 16.height, - MultiFilesPicker( - label: context.translation.attachFiles, - files: _attachments, - buttonColor: AppColor.black10, - onlyImages: false, - buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), - ), - 8.height, - ], - ).toShadowContainer(context), - ).expanded, - FooterActionButton.footerContainer( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - AppFilledButton( - label: context.translation.save, - buttonColor: AppColor.white60, - textColor: AppColor.black10, - onPressed: () => _onSubmit(context, 0), - ).expanded, - 12.width, - AppFilledButton( - label: context.translation.complete, - buttonColor: AppColor.primary10, - onPressed: () => _onSubmit(context, 1), - ).expanded, - ], - ), + child: LoadingManager( + isLoading: _isLoading, + isFailedLoading: false, + stateCode: 200, + onRefresh: () async {}, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + SingleChildScrollView( + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + 8.height, + SingleItemDropDownMenu( + context: context, + title: context.translation.quantity, + backgroundColor: AppColor.neutral100, + showShadow: false, + showAsBottomSheet: true, + initialValue: _deliveredQuantity, + staticData: deliveredQuantity, + onSelect: (value) { + _deliveredQuantity = value; + _currentDetails.deliverdQty = value!.value; + }, + ), + 8.height, + _timerWidget(context, totalWorkingHours), + 8.height, + AppTextFormField( + labelText: context.translation.technicalComment, + textInputType: TextInputType.multiline, + alignLabelWithHint: true, + backgroundColor: AppColor.neutral100, + showShadow: false, + controller: _commentController, + onChange: (value) { + _formModel.techComment = value; + }, + onSaved: (value) {}, + ), + 16.height, + MultiFilesPicker( + label: context.translation.attachFiles, + files: _attachments, + buttonColor: AppColor.black10, + onlyImages: false, + buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), + ), + 8.height, + ], + ).toShadowContainer(context), + ).expanded, + FooterActionButton.footerContainer( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + AppFilledButton( + label: context.translation.save, + buttonColor: AppColor.white60, + textColor: AppColor.black10, + onPressed: () => _onSubmit(context, 0), + ).expanded, + 12.width, + AppFilledButton( + label: context.translation.complete, + buttonColor: AppColor.primary10, + onPressed: () => _onSubmit(context, 1), + ).expanded, + ], ), - ], - )), - ), + ), + ], + )), ), ).handlePopScope( cxt: context, diff --git a/lib/views/pages/user/profile_page.dart b/lib/views/pages/user/profile_page.dart index 3ba6fa42..af0a89fb 100644 --- a/lib/views/pages/user/profile_page.dart +++ b/lib/views/pages/user/profile_page.dart @@ -177,15 +177,8 @@ class _ProfilePageState extends State { label: "Update Information", buttonColor: AppColor.neutral50, onPressed: () { - showModalBottomSheet( - context: context, - useSafeArea: true, - isScrollControlled: true, - isDismissible: true, - backgroundColor: Colors.transparent, - builder: (context) => SingleChildScrollView( - padding: const EdgeInsets.all(0), - child: UpdateUserContactInfoBottomSheet( + context.showBottomSheet( + UpdateUserContactInfoBottomSheet( _userProvider.user!.userID!, uEmail: _user.email, uPhoneNo: _user.phoneNumber, @@ -198,8 +191,7 @@ class _ProfilePageState extends State { Provider.of(context, listen: false).setUser(_userProvider.user!); }, ), - ).bottomSheetContainer(context), - ); + title: "Update Information"); }, ) ], diff --git a/lib/views/pages/user/update_user_contact_info_bottomsheet.dart b/lib/views/pages/user/update_user_contact_info_bottomsheet.dart index 1f6eb1da..2330a385 100644 --- a/lib/views/pages/user/update_user_contact_info_bottomsheet.dart +++ b/lib/views/pages/user/update_user_contact_info_bottomsheet.dart @@ -48,12 +48,6 @@ class _UpdateUserContactInfoBottomSheetState extends State extends State> setState(() {}); }, ).paddingOnly(top: 16, start: 16, end: 16, bottom: 8), - // TextField( - // onChanged: (queryString) { - // query = queryString; - // setState(() {}); - // }, - // style: const TextStyle(fontSize: 14), - // focusNode: searchFocusNode, - // decoration: InputDecoration( - // hintText: 'Search by name', - // labelText: 'Search', - // hintStyle: const TextStyle(fontSize: 14), - // focusedBorder: OutlineInputBorder( - // borderSide: BorderSide(color: AppColor.blueStatus(context), width: 2.0), - // borderRadius: const BorderRadius.all(Radius.circular(12.0)), - // ), - // enabledBorder: OutlineInputBorder( - // borderSide: BorderSide(color: AppColor.blueStatus(context), width: 1.0), - // borderRadius: const BorderRadius.all(Radius.circular(12.0)), - // ), - // contentPadding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0), - // ), - // ), 8.height, Expanded( child: ListView.builder( @@ -145,14 +124,16 @@ class _SelectionBottomSheetState extends State> ), 8.height, if (_selectedValue != null) - AppFilledButton( - label: context.translation.select, - maxWidth: true, - onPressed: () { - Navigator.pop(context); - widget.onSelect(_selectedValue); - }, - ).paddingAll(16), + FooterActionButton.footerContainer( + child: AppFilledButton( + label: context.translation.select, + maxWidth: true, + onPressed: () { + Navigator.pop(context); + widget.onSelect(_selectedValue); + }, + ), + ), ], ), ); diff --git a/lib/views/widgets/images/multi_image_picker.dart b/lib/views/widgets/images/multi_image_picker.dart index 3608aa5b..3a22dd10 100644 --- a/lib/views/widgets/images/multi_image_picker.dart +++ b/lib/views/widgets/images/multi_image_picker.dart @@ -1,7 +1,6 @@ import 'dart:io'; import 'package:file_picker/file_picker.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:image_picker/image_picker.dart'; @@ -18,12 +17,13 @@ class MultiFilesPicker extends StatefulWidget { final String label; final bool error; final List files; - final List attachment ; + final List attachment; + final bool enabled, onlyImages; double? buttonHeight; Widget? buttonIcon; Color? buttonColor; - final Function(List)? onChange; + final VoidCallback? onChange; final bool showAsGrid; MultiFilesPicker( @@ -51,7 +51,7 @@ class _MultiFilesPickerState extends State { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - if(widget.enabled)...[ + if (widget.enabled) ...[ AppDashedButton( title: widget.label, height: widget.buttonHeight, @@ -60,8 +60,8 @@ class _MultiFilesPickerState extends State { onPressed: (widget.enabled == false) ? () {} : widget.showAsGrid - ? showFileSourceSheet - : onFilePicker), + ? showFileSourceSheet + : onFilePicker), 16.height, ], if (widget.files.isNotEmpty) @@ -80,7 +80,7 @@ class _MultiFilesPickerState extends State { } widget.files.remove(image); if (widget.onChange != null) { - widget.onChange!(widget.files); + widget.onChange!(); } setState(() {}); }, @@ -101,6 +101,7 @@ class _MultiFilesPickerState extends State { if (result != null) { for (var path in result.paths) { widget.files.add(File(path!)); + widget.onChange!(); } setState(() {}); } @@ -151,10 +152,10 @@ class _MultiFilesPickerState extends State { File fileImage = File(pickedFile.path); widget.files.add(fileImage); if (widget.onChange != null) { - widget.onChange!(widget.files); + widget.onChange!(); } setState(() {}); - } + } } Widget gridItem(IconData iconData, String title) { @@ -187,28 +188,26 @@ class _MultiFilesPickerState extends State { ImageSource? source = await showModalBottomSheet( context: context, builder: (BuildContext context) { - Widget listCard({required String icon, required String label, required VoidCallback onTap}){ + Widget listCard({required String icon, required String label, required VoidCallback onTap}) { return GestureDetector( onTap: onTap, child: Container( - constraints: BoxConstraints(minWidth: 111.toScreenWidth,minHeight: 111.toScreenHeight), - padding: EdgeInsets.symmetric(horizontal: 12.toScreenWidth,vertical: 12.toScreenHeight), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - border: Border.all(width: 1,color:AppColor.white70) - ), + constraints: BoxConstraints(minWidth: 111.toScreenWidth, minHeight: 111.toScreenHeight), + padding: EdgeInsets.symmetric(horizontal: 12.toScreenWidth, vertical: 12.toScreenHeight), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), border: Border.all(width: 1, color: AppColor.white70)), child: Column( mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - icon.toSvgAsset(), - 24.height, - label.bodyText2(context).custom(color: AppColor.black20), - ], + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + icon.toSvgAsset(), + 24.height, + label.bodyText2(context).custom(color: AppColor.black20), + ], ), ), ); } + return Container( padding: const EdgeInsets.all(16.0), child: Row( @@ -216,7 +215,7 @@ class _MultiFilesPickerState extends State { children: [ listCard( icon: 'camera_icon', - label: '${context.translation.open}\n${context.translation.camera}', + label: '${context.translation.open}\n${context.translation.camera}', onTap: () { Navigator.of(context).pop(ImageSource.camera); }, @@ -230,7 +229,7 @@ class _MultiFilesPickerState extends State { ), listCard( icon: 'file_icon', - label: '${context.translation.open}\n${context.translation.files}', + label: '${context.translation.open}\n${context.translation.files}', onTap: () async { await fromFilePicker(); Navigator.pop(context); @@ -273,49 +272,41 @@ class _MultiFilesPickerState extends State { if (pickedFile != null) { File fileImage = File(pickedFile.path); - if (fileImage != null) { - widget.files.add(fileImage); - if (widget.onChange != null) { - widget.onChange!(widget.files); - } - setState(() {}); + widget.files.add(fileImage); + if (widget.onChange != null) { + widget.onChange!(); } + setState(() {}); } - - setState(() {}); } } +class AttachmentModel { + int id = 0; + File? file; + AttachmentModel(this.id, this.file); - - -class AttachmentModel { - int id =0; - File ? file; - AttachmentModel(this.id,this.file); - factory AttachmentModel.fromJson(Map json) { return AttachmentModel( json['id'] ?? 0, json['file'] != null ? File(json['file']) : null, ); } - + Map toJson() { return { 'id': id, 'file': file?.path, }; } - - } class AttachmentPicker extends StatefulWidget { final String label; final bool error; - final List attachment ; + final List attachment; + final bool enabled, onlyImages; double? buttonHeight; Widget? buttonIcon; @@ -325,16 +316,16 @@ class AttachmentPicker extends StatefulWidget { AttachmentPicker( {Key? key, - this.attachment = const [], - required this.label, - this.error = false, - this.buttonHeight, - this.buttonIcon, - this.enabled = true, - this.onlyImages = false, - this.onChange, - this.showAsGrid = false, - this.buttonColor}) + this.attachment = const [], + required this.label, + this.error = false, + this.buttonHeight, + this.buttonIcon, + this.enabled = true, + this.onlyImages = false, + this.onChange, + this.showAsGrid = false, + this.buttonColor}) : super(key: key); @override @@ -355,15 +346,15 @@ class _AttachmentPickerState extends State { onPressed: (widget.enabled == false) ? () {} : widget.showAsGrid - ? showFileSourceSheet - : onFilePicker), + ? showFileSourceSheet + : onFilePicker), 16.height, if (widget.attachment.isNotEmpty) Wrap( spacing: 8.toScreenWidth, children: List.generate( widget.attachment.length, - (index) { + (index) { File image = widget.attachment[index].file!; return MultiFilesPickerItem( file: image, @@ -481,16 +472,13 @@ class _AttachmentPickerState extends State { ImageSource? source = await showModalBottomSheet( context: context, builder: (BuildContext context) { - Widget listCard({required String icon, required String label, required VoidCallback onTap}){ + Widget listCard({required String icon, required String label, required VoidCallback onTap}) { return GestureDetector( onTap: onTap, child: Container( - constraints: BoxConstraints(minWidth: 111.toScreenWidth,minHeight: 111.toScreenHeight), - padding: EdgeInsets.symmetric(horizontal: 12.toScreenWidth,vertical: 12.toScreenHeight), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - border: Border.all(width: 1,color:AppColor.white70) - ), + constraints: BoxConstraints(minWidth: 111.toScreenWidth, minHeight: 111.toScreenHeight), + padding: EdgeInsets.symmetric(horizontal: 12.toScreenWidth, vertical: 12.toScreenHeight), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), border: Border.all(width: 1, color: AppColor.white70)), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, @@ -503,6 +491,7 @@ class _AttachmentPickerState extends State { ), ); } + return Container( padding: const EdgeInsets.all(16.0), child: Row( @@ -510,7 +499,7 @@ class _AttachmentPickerState extends State { children: [ listCard( icon: 'camera_icon', - label: '${context.translation.open}\n${context.translation.camera}', + label: '${context.translation.open}\n${context.translation.camera}', onTap: () { Navigator.of(context).pop(ImageSource.camera); }, @@ -524,7 +513,7 @@ class _AttachmentPickerState extends State { ), listCard( icon: 'file_icon', - label: '${context.translation.open}\n${context.translation.files}', + label: '${context.translation.open}\n${context.translation.files}', onTap: () async { await fromFilePicker(); Navigator.pop(context); @@ -572,7 +561,7 @@ class _AttachmentPickerState extends State { widget.onChange!(widget.attachment); } setState(() {}); - } + } setState(() {}); }