Merge branch 'home_screen_parallel' into 'development'

home parallel calling services

See merge request Cloud_Solution/doctor_app_flutter!817
merge-requests/818/merge
Mohammad Aljammal 4 years ago
commit ae190d8802

@ -1,3 +1,5 @@
import 'dart:isolate';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
@ -47,6 +49,21 @@ class BaseViewModel extends ChangeNotifier {
}
}
void getIsolateDoctorProfile(bool isGetProfile) async {
if (isGetProfile) {
Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
if (profile != null) {
doctorProfile = DoctorProfileModel.fromJson(profile);
}
}
if (doctorProfile == null) {
Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
if (profile != null) {
doctorProfile = DoctorProfileModel.fromJson(profile);
}
}
}
setDoctorProfile(DoctorProfileModel doctorProfile) async {
await sharedPref.setObj(DOCTOR_PROFILE, doctorProfile);
this.doctorProfile = doctorProfile;

@ -1,5 +1,3 @@
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/service/home/dasboard_service.dart';
import 'package:doctor_app_flutter/core/service/home/doctor_reply_service.dart';
@ -8,16 +6,17 @@ import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/models/dashboard/dashboard_model.dart';
import 'package:doctor_app_flutter/models/dashboard/get_special_clinical_care_List_Respose_Model.dart';
import 'package:doctor_app_flutter/models/doctor/clinic_model.dart';
import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import '../../locator.dart';
import 'authentication_view_model.dart';
import 'base_view_model.dart';
class DashboardViewModel extends BaseViewModel {
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
DashboardService _dashboardService = locator<DashboardService>();
SpecialClinicsService _specialClinicsService = locator<SpecialClinicsService>();
SpecialClinicsService _specialClinicsService =
locator<SpecialClinicsService>();
DoctorReplyService _doctorReplyService = locator<DoctorReplyService>();
List<DashboardModel> get dashboardItemsList =>
@ -26,17 +25,34 @@ class DashboardViewModel extends BaseViewModel {
bool get hasVirtualClinic => _dashboardService.hasVirtualClinic;
String get sServiceID => _dashboardService.sServiceID;
int get notRepliedCount => _doctorReplyService.notRepliedCount;
List<GetSpecialClinicalCareListResponseModel> get specialClinicalCareList => _specialClinicsService.specialClinicalCareList;
int get notRepliedCount => _doctorReplyService.notRepliedCount;
List<GetSpecialClinicalCareListResponseModel> get specialClinicalCareList =>
_specialClinicsService.specialClinicalCareList;
Future setFirebaseNotification(ProjectViewModel projectsProvider,
Future startHomeScreenServices(ProjectViewModel projectsProvider,
AuthenticationViewModel authProvider) async {
setState(ViewState.Busy);
await projectsProvider.getDoctorClinicsList();
await getDoctorProfile(isGetProfile: true);
final results = await Future.wait([
projectsProvider.getDoctorClinicsList(),
_dashboardService.getDashboard(),
_dashboardService.checkDoctorHasLiveCare(),
_specialClinicsService.getSpecialClinicalCareList(),
]);
// _firebaseMessaging.setAutoInitEnabled(true);
if (_dashboardService.hasError) {
error = _dashboardService.error;
setState(ViewState.Error);
} else
setState(ViewState.Idle);
setFirebaseNotification(authProvider);
}
Future setFirebaseNotification(AuthenticationViewModel authProvider) async {
_firebaseMessaging.requestNotificationPermissions(
const IosNotificationSettings(
sound: true, badge: true, alert: true, provisional: true));
@ -105,20 +121,17 @@ class DashboardViewModel extends BaseViewModel {
return value.toString();
}
GetSpecialClinicalCareListResponseModel getSpecialClinic(clinicId){
GetSpecialClinicalCareListResponseModel special ;
GetSpecialClinicalCareListResponseModel getSpecialClinic(clinicId) {
GetSpecialClinicalCareListResponseModel special;
specialClinicalCareList.forEach((element) {
if(element.clinicID == clinicId){
if (element.clinicID == clinicId) {
special = element;
}
});
return special;
}
Future getNotRepliedCount() async {
setState(ViewState.BusyLocal);
await getDoctorProfile();

@ -66,12 +66,7 @@ class _HomeScreenState extends State<HomeScreen> {
return BaseView<DashboardViewModel>(
onModelReady: (model) async {
await model.setFirebaseNotification(
projectsProvider, authenticationViewModel);
await model.getDashboard();
await model.getDoctorProfile(isGetProfile: true);
await model.checkDoctorHasLiveCare();
await model.getSpecialClinicalCareList();
model.startHomeScreenServices(projectsProvider, authenticationViewModel);
},
builder: (_, model, w) => AppScaffold(
baseViewModel: model,

Loading…
Cancel
Save