From 25d42c4a26ea7ab269a2cff296b07ed9780ad6ba Mon Sep 17 00:00:00 2001 From: Elham Date: Thu, 11 Jun 2020 08:43:00 +0000 Subject: [PATCH] Revert "Merge branch 'elham' into 'master'" This reverts merge request !105 --- lib/client/base_app_client.dart | 8 +-- lib/providers/patients_provider.dart | 2 - lib/screens/auth/login_screen.dart | 2 +- lib/screens/dashboard_screen.dart | 21 +++---- lib/util/dr_app_shared_pref.dart | 14 +---- lib/util/helpers.dart | 36 ++++------- lib/widgets/auth/login_form.dart | 69 +++++++++++---------- lib/widgets/auth/verfiy_account.dart | 33 ++++------ lib/widgets/auth/verification_methods.dart | 3 +- lib/widgets/shared/app_scaffold_widget.dart | 7 ++- 10 files changed, 81 insertions(+), 114 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index d04cfa78..93ca0690 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -7,6 +7,7 @@ import 'package:doctor_app_flutter/routes.dart'; 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:flutter/material.dart'; import 'package:http/http.dart' as http; import 'package:http_interceptor/http_methods.dart'; import 'package:http_interceptor/models/request_data.dart'; @@ -51,7 +52,7 @@ class BaseAppClient { // if (!body.containsKey('ClinicID')) body['ClinicID'] = doctorProfile?.clinicID; } - body['TokenID'] = token?? ''; + body['TokenID'] = token ?? ''; body['LanguageID'] = LANGUAGE_ID; body['stamp'] = STAMP; body['IPAdress'] = IP_ADDRESS; @@ -63,7 +64,7 @@ class BaseAppClient { print("URL : $url"); print("Body : ${json.encode(body)}"); - if (await Helpers.checkConnection()) { + if (await Helpers.checkConnection()) { final response = await http.post(url, body: json.encode(body), headers: { @@ -76,8 +77,7 @@ class BaseAppClient { } else { var parsed = json.decode(response.body.toString()); if (!parsed['IsAuthenticated']) { - await helpers.logout(); - + Navigator.of(AppGlobal.CONTEX).pushNamed(LOGIN); helpers.showErrorToast('Your session expired Please login agian'); } else if (parsed['MessageStatus'] == 1) { onSuccess(parsed, statusCode); diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index 2a626c28..3aebd306 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -13,7 +13,6 @@ import 'package:doctor_app_flutter/models/patient/prescription_res_model.dart'; import 'package:doctor_app_flutter/models/patient/radiology_res_model.dart'; import 'package:doctor_app_flutter/models/patient/refer_to_doctor_request.dart'; import 'package:doctor_app_flutter/models/prescription_report.dart'; -import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:flutter/cupertino.dart'; import '../config/config.dart'; @@ -26,7 +25,6 @@ import '../models/patient/vital_sign_res_model.dart'; import '../util/helpers.dart'; Helpers helpers = Helpers(); -DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); class PatientsProvider with ChangeNotifier { bool isLoading = false; diff --git a/lib/screens/auth/login_screen.dart b/lib/screens/auth/login_screen.dart index 737f42e4..2d43a048 100644 --- a/lib/screens/auth/login_screen.dart +++ b/lib/screens/auth/login_screen.dart @@ -56,7 +56,7 @@ class _LoginsreenState extends State { @override Widget build(BuildContext context) { - + AppGlobal.CONTEX = context; getSharedPref(); return AppScaffold( isLoading: _isLoading, diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index d8e31273..a00471df 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -36,18 +36,13 @@ class _DashboardScreenState extends State { @override Widget build(BuildContext context) { - FocusScopeNode currentFocus = FocusScope.of(context); - - if (!currentFocus.hasPrimaryFocus) { - currentFocus.unfocus(); - } projectsProvider = Provider.of(context); return SafeArea( bottom: true, child: Scaffold( body: SingleChildScrollView( child: SizedBox( - height: MediaQuery.of(context).size.height * 1.09, + height: MediaQuery.of(context).size.height*1.09, // height: MediaQuery.of(context).size.height * 0.2, // width: SizeConfig.screenWidth * 0.9, child: Column( @@ -106,17 +101,16 @@ class _DashboardScreenState extends State { flex: 1, child: Column( crossAxisAlignment: - CrossAxisAlignment.stretch, + CrossAxisAlignment.stretch, children: [ Expanded( child: DashboardItemTexts( - TranslationBase.of(context).arrived, + TranslationBase.of(context).arrived, "23", )), Expanded( child: DashboardItemTexts( - TranslationBase.of(context) - .notArrived, + TranslationBase.of(context).notArrived, "23", ), ), @@ -125,17 +119,18 @@ class _DashboardScreenState extends State { ), Expanded( child: Column( - crossAxisAlignment: + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Expanded( child: DashboardItemTexts( - TranslationBase.of(context).er, + TranslationBase.of(context).er, "23", )), Expanded( child: DashboardItemTexts( - TranslationBase.of(context).walkIn, + + TranslationBase.of(context).walkIn, "23", )), ], diff --git a/lib/util/dr_app_shared_pref.dart b/lib/util/dr_app_shared_pref.dart index 830622e1..f75c171e 100644 --- a/lib/util/dr_app_shared_pref.dart +++ b/lib/util/dr_app_shared_pref.dart @@ -74,22 +74,12 @@ class DrAppSharedPreferances { return prefs.getInt(key); } - getObj(String key) async { + getObj(String key) async{ final SharedPreferences prefs = await _prefs; var string = prefs.getString(key); - if (string == null) { + if (string == null ){ return null; } return json.decode(string); } - - clear() async { - final SharedPreferences prefs = await _prefs; - prefs.clear(); - } - - remove(String key) async { - final SharedPreferences prefs = await _prefs; - prefs.remove(key); - } } diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index ebcf817c..e05f0d74 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -1,16 +1,12 @@ import 'package:doctor_app_flutter/models/list_doctor_working_hours_table_model.dart'; -import 'package:doctor_app_flutter/routes.dart'; -import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:doctor_app_flutter/config/config.dart'; import '../config/size_config.dart'; import '../util/dr_app_toast_msg.dart'; import 'package:connectivity/connectivity.dart'; -DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); /* *@author: Elham Rababah @@ -52,6 +48,10 @@ class Helpers { onPressed: () { Navigator.pop(context); }, + // padding: const EdgeInsets.symmetric( + // horizontal: 16.0, + // vertical: 5.0, + // ), ), CupertinoButton( child: Text( @@ -97,7 +97,7 @@ class Helpers { children: items.map((item) { return Text( '${item["$decKey"]}', - style: TextStyle(fontSize: SizeConfig.textMultiplier * 2), + style: TextStyle(fontSize: SizeConfig.textMultiplier * 3), ); }).toList(), @@ -164,15 +164,14 @@ class Helpers { ), ); } - - /* + /* *@author: Amjad Amireh *@Date:5/5/2020 *@param: checkDate *@return: DateTime *@desc: convert String to DateTime */ - static String checkDate(String dateString) { +static String checkDate(String dateString) { DateTime checkedTime = DateTime.parse(dateString); DateTime currentTime = DateTime.now(); @@ -258,7 +257,6 @@ class Helpers { return "Sunday"; } } - /* *@author: Mohammad Aljammal *@Date:26/5/2020 @@ -277,7 +275,6 @@ class Helpers { else return ""; } - /* *@author: Mohammad Aljammal *@Date:26/5/2020 @@ -304,14 +301,13 @@ class Helpers { *@return: List *@desc: convert workingHours string to List */ - static List getWorkingHours(String workingHours) { - List myWorkingHours = []; + static List getWorkingHours(String workingHours ){ + List myWorkingHours =[]; List listOfHours = workingHours.split('a'); listOfHours.forEach((element) { WorkingHours workingHours = WorkingHours(); - var from = element.substring( - element.indexOf('m ') + 2, element.indexOf('To') - 2); + var from = element.substring(element.indexOf('m ') + 2 , element.indexOf('To')-2); workingHours.from = from.trim(); var to = element.substring(element.indexOf('To') + 2); workingHours.to = to.trim(); @@ -320,6 +316,9 @@ class Helpers { return myWorkingHours; } + + + /* *@author: Elham Rababah *@Date:12/5/2020 @@ -334,13 +333,4 @@ class Helpers { } return localMsg; } - - clearSharedPref() async { - await sharedPref.clear(); - } - - logout() async { - await clearSharedPref(); - Navigator.of(AppGlobal.CONTEX).pushReplacementNamed(LOGIN); - } } diff --git a/lib/widgets/auth/login_form.dart b/lib/widgets/auth/login_form.dart index bfbc5a59..ba6c9a02 100644 --- a/lib/widgets/auth/login_form.dart +++ b/lib/widgets/auth/login_form.dart @@ -54,15 +54,17 @@ class _LoginFormState extends State { void initState() { super.initState(); initPlatformState(); + + } @override void didChangeDependencies() { super.didChangeDependencies(); if (_isInit) { - if (projectsList.length == 0) { - getProjectsList(); - } + if (projectsList.length == 0) { + getProjectsList(); + } } _isInit = false; } @@ -97,9 +99,8 @@ class _LoginFormState extends State { userInfo.UserID = value.trim(); }, onFieldSubmitted: (_) { - FocusScope.of(context).nextFocus(); + FocusScope.of(context).requestFocus(focusPass); }, - autofocus: false, ), buildSizedBox(), TextFormField( @@ -118,7 +119,7 @@ class _LoginFormState extends State { userInfo.Password = value; }, onFieldSubmitted: (_) { - FocusScope.of(context).nextFocus(); + FocusScope.of(context).requestFocus(focusProject); helpers.showCupertinoPicker( context, projectsList, 'Name', onSelectProject); }, @@ -143,8 +144,22 @@ class _LoginFormState extends State { }), buildSizedBox(), Row( - mainAxisAlignment: MainAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Checkbox( + value: true, + activeColor: Theme.of(context).primaryColor, + onChanged: (bool newValue) {}), + Text("Remember me", + style: TextStyle( + fontSize: 2 * SizeConfig.textMultiplier)), + ], + ), + ), RaisedButton( onPressed: () { login(context, authProv, widget.changeLoadingStata); @@ -189,26 +204,17 @@ class _LoginFormState extends State { */ InputDecoration buildInputDecoration(BuildContext context, hint, asset) { return InputDecoration( - prefixIcon: Image.asset(asset), - hintText: hint, - 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), - ), - 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), - ), - ); + prefixIcon: Image.asset(asset), + hintText: hint, + 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), + )); } SizedBox buildSizedBox() { @@ -218,11 +224,6 @@ class _LoginFormState extends State { } login(context, AuthProvider authProv, Function changeLoadingStata) { - FocusScopeNode currentFocus = FocusScope.of(context); - - // if (!currentFocus.hasPrimaryFocus) { - // currentFocus.unfocus(); - // } changeLoadingStata(true); if (loginFormKey.currentState.validate()) { loginFormKey.currentState.save(); @@ -236,7 +237,7 @@ class _LoginFormState extends State { sharedPref.setString(TOKEN, res['LogInTokenID']); print("token" + res['LogInTokenID']); - Navigator.of(context).pushReplacementNamed(VERIFICATION_METHODS); + Navigator.of(context).pushNamed(VERIFICATION_METHODS); } else { // handel error // widget.showCenterShortLoadingToast("watting"); @@ -246,7 +247,7 @@ class _LoginFormState extends State { }).catchError((err) { print('$err'); changeLoadingStata(false); - helpers.showErrorToast(err); + helpers.showErrorToast(); }); } else { changeLoadingStata(false); diff --git a/lib/widgets/auth/verfiy_account.dart b/lib/widgets/auth/verfiy_account.dart index 0448c838..c72b0c10 100644 --- a/lib/widgets/auth/verfiy_account.dart +++ b/lib/widgets/auth/verfiy_account.dart @@ -264,25 +264,16 @@ class _VerifyAccountState extends State { */ InputDecoration buildInputDecoration(BuildContext context) { return InputDecoration( - // ts/images/password_icon.png - 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), - ), - ); + // ts/images/password_icon.png + 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), + )); } /* @@ -331,7 +322,7 @@ class _VerifyAccountState extends State { verifyAccountFormValue['digit4']; print(activationCode); int projectID = await sharedPref.getInt(PROJECT_ID); - Map model = { + Map model = { "activationCode": activationCode, "DoctorID": _loggedUser['DoctorID'], "LogInTokenID": _loggedUser['LogInTokenID'], @@ -390,7 +381,7 @@ class _VerifyAccountState extends State { Map profile, Function changeLoadingStata) { changeLoadingStata(false); sharedPref.setObj(DOCTOR_PROFILE, profile); - Navigator.of(context).pushReplacementNamed(HOME); + Navigator.of(context).pushNamed(HOME); } Future _asyncSimpleDialog( diff --git a/lib/widgets/auth/verification_methods.dart b/lib/widgets/auth/verification_methods.dart index 2b620e10..af72b092 100644 --- a/lib/widgets/auth/verification_methods.dart +++ b/lib/widgets/auth/verification_methods.dart @@ -251,7 +251,6 @@ class _VerificationMethodsState extends State { *@desc: send Activation Code By Otp Notification Type */ sendActivationCodeByOtpNotificationType(oTPSendType, AuthProvider authProv) { - // TODO : build enum for verfication method if (oTPSendType == 1 || oTPSendType == 2) { widget.changeLoadingStata(true); @@ -271,7 +270,7 @@ class _VerificationMethodsState extends State { widget.changeLoadingStata(false); if (res['MessageStatus'] == 1) { - Navigator.of(context).pushReplacementNamed(VERIFY_ACCOUNT, arguments: {'model':model}); + Navigator.of(context).pushNamed(VERIFY_ACCOUNT, arguments: {'model':model}); } else { print(res['ErrorEndUserMessage']); helpers.showErrorToast(res['ErrorEndUserMessage']); diff --git a/lib/widgets/shared/app_scaffold_widget.dart b/lib/widgets/shared/app_scaffold_widget.dart index 5b87dba0..1e6da3fc 100644 --- a/lib/widgets/shared/app_scaffold_widget.dart +++ b/lib/widgets/shared/app_scaffold_widget.dart @@ -1,9 +1,13 @@ -import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/widgets/shared/profile_image_widget.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; +import '../../config/size_config.dart'; +import '../../presentation/doctor_app_icons.dart'; +import '../../widgets/shared/app_drawer_widget.dart'; import '../../widgets/shared/app_loader_widget.dart'; +import '../../widgets/shared/custom_shape_clipper.dart'; class AppScaffold extends StatelessWidget { String appBarTitle; @@ -14,7 +18,6 @@ class AppScaffold extends StatelessWidget { @override Widget build(BuildContext context) { - AppGlobal.CONTEX = context; return Scaffold( backgroundColor: Hexcolor('#F5F5F5'), appBar: appBarTitle != ''