From 46dd66b165f7b79952d000970620dd73ea9f7590 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Mon, 23 Jun 2025 13:26:00 +0300 Subject: [PATCH] selection replaced to full screen. --- .../components/external_request.dart | 2 +- .../single_item_drop_down_menu.dart | 28 +++++++++----- .../bottom_sheets/selection_bottom_sheet.dart | 2 +- .../selection_fullscreen_dialog.dart | 38 +++++++++++++++++-- 4 files changed, 55 insertions(+), 15 deletions(-) diff --git a/lib/modules/cm_module/views/forms/maintenance_request/components/external_request.dart b/lib/modules/cm_module/views/forms/maintenance_request/components/external_request.dart index 04e492e8..b58c1634 100644 --- a/lib/modules/cm_module/views/forms/maintenance_request/components/external_request.dart +++ b/lib/modules/cm_module/views/forms/maintenance_request/components/external_request.dart @@ -138,7 +138,7 @@ class _ExternalMaintenanceRequestState extends State hideShadow: true, backgroundColor: AppColor.neutral100, date: requestDetailProvider.activityMaintenanceHelperModel?.supplierStartTime, - from:requestDetailProvider.currentWorkOrder?.data?.requestedDate, + from: requestDetailProvider.currentWorkOrder?.data?.requestedDate, formatDateWithTime: true, onDatePicker: (selectedDate) { showTimePicker( diff --git a/lib/new_views/common_widgets/single_item_drop_down_menu.dart b/lib/new_views/common_widgets/single_item_drop_down_menu.dart index 1fb81225..ae83c245 100644 --- a/lib/new_views/common_widgets/single_item_drop_down_menu.dart +++ b/lib/new_views/common_widgets/single_item_drop_down_menu.dart @@ -38,7 +38,7 @@ class SingleItemDropDownMenu exte this.enabled = true, this.height, this.showAsBottomSheet = false, - this.showAsFullScreenDialog = false, + this.showAsFullScreenDialog = true, this.staticData, // Provide a default empty list this.showShadow = true, this.showCancel = false, @@ -218,19 +218,27 @@ class _SingleItemDropDownMenuState( // Specify generic type - items: ((X == NullableLoadingProvider) ? widget.staticData : provider?.items as List) ?? [], // Provide default empty list if null + items: ((X == NullableLoadingProvider) ? widget.staticData : provider?.items as List) ?? [], + // Provide default empty list if null selectedItem: _selectedItem, title: widget.title, + showCancel: widget.showCancel, + onSelect: (selectedT) { + setState(() { + _selectedItem = selectedT; + }); + widget.onSelect!(selectedT); + }, builderString: (emp) => emp?.name ?? "", // Null-aware operator for emp.name ); - - final selectedT = await pushRouter(child); - if (selectedT != null) { - setState(() { - _selectedItem = selectedT; - }); - widget.onSelect!(selectedT); // Non-null assertion after null check - } + pushRouter(child); + // final selectedT = await pushRouter(child); + // if (selectedT != null) { + // setState(() { + // _selectedItem = selectedT; + // }); + // widget.onSelect!(selectedT); // Non-null assertion after null check + // } } Future pushRouter(Widget child) async { diff --git a/lib/views/widgets/bottom_sheets/selection_bottom_sheet.dart b/lib/views/widgets/bottom_sheets/selection_bottom_sheet.dart index a59bef56..8c7561da 100644 --- a/lib/views/widgets/bottom_sheets/selection_bottom_sheet.dart +++ b/lib/views/widgets/bottom_sheets/selection_bottom_sheet.dart @@ -16,7 +16,7 @@ class SelectionBottomSheet extends StatefulWidget { final bool showCancel; final Function(T?) onSelect; - const SelectionBottomSheet({Key? key, this.items, this.selectedItem, this.title = "", required this.builderString, this.showCancel = false,required this.onSelect}) : super(key: key); + const SelectionBottomSheet({Key? key, this.items, this.selectedItem, this.title = "", required this.builderString, this.showCancel = false, required this.onSelect}) : super(key: key); @override _SelectionBottomSheetState createState() => _SelectionBottomSheetState(); diff --git a/lib/views/widgets/fullscreen_dialogs/selection_fullscreen_dialog.dart b/lib/views/widgets/fullscreen_dialogs/selection_fullscreen_dialog.dart index 5cdc5429..5add8626 100644 --- a/lib/views/widgets/fullscreen_dialogs/selection_fullscreen_dialog.dart +++ b/lib/views/widgets/fullscreen_dialogs/selection_fullscreen_dialog.dart @@ -12,9 +12,11 @@ class SelectionFullScreenDialog extends StatefulWidget { final List? items; final T? selectedItem; // Now nullable final String title; + final bool showCancel; final SelectionBuilderString builderString; + final Function(T?) onSelect; - const SelectionFullScreenDialog({Key? key, this.items, this.selectedItem, this.title = "", required this.builderString}) : super(key: key); + const SelectionFullScreenDialog({Key? key, this.items, this.selectedItem, this.title = "", required this.builderString, this.showCancel = false, required this.onSelect}) : super(key: key); @override _SelectionBottomSheetState createState() => _SelectionBottomSheetState(); @@ -44,7 +46,36 @@ class _SelectionBottomSheetState extends State> @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: widget.title.heading5(context)), + appBar: AppBar( + title: widget.title.heading5(context), + actions: [ + if (widget.showCancel) + AnimatedContainer( + height: 24, + duration: const Duration(milliseconds: 250), + margin: const EdgeInsets.only(right: 16), + decoration: BoxDecoration(color: _selectedValue != null ? const Color(0xffF63939).withOpacity(.75) : Colors.grey.withOpacity(.75), borderRadius: BorderRadius.circular(30)), + padding: const EdgeInsets.only(left: 4, right: 8, top: 4, bottom: 4), + alignment: Alignment.center, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon(Icons.clear, color: Colors.white, size: 16), + 4.width, + const Text( + "Clear", + style: TextStyle(fontSize: 14, color: Colors.white), + ) + ], + ).onPress(_selectedValue != null + ? () { + Navigator.pop(context); + widget.onSelect(null); + } + : null), + ), + ], + ), body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -117,7 +148,8 @@ class _SelectionBottomSheetState extends State> label: context.translation.select, maxWidth: true, onPressed: () { - Navigator.pop(context, _selectedValue); + Navigator.pop(context); + widget.onSelect(_selectedValue); }, ).paddingAll(16), ],