diff --git a/lib/providers/auth_provider.dart b/lib/providers/auth_provider.dart index ae7b4cbe..e7ad409c 100644 --- a/lib/providers/auth_provider.dart +++ b/lib/providers/auth_provider.dart @@ -17,11 +17,17 @@ class AuthProvider with ChangeNotifier { bool isLoading = true; DoctorProfileModel doctorProfile; + setDoctorProfile(DoctorProfileModel profileModel){ + doctorProfile = profileModel; + notifyListeners(); + } + + AuthProvider() { getUserAuthentication(); } - void getUserAuthentication() async { + getUserAuthentication() async { Map profile = await sharedPref.getObj(DOCTOR_PROFILE); if (profile != null) { doctorProfile = new DoctorProfileModel.fromJson(profile); @@ -148,7 +154,7 @@ class AuthProvider with ChangeNotifier { await BaseAppClient.post(GET_DOC_PROFILES, onSuccess: (dynamic response, int statusCode) { localRes = response; - //ClinicDescription + doctorProfile = DoctorProfileModel.fromJson(response['DoctorProfileList'][0]); selectedClinicName = response['DoctorProfileList'][0]['ClinicDescription']; }, onFailure: (String error, int statusCode) { diff --git a/lib/widgets/auth/verfiy_account.dart b/lib/widgets/auth/verfiy_account.dart index f7ccfa5c..8a43a42f 100644 --- a/lib/widgets/auth/verfiy_account.dart +++ b/lib/widgets/auth/verfiy_account.dart @@ -2,6 +2,7 @@ import 'dart:async'; 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/widgets/auth/show_timer_text.dart'; import 'package:flutter/material.dart'; @@ -362,7 +363,7 @@ class _VerifyAccountState extends State { "IsSilentLogIN": false }; - authProv.memberCheckActivationCodeNew(model).then((res) { + authProv.memberCheckActivationCodeNew(model).then((res) async{ if (res['MessageStatus'] == 1) { sharedPref.setString(TOKEN, res['AuthenticationTokenID']); if (res['List_DoctorProfile'] != null) { @@ -393,6 +394,9 @@ class _VerifyAccountState extends State { */ loginProcessCompleted( Map profile, Function changeLoadingStata) { + var doctor = DoctorProfileModel.fromJson(profile); + authProv.setDoctorProfile(doctor); + changeLoadingStata(false); sharedPref.setObj(DOCTOR_PROFILE, profile); Navigator.of(context).pushReplacementNamed(HOME); diff --git a/lib/widgets/shared/app_drawer_widget.dart b/lib/widgets/shared/app_drawer_widget.dart index 6d70aa2d..37c0717c 100644 --- a/lib/widgets/shared/app_drawer_widget.dart +++ b/lib/widgets/shared/app_drawer_widget.dart @@ -1,4 +1,5 @@ import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; +import 'package:doctor_app_flutter/providers/auth_provider.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -28,30 +29,22 @@ class AppDrawer extends StatefulWidget { class _AppDrawerState extends State { bool _isInit = true; - DoctorProfileModel doctorProfile; Helpers helpers = new Helpers(); - @override - void didChangeDependencies() { - super.didChangeDependencies(); - // if (_isInit) { - getDocProfile(); // TODO: Refactor this code to prevent errors in the cosole. - // } - _isInit = false; - } + // @override + // void didChangeDependencies() { + // super.didChangeDependencies(); + // // if (_isInit) { + // getDocProfile(); // TODO: Refactor this code to prevent errors in the cosole. + // // } + // _isInit = false; + // } + - getDocProfile() async { - Map profile = await sharedPref.getObj(DOCTOR_PROFILE); - // doctorProfile = DoctorProfileModel.fromJson(profile); - setState(() { - doctorProfile = DoctorProfileModel.fromJson(profile); - }); - String token = await sharedPref.getString(TOKEN); - } @override Widget build(BuildContext context) { - // var x = getDocProfile(); + AuthProvider authProvider = Provider.of(context); return RoundedContainer( child: Container( color: Colors.white, @@ -82,13 +75,13 @@ class _AppDrawerState extends State { CircleAvatar( radius: SizeConfig.imageSizeMultiplier * 12, backgroundImage: - NetworkImage(doctorProfile.doctorImageURL), + NetworkImage(authProvider.doctorProfile.doctorImageURL), backgroundColor: Colors.white, ), Padding( padding: EdgeInsets.only(top: 10), child: AppText( - doctorProfile.doctorName, + authProvider.doctorProfile?.doctorName, fontWeight: FontWeight.bold, color: Colors.black, fontSize: SizeConfig.textMultiplier * 2, @@ -116,8 +109,8 @@ class _AppDrawerState extends State { onTap: () { //Navigator.of(context).pushNamed(PROFILE); Navigator.of(context).pushNamed(PROFILE, arguments: { - 'title': doctorProfile.doctorName, - "doctorProfileall": doctorProfile + 'title': authProvider.doctorProfile.doctorName, + "doctorProfileall": authProvider.doctorProfile }); }, ), diff --git a/pubspec.lock b/pubspec.lock index 7c695999..9f77f0b9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -35,7 +35,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.1" + version: "2.4.2" barcode_scan: dependency: "direct main" description: @@ -127,6 +127,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "7.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" charcode: dependency: transitive description: @@ -175,7 +182,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.12" + version: "1.14.13" connectivity: dependency: "direct main" description: @@ -253,6 +260,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.1.4" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" fixnum: dependency: transitive description: @@ -357,13 +371,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.4" - image: - dependency: transitive - description: - name: image - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.12" imei_plugin: dependency: "direct main" description: @@ -426,7 +433,7 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.8" meta: dependency: transitive description: @@ -475,7 +482,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" + version: "1.7.0" pedantic: dependency: transitive description: @@ -504,13 +511,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.0" platform: dependency: transitive description: @@ -655,7 +655,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.9.5" stream_channel: dependency: transitive description: @@ -690,7 +690,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.15" + version: "0.2.17" timing: dependency: transitive description: @@ -704,7 +704,7 @@ packages: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.2.0" url_launcher: dependency: "direct main" description: @@ -754,13 +754,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.dartlang.org" - source: hosted - version: "3.6.1" yaml: dependency: transitive description: @@ -769,5 +762,5 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.7.0 <3.0.0" + dart: ">=2.9.0-14.0.dev <3.0.0" flutter: ">=1.12.13+hotfix.5 <2.0.0"