Refactor tender dialogs to utilize ViewModel and improve state management
- Updated `TendersFilterDialog` and `TendersSortDialog` to use a stateful approach, allowing for better management of selected filters and sorting options. - Integrated `TendersViewModel` into both dialogs, enabling direct interaction with the view model for setting date ranges and statuses. - Enhanced the UI to reflect changes in state, ensuring a more responsive user experience when applying filters and sorting. - Updated the `d_tenders_page.dart` to pass the view model and handle filter and sort actions appropriately.
This commit is contained in:
@@ -185,6 +185,7 @@ class _ActionButtons extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final viewModel = context.read<TendersViewModel>();
|
||||
return Container(
|
||||
margin: EdgeInsets.only(top: 25.0.h()),
|
||||
height: 40.0.h(),
|
||||
@@ -203,9 +204,16 @@ class _ActionButtons extends StatelessWidget {
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: const SizedBox(
|
||||
child: SizedBox(
|
||||
width: 560,
|
||||
child: TendersFilterDialog(),
|
||||
child: TendersFilterDialog(
|
||||
viewModel: viewModel,
|
||||
onFilterChanged: (dateRange, status) {
|
||||
viewModel.setDateRange(dateRange);
|
||||
viewModel.setStatus(status!);
|
||||
viewModel.callWithSortAndStatus();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -229,9 +237,15 @@ class _ActionButtons extends StatelessWidget {
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: const SizedBox(
|
||||
child: SizedBox(
|
||||
width: 560,
|
||||
child: TendersSortDialog(),
|
||||
child: TendersSortDialog(
|
||||
viewModel: viewModel,
|
||||
onConfirm: (sort) {
|
||||
viewModel.setSort(sort);
|
||||
viewModel.callWithSortAndStatus();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user