You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.6 KiB
Dart
46 lines
1.6 KiB
Dart
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<AppointmentListModel> myAppointments = [];
|
|
List<FilterListModel> 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<void> getMyAppointments() async {
|
|
isFetchingLists = true;
|
|
myAppointments = await commonRepo.getMyAppointments();
|
|
isFetchingLists = false;
|
|
notifyListeners();
|
|
}
|
|
}
|