|  |  |  | import 'dart:developer'; | 
					
						
							|  |  |  | import 'dart:io'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import 'package:flutter/material.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/core/api_consts.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/core/app_state.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/core/utils/utils.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/authentication/authentication_repo.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/authentication/models/check_activation_code_request_register.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class AuthenticationViewModel extends ChangeNotifier { | 
					
						
							|  |  |  |   AuthenticationRepo authenticationRepo; | 
					
						
							|  |  |  |   AppState appState; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   AuthenticationViewModel({ | 
					
						
							|  |  |  |     required this.appState, | 
					
						
							|  |  |  |     required this.authenticationRepo, | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   final TextEditingController nationalIdController = TextEditingController(); | 
					
						
							|  |  |  |   final TextEditingController phoneNumberController = TextEditingController(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> selectDeviceImei({ | 
					
						
							|  |  |  |     Function(dynamic)? onSuccess, | 
					
						
							|  |  |  |     Function(String)? onError | 
					
						
							|  |  |  |   }) async { | 
					
						
							|  |  |  |     final String firebaseToken = | 
					
						
							|  |  |  |         "cIkkB7h7Q7uoFkC4Qv82xG:APA91bEb53Z9XzqymCIctaLxCoMX6bm9fuKlWILQ59uUqfwhCoD42AOP1-jWGB1WYd9BVN5PT2pUUFxrT07vcNg1KH9OH39mrPgCl0m21XVIgWrzNnCkufg"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final resultEither = | 
					
						
							|  |  |  |         await authenticationRepo.selectDeviceByImei(firebaseToken: firebaseToken); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     resultEither.fold( | 
					
						
							|  |  |  |       (failure) { | 
					
						
							|  |  |  |         notifyListeners(); | 
					
						
							|  |  |  |         if (onError != null) onError(failure.message); | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       (data) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         log("resultEither: ${data.toString()} "); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         notifyListeners(); | 
					
						
							|  |  |  |         if (onSuccess != null) onSuccess(data); | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |