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.
39 lines
1.5 KiB
Dart
39 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:hmg_patient_app_new/core/app_state.dart';
|
|
import 'package:hmg_patient_app_new/features/authentication/authentication_repo.dart';
|
|
import 'package:hmg_patient_app_new/services/dialog_service.dart';
|
|
import 'package:hmg_patient_app_new/services/error_handler_service.dart';
|
|
|
|
class AuthenticationViewModel extends ChangeNotifier {
|
|
AuthenticationRepo authenticationRepo;
|
|
AppState appState;
|
|
ErrorHandlerService errorHandlerService;
|
|
DialogService dialogService;
|
|
|
|
AuthenticationViewModel({
|
|
required this.appState,
|
|
required this.authenticationRepo,
|
|
required this.errorHandlerService,
|
|
required this.dialogService,
|
|
});
|
|
|
|
final TextEditingController nationalIdController = TextEditingController();
|
|
final TextEditingController phoneNumberController = TextEditingController();
|
|
|
|
Future<void> selectDeviceImei({Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
|
String firebaseToken =
|
|
"dOGRRszQQMGe_9wA5Hx3kO:APA91bFV5IcIJXvcCXXk0tc2ddtZgWwCPq7sGSuPr-YW7iiJpQZKgFGN9GAzCVOWL8MfheaP1slE8MdxB7lczdPBGdONQ7WbMmhgHcsUCUktq-hsapGXXqc";
|
|
final result = await authenticationRepo.selectDeviceByImei(firebaseToken: firebaseToken);
|
|
result.fold(
|
|
(failure) async => await errorHandlerService.handleError(failure),
|
|
(apiResponse) {
|
|
if (apiResponse.messageStatus == 2) {
|
|
dialogService.showErrorDialog(apiResponse.errorMessage!);
|
|
} else if (apiResponse.messageStatus == 1) {
|
|
// move to next api call
|
|
}
|
|
},
|
|
);
|
|
}
|
|
}
|