From 663d2a942f339ef41f839bbc564cf5c1797d8981 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 3 May 2021 16:18:00 +0300 Subject: [PATCH] first step from refactoring auth part --- .../get_hospitals_request_model.dart | 48 ++ .../get_hospitals_response_model.dart | 0 lib/core/service/auth_service.dart | 14 - .../service/hospitals/hospitals_service.dart | 23 + lib/core/viewModel/auth_view_model.dart | 72 +-- lib/core/viewModel/hospital_view_model.dart | 32 -- lib/core/viewModel/hospitals_view_model.dart | 27 ++ lib/core/viewModel/imei_view_model.dart | 20 +- lib/locator.dart | 4 + lib/main.dart | 6 +- lib/screens/auth/change_password_screen.dart | 29 -- lib/screens/auth/login_screen.dart | 430 +++++++++++++++++- .../auth/verification_methods_screen.dart | 19 +- lib/screens/home/home_screen.dart | 2 +- .../medicine/medicine_search_screen.dart | 4 +- lib/util/helpers.dart | 1 + lib/widgets/auth/auth_header.dart | 85 ---- lib/widgets/auth/change_password.dart | 159 ------- lib/widgets/auth/known_user_login.dart | 328 ------------- lib/widgets/auth/login_form.dart | 312 ------------- lib/widgets/auth/show_timer_text.dart | 105 ----- lib/widgets/auth/verfiy_account.dart | 386 ---------------- lib/widgets/auth/verification_methods.dart | 47 +- 23 files changed, 562 insertions(+), 1591 deletions(-) create mode 100644 lib/core/model/hospitals/get_hospitals_request_model.dart create mode 100644 lib/core/model/hospitals/get_hospitals_response_model.dart create mode 100644 lib/core/service/hospitals/hospitals_service.dart delete mode 100644 lib/core/viewModel/hospital_view_model.dart create mode 100644 lib/core/viewModel/hospitals_view_model.dart delete mode 100644 lib/screens/auth/change_password_screen.dart delete mode 100644 lib/widgets/auth/change_password.dart delete mode 100644 lib/widgets/auth/known_user_login.dart delete mode 100644 lib/widgets/auth/login_form.dart delete mode 100644 lib/widgets/auth/show_timer_text.dart delete mode 100644 lib/widgets/auth/verfiy_account.dart diff --git a/lib/core/model/hospitals/get_hospitals_request_model.dart b/lib/core/model/hospitals/get_hospitals_request_model.dart new file mode 100644 index 00000000..8a5f1bc1 --- /dev/null +++ b/lib/core/model/hospitals/get_hospitals_request_model.dart @@ -0,0 +1,48 @@ +class GetHospitalsRequestModel { + int languageID; + String stamp; + String iPAdress; + double versionID; + int channel; + String tokenID; + String sessionID; + bool isLoginForDoctorApp; + String memberID; + + GetHospitalsRequestModel( + {this.languageID, + this.stamp, + this.iPAdress, + this.versionID, + this.channel, + this.tokenID, + this.sessionID, + this.isLoginForDoctorApp, + this.memberID}); + + GetHospitalsRequestModel.fromJson(Map json) { + languageID = json['LanguageID']; + stamp = json['stamp']; + iPAdress = json['IPAdress']; + versionID = json['VersionID']; + channel = json['Channel']; + tokenID = json['TokenID']; + sessionID = json['SessionID']; + isLoginForDoctorApp = json['IsLoginForDoctorApp']; + memberID = json['MemberID']; + } + + Map toJson() { + final Map data = new Map(); + data['LanguageID'] = this.languageID; + data['stamp'] = this.stamp; + data['IPAdress'] = this.iPAdress; + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['TokenID'] = this.tokenID; + data['SessionID'] = this.sessionID; + data['IsLoginForDoctorApp'] = this.isLoginForDoctorApp; + data['MemberID'] = this.memberID; + return data; + } +} diff --git a/lib/core/model/hospitals/get_hospitals_response_model.dart b/lib/core/model/hospitals/get_hospitals_response_model.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/core/service/auth_service.dart b/lib/core/service/auth_service.dart index adb2d646..ec56bed7 100644 --- a/lib/core/service/auth_service.dart +++ b/lib/core/service/auth_service.dart @@ -44,19 +44,5 @@ class AuthService extends BaseService { super.error = error; } - // await baseAppClient.post(SELECT_DEVICE_IMEI, - // onSuccess: (dynamic response, int statusCode) { - // _imeiDetails = []; - // response['List_DoctorDeviceDetails'].forEach((v) { - // _imeiDetails.add(GetIMEIDetailsModel.fromJson(v)); - // }); - // }, onFailure: (String error, int statusCode) { - // hasError = true; - // super.error = error; - // }, body: {}); - // } catch (error) { - // hasError = true; - // super.error = error; - // } } } diff --git a/lib/core/service/hospitals/hospitals_service.dart b/lib/core/service/hospitals/hospitals_service.dart new file mode 100644 index 00000000..2c670e09 --- /dev/null +++ b/lib/core/service/hospitals/hospitals_service.dart @@ -0,0 +1,23 @@ +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/model/hospitals/get_hospitals_request_model.dart'; +import 'package:doctor_app_flutter/core/service/base/base_service.dart'; + +class HospitalsService extends BaseService { + +List hospitals; + + Future getHospitals(GetHospitalsRequestModel getHospitalsRequestModel) async { + hasError = false; + await baseAppClient.post( + GET_PROJECTS, + onSuccess: (dynamic response, int statusCode) { + hospitals = response['ProjectInfo']; + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: getHospitalsRequestModel.toJson(), + ); + } +} diff --git a/lib/core/viewModel/auth_view_model.dart b/lib/core/viewModel/auth_view_model.dart index 4e40fe31..48f4661d 100644 --- a/lib/core/viewModel/auth_view_model.dart +++ b/lib/core/viewModel/auth_view_model.dart @@ -56,23 +56,23 @@ class AuthViewModel extends BaseViewModel { } } - Future login(UserModel userInfo) async { - try { - dynamic localRes; - - await baseAppClient.post(LOGIN_URL, - onSuccess: (dynamic response, int statusCode) { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: userInfo.toJson()); - - return Future.value(localRes); - } catch (error) { - print(error); - throw error; - } - } + // Future login(UserModel userInfo) async { + // try { + // dynamic localRes; + // + // await baseAppClient.post(LOGIN_URL, + // onSuccess: (dynamic response, int statusCode) { + // localRes = response; + // }, onFailure: (String error, int statusCode) { + // throw error; + // }, body: userInfo.toJson()); + // + // return Future.value(localRes); + // } catch (error) { + // print(error); + // throw error; + // } + // } Future insertDeviceImei(request) async { var loggedIn = await sharedPref.getObj(LOGGED_IN_USER); @@ -112,22 +112,6 @@ class AuthViewModel extends BaseViewModel { } } - Future sendActivationCodeByOtpNotificationType(activationCodeModel) async { - try { - var localRes; - await baseAppClient.post(SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE, - onSuccess: (dynamic response, int statusCode) { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: activationCodeModel); - return Future.value(localRes); - } catch (error) { - print(error); - throw error; - } - } - Future sendActivationCodeForDoctorApp( ActivationCodeModel activationCodeModel) async { try { @@ -145,28 +129,6 @@ class AuthViewModel extends BaseViewModel { } } - Future memberCheckActivationCodeNew(activationCodeModel) async { - try { - dynamic localRes; - await baseAppClient.post(MEMBER_CHECK_ACTIVATION_CODE_NEW, - onSuccess: (dynamic response, int statusCode) { - localRes = response; - selectedClinicName = - ClinicModel.fromJson(response['List_DoctorsClinic'][0]).clinicName; - - response['List_DoctorsClinic'].forEach((v) { - doctorsClinicList.add(new ClinicModel.fromJson(v)); - }); - }, onFailure: (String error, int statusCode) { - throw error; - }, body: activationCodeModel); - return Future.value(localRes); - } catch (error) { - print(error); - throw error; - } - } - Future checkActivationCodeForDoctorApp( CheckActivationCodeRequestModel checkActivationCodeRequestModel) async { try { diff --git a/lib/core/viewModel/hospital_view_model.dart b/lib/core/viewModel/hospital_view_model.dart deleted file mode 100644 index a49b85e5..00000000 --- a/lib/core/viewModel/hospital_view_model.dart +++ /dev/null @@ -1,32 +0,0 @@ -import 'package:doctor_app_flutter/client/base_app_client.dart'; -import 'package:doctor_app_flutter/config/config.dart'; -import 'package:flutter/cupertino.dart'; - -// TODO change it when change login -class HospitalViewModel with ChangeNotifier { - BaseAppClient baseAppClient = BaseAppClient(); - - Future getProjectsList(memberID) async { - const url = GET_PROJECTS; - // TODO create model or remove it if no info need - var info = { - "LanguageID": 1, - "stamp": "2020-02-26T13:51:44.111Z", - "IPAdress": "11.11.11.11", - "VersionID": 5.8, - "Channel": 9, - "TokenID": "", - "SessionID": "i1UJwCTSqt", - "IsLoginForDoctorApp": true, - "MemberID": memberID - }; - dynamic localRes; - - await baseAppClient.post(url, onSuccess: (response, statusCode) async { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: info); - return Future.value(localRes); - } -} diff --git a/lib/core/viewModel/hospitals_view_model.dart b/lib/core/viewModel/hospitals_view_model.dart new file mode 100644 index 00000000..c0ce1bc4 --- /dev/null +++ b/lib/core/viewModel/hospitals_view_model.dart @@ -0,0 +1,27 @@ +import 'package:doctor_app_flutter/client/base_app_client.dart'; +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/model/hospitals/get_hospitals_request_model.dart'; +import 'package:doctor_app_flutter/core/service/hospitals/hospitals_service.dart'; +import 'package:flutter/cupertino.dart'; + +import '../../locator.dart'; +import 'base_view_model.dart'; + + +class HospitalViewModel extends BaseViewModel { + HospitalsService _hospitalsService = locator(); + // List get imeiDetails => _authService.dashboardItemsList; + // get loginInfo => _authService.loginInfo; + Future getHospitalsList(memberID) async { + GetHospitalsRequestModel getHospitalsRequestModel =GetHospitalsRequestModel(); + getHospitalsRequestModel.memberID = memberID; + setState(ViewState.Busy); + await _hospitalsService.getHospitals(getHospitalsRequestModel); + if (_hospitalsService.hasError) { + error = _hospitalsService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } +} diff --git a/lib/core/viewModel/imei_view_model.dart b/lib/core/viewModel/imei_view_model.dart index c2d16206..ba462553 100644 --- a/lib/core/viewModel/imei_view_model.dart +++ b/lib/core/viewModel/imei_view_model.dart @@ -1,6 +1,8 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/model/hospitals/get_hospitals_request_model.dart'; import 'package:doctor_app_flutter/core/model/imei_details.dart'; import 'package:doctor_app_flutter/core/service/auth_service.dart'; +import 'package:doctor_app_flutter/core/service/hospitals/hospitals_service.dart'; import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; import 'package:doctor_app_flutter/locator.dart'; import 'package:doctor_app_flutter/models/doctor/user_model.dart'; @@ -8,7 +10,10 @@ import 'package:doctor_app_flutter/util/helpers.dart'; class IMEIViewModel extends BaseViewModel { AuthService _authService = locator(); + HospitalsService _hospitalsService = locator(); + List get imeiDetails => _authService.dashboardItemsList; + List get hospitals => _hospitalsService.hospitals; get loginInfo => _authService.loginInfo; Future selectDeviceImei(imei) async { setState(ViewState.Busy); @@ -21,13 +26,24 @@ class IMEIViewModel extends BaseViewModel { } Future login(UserModel userInfo) async { - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _authService.login(userInfo); if (_authService.hasError) { error = _authService.error; - Helpers.showErrorToast(error); setState(ViewState.ErrorLocal); } else setState(ViewState.Idle); } + + Future getHospitalsList(memberID) async { + GetHospitalsRequestModel getHospitalsRequestModel =GetHospitalsRequestModel(); + getHospitalsRequestModel.memberID = memberID; + // setState(ViewState.Busy); + await _hospitalsService.getHospitals(getHospitalsRequestModel); + if (_hospitalsService.hasError) { + error = _hospitalsService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } } diff --git a/lib/locator.dart b/lib/locator.dart index 13b51d95..d0d76ea3 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -6,6 +6,7 @@ import 'package:doctor_app_flutter/core/service/prescription_service.dart'; import 'package:doctor_app_flutter/core/service/procedure_service.dart'; import 'package:doctor_app_flutter/core/service/sickleave_service.dart'; import 'package:doctor_app_flutter/core/viewModel/dashboard_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/hospitals_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/imei_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/medical_file_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; @@ -21,6 +22,7 @@ import 'core/service/PatientMuseService.dart'; import 'core/service/ReferralService.dart'; import 'core/service/SOAP_service.dart'; import 'core/service/doctor_reply_service.dart'; +import 'core/service/hospitals/hospitals_service.dart'; import 'core/service/labs_service.dart'; import 'core/service/medicine_service.dart'; import 'core/service/patient-admission-request-service.dart'; @@ -84,6 +86,7 @@ void setupLocator() { locator.registerLazySingleton(() => DischargedPatientService()); locator.registerLazySingleton(() => PatientInPatientService()); locator.registerLazySingleton(() => OutPatientService()); + locator.registerLazySingleton(() => HospitalsService()); /// View Model locator.registerFactory(() => DoctorReplayViewModel()); @@ -110,4 +113,5 @@ void setupLocator() { locator.registerFactory(() => PrescriptionsViewModel()); locator.registerFactory(() => DischargedPatientViewModel()); locator.registerFactory(() => PatientSearchViewModel()); + locator.registerFactory(() => HospitalViewModel()); } diff --git a/lib/main.dart b/lib/main.dart index 4e140920..83c2a450 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -12,7 +12,7 @@ import './config/size_config.dart'; import './routes.dart'; import 'config/config.dart'; import 'core/viewModel/auth_view_model.dart'; -import 'core/viewModel/hospital_view_model.dart'; +import 'core/viewModel/hospitals_view_model.dart'; import 'locator.dart'; void main() async { @@ -35,8 +35,8 @@ class MyApp extends StatelessWidget { providers: [ ChangeNotifierProvider( create: (context) => AuthViewModel()), - ChangeNotifierProvider( - create: (context) => HospitalViewModel()), + // ChangeNotifierProvider( + // create: (context) => HospitalViewModel()), ChangeNotifierProvider( create: (context) => ProjectViewModel(), ), diff --git a/lib/screens/auth/change_password_screen.dart b/lib/screens/auth/change_password_screen.dart deleted file mode 100644 index 1a502b68..00000000 --- a/lib/screens/auth/change_password_screen.dart +++ /dev/null @@ -1,29 +0,0 @@ -import 'package:doctor_app_flutter/lookups/auth_lookup.dart'; -import 'package:doctor_app_flutter/widgets/auth/auth_header.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; -import 'package:flutter/material.dart'; - -import '../../widgets/auth/change_password.dart'; - -class ChangePasswordScreen extends StatelessWidget { - @override - Widget build(BuildContext context) { - - return AppScaffold( - isShowAppBar: false, - body: SafeArea( - child: ListView(children: [ - Container( - margin: EdgeInsetsDirectional.fromSTEB(30, 0, 0, 0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AuthHeader(loginType.changePassword), - ChangePassword(), - ], - ), - ), - ]), - )); - } -} diff --git a/lib/screens/auth/login_screen.dart b/lib/screens/auth/login_screen.dart index fbba6360..b49b492f 100644 --- a/lib/screens/auth/login_screen.dart +++ b/lib/screens/auth/login_screen.dart @@ -3,22 +3,30 @@ import 'dart:io'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/service/auth_service.dart'; +import 'package:doctor_app_flutter/core/viewModel/hospitals_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/imei_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; +import 'package:doctor_app_flutter/models/doctor/user_model.dart'; import 'package:doctor_app_flutter/screens/auth/verification_methods_screen.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; +import 'package:doctor_app_flutter/widgets/shared/text_fields/app_text_form_field.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; -import 'package:shared_preferences/shared_preferences.dart'; import '../../lookups/auth_lookup.dart'; import '../../util/dr_app_shared_pref.dart'; import '../../widgets/auth/auth_header.dart'; -import '../../widgets/auth/login_form.dart'; import '../../widgets/shared/app_scaffold_widget.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); @@ -29,14 +37,22 @@ class Loginsreen extends StatefulWidget { } class _LoginsreenState extends State { - Future _prefs = SharedPreferences.getInstance(); String platformImei; - // Future platformImeiFuture; final FirebaseMessaging _firebaseMessaging = FirebaseMessaging(); bool _isLoading = true; ProjectViewModel projectViewModel; AuthService authService = AuthService(); + + //TODO change AppTextFormField to AppTextFormFieldCustom + final loginFormKey = GlobalKey(); + var projectIdController = TextEditingController(); + var projectsList = []; + FocusNode focusPass = FocusNode(); + FocusNode focusProject = FocusNode(); + // HospitalViewModel hospitalViewModel; + var userInfo = UserModel(); + @override void initState() { super.initState(); @@ -49,7 +65,7 @@ class _LoginsreenState extends State { _firebaseMessaging.getToken().then((String token) async { if (DEVICE_TOKEN == "" && projectViewModel.isLogin == false) { DEVICE_TOKEN = token; - changeLoadingStata(true); + changeLoadingState(true); authService.selectDeviceImei(DEVICE_TOKEN).then((value) { print(authService.dashboardItemsList); @@ -61,30 +77,18 @@ class _LoginsreenState extends State { password: null, ))); } else { - changeLoadingStata(false); + changeLoadingState(false); } - //changeLoadingStata(false); }); } else { - changeLoadingStata(false); + changeLoadingState(false); } - - // else if (projectViewModel.isLogin) { - // getNotificationCount(token); - // } }).catchError((err) { print(err); }); } -/* - *@author: Elham Rababah - *@Date:19/4/2020 - *@param: isLoading - *@return: - *@desc: Change Isloading attribute in order to show or hide loader - */ - void changeLoadingStata(isLoading) { + void changeLoadingState(isLoading) { setState(() { _isLoading = isLoading; }); @@ -94,9 +98,11 @@ class _LoginsreenState extends State { Widget build(BuildContext context) { projectViewModel = Provider.of(context); + return BaseView( onModelReady: (model) => {}, - builder: (_, model, w) => AppScaffold( + builder: (_, model, w) => + AppScaffold( baseViewModel: model, isShowAppBar: false, backgroundColor: HexColor('#F8F8F8'), @@ -118,15 +124,389 @@ class _LoginsreenState extends State { SizedBox( height: 40, ), - LoginForm( - model: model, - ), + Form( + key: loginFormKey, + child: Column( + mainAxisAlignment: MainAxisAlignment + .spaceBetween, + children: [ + Container( + width: SizeConfig + .realScreenWidth * 0.90, + height: SizeConfig + .realScreenHeight * 0.65, + child: + Column( + crossAxisAlignment: CrossAxisAlignment + .start, children: [ + buildSizedBox(), + Padding( + child: AppText( + TranslationBase + .of(context) + .enterCredentials, + fontSize: 18, + fontWeight: FontWeight + .bold, + ), + padding: EdgeInsets.only( + top: 10, bottom: 10)), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius + .all( + Radius.circular( + 6.0)), + border: Border.all( + width: 1.0, + color: HexColor( + "#CCCCCC"), + ), + color: Colors.white), + child: Column( + crossAxisAlignment: CrossAxisAlignment + .start, + children: [ + Padding( + padding: EdgeInsets + .only( + left: 10, + top: 10), + child: AppText( + TranslationBase + .of(context) + .enterId, + fontWeight: FontWeight + .w800, + fontSize: 14, + )), + AppTextFormField( + labelText: '', + borderColor: Colors + .white, + textInputAction: TextInputAction + .next, + + validator: (value) { + if (value != + null && value + .isEmpty) { + return TranslationBase + .of(context) + .pleaseEnterYourID; + } + return null; + }, + onSaved: (value) { + if (value != + null) setState(() { + userInfo + .userID = + value + .trim(); + }); + }, + onChanged: (value) { + if (value != null) + setState(() { + userInfo + .userID = + value + .trim(); + }); + }, + onFieldSubmitted: ( + _) { + focusPass + .nextFocus(); + }, + ) + ])), + buildSizedBox(), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius + .all( + Radius.circular( + 6.0)), + border: Border.all( + width: 1.0, + color: HexColor( + "#CCCCCC"), + ), + color: Colors.white), + child: Column( + crossAxisAlignment: CrossAxisAlignment + .start, + children: [ + Padding( + padding: EdgeInsets + .only( + left: 10, + top: 10), + child: AppText( + TranslationBase + .of(context) + .enterPassword, + fontWeight: FontWeight + .w800, + fontSize: 14, + )), + AppTextFormField( + focusNode: focusPass, + obscureText: true, + borderColor: Colors + .white, + textInputAction: TextInputAction + .next, + validator: (value) { + if (value != + null && value + .isEmpty) { + return TranslationBase + .of(context) + .pleaseEnterPassword; + } + return null; + }, + onSaved: (value) { + setState(() { + userInfo + .password = + value; + }); + + }, + onChanged: (value){ + setState(() { + userInfo + .password = + value; + }); + }, + onFieldSubmitted: ( + _) { + focusPass + .nextFocus(); + Helpers + .showCupertinoPicker( + context, + projectsList, + 'facilityName', + onSelectProject); + }, + onTap: () { + this.getProjects( + userInfo + .userID, model); + }, + ) + ])), + buildSizedBox(), + projectsList.length > 0 + ? Container( + decoration: BoxDecoration( + borderRadius: BorderRadius + .all( + Radius.circular( + 6.0)), + border: Border.all( + width: 1.0, + color: HexColor( + "#CCCCCC"), + ), + color: Colors.white), + child: Column( + crossAxisAlignment: CrossAxisAlignment + .start, + children: [ + Padding( + padding: EdgeInsets + .only( + left: 10, + top: 10), + child: AppText( + TranslationBase + .of(context) + .selectYourProject, + fontWeight: FontWeight + .w600, + )), + AppTextFormField( + focusNode: focusProject, + controller: projectIdController, + borderColor: Colors + .white, + suffixIcon: Icons + .arrow_drop_down, + onTap: () { + Helpers + .showCupertinoPicker( + context, + projectsList, + 'facilityName', + onSelectProject); + }, + validator: ( + value) { + if (value != + null && + value + .isEmpty) { + return TranslationBase + .of( + context) + .pleaseEnterYourProject; + } + return null; + }) + ])) + : Container( + decoration: BoxDecoration( + borderRadius: BorderRadius + .all( + Radius.circular( + 6.0)), + border: Border.all( + width: 1.0, + color: HexColor( + "#CCCCCC"), + ), + color: Colors.white), + child: Column( + crossAxisAlignment: CrossAxisAlignment + .start, + children: [ + Padding( + padding: EdgeInsets + .only( + left: 10, + top: 10), + child: AppText( + TranslationBase + .of(context) + .selectYourProject, + fontWeight: FontWeight + .w800, + fontSize: 14, + )), + AppTextFormField( + readOnly: true, + borderColor: Colors + .white, + prefix: IconButton( + icon: Icon(Icons + .arrow_drop_down), + iconSize: 30, + padding: EdgeInsets + .only( + bottom: 30), + ), + ) + ])), + ]), + ), + Row( + mainAxisAlignment: MainAxisAlignment + .end, + children: [ + Expanded( + child: AppButton( + title: TranslationBase + .of(context) + .login, + color: HexColor( + '#D02127'), + disabled: userInfo + .userID == null || + userInfo.password == + null, + fontWeight: FontWeight + .bold, + onPressed: () { + login(context, model); + }, + )), + ], + ) + ], + ), + ) ], ) ])) - ]) + ]) : Center(child: AppLoaderWidget()), ), )); } + + SizedBox buildSizedBox() { + return SizedBox( + height: 20, + ); + } + + login(context, + IMEIViewModel model,) async { + if (loginFormKey.currentState.validate()) { + loginFormKey.currentState.save(); + GifLoaderDialogUtils.showMyDialog(context); + sharedPref.setInt(PROJECT_ID, userInfo.projectID); + await model.login(userInfo); + if (model.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(model.error); + } else { + if (model.loginInfo['MessageStatus'] == 1) { + saveObjToString(LOGGED_IN_USER, model.loginInfo); + sharedPref.remove(LAST_LOGIN_USER); + sharedPref.setString(TOKEN, model.loginInfo['LogInTokenID']); + Navigator.of(AppGlobal.CONTEX).pushReplacement(MaterialPageRoute( + builder: (BuildContext context) => + VerificationMethodsScreen( + password: userInfo.password, + ))); + } + } + GifLoaderDialogUtils.hideDialog(context); + } + } + + Future setSharedPref(key, value) async { + sharedPref.setString(key, value).then((success) { + print("sharedPref.setString" + success.toString()); + }); + } + + + saveObjToString(String key, value) async { + sharedPref.setObj(key, value); + } + + onSelectProject(index) { + setState(() { + userInfo.projectID = projectsList[index]["facilityId"]; + projectIdController.text = projectsList[index]['facilityName']; + }); + + primaryFocus.unfocus(); + } + + getProjects(memberID, IMEIViewModel model) { + if (memberID != null && memberID != '') { + if (projectsList.length == 0) { + model.getHospitalsList(memberID).then((res) { + if (res['MessageStatus'] == 1) { + projectsList = res['ProjectInfo']; + setState(() { + userInfo.projectID = projectsList[0]["facilityId"]; + projectIdController.text = projectsList[0]['facilityName']; + }); + } else { + print(res); + } + }); + } + } + } } diff --git a/lib/screens/auth/verification_methods_screen.dart b/lib/screens/auth/verification_methods_screen.dart index 0ad71b76..7503a70e 100644 --- a/lib/screens/auth/verification_methods_screen.dart +++ b/lib/screens/auth/verification_methods_screen.dart @@ -4,13 +4,6 @@ import 'package:hexcolor/hexcolor.dart'; import '../../widgets/auth/verification_methods.dart'; -/* - *@author: Elham Rababah - *@Date:4/7/2020 - *@param: - *@return: - *@desc: Verification Methods screen - */ class VerificationMethodsScreen extends StatefulWidget { const VerificationMethodsScreen({Key key, this.password}) : super(key: key); @@ -24,14 +17,7 @@ class VerificationMethodsScreen extends StatefulWidget { class _VerificationMethodsScreenState extends State { bool _isLoading = false; - /* - *@author: Elham Rababah - *@Date:19/4/2020 - *@param: isLoading - *@return: - *@desc: Change Isloading attribute in order to show or hide loader - */ - void changeLoadingStata(isLoading) { + void changeLoadingState(isLoading) { setState(() { _isLoading = isLoading; }); @@ -50,13 +36,12 @@ class _VerificationMethodsScreenState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - // AuthHeader(loginType.verificationMethods), SizedBox( height: 50, ), VerificationMethods( password: widget.password, - changeLoadingStata: changeLoadingStata, + changeLoadingState: changeLoadingState, ), ], ), diff --git a/lib/screens/home/home_screen.dart b/lib/screens/home/home_screen.dart index fdc4e3df..284fa1ed 100644 --- a/lib/screens/home/home_screen.dart +++ b/lib/screens/home/home_screen.dart @@ -6,7 +6,7 @@ import 'package:doctor_app_flutter/core/enum/patient_type.dart'; import 'package:doctor_app_flutter/core/model/PatientSearchRequestModel.dart'; import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/dashboard_view_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/hospital_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/hospitals_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/models/dashboard/dashboard_model.dart'; diff --git a/lib/screens/medicine/medicine_search_screen.dart b/lib/screens/medicine/medicine_search_screen.dart index 3ce5c1be..f1bb4c7b 100644 --- a/lib/screens/medicine/medicine_search_screen.dart +++ b/lib/screens/medicine/medicine_search_screen.dart @@ -29,9 +29,9 @@ import '../../util/extenstions.dart'; DrAppSharedPreferances sharedPref = DrAppSharedPreferances(); class MedicineSearchScreen extends StatefulWidget with DrAppToastMsg { - MedicineSearchScreen({this.changeLoadingStata}); + MedicineSearchScreen({this.changeLoadingState}); - final Function changeLoadingStata; + final Function changeLoadingState; @override _MedicineSearchState createState() => _MedicineSearchState(); diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index 13b7b2ae..625a31c6 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -128,6 +128,7 @@ class Helpers { } static generateContactAdminMsg([err = null]) { + //TODO: Add translation String localMsg = 'Something wrong happened, please contact the admin'; if (err != null) { localMsg = localMsg + '\n \n' + err.toString(); diff --git a/lib/widgets/auth/auth_header.dart b/lib/widgets/auth/auth_header.dart index f84e9425..47e128be 100644 --- a/lib/widgets/auth/auth_header.dart +++ b/lib/widgets/auth/auth_header.dart @@ -24,18 +24,9 @@ class AuthHeader extends StatelessWidget { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - // Container( - // margin: SizeConfig.isMobile - // ? EdgeInsetsDirectional.fromSTEB( - // 0, SizeConfig.realScreenHeight * 0.03, 0, 0) - // : EdgeInsetsDirectional.fromSTEB( - // SizeConfig.realScreenWidth * 0.13, 0, 0, 0), - // child: buildImageLogo(), - // ), SizedBox( height: 30, ), - //buildTextUnderLogo(context), ], ), Column( @@ -67,78 +58,6 @@ class AuthHeader extends StatelessWidget { return screen; } - Image buildImageLogo() { - String img = 'assets/images/dr_app_logo.png'; - return Image.asset( - img, - fit: BoxFit.cover, - height: SizeConfig.isMobile ? null : SizeConfig.realScreenWidth * 0.09, - ); - } - - Widget buildTextUnderLogo(context) { - Widget finalWid; - double textFontSize = - SizeConfig.isMobile ? 30 : SizeConfig.textMultiplier * 3; - EdgeInsetsDirectional containerMargin; - if (userType == loginType.knownUser || userType == loginType.unknownUser) { - finalWid = Text( - TranslationBase.of(context).login, - style: TextStyle(fontSize: textFontSize, fontWeight: FontWeight.w800), - ); - } else { - String text1; - String text2; - if (userType == loginType.changePassword) { - text1 = 'Change '; - text2 = 'Password!'; - } - if (userType == loginType.verifyPassword) { - text1 = TranslationBase.of(context).verify1; - text2 = TranslationBase.of(context).yourAccount; - } - if (userType == loginType.verificationMethods) { - text1 = TranslationBase.of(context).choose; - text2 = TranslationBase.of(context).verification; - } - List childrens = [ - Text( - text1, - style: TextStyle(fontSize: textFontSize, fontWeight: FontWeight.w800), - ), - Text( - text2, - style: TextStyle( - color: HexColor('#B8382C'), - fontSize: textFontSize, - fontWeight: FontWeight.w800), - ) - ]; - - if (!SizeConfig.isMobile) { - finalWid = Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: childrens, - ); - } else { - finalWid = Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: childrens, - ); - } - } - if (!SizeConfig.isMobile) { - double start = SizeConfig.realScreenWidth * 0.13; - if (loginType.verifyPassword == userType || - loginType.changePassword == userType || - userType == loginType.verificationMethods) { - start = 0; - } - containerMargin = EdgeInsetsDirectional.fromSTEB(start, 0, 0, 0); - } - - return Container(margin: containerMargin, child: finalWid); - } Container buildDrAppContainer(BuildContext context) { if (userType == loginType.changePassword || @@ -147,10 +66,6 @@ class AuthHeader extends StatelessWidget { return Container(); } return Container( - // margin: SizeConfig.isMobile - // ? null - // : EdgeInsetsDirectional.fromSTEB( - // SizeConfig.realScreenWidth * 0.13, 0, 0, 0), child: Text( "Doctor App", style: TextStyle( diff --git a/lib/widgets/auth/change_password.dart b/lib/widgets/auth/change_password.dart deleted file mode 100644 index 3eb9b975..00000000 --- a/lib/widgets/auth/change_password.dart +++ /dev/null @@ -1,159 +0,0 @@ -import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:flutter/material.dart'; -import 'package:hexcolor/hexcolor.dart'; - -class ChangePassword extends StatelessWidget { - final changePassFormKey = GlobalKey(); - var changePassFormValues = { - 'currentPass': null, - 'newPass': null, - 'repeatedPass': null - }; - - @override - Widget build(BuildContext context) { - return Form( - key: changePassFormKey, - child: Container( - width: SizeConfig.realScreenWidth * 0.90, - child: - Column(crossAxisAlignment: CrossAxisAlignment.start, children: < - Widget>[ - buildSizedBox(), - TextFormField( - keyboardType: TextInputType.number, - decoration: InputDecoration( - // ts/images/password_icon.png - prefixIcon: Image.asset('assets/images/password_icon.png'), - hintText: 'Current Password', - hintStyle: - TextStyle(fontSize: 2 * SizeConfig.textMultiplier), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(20)), - borderSide: BorderSide(color: HexColor('#CCCCCC')), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0)), - borderSide: - BorderSide(color: Theme.of(context).primaryColor), - ) - //BorderRadius.all(Radius.circular(20)); - ), - validator: (value) { - if (value.isEmpty) { - return 'Please enter your Current Password'; - } - return null; - }, - onSaved: (value) { - // changePassFormValues. = value; - }, - ), - buildSizedBox(40), - // buildSizedBox(), - Text( - "New Password", - style: TextStyle( - fontSize: 2.8 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w800), - ), - buildSizedBox(10.0), - // Text() - TextFormField( - keyboardType: TextInputType.number, - decoration: InputDecoration( - // ts/images/password_icon.png - prefixIcon: Image.asset('assets/images/password_icon.png'), - hintText: 'New Password', - hintStyle: - TextStyle(fontSize: 2 * SizeConfig.textMultiplier), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(20)), - borderSide: BorderSide(color: HexColor('#CCCCCC')), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0)), - borderSide: - BorderSide(color: Theme.of(context).primaryColor), - ) - //BorderRadius.all(Radius.circular(20)); - ), - validator: (value) { - if (value.isEmpty) { - return 'Please enter your New Password'; - } - return null; - }, - onSaved: (value) { - // userInfo.UserID = value; - }, - ), - buildSizedBox(), - TextFormField( - keyboardType: TextInputType.number, - decoration: InputDecoration( - prefixIcon: Image.asset('assets/images/password_icon.png'), - hintText: 'Repeat Password', - hintStyle: - TextStyle(fontSize: 2 * SizeConfig.textMultiplier), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(20)), - borderSide: BorderSide(color: HexColor('#CCCCCC')), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0)), - borderSide: - BorderSide(color: Theme.of(context).primaryColor), - ) - //BorderRadius.all(Radius.circular(20)); - ), - validator: (value) { - if (value.isEmpty) { - return 'Please enter your Repeat Password'; - } - return null; - }, - onSaved: (value) { - // userInfo.UserID = value; - }, - ), - buildSizedBox(), - RaisedButton( - onPressed:changePass, - elevation: 0.0, - child: Container( - width: double.infinity, - height: 50, - child: Center( - child: Text( - 'Change Password' - .toUpperCase(), - // textAlign: TextAlign.center, - style: TextStyle( - color: Colors.white, - fontSize: 2.5 * SizeConfig.textMultiplier), - ), - ), - ), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - side: BorderSide(width: 0.5, color: HexColor('#CCCCCC'))), - ), - SizedBox( - height: 10, - ), - ]))); - } - - SizedBox buildSizedBox([double height = 20]) { - return SizedBox( - height: height, - ); - } - changePass(){ - if(changePassFormKey.currentState.validate()){ - changePassFormKey.currentState.save(); - // call Api - } - } -} diff --git a/lib/widgets/auth/known_user_login.dart b/lib/widgets/auth/known_user_login.dart deleted file mode 100644 index cbf3c71a..00000000 --- a/lib/widgets/auth/known_user_login.dart +++ /dev/null @@ -1,328 +0,0 @@ -import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:hexcolor/hexcolor.dart'; -import 'package:local_auth/error_codes.dart' as auth_error; -import 'package:local_auth/local_auth.dart'; -import 'package:provider/provider.dart'; -import 'package:shared_preferences/shared_preferences.dart'; - -import '../../config/size_config.dart'; -import '../../core/viewModel/auth_view_model.dart'; -import '../../routes.dart'; -import '../../util/dr_app_shared_pref.dart'; -import '../../util/dr_app_toast_msg.dart'; -import '../../widgets/shared/dr_app_circular_progress_Indeicator.dart'; - -DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); - -class KnownUserLogin extends StatefulWidget { - @override - _KnownUserLoginState createState() => _KnownUserLoginState(); -} - -class _KnownUserLoginState extends State { - Future _prefs = SharedPreferences.getInstance(); - final LocalAuthentication auth = LocalAuthentication(); - - String _authorized = "not Authorized"; - bool _isAuthenticating = false; - Future _loggedUserFuture; - var _loggedUser; - int _loginType = 1; - String _platformImei; - Future _loginTypeFuture; - - Map _loginTypeMap = { - 1: { - "name": "SMS", - 'imageUrl': 'assets/images/verification_sms_lg_icon.png', - }, - 2: { - "name": "FingerPrint", - 'imageUrl': 'assets/images/verification_fingerprint_lg_icon.png' - }, - 3: { - "name": "Face", - 'imageUrl': 'assets/images/verification_faceid_lg_icon.png' - }, - 4: { - "name": "WhatsApp", - 'imageUrl': 'assets/images/verification_whatsapp_lg_icon.png' - } - }; - - Future getSharedPref() async { - sharedPref.getObj(LOGGED_IN_USER).then((userInfo) { - _loggedUser = userInfo; - }); - sharedPref.getString('platformImei').then((imei) { - _platformImei = imei; - }); - } - - @override - void initState() { - super.initState(); - _loggedUserFuture = getSharedPref(); - } - - @override - Widget build(BuildContext context) { - AuthViewModel authProv = Provider.of(context); - // var imeiModel = {'IMEI': _platformImei}; - // _loginTypeFuture = authProv.selectDeviceImei(imeiModel); - return FutureBuilder( - future: Future.wait([_loggedUserFuture, _loginTypeFuture]), - builder: (BuildContext context, AsyncSnapshot snapshot) { - _loginTypeFuture.then((res) { - _loginType = - 2; //res['SELECTDeviceIMEIbyIMEI_List'][0]['LogInType']; - }).catchError((err) { - print('${err}'); - DrAppToastMsg.showErrorToast(err); - }); - switch (snapshot.connectionState) { - case ConnectionState.waiting: - return DrAppCircularProgressIndeicator(); - default: - if (snapshot.hasError) { - DrAppToastMsg.showErrorToast('Error: ${snapshot.error}'); - return Text('Error: ${snapshot.error}'); - } else { - return Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Stack(children: [ - Container( - decoration: BoxDecoration( - border: Border.all( - color: HexColor('#CCCCCC'), - ), - borderRadius: BorderRadius.circular(50)), - margin: const EdgeInsets.fromLTRB(0, 20.0, 30, 0), - child: Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - height: 100, - width: 100, - decoration: new BoxDecoration( - // color: Colors.green, // border color - shape: BoxShape.circle, - border: - Border.all(color: HexColor('#CCCCCC'))), - child: CircleAvatar( - child: Image.asset( - 'assets/images/dr_avatar.png', - fit: BoxFit.cover, - ), - )), - Container( - margin: EdgeInsets.symmetric( - vertical: 3, horizontal: 15), - child: Column( - // mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - _loggedUser['List_MemberInformation'][0] - ['MemberName'], - style: TextStyle( - color: HexColor('515A5D'), - fontSize: - 2.5 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w800), - ), - Text( - 'ENT Spec', - style: TextStyle( - color: HexColor('515A5D'), - fontSize: - 1.5 * SizeConfig.textMultiplier), - ) - ], - ), - ) - ], - ), - ), - Positioned( - top: 7, - right: 70, - child: Image.asset( - 'assets/images/close_icon.png', - fit: BoxFit.cover, - )) - ]), - buildVerificationTypeImageContainer(), - buildButtonsContainer(context) - ], - ); - } - } - }); - } - - Container buildVerificationTypeImageContainer() { - print('${_loginTypeMap[_loginType]}'); - return Container( - height: 200, - width: 200, - child: Center( - child: Image.asset( - _loginTypeMap[_loginType]['imageUrl'], - fit: BoxFit.cover, - ), - )); - } - - // - Container buildButtonsContainer(BuildContext context) { - return Container( - margin: EdgeInsetsDirectional.fromSTEB(0, 0, 30, 0), - width: double.infinity, - child: Column( - children: [ - RaisedButton( - onPressed: _authenticate, - elevation: 0.0, - child: Container( - width: double.infinity, - height: 50, - child: Center( - child: Text( - "Verify using ${_loginTypeMap[_loginType]['name']}" - .toUpperCase(), - // textAlign: TextAlign.center, - style: TextStyle( - color: Colors.white, - fontSize: 2.5 * SizeConfig.textMultiplier), - ), - ), - ), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - side: BorderSide(width: 0.5, color: HexColor('#CCCCCC'))), - ), - SizedBox( - height: 10, - ), - Container( - width: double.infinity, - height: 50, - child: FlatButton( - onPressed: () { - navigateToMoreOption(); - }, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - side: BorderSide( - width: 1, color: Theme.of(context).primaryColor)), - child: Text( - "More verification Options".toUpperCase(), - style: TextStyle( - color: Theme.of(context).primaryColor, - fontSize: 2.5 * SizeConfig.textMultiplier), - )), - ), - SizedBox( - height: 20, - ), - ], - ), - ); - } - - navigateToMoreOption() { - Navigator.of(context).pushNamed(VERIFICATION_METHODS); - } - - _authenticate() { - if (_loginType == 1) { - _authenticateBySMS(); - } - if (_loginType == 2) { - _authenticateByFingerPrint(); - } - if (_loginType == 3) { - _authenticateByFace(); - } - if (_loginType == 4) { - _authenticateByWhatsApp(); - } - } - - Future _authenticateByFingerPrint() async { - _getAvailableBiometrics(); - bool authenticated = false; - try { - setState(() { - _isAuthenticating = true; - _authorized = 'Authenticating'; - }); - authenticated = await auth.authenticateWithBiometrics( - localizedReason: 'Scan your fingerprint to authenticate', - useErrorDialogs: true, - stickyAuth: false); - setState(() { - _isAuthenticating = false; - _authorized = 'Authenticating'; - }); - } on PlatformException catch (e) { - print(e); - } - if (!mounted) return; - - final String message = authenticated ? 'Authorized' : 'Not Authorized'; - if (message == 'Authorized') { - navigateToHome(); - } - setState(() { - print('_authorized' + _authorized); - _authorized = message; - print('_authorized' + _authorized); - }); - } - - Future _authenticateBySMS() { - print('_authenticateBySMS'); - } - - Future _authenticateByFace() { - print('_authenticateByFace'); - } - - Future _authenticateByWhatsApp() { - print('_authenticateByWhatsApp'); - } - - Future _getAvailableBiometrics() async { - List availableBiometrics; - try { - availableBiometrics = await auth.getAvailableBiometrics(); - } on PlatformException catch (e) { - print(e); - if (e.code == auth_error.notAvailable) { - showErorrMsg("Auth Methods Not Available"); - } else if (e.code == auth_error.passcodeNotSet) { - showErorrMsg("Auth Methods Not passcodeNotSet"); - } else if (e.code == auth_error.permanentlyLockedOut) { - showErorrMsg("Auth Methods Not permanentlyLockedOut"); - } - } - if (!mounted) return; - - setState(() { - print('availableBiometrics $availableBiometrics'); - }); - } - - navigateToHome() { - Navigator.of(context).pushReplacementNamed(HOME); - } - - showErorrMsg(localMsg) { - DrAppToastMsg.showErrorToast(localMsg); - } -} diff --git a/lib/widgets/auth/login_form.dart b/lib/widgets/auth/login_form.dart deleted file mode 100644 index a2c200cb..00000000 --- a/lib/widgets/auth/login_form.dart +++ /dev/null @@ -1,312 +0,0 @@ -import 'package:doctor_app_flutter/config/config.dart'; -import 'package:doctor_app_flutter/core/viewModel/imei_view_model.dart'; -import 'package:doctor_app_flutter/screens/auth/verification_methods_screen.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/text_fields/app_text_form_field.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; -import 'package:flutter/services.dart'; -import 'package:hexcolor/hexcolor.dart'; -import 'package:provider/provider.dart'; - -import '../../config/shared_pref_kay.dart'; -import '../../config/size_config.dart'; -import '../../core/viewModel/hospital_view_model.dart'; -import '../../models/doctor/user_model.dart'; -import '../../util/dr_app_shared_pref.dart'; -import '../../util/dr_app_toast_msg.dart'; -import '../../util/helpers.dart'; - -DrAppSharedPreferances sharedPref = DrAppSharedPreferances(); -DrAppToastMsg toastMsg = DrAppToastMsg(); -Helpers helpers = Helpers(); - -class LoginForm extends StatefulWidget with DrAppToastMsg { - LoginForm({this.model}); - - final IMEIViewModel model; - - @override - _LoginFormState createState() => _LoginFormState(); -} - -class _LoginFormState extends State { - final loginFormKey = GlobalKey(); - var projectIdController = TextEditingController(); - var projectsList = []; - FocusNode focusPass = FocusNode(); - FocusNode focusProject = FocusNode(); - HospitalViewModel projectsProv; - var userInfo = UserModel(); - @override - void initState() { - super.initState(); - } - - @override - Widget build(BuildContext context) { - projectsProv = Provider.of(context); - return Form( - key: loginFormKey, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - width: SizeConfig.realScreenWidth * 0.90, - height: SizeConfig.realScreenHeight * 0.65, - child: - Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - buildSizedBox(), - Padding( - child: AppText( - TranslationBase.of(context).enterCredentials, - fontSize: 18, - fontWeight: FontWeight.bold, - ), - padding: EdgeInsets.only(top: 10, bottom: 10)), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"), - ), - color: Colors.white), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(left: 10, top: 10), - child: AppText( - TranslationBase.of(context).enterId, - fontWeight: FontWeight.w800, - fontSize: 14, - )), - AppTextFormField( - labelText: '', - borderColor: Colors.white, - // keyboardType: TextInputType.number, - textInputAction: TextInputAction.next, - - validator: (value) { - if (value != null && value.isEmpty) { - return TranslationBase.of(context) - .pleaseEnterYourID; - } - return null; - }, - onSaved: (value) { - if (value != null) userInfo.userID = value.trim(); - }, - onChanged: (value) { - if (value != null) userInfo.userID = value.trim(); - }, - onFieldSubmitted: (_) { - focusPass.nextFocus(); - }, - ) - ])), - buildSizedBox(), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"), - ), - color: Colors.white), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(left: 10, top: 10), - child: AppText( - TranslationBase.of(context).enterPassword, - fontWeight: FontWeight.w800, - fontSize: 14, - )), - AppTextFormField( - focusNode: focusPass, - obscureText: true, - borderColor: Colors.white, - textInputAction: TextInputAction.next, - validator: (value) { - if (value != null && value.isEmpty) { - return TranslationBase.of(context) - .pleaseEnterPassword; - } - return null; - }, - onSaved: (value) { - userInfo.password = value; - }, - onFieldSubmitted: (_) { - focusPass.nextFocus(); - Helpers.showCupertinoPicker(context, projectsList, - 'facilityName', onSelectProject); - }, - onTap: () { - this.getProjects(userInfo.userID); - }, - ) - ])), - buildSizedBox(), - projectsList.length > 0 - ? Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"), - ), - color: Colors.white), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(left: 10, top: 10), - child: AppText( - TranslationBase.of(context).selectYourProject, - fontWeight: FontWeight.w600, - )), - AppTextFormField( - focusNode: focusProject, - controller: projectIdController, - borderColor: Colors.white, - suffixIcon: Icons.arrow_drop_down, - onTap: () { - Helpers.showCupertinoPicker( - context, - projectsList, - 'facilityName', - onSelectProject); - }, - validator: (value) { - if (value != null && value.isEmpty) { - return TranslationBase.of(context) - .pleaseEnterYourProject; - } - return null; - }) - ])) - : Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"), - ), - color: Colors.white), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(left: 10, top: 10), - child: AppText( - TranslationBase.of(context).selectYourProject, - fontWeight: FontWeight.w800, - fontSize: 14, - )), - AppTextFormField( - readOnly: true, - borderColor: Colors.white, - prefix: IconButton( - icon: Icon(Icons.arrow_drop_down), - iconSize: 30, - padding: EdgeInsets.only(bottom: 30), - ), - ) - ])), - ]), - ), - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Expanded( - child: AppButton( - title: TranslationBase.of(context).login, - color: HexColor('#D02127'), - fontWeight: FontWeight.bold, - onPressed: () { - login(context, this.widget.model); - }, - )), - ], - ) - ], - ), - ); - //)); - } - - SizedBox buildSizedBox() { - return SizedBox( - height: 20, - ); - } - - login( - context, - model, - ) { - if (loginFormKey.currentState.validate()) { - loginFormKey.currentState.save(); - sharedPref.setInt(PROJECT_ID, userInfo.projectID); - model.login(userInfo).then((res) { - if (model.loginInfo['MessageStatus'] == 1) { - saveObjToString(LOGGED_IN_USER, model.loginInfo); - sharedPref.remove(LAST_LOGIN_USER); - sharedPref.setString(TOKEN, model.loginInfo['LogInTokenID']); - Navigator.of(AppGlobal.CONTEX).pushReplacement(MaterialPageRoute( - builder: (BuildContext context) => VerificationMethodsScreen( - password: userInfo.password, - ))); - } - }); - } - } - - Future setSharedPref(key, value) async { - sharedPref.setString(key, value).then((success) { - print("sharedPref.setString" + success.toString()); - }); - } - - getProjectsList(memberID) { - projectsProv.getProjectsList(memberID).then((res) { - if (res['MessageStatus'] == 1) { - projectsList = res['ProjectInfo']; - setState(() { - userInfo.projectID = projectsList[0]["facilityId"]; - projectIdController.text = projectsList[0]['facilityName']; - }); - } else { - print(res); - } - }); - } - - saveObjToString(String key, value) async { - sharedPref.setObj(key, value); - } - - onSelectProject(index) { - setState(() { - userInfo.projectID = projectsList[index]["facilityId"]; - projectIdController.text = projectsList[index]['facilityName']; - }); - - primaryFocus.unfocus(); - } - - getProjects(value) { - if (value != null && value != '') { - if (projectsList.length == 0) { - getProjectsList(value); - } - } - } -} diff --git a/lib/widgets/auth/show_timer_text.dart b/lib/widgets/auth/show_timer_text.dart deleted file mode 100644 index a418e1b5..00000000 --- a/lib/widgets/auth/show_timer_text.dart +++ /dev/null @@ -1,105 +0,0 @@ -import 'dart:async'; - -import 'package:doctor_app_flutter/config/config.dart'; -import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart'; -import 'package:doctor_app_flutter/routes.dart'; -import 'package:doctor_app_flutter/util/helpers.dart'; -import 'package:flutter/material.dart'; -import 'package:hexcolor/hexcolor.dart'; -import 'package:provider/provider.dart'; -Helpers helpers = Helpers(); - -class ShowTimerText extends StatefulWidget { - ShowTimerText({Key key, this.model}); - final model; - - @override - _ShowTimerTextState createState() => _ShowTimerTextState(); -} - -class _ShowTimerTextState extends State { - String timerText = (TIMER_MIN - 1).toString() + ':59'; - int min = TIMER_MIN - 1; - int sec = 59; - Timer _timer; - - AuthViewModel authProv; - - resendCode() { - min = TIMER_MIN - 1; - sec = 59; - _timer = Timer.periodic(Duration(seconds: 1), (Timer timer) { - if (min <= 0 && sec <= 0) { - timer.cancel(); - } else { - setState(() { - sec = sec - 1; - if (sec == 0 && min == 0) { - Navigator.of(context).pushNamed(LOGIN); - - min = 0; - sec = 0; - } else if (sec == 0) { - min = min - 1; - sec = 59; - } - timerText = min.toString() + ':' + sec.toString(); - }); - } - }); - } - - @override - void initState() { - super.initState(); - resendCode(); - } - - @override - void dispose() { - _timer.cancel(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - authProv = Provider.of(context); - return Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - InkWell( - onTap: min != 0 || sec != 0 - ? null - : () { - resendActivatioinCode(); - }, - child: Text( - timerText, - style: TextStyle( - fontSize: 3.0 * SizeConfig.textMultiplier, - color: HexColor('#B8382C'), - fontWeight: FontWeight.bold), - ), - ), - ], - ), - ); - } - - resendActivatioinCode() { - authProv - .sendActivationCodeByOtpNotificationType(widget.model) - .then((res) => { - // print('$value') - if (res['MessageStatus'] == 1) - {resendCode()} - else - {Helpers.showErrorToast(res['ErrorEndUserMessage'])} - }) - .catchError((err) { - Helpers.showErrorToast(); - }); - } -} diff --git a/lib/widgets/auth/verfiy_account.dart b/lib/widgets/auth/verfiy_account.dart deleted file mode 100644 index 1574d3d4..00000000 --- a/lib/widgets/auth/verfiy_account.dart +++ /dev/null @@ -1,386 +0,0 @@ -import 'dart:async'; - -import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; -import 'package:doctor_app_flutter/models/auth/check_activation_code_request_model.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/util/translations_delegate_base.dart'; -import 'package:doctor_app_flutter/widgets/auth/show_timer_text.dart'; -import 'package:flutter/material.dart'; -import 'package:hexcolor/hexcolor.dart'; -import 'package:provider/provider.dart'; - -import '../../config/size_config.dart'; -import '../../core/viewModel/auth_view_model.dart'; -import '../../routes.dart'; -import '../../util/dr_app_shared_pref.dart'; -import '../../util/dr_app_toast_msg.dart'; -import '../../util/helpers.dart'; -import '../../widgets/shared/dr_app_circular_progress_Indeicator.dart'; - -DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); -Helpers helpers = Helpers(); - -class VerifyAccount extends StatefulWidget { - VerifyAccount({this.changeLoadingStata}); - - final Function changeLoadingStata; - - @override - _VerifyAccountState createState() => _VerifyAccountState(); -} - -class _VerifyAccountState extends State { - final verifyAccountForm = GlobalKey(); - Map verifyAccountFormValue = { - 'digit1': null, - 'digit2': null, - 'digit3': null, - 'digit4': null, - }; - Future _loggedUserFuture; - var _loggedUser; - AuthViewModel authProv; - bool _isInit = true; - var model; - TextEditingController digit1 = TextEditingController(text: ""); - TextEditingController digit2 = TextEditingController(text: ""); - TextEditingController digit3 = TextEditingController(text: ""); - TextEditingController digit4 = TextEditingController(text: ""); - - @override - void initState() { - super.initState(); - _loggedUserFuture = getSharedPref(); - } - - Future getSharedPref() async { - sharedPref.getObj(LOGGED_IN_USER).then((userInfo) { - _loggedUser = userInfo; - }); - } - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - if (_isInit) { - authProv = Provider.of(context); - final routeArgs = ModalRoute.of(context).settings.arguments as Map; - model = routeArgs['model']; - } - _isInit = false; - } - - @override - Widget build(BuildContext context) { - authProv = Provider.of(context); - final focusD1 = FocusNode(); - final focusD2 = FocusNode(); - final focusD3 = FocusNode(); - final focusD4 = FocusNode(); - return FutureBuilder( - future: Future.wait([_loggedUserFuture]), - builder: (BuildContext context, AsyncSnapshot snapshot) { - switch (snapshot.connectionState) { - case ConnectionState.waiting: - return DrAppCircularProgressIndeicator(); - default: - if (snapshot.hasError) { - DrAppToastMsg.showErrorToast('Error: ${snapshot.error}'); - return Text('Error: ${snapshot.error}'); - } else { - return Form( - key: verifyAccountForm, - child: Container( - width: SizeConfig.realScreenWidth * 0.95, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - buildSizedBox(30), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceAround, - children: [ - Container( - width: SizeConfig.realScreenWidth * 0.20, - child: TextFormField( - textInputAction: TextInputAction.next, - style: buildTextStyle(), - autofocus: true, - maxLength: 1, - controller: digit1, - textAlign: TextAlign.center, - keyboardType: TextInputType.number, - decoration: buildInputDecoration(context), - onSaved: (val) { - verifyAccountFormValue['digit1'] = val; - }, - validator: validateCodeDigit, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(focusD2); - }, - onChanged: (val) { - if (val.length == 1) { - FocusScope.of(context) - .requestFocus(focusD2); - } - }, - ), - ), - Container( - width: SizeConfig.realScreenWidth * 0.20, - child: TextFormField( - focusNode: focusD2, - controller: digit2, - textInputAction: TextInputAction.next, - maxLength: 1, - textAlign: TextAlign.center, - style: buildTextStyle(), - keyboardType: TextInputType.number, - decoration: - buildInputDecoration(context), - onSaved: (val) { - verifyAccountFormValue['digit2'] = - val; - }, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(focusD3); - }, - onChanged: (val) { - if (val.length == 1) { - FocusScope.of(context) - .requestFocus(focusD3); - } - }, - validator: validateCodeDigit), - ), - Container( - width: SizeConfig.realScreenWidth * 0.20, - child: TextFormField( - focusNode: focusD3, - controller: digit3, - textInputAction: TextInputAction.next, - maxLength: 1, - textAlign: TextAlign.center, - style: buildTextStyle(), - keyboardType: TextInputType.number, - decoration: - buildInputDecoration(context), - onSaved: (val) { - verifyAccountFormValue['digit3'] = - val; - }, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(focusD4); - }, - onChanged: (val) { - if (val.length == 1) { - FocusScope.of(context) - .requestFocus(focusD4); - } - }, - validator: validateCodeDigit)), - Container( - width: SizeConfig.realScreenWidth * 0.20, - child: TextFormField( - focusNode: focusD4, - controller: digit4, - maxLength: 1, - textAlign: TextAlign.center, - style: buildTextStyle(), - keyboardType: TextInputType.number, - decoration: - buildInputDecoration(context), - onSaved: (val) { - verifyAccountFormValue['digit4'] = - val; - }, - validator: validateCodeDigit)) - ], - ), - buildSizedBox(20), - buildText(), - buildSizedBox(40), - RaisedButton( - onPressed: () { - verifyAccount( - authProv, widget.changeLoadingStata); - }, - elevation: 0.0, - child: Container( - width: double.infinity, - height: 50, - child: Center( - child: Text( - TranslationBase.of(context).verify, - style: TextStyle( - color: Colors.white, - fontSize: - 3 * SizeConfig.textMultiplier), - ), - ), - ), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - side: BorderSide( - width: 0.5, - color: HexColor('#CCCCCC'))), - ), - buildSizedBox(20), - ShowTimerText(model: model), - buildSizedBox(10), - ]))); - } - } - }); - } - - TextStyle buildTextStyle() { - return TextStyle( - fontSize: SizeConfig.textMultiplier * 3, - ); - } - - String validateCodeDigit(value) { - if (value.isEmpty) { - return 'Please enter your Password'; - } - - return null; - } - - InputDecoration buildInputDecoration(BuildContext context) { - return InputDecoration( - contentPadding: EdgeInsets.only(top: 30, bottom: 30), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10)), - borderSide: BorderSide(color: Colors.black), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0)), - borderSide: BorderSide(color: Theme.of(context).primaryColor), - ), - errorBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0)), - borderSide: BorderSide(color: Theme.of(context).errorColor), - ), - focusedErrorBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0)), - borderSide: BorderSide(color: Theme.of(context).errorColor), - ), - ); - } - - RichText buildText() { - String medthodName; - switch (model['OTP_SendType']) { - case 1: - medthodName = TranslationBase.of(context).smsBy; - break; - case 2: - medthodName = TranslationBase.of(context).whatsAppBy; - break; - default: - } - var text = RichText( - text: new TextSpan( - style: new TextStyle( - fontSize: 3.0 * SizeConfig.textMultiplier, color: Colors.black), - children: [ - new TextSpan(text: TranslationBase.of(context).youWillReceiveA), - new TextSpan( - text: TranslationBase.of(context).loginCode, - style: TextStyle(fontWeight: FontWeight.w700)), - new TextSpan(text: ' ${medthodName},'), - TextSpan(text: TranslationBase.of(context).pleaseEnterTheCode) - ])); - return text; - } - - SizedBox buildSizedBox([double height = 20]) { - return SizedBox( - height: height, - ); - } - - verifyAccount(AuthViewModel authProv, Function changeLoadingStata) async { - if (verifyAccountForm.currentState.validate()) { - changeLoadingStata(true); - - verifyAccountForm.currentState.save(); - final activationCode = verifyAccountFormValue['digit1'] + - verifyAccountFormValue['digit2'] + - verifyAccountFormValue['digit3'] + - verifyAccountFormValue['digit4']; - - CheckActivationCodeRequestModel checkActivationCodeForDoctorApp = - new CheckActivationCodeRequestModel( - zipCode: _loggedUser['ZipCode'], - mobileNumber: _loggedUser['MobileNumber'], - projectID: await sharedPref.getInt(PROJECT_ID), - logInTokenID: await sharedPref.getString(LOGIN_TOKEN_ID), - activationCode: activationCode, - generalid: "Cs2020@2016\$2958"); - - authProv - .checkActivationCodeForDoctorApp(checkActivationCodeForDoctorApp) - .then((res) async { - if (res['MessageStatus'] == 1) { - sharedPref.setString(TOKEN, res['AuthenticationTokenID']); - if (res['List_DoctorProfile'] != null) { - loginProcessCompleted( - res['List_DoctorProfile'][0], changeLoadingStata); - } else { - ClinicModel clinic = - ClinicModel.fromJson(res['List_DoctorsClinic'][0]); - getDocProfiles(clinic, changeLoadingStata); - } - } else { - changeLoadingStata(false); - Helpers.showErrorToast(res['ErrorEndUserMessage']); - } - }).catchError((err) { - changeLoadingStata(false); - Helpers.showErrorToast(err); - }); - } - } - - loginProcessCompleted( - Map profile, Function changeLoadingStata) { - var doctor = DoctorProfileModel.fromJson(profile); - authProv.setDoctorProfile(doctor); - sharedPref.setObj(DOCTOR_PROFILE, profile); - this.getDashboard(doctor, changeLoadingStata); - } - - getDashboard(doctor, Function changeLoadingStata) { - changeLoadingStata(false); - Navigator.of(context).pushReplacementNamed(HOME); - } - - getDocProfiles(ClinicModel clinicInfo, Function changeLoadingStata) { - ProfileReqModel docInfo = new ProfileReqModel( - doctorID: clinicInfo.doctorID, - clinicID: clinicInfo.clinicID, - license: true, - projectID: clinicInfo.projectID, - tokenID: '', - languageID: 2); - authProv.getDocProfiles(docInfo.toJson()).then((res) { - if (res['MessageStatus'] == 1) { - loginProcessCompleted(res['DoctorProfileList'][0], changeLoadingStata); - } else { - changeLoadingStata(false); - Helpers.showErrorToast(res['ErrorEndUserMessage']); - } - }).catchError((err) { - changeLoadingStata(false); - Helpers.showErrorToast(err); - }); - } -} diff --git a/lib/widgets/auth/verification_methods.dart b/lib/widgets/auth/verification_methods.dart index 48d93f54..91d80a71 100644 --- a/lib/widgets/auth/verification_methods.dart +++ b/lib/widgets/auth/verification_methods.dart @@ -34,18 +34,11 @@ import '../../widgets/shared/dr_app_circular_progress_Indeicator.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); Helpers helpers = Helpers(); -/* - *@author: Elham Rababah - *@Date:4/7/2020 - *@param: - *@return: - *@desc: Verification Methods widget - */ class VerificationMethods extends StatefulWidget { - VerificationMethods({this.changeLoadingStata, this.password}); + VerificationMethods({this.changeLoadingState, this.password}); final password; - final Function changeLoadingStata; + final Function changeLoadingState; @override _VerificationMethodsState createState() => _VerificationMethodsState(); @@ -62,7 +55,6 @@ class _VerificationMethodsState extends State { ProjectViewModel projectsProvider; var isMoreOption = false; var onlySMSBox = false; - static BuildContext _context; var loginTokenID; bool authenticated; @@ -254,11 +246,6 @@ class _VerificationMethodsState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ - // Expanded( - // child: - // getButton(3, authProv)), - // Expanded( - // child: getButton(4, authProv)) Expanded( child: InkWell( onTap: () => { @@ -343,7 +330,7 @@ class _VerificationMethodsState extends State { oTPSendType, AuthViewModel authProv) async { // TODO : build enum for verfication method if (oTPSendType == 1 || oTPSendType == 2) { - widget.changeLoadingStata(true); + widget.changeLoadingState(true); int projectID = await sharedPref.getInt(PROJECT_ID); ActivationCodeModel activationCodeModel = ActivationCodeModel( facilityId: projectID, @@ -371,7 +358,7 @@ class _VerificationMethodsState extends State { } }).catchError((err) { print('$err'); - widget.changeLoadingStata(false); + widget.changeLoadingState(false); Helpers.showErrorToast(); }); @@ -393,9 +380,7 @@ class _VerificationMethodsState extends State { sendActivationCodeVerificationScreen( oTPSendType, AuthViewModel authProv) async { - // TODO : build enum for verfication method - //if (oTPSendType == 1 || oTPSendType == 2) { - widget.changeLoadingStata(true); + widget.changeLoadingState(true); ActivationCodeModel2 activationCodeModel = ActivationCodeModel2( iMEI: user.iMEI, facilityId: user.projectID, @@ -418,7 +403,7 @@ class _VerificationMethodsState extends State { VIDA_REFRESH_TOKEN_ID, res["VidaRefreshTokenID"]); sharedPref.setString(LOGIN_TOKEN_ID, res["LogInTokenID"]); if (oTPSendType == 1 || oTPSendType == 2) { - widget.changeLoadingStata(false); + widget.changeLoadingState(false); this.startSMSService(oTPSendType, authProv); } else { checkActivationCode(authProv); @@ -429,7 +414,7 @@ class _VerificationMethodsState extends State { } }).catchError((err) { print('$err'); - widget.changeLoadingStata(false); + widget.changeLoadingState(false); Helpers.showErrorToast(); }); @@ -557,12 +542,6 @@ class _VerificationMethodsState extends State { } }, child: - // RoundedContainer( - // backgroundColor: checkIfBiometricAvailable(BiometricType.face) - // ? Colors.white - // : Colors.white.withOpacity(.7), - // borderColor: Colors.grey, - // showBorder: false, Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), @@ -601,9 +580,6 @@ class _VerificationMethodsState extends State { }) }, child: Container( - // backgroundColor: Colors.white, - // borderColor: Colors.grey, - // showBorder: false, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.white, @@ -630,7 +606,6 @@ class _VerificationMethodsState extends State { TranslationBase.of(context).moreVerification, fontSize: 14, fontWeight: FontWeight.w600, - // textAlign: TextAlign.center, ) ], ), @@ -743,7 +718,7 @@ class _VerificationMethodsState extends State { this.checkActivationCode(authProv, value: value); }, () => { - widget.changeLoadingStata(false), + widget.changeLoadingState(false), print('Faild..'), }, ).displayDialog(context); @@ -798,7 +773,7 @@ class _VerificationMethodsState extends State { authProv .checkActivationCodeForDoctorApp(checkActivationCodeForDoctorApp) .then((res) async { - widget.changeLoadingStata(false); + widget.changeLoadingState(false); if (res['MessageStatus'] == 1) { sharedPref.setString(TOKEN, res['AuthenticationTokenID']); if (res['List_DoctorProfile'] != null) { @@ -846,11 +821,11 @@ class _VerificationMethodsState extends State { if (res['MessageStatus'] == 1) { loginProcessCompleted(res['DoctorProfileList'][0], authProv); } else { - // changeLoadingStata(false); + // changeLoadingState(false); Helpers.showErrorToast(res['ErrorEndUserMessage']); } }).catchError((err) { - // changeLoadingStata(false); + // changeLoadingState(false); Helpers.showErrorToast(err); }); }