import 'package:flutter/cupertino.dart'; import 'package:mc_common_app/models/appointments_models/appointment_list_model.dart'; import 'package:mc_common_app/models/widgets_models.dart'; import 'package:mc_common_app/repositories/common_repo.dart'; import 'package:mc_common_app/services/services.dart'; class AppointmentsVM extends ChangeNotifier { final CommonRepo commonRepo; final CommonServices commonServices; AppointmentsVM({required this.commonServices, required this.commonRepo}); bool isFetchingLists = false; List myAppointments = []; List appointmentsFilterOptions = []; populateAppointmentsFilterList() { appointmentsFilterOptions.clear(); appointmentsFilterOptions = [ FilterListModel(title: "All Appointments", isSelected: true, id: -1), FilterListModel(title: "Booked", isSelected: false, id: 1), FilterListModel(title: "Confirmed", isSelected: false, id: 2), FilterListModel(title: "Arrived", isSelected: false, id: 3), FilterListModel(title: "Cancelled", isSelected: false, id: 4), ]; notifyListeners(); } applyFilterOnAppointmentsVM({required int index}) { if (appointmentsFilterOptions.isEmpty) return; for (var value in appointmentsFilterOptions) { value.isSelected = false; } appointmentsFilterOptions[index].isSelected = true; notifyListeners(); } Future getMyAppointments() async { isFetchingLists = true; myAppointments = await commonRepo.getMyAppointments(); isFetchingLists = false; notifyListeners(); } }