selection replaced to full screen.

design_3.0_task_module_new
Sikander Saleem 4 months ago
parent fb6641f880
commit 46dd66b165

@ -138,7 +138,7 @@ class _ExternalMaintenanceRequestState extends State<ExternalMaintenanceRequest>
hideShadow: true,
backgroundColor: AppColor.neutral100,
date: requestDetailProvider.activityMaintenanceHelperModel?.supplierStartTime,
from:requestDetailProvider.currentWorkOrder?.data?.requestedDate,
from: requestDetailProvider.currentWorkOrder?.data?.requestedDate,
formatDateWithTime: true,
onDatePicker: (selectedDate) {
showTimePicker(

@ -38,7 +38,7 @@ class SingleItemDropDownMenu<T extends Base, X extends LoadingListNotifier> 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<T extends Base, X extends LoadingListNotifier
void openDialog() async {
Widget child = SelectionFullScreenDialog<T>(
// Specify generic type
items: ((X == NullableLoadingProvider) ? widget.staticData : provider?.items as List<T>) ?? [], // Provide default empty list if null
items: ((X == NullableLoadingProvider) ? widget.staticData : provider?.items as List<T>) ?? [],
// 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<T?> pushRouter(Widget child) async {

@ -16,7 +16,7 @@ class SelectionBottomSheet<T> 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<T>();

@ -12,9 +12,11 @@ class SelectionFullScreenDialog<T> extends StatefulWidget {
final List<T>? 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<T>();
@ -44,7 +46,36 @@ class _SelectionBottomSheetState<T> extends State<SelectionFullScreenDialog<T>>
@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<T> extends State<SelectionFullScreenDialog<T>>
label: context.translation.select,
maxWidth: true,
onPressed: () {
Navigator.pop(context, _selectedValue);
Navigator.pop(context);
widget.onSelect(_selectedValue);
},
).paddingAll(16),
],

Loading…
Cancel
Save