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:
amirrezaghabeli
2025-10-12 15:29:54 +03:30
parent 6d674a4a1b
commit 79a0ecd87f
3 changed files with 322 additions and 252 deletions
+18 -4
View File
@@ -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();
},
),
),
),
);