|
|
|
|
@ -4,6 +4,7 @@ import 'dart:developer';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:hijri_gregorian_calendar/hijri_gregorian_calendar.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/app_state.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/cache_consts.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/common_models/nationality_country_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/enums.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/loading_utils.dart';
|
|
|
|
|
@ -32,6 +33,7 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
final DialogService _dialogService;
|
|
|
|
|
final NavigationService _navigationService;
|
|
|
|
|
final LocalAuthService _localAuthService;
|
|
|
|
|
|
|
|
|
|
AuthenticationViewModel({
|
|
|
|
|
required AppState appState,
|
|
|
|
|
required AuthenticationRepo authenticationRepo,
|
|
|
|
|
@ -164,9 +166,11 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
Future<void> selectDeviceImei({required Function(dynamic data) onSuccess, Function(String)? onError}) async {
|
|
|
|
|
// LoadingUtils.showFullScreenLoading();
|
|
|
|
|
String firebaseToken = _appState.deviceToken == ""
|
|
|
|
|
? "dOGRRszQQMGe_9wA5Hx3kO:APA91bFV5IcIJXvcCXXk0tc2ddtZgWwCPq7sGSuPr-YW7iiJpQZKgFGN9GAzCVOWL8MfheaP1slE8MdxB7lczdPBGdONQ7WbMmhgHcsUCUktq-hsapGXXqc"
|
|
|
|
|
: _appState.deviceToken;
|
|
|
|
|
// String firebaseToken = _appState.deviceToken;
|
|
|
|
|
String firebaseToken = await Utils.getStringFromPrefs(CacheConst.pushToken);
|
|
|
|
|
// == ""
|
|
|
|
|
// ? "dOGRRszQQMGe_9wA5Hx3kO:APA91bFV5IcIJXvcCXXk0tc2ddtZgWwCPq7sGSuPr-YW7iiJpQZKgFGN9GAzCVOWL8MfheaP1slE8MdxB7lczdPBGdONQ7WbMmhgHcsUCUktq-hsapGXXqc"
|
|
|
|
|
// : _appState.deviceToken;
|
|
|
|
|
final result = await _authenticationRepo.selectDeviceByImei(firebaseToken: firebaseToken);
|
|
|
|
|
|
|
|
|
|
result.fold(
|
|
|
|
|
@ -406,7 +410,6 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
} else {
|
|
|
|
|
if (activation.list != null && activation.list!.isNotEmpty) {
|
|
|
|
|
_appState.setAuthenticatedUser(activation.list!.first);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
_appState.setUserBloodGroup = (activation.patientBlodType ?? "");
|
|
|
|
|
_appState.setAppLoginTokenID = activation.authenticationTokenId;
|
|
|
|
|
@ -512,15 +515,14 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
});
|
|
|
|
|
this.selectedOption = selectedOption;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkLastLoginStatus(Function() onSuccess) async {
|
|
|
|
|
if(_appState.getSelectDeviceByImeiRespModelElement !=null && (_appState.getSelectDeviceByImeiRespModelElement!.logInType ==1 || _appState.getSelectDeviceByImeiRespModelElement!.logInType ==4)){
|
|
|
|
|
if (_appState.getSelectDeviceByImeiRespModelElement != null &&
|
|
|
|
|
(_appState.getSelectDeviceByImeiRespModelElement!.logInType == 1 || _appState.getSelectDeviceByImeiRespModelElement!.logInType == 4)) {
|
|
|
|
|
Future.delayed(Duration(seconds: 1), () {
|
|
|
|
|
onSuccess();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|