|
|
|
|
@ -1,7 +1,8 @@
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
import'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
|
|
|
|
|
|
|
|
|
@ -12,8 +13,10 @@ class SelectionBottomSheet<T> extends StatefulWidget {
|
|
|
|
|
final T? selectedItem; // Now nullable
|
|
|
|
|
final String title;
|
|
|
|
|
final SelectionBuilderString builderString;
|
|
|
|
|
final bool showCancel;
|
|
|
|
|
final Function(T?) onSelect;
|
|
|
|
|
|
|
|
|
|
const SelectionBottomSheet({Key? key, this.items, this.selectedItem, this.title = "", required this.builderString}) : 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>();
|
|
|
|
|
@ -48,7 +51,38 @@ class _SelectionBottomSheetState<T> extends State<SelectionBottomSheet<T>> {
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
widget.title.heading5(context),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
widget.title.heading5(context).expanded,
|
|
|
|
|
if (widget.showCancel)
|
|
|
|
|
AnimatedOpacity(
|
|
|
|
|
opacity: _selectedValue != null ? 1 : 0,
|
|
|
|
|
duration: const Duration(milliseconds: 250),
|
|
|
|
|
child: Container(
|
|
|
|
|
height: 30,
|
|
|
|
|
decoration: BoxDecoration(color: const Color(0xffF63939).withOpacity(.75), borderRadius: BorderRadius.circular(30)),
|
|
|
|
|
padding: const EdgeInsets.only(left: 8, right: 12, 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),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
16.height,
|
|
|
|
|
TextField(
|
|
|
|
|
onChanged: (queryString) {
|
|
|
|
|
@ -103,7 +137,8 @@ class _SelectionBottomSheetState<T> extends State<SelectionBottomSheet<T>> {
|
|
|
|
|
label: context.translation.select,
|
|
|
|
|
maxWidth: true,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.pop(context, _selectedValue);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
widget.onSelect(_selectedValue);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
|