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.
103 lines
3.2 KiB
Dart
103 lines
3.2 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/provider_category_model.dart';
|
|
import 'package:mc_common_app/models/provider_service_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/common_services.dart';
|
|
|
|
class AppointmentsVM extends ChangeNotifier {
|
|
final CommonRepo commonRepo;
|
|
final CommonAppServices commonServices;
|
|
|
|
AppointmentsVM({required this.commonServices, required this.commonRepo});
|
|
|
|
bool isFetchingLists = false;
|
|
|
|
List<AppointmentListModel> myAppointments = [];
|
|
List<FilterListModel> appointmentsFilterOptions = [];
|
|
|
|
bool isFetchingServices = false;
|
|
|
|
List<ProviderCategoryModel> providerCategories = [];
|
|
|
|
bool isHomeTapped = false;
|
|
|
|
void updateIsHomeTapped(bool value) {
|
|
isHomeTapped = value;
|
|
notifyListeners();
|
|
}
|
|
|
|
String pickedHomeLocation = "";
|
|
|
|
void updatePickedHomeLocation(String value) {
|
|
pickedHomeLocation = value;
|
|
notifyListeners();
|
|
}
|
|
|
|
SelectionModel providerCategoryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
void updateProviderCategoryId(SelectionModel id) async {
|
|
providerCategoryId = id;
|
|
await getProviderServices(id.selectedId);
|
|
notifyListeners();
|
|
}
|
|
|
|
List<ProviderServiceModel> providerServices = [];
|
|
|
|
SelectionModel providerServiceId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
|
|
void updateProviderServiceId(SelectionModel id) async {
|
|
providerServiceId = id;
|
|
notifyListeners();
|
|
}
|
|
|
|
void getProviderCategories() async {
|
|
notifyListeners();
|
|
providerCategories = await commonRepo.getProviderServiceCategories();
|
|
notifyListeners();
|
|
}
|
|
|
|
getProviderServices(int categoryId) async {
|
|
providerServiceId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
|
|
isHomeTapped = false;
|
|
pickedHomeLocation = "";
|
|
if (categoryId != -1) {
|
|
isFetchingServices = true;
|
|
notifyListeners();
|
|
providerServices = await commonRepo.getProviderServices(categoryId: categoryId);
|
|
isFetchingServices = false;
|
|
|
|
notifyListeners();
|
|
}
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|