|
|
|
@ -1,8 +1,10 @@
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
|
|
import 'package:connectivity/connectivity.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/client/base_app_client.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/config/config.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/doctor/clinic_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/providers/auth_provider.dart';
|
|
|
|
@ -10,6 +12,7 @@ import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/util/helpers.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
Helpers helpers = Helpers();
|
|
|
|
|
|
|
|
|
|
class ProjectProvider with ChangeNotifier {
|
|
|
|
@ -18,12 +21,15 @@ class ProjectProvider with ChangeNotifier {
|
|
|
|
|
String currentLanguage = 'ar';
|
|
|
|
|
bool _isArabic = false;
|
|
|
|
|
bool isInternetConnection = true;
|
|
|
|
|
List<ClinicModel> clinicList = [];
|
|
|
|
|
bool isLoading = false;
|
|
|
|
|
bool isError = false;
|
|
|
|
|
String error = '';
|
|
|
|
|
|
|
|
|
|
Locale get appLocal => _appLocale;
|
|
|
|
|
|
|
|
|
|
bool get isArabic => _isArabic;
|
|
|
|
|
StreamSubscription subscription;
|
|
|
|
|
// AuthProvider authProvider = AuthProvider();
|
|
|
|
|
ProjectProvider() {
|
|
|
|
|
loadSharedPrefLanguage();
|
|
|
|
|
|
|
|
|
@ -66,7 +72,7 @@ class ProjectProvider with ChangeNotifier {
|
|
|
|
|
currentLanguage = 'en';
|
|
|
|
|
sharedPref.setString(APP_Language, 'en');
|
|
|
|
|
}
|
|
|
|
|
getProfile();
|
|
|
|
|
getProfile();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -76,7 +82,29 @@ class ProjectProvider with ChangeNotifier {
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void getProfile()async{
|
|
|
|
|
Future<dynamic> getClinicNames() async {
|
|
|
|
|
try {
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
|
|
|
|
|
await BaseAppClient.post(GET_CLINICS_FOR_DOCTOR,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
clinicList = [];
|
|
|
|
|
response['List_DoctorsClinic'].forEach((v) {
|
|
|
|
|
clinicList.add(new ClinicModel.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
localRes = response;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
throw error;
|
|
|
|
|
}, body: {});
|
|
|
|
|
|
|
|
|
|
return Future.value(localRes);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
print(error);
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void getProfile() async {
|
|
|
|
|
Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
|
|
|
|
|
DoctorProfileModel doctorProfile = new DoctorProfileModel.fromJson(profile);
|
|
|
|
|
ProfileReqModel docInfo = new ProfileReqModel(
|
|
|
|
@ -87,13 +115,12 @@ class ProjectProvider with ChangeNotifier {
|
|
|
|
|
tokenID: '',
|
|
|
|
|
languageID: 2);
|
|
|
|
|
|
|
|
|
|
Provider.of<AuthProvider>(AppGlobal.CONTEX,listen: false)
|
|
|
|
|
.getDocProfiles(docInfo.toJson()).then((res) async {
|
|
|
|
|
Provider.of<AuthProvider>(AppGlobal.CONTEX, listen: false)
|
|
|
|
|
.getDocProfiles(docInfo.toJson())
|
|
|
|
|
.then((res) async {
|
|
|
|
|
sharedPref.setObj(DOCTOR_PROFILE, res['DoctorProfileList'][0]);
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
print(err);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|