|
|
|
|
@ -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),
|
|
|
|
|
],
|
|
|
|
|
|