From 60a3b12719a6aeb7c8fbd93fd922e07665dca271 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 30 Mar 2020 10:42:47 +0300 Subject: [PATCH 1/7] improve design + add local auth ios --- ios/Runner/Info.plist | 2 ++ lib/widgets/auth/login_form.dart | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 15cf7448..695cf105 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -26,6 +26,8 @@ LaunchScreen UIMainStoryboardFile Main + NSFaceIDUsageDescription + Why is my app authenticating using face id? UISupportedInterfaceOrientations UIInterfaceOrientationPortrait diff --git a/lib/widgets/auth/login_form.dart b/lib/widgets/auth/login_form.dart index f746f609..54e48068 100644 --- a/lib/widgets/auth/login_form.dart +++ b/lib/widgets/auth/login_form.dart @@ -209,14 +209,14 @@ class _LoginFormState extends State { child: Container( padding: const EdgeInsets.all(10.0), height: 50, - width: 140, + width: constraints.maxWidth * 0.30, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text('LOG IN', + Text('LOGIN', style: TextStyle( fontSize: isSmallScreen - ? 20 + ? 15 : constraints.maxWidth * 0.020)), Image.asset('assets/images/login_btn_arrow_icon.png') ], From 47a897a2c94343392d53cfcbb75beddd4edbb572 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 30 Mar 2020 22:04:01 +0300 Subject: [PATCH 2/7] first step form size config --- lib/config/size_config.dart | 47 +++++++++++++++++++++++++++ lib/interceptor/http_interceptor.dart | 4 +-- lib/main.dart | 47 ++++++++++++++++----------- lib/screens/home_screen.dart | 4 +-- lib/widgets/auth/login_form.dart | 36 ++++++++------------ pubspec.lock | 10 +++--- 6 files changed, 98 insertions(+), 50 deletions(-) create mode 100644 lib/config/size_config.dart diff --git a/lib/config/size_config.dart b/lib/config/size_config.dart new file mode 100644 index 00000000..3b443ea7 --- /dev/null +++ b/lib/config/size_config.dart @@ -0,0 +1,47 @@ +import 'package:flutter/cupertino.dart'; + +class SizeConfig { + static double _blockWidth = 0; + static double _blockHeight = 0; + + static double screenWidth; + static double screenHeight; + static double textMultiplier; + static double imageSizeMultiplier; + static double heightMultiplier; + static double widthMultiplier; + + static bool isPortrait = true; + static bool isMobilePortrait = false; + + void init(BoxConstraints constraints, Orientation orientation) { + if (orientation == Orientation.portrait) { + screenHeight = constraints.maxHeight; + screenWidth = constraints.maxWidth; + isPortrait = true; + if (screenWidth < 450) { + isMobilePortrait = true; + } + } else { + screenHeight = constraints.maxWidth; + screenWidth = constraints.maxHeight; + isPortrait = false; + isMobilePortrait = false; + } + + _blockWidth = screenWidth / 100; + _blockHeight = screenHeight / 100; + + textMultiplier = _blockHeight; + imageSizeMultiplier = _blockWidth; + heightMultiplier = _blockHeight; + widthMultiplier = _blockWidth; + + print('textMultiplier $textMultiplier'); + print('imageSizeMultiplier $imageSizeMultiplier'); + print('heightMultiplier$heightMultiplier'); + print('widthMultiplier $widthMultiplier'); + print('isPortrait $isPortrait'); + print('isMobilePortrait $isMobilePortrait'); + } +} diff --git a/lib/interceptor/http_interceptor.dart b/lib/interceptor/http_interceptor.dart index 02e76ea1..997a8c47 100644 --- a/lib/interceptor/http_interceptor.dart +++ b/lib/interceptor/http_interceptor.dart @@ -2,7 +2,7 @@ import 'package:http_interceptor/http_interceptor.dart'; class HttpInterceptor extends InterceptorContract { Future interceptRequest({RequestData data}) async { - print('RequestData ${data.body}'); + // print('RequestData ${data.body}'); try { // data.params['appid'] = OPEN_WEATHER_API_KEY; // data.params['units'] = 'metric'; @@ -17,7 +17,7 @@ class HttpInterceptor extends InterceptorContract { @override Future interceptResponse({ResponseData data}) async { - print('${data.body}'); + // print('ResponseData ${data.body}'); return data; } } \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 119c7816..e752234a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,9 +1,11 @@ -import 'package:doctor_app_flutter/providers/auth_provider.dart'; -import 'package:doctor_app_flutter/providers/patients_provider.dart'; -import 'package:doctor_app_flutter/providers/projects_provider.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; + +import './config/size_config.dart'; +import './providers/auth_provider.dart'; +import './providers/patients_provider.dart'; +import './providers/projects_provider.dart'; import './routes.dart'; void main() => runApp(MyApp()); @@ -12,22 +14,29 @@ class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { - return MultiProvider( - providers: [ - ChangeNotifierProvider.value(value: PatientsProvider()), - ChangeNotifierProvider.value(value: AuthProvider()), - ChangeNotifierProvider.value(value: ProjectsProvider()), - ], - child: MaterialApp( - title: 'Flutter Demo', - theme: ThemeData( - primarySwatch: Colors.blue, - primaryColor: Hexcolor('#B8382C'), - buttonColor: Hexcolor('#B8382C'), - fontFamily: 'WorkSans'), - initialRoute: INIT_ROUTE, - routes: routes, - ), + return LayoutBuilder( + builder: (context, constraints) { + return OrientationBuilder(builder: (context, orientation) { + SizeConfig().init(constraints, orientation); + return MultiProvider( + providers: [ + ChangeNotifierProvider.value(value: PatientsProvider()), + ChangeNotifierProvider.value(value: AuthProvider()), + ChangeNotifierProvider.value(value: ProjectsProvider()), + ], + child: MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + primarySwatch: Colors.blue, + primaryColor: Hexcolor('#B8382C'), + buttonColor: Hexcolor('#B8382C'), + fontFamily: 'WorkSans'), + initialRoute: INIT_ROUTE, + routes: routes, + ), + ); + }); + }, ); } } diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index 47b449f8..704d8be4 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -1,5 +1,5 @@ -import 'package:doctor_app_flutter/lookups/home_items_lookup.dart'; -import 'package:doctor_app_flutter/routes.dart'; +import '../lookups/home_items_lookup.dart'; +import '../routes.dart'; import '../widgets/home/home_item.dart'; import '../widgets/shared/app.drawer.dart'; diff --git a/lib/widgets/auth/login_form.dart b/lib/widgets/auth/login_form.dart index 54e48068..da7c1d2c 100644 --- a/lib/widgets/auth/login_form.dart +++ b/lib/widgets/auth/login_form.dart @@ -1,5 +1,3 @@ -import '../../providers/projects_provider.dart'; -import '../../util/dr_app_toast_msg.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; @@ -7,13 +5,16 @@ import 'package:hexcolor/hexcolor.dart'; import 'package:imei_plugin/imei_plugin.dart'; import 'package:provider/provider.dart'; +import '../../config/size_config.dart'; import '../../models/user_model.dart'; import '../../providers/auth_provider.dart'; +import '../../providers/projects_provider.dart'; import '../../routes.dart'; import '../../util/dr_app_shared_pref.dart'; +import '../../util/dr_app_toast_msg.dart'; DrAppSharedPreferances sharedPref = DrAppSharedPreferances(); -DrAppToastMsg toastMsg = DrAppToastMsg(); +DrAppToastMsg toastMsg = DrAppToastMsg(); class LoginForm extends StatefulWidget with DrAppToastMsg { LoginForm({ @@ -71,9 +72,8 @@ class _LoginFormState extends State { decoration: InputDecoration( prefixIcon: Image.asset('assets/images/user_id_icon.png'), hintText: 'Enter ID', - hintStyle: TextStyle( - fontSize: - isSmallScreen ? 14 : constraints.maxWidth * 0.024), + hintStyle: + TextStyle(fontSize: 2 * SizeConfig.textMultiplier), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(20)), borderSide: BorderSide(color: Hexcolor('#CCCCCC')), @@ -104,10 +104,8 @@ class _LoginFormState extends State { prefixIcon: Image.asset('assets/images/password_icon.png'), hintText: 'Enter Password', - hintStyle: TextStyle( - fontSize: isSmallScreen - ? 14 - : constraints.maxWidth * 0.024), + hintStyle: + TextStyle(fontSize: 2 * SizeConfig.textMultiplier), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(20)), borderSide: BorderSide(color: Hexcolor('#CCCCCC')), @@ -140,10 +138,8 @@ class _LoginFormState extends State { prefixIcon: Image.asset('assets/images/hospital_icon.png'), // hintText: 'Enter Password', - hintStyle: TextStyle( - fontSize: isSmallScreen - ? 14 - : constraints.maxWidth * 0.024), + hintStyle: + TextStyle(fontSize: 2 * SizeConfig.textMultiplier), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(20)), borderSide: BorderSide(color: Hexcolor('#CCCCCC')), @@ -189,9 +185,7 @@ class _LoginFormState extends State { onChanged: (bool newValue) {}), Text("Remember me", style: TextStyle( - fontSize: isSmallScreen - ? 18 - : constraints.maxWidth * 0.018)), + fontSize: 2 * SizeConfig.textMultiplier)), ], ), ), @@ -208,16 +202,14 @@ class _LoginFormState extends State { BorderSide(width: 0.5, color: Hexcolor('#CCCCCC'))), child: Container( padding: const EdgeInsets.all(10.0), - height: 50, + height: 5*SizeConfig.heightMultiplier, width: constraints.maxWidth * 0.30, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('LOGIN', style: TextStyle( - fontSize: isSmallScreen - ? 15 - : constraints.maxWidth * 0.020)), + fontSize: SizeConfig.isMobilePortrait?2*SizeConfig.textMultiplier: 2.3*SizeConfig.textMultiplier)), Image.asset('assets/images/login_btn_arrow_icon.png') ], ), @@ -310,7 +302,7 @@ class _LoginFormState extends State { } Future setSharedPref(key, value) async { - sharedPref.setString(key, value).then(( success) { + sharedPref.setString(key, value).then((success) { print("sharedPref.setString" + success.toString()); }); } diff --git a/pubspec.lock b/pubspec.lock index d1775f85..90ac402c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -70,7 +70,7 @@ packages: name: build_daemon url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "2.1.4" build_modules: dependency: transitive description: @@ -98,7 +98,7 @@ packages: name: build_runner_core url: "https://pub.dartlang.org" source: hosted - version: "4.5.2" + version: "4.5.3" build_web_compilers: dependency: "direct dev" description: @@ -281,7 +281,7 @@ packages: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "3.1.3" + version: "3.1.4" i18n: dependency: "direct main" description: @@ -386,7 +386,7 @@ packages: name: package_config url: "https://pub.dartlang.org" source: hosted - version: "1.9.1" + version: "1.9.3" package_resolver: dependency: transitive description: @@ -449,7 +449,7 @@ packages: name: pub_semver url: "https://pub.dartlang.org" source: hosted - version: "1.4.3" + version: "1.4.4" pubspec_parse: dependency: transitive description: From f75c6376b5712f8535b4887166b61d079ddb3e16 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Tue, 31 Mar 2020 15:54:57 +0300 Subject: [PATCH 3/7] add size config in order to help dev build responsive desing --- lib/config/size_config.dart | 27 ++- lib/widgets/auth/auth_header.dart | 160 +++++++-------- lib/widgets/auth/known_user_login.dart | 155 +++++++------- lib/widgets/auth/login_form.dart | 270 ++++++++++++------------- 4 files changed, 296 insertions(+), 316 deletions(-) diff --git a/lib/config/size_config.dart b/lib/config/size_config.dart index 3b443ea7..b029c89c 100644 --- a/lib/config/size_config.dart +++ b/lib/config/size_config.dart @@ -1,3 +1,4 @@ +import 'package:doctor_app_flutter/config/config.dart'; import 'package:flutter/cupertino.dart'; class SizeConfig { @@ -13,30 +14,36 @@ class SizeConfig { static bool isPortrait = true; static bool isMobilePortrait = false; + static bool isMobile = false; void init(BoxConstraints constraints, Orientation orientation) { + + screenHeight = constraints.maxHeight; + screenWidth = constraints.maxWidth; + + _blockWidth = screenWidth / 100; + _blockHeight = screenHeight / 100; + if(constraints.maxWidth<= MAX_SMALL_SCREEN){ + isMobile = true; + } if (orientation == Orientation.portrait) { - screenHeight = constraints.maxHeight; - screenWidth = constraints.maxWidth; isPortrait = true; if (screenWidth < 450) { isMobilePortrait = true; } + textMultiplier = _blockHeight; + imageSizeMultiplier = _blockWidth; } else { - screenHeight = constraints.maxWidth; - screenWidth = constraints.maxHeight; isPortrait = false; isMobilePortrait = false; + textMultiplier = _blockWidth; + imageSizeMultiplier = _blockHeight; } - - _blockWidth = screenWidth / 100; - _blockHeight = screenHeight / 100; - - textMultiplier = _blockHeight; - imageSizeMultiplier = _blockWidth; heightMultiplier = _blockHeight; widthMultiplier = _blockWidth; + print('screenWidth $screenWidth'); + print('screenHeight $screenHeight'); print('textMultiplier $textMultiplier'); print('imageSizeMultiplier $imageSizeMultiplier'); print('heightMultiplier$heightMultiplier'); diff --git a/lib/widgets/auth/auth_header.dart b/lib/widgets/auth/auth_header.dart index 7c9de094..efd351cf 100644 --- a/lib/widgets/auth/auth_header.dart +++ b/lib/widgets/auth/auth_header.dart @@ -1,7 +1,7 @@ -import 'package:doctor_app_flutter/lookups/auth_lookup.dart'; +import '../../config/size_config.dart'; +import '../../lookups/auth_lookup.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; -import 'package:flutter_device_type/flutter_device_type.dart'; class AuthHeader extends StatelessWidget { var userType; @@ -9,110 +9,106 @@ class AuthHeader extends StatelessWidget { @override Widget build(BuildContext context) { - var smallScreenSize = 660; - return LayoutBuilder(builder: (ctx, constraints) { - bool isSmallScreen = constraints.maxWidth <= smallScreenSize; - var screen = Container( - margin: isSmallScreen - ? null - : EdgeInsetsDirectional.fromSTEB(constraints.maxWidth * 0.30, - constraints.maxWidth * 0.1, 0, 0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - margin: isSmallScreen - ? EdgeInsetsDirectional.fromSTEB(0, 50, 0, 0) - : EdgeInsetsDirectional.fromSTEB( - constraints.maxWidth * 0.13, 0, 0, 0), - child: Image.asset( - 'assets/images/login_icon.png', - fit: BoxFit.cover, - height: - isSmallScreen ? null : constraints.maxWidth * 0.09, - ), + var screen = Container( + margin: SizeConfig.isMobile + ? null + : EdgeInsetsDirectional.fromSTEB(SizeConfig.screenWidth * 0.30, + SizeConfig.screenWidth * 0.1, 0, 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + margin: SizeConfig.isMobile + ? EdgeInsetsDirectional.fromSTEB(0, 50, 0, 0) + : EdgeInsetsDirectional.fromSTEB( + SizeConfig.screenWidth * 0.13, 0, 0, 0), + child: Image.asset( + 'assets/images/login_icon.png', + fit: BoxFit.cover, + height: SizeConfig.isMobile + ? null + : SizeConfig.screenWidth * 0.09, ), - SizedBox( - height: 10, + ), + SizedBox( + height: 10, + ), + Container( + margin: SizeConfig.isMobile + ? null + : EdgeInsetsDirectional.fromSTEB( + SizeConfig.screenWidth * 0.13, 0, 0, 0), + child: Text( + "LOGIN", + style: TextStyle( + fontSize: SizeConfig.isMobile + ? 30 + : SizeConfig.screenWidth * 0.035, + fontWeight: FontWeight.w800), ), - Container( - margin: isSmallScreen - ? null - : EdgeInsetsDirectional.fromSTEB( - constraints.maxWidth * 0.13, 0, 0, 0), - child: Text( - "LOGIN", - style: TextStyle( - fontSize: - isSmallScreen ? 30 : constraints.maxWidth * 0.035, - fontWeight: FontWeight.w800), - ), - ) - ], - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: isSmallScreen - ? [ - SizedBox( - height: 10, - ), - buildWelText(isSmallScreen, constraints), - buildDrSulText(isSmallScreen, constraints, context), - ] - : [ - SizedBox( - height: 10, - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - buildWelText(isSmallScreen, constraints), - buildDrSulText(isSmallScreen, constraints, context), - ], - ), - ], - ), - buildDrAppContainer(isSmallScreen, constraints, context) - ], - )); - return screen; - }); + ) + ], + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: SizeConfig.isMobile + ? [ + SizedBox( + height: 10, + ), + buildWelText(), + buildDrSulText(context), + ] + : [ + SizedBox( + height: 10, + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + buildWelText(), + buildDrSulText(context), + ], + ), + ], + ), + buildDrAppContainer(context) + ], + )); + return screen; } - Container buildDrAppContainer( - bool isSmallScreen, BoxConstraints constraints, BuildContext context) { + Container buildDrAppContainer(BuildContext context) { return Container( - margin: isSmallScreen + margin: SizeConfig.isMobile ? null : EdgeInsetsDirectional.fromSTEB( - constraints.maxWidth * 0.13, 0, 0, 0), + SizeConfig.screenWidth * 0.13, 0, 0, 0), child: Text( "Doctor App", style: TextStyle( - fontSize: isSmallScreen ? 26 : constraints.maxWidth * 0.030, + fontSize: SizeConfig.isMobile ? 26 : SizeConfig.screenWidth * 0.030, fontWeight: FontWeight.w800, color: Theme.of(context).primaryColor), ), ); } - Text buildDrSulText( - bool isSmallScreen, BoxConstraints constraints, BuildContext context) { + Text buildDrSulText(BuildContext context) { return Text( 'Dr Sulaiman Al Habib', style: TextStyle( fontWeight: FontWeight.w800, - fontSize: isSmallScreen ? 24 : constraints.maxWidth * 0.029, + fontSize: SizeConfig.isMobile ? 24 : SizeConfig.screenWidth * 0.029, color: Theme.of(context).primaryColor, ), ); } - Text buildWelText(bool isSmallScreen, BoxConstraints constraints) { + Text buildWelText() { String text = 'Welcome to '; if (userType == loginType.unknownUser) { text = 'Welcome Back to '; @@ -121,7 +117,7 @@ class AuthHeader extends StatelessWidget { return Text( text, style: TextStyle( - fontSize: isSmallScreen ? 24 : constraints.maxWidth * 0.029), + fontSize: SizeConfig.isMobile ? 24 : SizeConfig.screenWidth * 0.029), ); } } diff --git a/lib/widgets/auth/known_user_login.dart b/lib/widgets/auth/known_user_login.dart index c6b2b3c6..9e7f26de 100644 --- a/lib/widgets/auth/known_user_login.dart +++ b/lib/widgets/auth/known_user_login.dart @@ -1,17 +1,18 @@ 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/config.dart'; +import '../../config/size_config.dart'; import '../../providers/auth_provider.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'; -import 'package:local_auth/error_codes.dart' as auth_error; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); DrAppToastMsg toastMsg = DrAppToastMsg(); @@ -88,85 +89,72 @@ class _KnownUserLoginState extends State { if (snapshot.hasError) { return Text('Error: ${snapshot.error}'); } else { - return LayoutBuilder( - builder: (ctx, constraints) { - int maxSmallScreenSize = MAX_SMALL_SCREEN; - bool isSmallScreen = - constraints.maxWidth <= maxSmallScreenSize; - 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: isSmallScreen - ? 24 - : constraints.maxWidth * 0.029, - fontWeight: FontWeight.w800), - ), - Text( - 'ENT Spec', - style: TextStyle( - color: Hexcolor('515A5D'), - fontSize: isSmallScreen - ? 20 - : constraints.maxWidth * 0.025), - ) - ], - ), - ) - ], + return Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Stack(children: [ + Container( + decoration: BoxDecoration( + border: Border.all( + color: Hexcolor('#CCCCCC'), ), - ), - Positioned( - top: 7, - right: 70, - child: Image.asset( - 'assets/images/close_icon.png', - fit: BoxFit.cover, - )) - ]), - buildVerificationTypeImageContainer(), - buildButtonsContainer( - isSmallScreen, constraints, context) - ], - ); - }, + 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) + ], ); } } @@ -187,8 +175,7 @@ class _KnownUserLoginState extends State { } // - Container buildButtonsContainer( - bool isSmallScreen, BoxConstraints constraints, BuildContext context) { + Container buildButtonsContainer(BuildContext context) { return Container( margin: EdgeInsetsDirectional.fromSTEB(0, 0, 30, 0), width: double.infinity, @@ -207,8 +194,7 @@ class _KnownUserLoginState extends State { // textAlign: TextAlign.center, style: TextStyle( color: Colors.white, - fontSize: - isSmallScreen ? 20 : constraints.maxWidth * 0.029), + fontSize: 2.5 *SizeConfig.textMultiplier), ), ), ), @@ -234,8 +220,7 @@ class _KnownUserLoginState extends State { "More verification Options".toUpperCase(), style: TextStyle( color: Theme.of(context).primaryColor, - fontSize: - isSmallScreen ? 20 : constraints.maxWidth * 0.029), + fontSize: 2.5 *SizeConfig.textMultiplier), )), ), SizedBox( diff --git a/lib/widgets/auth/login_form.dart b/lib/widgets/auth/login_form.dart index da7c1d2c..ae2bf55b 100644 --- a/lib/widgets/auth/login_form.dart +++ b/lib/widgets/auth/login_form.dart @@ -54,24 +54,47 @@ class _LoginFormState extends State { } AuthProvider authProv = Provider.of(context); - return LayoutBuilder(builder: (ctx, constraints) { - var smallScreenSize = 660; - bool isSmallScreen = constraints.maxWidth <= smallScreenSize; - return Form( - key: loginFormKey, - child: Container( - width: constraints.maxWidth * 0.9, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 20, - ), - TextFormField( - keyboardType: TextInputType.number, + return Form( + key: loginFormKey, + child: Container( + width: SizeConfig.widthMultiplier * 90, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + buildSizedBox(), + TextFormField( + keyboardType: TextInputType.number, + decoration: InputDecoration( + prefixIcon: Image.asset('assets/images/user_id_icon.png'), + hintText: 'Enter ID', + 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 ID'; + } + return null; + }, + onSaved: (value) { + userInfo.UserID = value; + }, + ), + buildSizedBox(), + TextFormField( + obscureText: true, decoration: InputDecoration( - prefixIcon: Image.asset('assets/images/user_id_icon.png'), - hintText: 'Enter ID', + prefixIcon: Image.asset('assets/images/password_icon.png'), + hintText: 'Enter Password', hintStyle: TextStyle(fontSize: 2 * SizeConfig.textMultiplier), enabledBorder: OutlineInputBorder( @@ -87,141 +110,110 @@ class _LoginFormState extends State { ), validator: (value) { if (value.isEmpty) { - return 'Please enter some text'; + return 'Please enter your Password'; } return null; }, onSaved: (value) { - userInfo.UserID = value; + userInfo.Password = value; + }), + buildSizedBox(), + DropdownButtonFormField( + value: userInfo.ProjectID, + isExpanded: false, + decoration: InputDecoration( + contentPadding: EdgeInsets.all(10), + isDense: true, + prefixIcon: Image.asset('assets/images/hospital_icon.png'), + // hintText: 'Enter 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) { + print(value); + if (value == null) { + return 'Please select your project'; + } + return null; }, - ), - SizedBox( - height: 20, - ), - TextFormField( - obscureText: true, - decoration: InputDecoration( - prefixIcon: - Image.asset('assets/images/password_icon.png'), - hintText: 'Enter 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 some text'; - } - return null; - }, - onSaved: (value) { - userInfo.Password = value; - }), - SizedBox( - height: 20, - ), - DropdownButtonFormField( - value: userInfo.ProjectID, - isExpanded: false, - decoration: InputDecoration( - contentPadding: EdgeInsets.all(10), - isDense: true, - prefixIcon: - Image.asset('assets/images/hospital_icon.png'), - // hintText: 'Enter 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) { - print(value); - if (value == null) { - return 'Please enter some text'; - } - return null; + items: projectsList.map((item) { + return DropdownMenuItem( + child: Text( + '${item['Desciption']}', + ), + value: item['ID'], + ); + }).toList(), + onChanged: (value) { + userInfo.ProjectID = value; + }), + buildSizedBox(), + Row( + 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); }, - items: projectsList.map((item) { - return DropdownMenuItem( - child: Text( - '${item['Desciption']}', - ), - value: item['ID'], - ); - }).toList(), - onChanged: (value) { - userInfo.ProjectID = value; - }), - SizedBox( - height: 20, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( + textColor: Colors.white, + elevation: 0.0, + padding: const EdgeInsets.all(0.0), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + side: BorderSide(width: 0.5, color: Hexcolor('#CCCCCC'))), + child: Container( + padding: const EdgeInsets.all(10.0), + height:50, + width: SizeConfig.widthMultiplier * 30, child: Row( - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Checkbox( - value: true, - activeColor: Theme.of(context).primaryColor, - onChanged: (bool newValue) {}), - Text("Remember me", + Text('LOGIN', style: TextStyle( - fontSize: 2 * SizeConfig.textMultiplier)), + fontSize: SizeConfig.isMobilePortrait + ? 2.3 * SizeConfig.textMultiplier + : 2.3 * SizeConfig.textMultiplier)), + Image.asset('assets/images/login_btn_arrow_icon.png') ], ), ), - RaisedButton( - onPressed: () { - login(context, authProv); - }, - textColor: Colors.white, - elevation: 0.0, - padding: const EdgeInsets.all(0.0), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - side: - BorderSide(width: 0.5, color: Hexcolor('#CCCCCC'))), - child: Container( - padding: const EdgeInsets.all(10.0), - height: 5*SizeConfig.heightMultiplier, - width: constraints.maxWidth * 0.30, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text('LOGIN', - style: TextStyle( - fontSize: SizeConfig.isMobilePortrait?2*SizeConfig.textMultiplier: 2.3*SizeConfig.textMultiplier)), - Image.asset('assets/images/login_btn_arrow_icon.png') - ], - ), - ), - ) - ], - ), - ], - ), + ) + ], + ), + ], ), - ); - }); + ), + ); + } + + SizedBox buildSizedBox() { + return SizedBox( + height: 20, + ); } login(context, AuthProvider authProv) { From 969bee73e1d190b9ceda435c142230bd0abfaf96 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Wed, 1 Apr 2020 13:31:32 +0300 Subject: [PATCH 4/7] change password UI --- lib/lookups/auth_lookup.dart | 2 +- lib/routes.dart | 40 +++-- lib/screens/auth/change_password_screen.dart | 24 +++ lib/widgets/auth/auth_header.dart | 90 ++++++++--- lib/widgets/auth/change_password.dart | 159 +++++++++++++++++++ pubspec.yaml | 1 + 6 files changed, 274 insertions(+), 42 deletions(-) create mode 100644 lib/screens/auth/change_password_screen.dart create mode 100644 lib/widgets/auth/change_password.dart diff --git a/lib/lookups/auth_lookup.dart b/lib/lookups/auth_lookup.dart index f3e3e3fc..bc4d3821 100644 --- a/lib/lookups/auth_lookup.dart +++ b/lib/lookups/auth_lookup.dart @@ -1 +1 @@ -enum loginType { knownUser, unknownUser } \ No newline at end of file +enum loginType { knownUser, unknownUser, changePassword, verifyPassword } diff --git a/lib/routes.dart b/lib/routes.dart index f26e18b8..fe88c286 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -9,35 +9,31 @@ import './screens/medicine/medicine_search_screen.dart'; import './screens/my_schedule_screen.dart'; import './screens/patients/patient_search_screen.dart'; import './screens/patients/patients_list_screen.dart'; +import './screens/auth/change_password_screen.dart'; const String HOME = '/'; const String LOGIN = 'login'; +const String CHANGE_PASSWORD = 'change-password'; const String INIT_ROUTE = LOGIN; const String MY_SCHEDULE = 'my-schedule'; -const String QR_READER = 'qr_reader'; +const String QR_READER = 'qr-reader'; const String PATIENT_SEARCH = 'patients/patient-search'; const String PATIENTS = 'patients/patients'; -const String BLOOD_BANK = 'blood_bank'; -const String DOCTOR_REPLY = 'doctor_reply'; -const String MEDICINE_SEARCH='medicine_search'; -const String SETTINGS ='settings'; - - - - +const String BLOOD_BANK = 'blood-bank'; +const String DOCTOR_REPLY = 'doctor-reply'; +const String MEDICINE_SEARCH = 'medicine-search'; +const String SETTINGS = 'settings'; var routes = { - HOME:(_)=>HomeScreen(), - INIT_ROUTE:(_)=>Loginsreen(), - MY_SCHEDULE:(_)=>MyScheduleScreen(), - PATIENT_SEARCH:(_)=>PatientSearchScreen(), - PATIENTS:(_)=>PatientsListScreen(), - QR_READER:(_)=>QrReaderScreen(), - BLOOD_BANK:(_)=>BloodBankScreen(), - DOCTOR_REPLY:(_)=>DoctorReplyScreen(), - MEDICINE_SEARCH:(_)=>MedicineSearchScreen(), - SETTINGS:(_)=>SettingsScreen() - - - + HOME: (_) => HomeScreen(), + INIT_ROUTE: (_) => Loginsreen(), + MY_SCHEDULE: (_) => MyScheduleScreen(), + PATIENT_SEARCH: (_) => PatientSearchScreen(), + PATIENTS: (_) => PatientsListScreen(), + QR_READER: (_) => QrReaderScreen(), + BLOOD_BANK: (_) => BloodBankScreen(), + DOCTOR_REPLY: (_) => DoctorReplyScreen(), + MEDICINE_SEARCH: (_) => MedicineSearchScreen(), + SETTINGS: (_) => SettingsScreen(), + CHANGE_PASSWORD: (_) => ChangePasswordScreen() }; diff --git a/lib/screens/auth/change_password_screen.dart b/lib/screens/auth/change_password_screen.dart new file mode 100644 index 00000000..507c6afc --- /dev/null +++ b/lib/screens/auth/change_password_screen.dart @@ -0,0 +1,24 @@ +import 'package:doctor_app_flutter/lookups/auth_lookup.dart'; +import 'package:doctor_app_flutter/widgets/auth/auth_header.dart'; +import 'package:flutter/material.dart'; +import '../../widgets/auth/change_password.dart'; +class ChangePasswordScreen extends StatelessWidget { + @override + Widget build(BuildContext context) { + // return Container()]; + return Scaffold( + backgroundColor: Colors.white, + body: SingleChildScrollView( + child: Container( + margin: EdgeInsetsDirectional.fromSTEB(30, 0, 0, 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AuthHeader(loginType.changePassword), + ChangePassword(), + ], + ), + ), + )); + } +} diff --git a/lib/widgets/auth/auth_header.dart b/lib/widgets/auth/auth_header.dart index efd351cf..2f3876bd 100644 --- a/lib/widgets/auth/auth_header.dart +++ b/lib/widgets/auth/auth_header.dart @@ -1,8 +1,9 @@ -import '../../config/size_config.dart'; -import '../../lookups/auth_lookup.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import '../../config/size_config.dart'; +import '../../lookups/auth_lookup.dart'; + class AuthHeader extends StatelessWidget { var userType; AuthHeader(this.userType); @@ -25,13 +26,7 @@ class AuthHeader extends StatelessWidget { ? EdgeInsetsDirectional.fromSTEB(0, 50, 0, 0) : EdgeInsetsDirectional.fromSTEB( SizeConfig.screenWidth * 0.13, 0, 0, 0), - child: Image.asset( - 'assets/images/login_icon.png', - fit: BoxFit.cover, - height: SizeConfig.isMobile - ? null - : SizeConfig.screenWidth * 0.09, - ), + child: buildImageLogo(), ), SizedBox( height: 10, @@ -41,14 +36,7 @@ class AuthHeader extends StatelessWidget { ? null : EdgeInsetsDirectional.fromSTEB( SizeConfig.screenWidth * 0.13, 0, 0, 0), - child: Text( - "LOGIN", - style: TextStyle( - fontSize: SizeConfig.isMobile - ? 30 - : SizeConfig.screenWidth * 0.035, - fontWeight: FontWeight.w800), - ), + child: buildTextUnderLogo(context), ) ], ), @@ -81,7 +69,66 @@ class AuthHeader extends StatelessWidget { return screen; } + Image buildImageLogo() { + String img = 'assets/images/login_icon.png'; + if (userType == loginType.unknownUser) { + img = 'assets/images/welcome_login_icon.png'; + } + + return Image.asset( + img, + fit: BoxFit.cover, + height: SizeConfig.isMobile ? null : SizeConfig.screenWidth * 0.09, + ); + } + + Widget buildTextUnderLogo(context) { + if (userType == loginType.knownUser || userType == loginType.unknownUser) { + return Text( + "LOGIN", + style: TextStyle( + fontSize: SizeConfig.isMobile ? 30 : SizeConfig.screenWidth * 0.035, + fontWeight: FontWeight.w800), + ); + } else { + String text1; + String text2; + if (userType == loginType.changePassword) { + text1 = 'Change'; + text2 = 'Password!'; + } + if (userType == loginType.verifyPassword) { + text1 = 'verify'; + text2 = 'Your Account!'; + } + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + text1, + style: TextStyle( + fontSize: + SizeConfig.isMobile ? 30 : SizeConfig.screenWidth * 0.035, + fontWeight: FontWeight.w800), + ), + Text( + text2, + style: TextStyle( + color: Theme.of(context).primaryColor, + fontSize: + SizeConfig.isMobile ? 30 : SizeConfig.screenWidth * 0.035, + fontWeight: FontWeight.w800), + ) + ], + ); + } + } + Container buildDrAppContainer(BuildContext context) { + if (userType == loginType.changePassword || userType == loginType.verifyPassword ) { + return Container(); + } return Container( margin: SizeConfig.isMobile ? null @@ -98,6 +145,9 @@ class AuthHeader extends StatelessWidget { } Text buildDrSulText(BuildContext context) { + if (userType == loginType.changePassword || userType == loginType.verifyPassword ) { + return Text(''); + } return Text( 'Dr Sulaiman Al Habib', style: TextStyle( @@ -108,12 +158,14 @@ class AuthHeader extends StatelessWidget { ); } - Text buildWelText() { + Widget buildWelText() { String text = 'Welcome to '; if (userType == loginType.unknownUser) { text = 'Welcome Back to '; } - + if (userType == loginType.changePassword || userType == loginType.verifyPassword ) { + return Text(''); + } return Text( text, style: TextStyle( diff --git a/lib/widgets/auth/change_password.dart b/lib/widgets/auth/change_password.dart new file mode 100644 index 00000000..5c231f6a --- /dev/null +++ b/lib/widgets/auth/change_password.dart @@ -0,0 +1,159 @@ +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.widthMultiplier * 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/pubspec.yaml b/pubspec.yaml index 24d55e61..4845112c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -68,6 +68,7 @@ flutter: - assets/images/verification_sms_lg_icon.png - assets/images/verification_whatsapp_lg_icon.png - assets/images/close_icon.png + - assets/images/welcome_login_icon.png # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see From 6737e457b5cadeaa724ecb001efd861658f8323e Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Wed, 1 Apr 2020 18:14:59 +0300 Subject: [PATCH 5/7] first step from handeling token in interceptor --- lib/interceptor/http_interceptor.dart | 33 ++++++++++++++++++++++---- lib/screens/auth/login_screen.dart | 8 +++---- lib/util/dr_app_shared_pref.dart | 2 +- lib/widgets/auth/known_user_login.dart | 1 - 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/lib/interceptor/http_interceptor.dart b/lib/interceptor/http_interceptor.dart index 997a8c47..1ad980c7 100644 --- a/lib/interceptor/http_interceptor.dart +++ b/lib/interceptor/http_interceptor.dart @@ -1,14 +1,39 @@ +import 'package:doctor_app_flutter/providers/auth_provider.dart'; +import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:http_interceptor/http_interceptor.dart'; +DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); +List publicUrls = [LOGIN_URL,SELECT_DEVICE_IMEI,]; + class HttpInterceptor extends InterceptorContract { Future interceptRequest({RequestData data}) async { // print('RequestData ${data.body}'); try { - // data.params['appid'] = OPEN_WEATHER_API_KEY; - // data.params['units'] = 'metric'; data.headers["Content-Type"] = "application/json"; data.headers["Accept"] = "application/json"; + if (!publicUrls.contains(data.url)) { + var loggedUserInfo = await sharedPref.getObj('loggedUser'); + print('loggedUserInfo$loggedUserInfo'); + // the sevices handel the token in differat name so I ask to be change + // we must change the implementaion once the name are changed + if(data.body['LogInTokenID']){ + data.body['LogInTokenID'] = loggedUserInfo['LogInTokenID']; + } + if(data.body['TokenID']){ + data.body['TokenID'] = loggedUserInfo['LogInTokenID']; + } + + print('data.body${data.body}'); + } + else { + if(data.body['LogInTokenID']){ + data.body['LogInTokenID'] = ''; + } + if(data.body['TokenID']){ + data.body['TokenID'] = ''; + } + } } catch (e) { print(e); } @@ -19,5 +44,5 @@ class HttpInterceptor extends InterceptorContract { Future interceptResponse({ResponseData data}) async { // print('ResponseData ${data.body}'); return data; - } -} \ No newline at end of file + } +} diff --git a/lib/screens/auth/login_screen.dart b/lib/screens/auth/login_screen.dart index 22bf76fd..ce0ce6ff 100644 --- a/lib/screens/auth/login_screen.dart +++ b/lib/screens/auth/login_screen.dart @@ -1,14 +1,14 @@ import 'dart:async'; -import 'package:doctor_app_flutter/lookups/auth_lookup.dart'; -import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; -import 'package:doctor_app_flutter/widgets/auth/known_user_login.dart'; -import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; import 'package:flutter/material.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/known_user_login.dart'; import '../../widgets/auth/login_form.dart'; +import '../../widgets/shared/dr_app_circular_progress_Indeicator.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); class Loginsreen extends StatefulWidget { diff --git a/lib/util/dr_app_shared_pref.dart b/lib/util/dr_app_shared_pref.dart index b8a330bd..f75c171e 100644 --- a/lib/util/dr_app_shared_pref.dart +++ b/lib/util/dr_app_shared_pref.dart @@ -80,6 +80,6 @@ class DrAppSharedPreferances { if (string == null ){ return null; } - return json.decode(prefs.getString(key)); + return json.decode(string); } } diff --git a/lib/widgets/auth/known_user_login.dart b/lib/widgets/auth/known_user_login.dart index 9e7f26de..b39b9c1b 100644 --- a/lib/widgets/auth/known_user_login.dart +++ b/lib/widgets/auth/known_user_login.dart @@ -6,7 +6,6 @@ import 'package:local_auth/local_auth.dart'; import 'package:provider/provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import '../../config/config.dart'; import '../../config/size_config.dart'; import '../../providers/auth_provider.dart'; import '../../routes.dart'; From 41d9101ca42c9a43f467af365629c9ce2ede5087 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Sun, 5 Apr 2020 10:36:35 +0300 Subject: [PATCH 6/7] first step fom verify account page --- lib/routes.dart | 7 ++++-- lib/screens/auth/verify_account_screen.dart | 24 +++++++++++++++++++++ pubspec.lock | 4 ++-- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 lib/screens/auth/verify_account_screen.dart diff --git a/lib/routes.dart b/lib/routes.dart index fe88c286..ae068a85 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -10,11 +10,13 @@ import './screens/my_schedule_screen.dart'; import './screens/patients/patient_search_screen.dart'; import './screens/patients/patients_list_screen.dart'; import './screens/auth/change_password_screen.dart'; +import './screens/auth/verify_account_screen.dart'; +const String INIT_ROUTE = LOGIN; const String HOME = '/'; const String LOGIN = 'login'; const String CHANGE_PASSWORD = 'change-password'; -const String INIT_ROUTE = LOGIN; +const String VERIFY_ACCOUNT = 'verify-account'; const String MY_SCHEDULE = 'my-schedule'; const String QR_READER = 'qr-reader'; const String PATIENT_SEARCH = 'patients/patient-search'; @@ -35,5 +37,6 @@ var routes = { DOCTOR_REPLY: (_) => DoctorReplyScreen(), MEDICINE_SEARCH: (_) => MedicineSearchScreen(), SETTINGS: (_) => SettingsScreen(), - CHANGE_PASSWORD: (_) => ChangePasswordScreen() + CHANGE_PASSWORD: (_) => ChangePasswordScreen(), + VERIFY_ACCOUNT: (_) => VerifyAccountScreen(), }; diff --git a/lib/screens/auth/verify_account_screen.dart b/lib/screens/auth/verify_account_screen.dart new file mode 100644 index 00000000..77327292 --- /dev/null +++ b/lib/screens/auth/verify_account_screen.dart @@ -0,0 +1,24 @@ +import 'package:doctor_app_flutter/lookups/auth_lookup.dart'; +import 'package:doctor_app_flutter/widgets/auth/auth_header.dart'; +import 'package:flutter/material.dart'; + +class VerifyAccountScreen extends StatelessWidget { + @override + Widget build(BuildContext context) { + // return Container()]; + return Scaffold( + backgroundColor: Colors.white, + body: SingleChildScrollView( + child: Container( + margin: EdgeInsetsDirectional.fromSTEB(30, 0, 0, 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AuthHeader(loginType.verifyPassword), + // ChangePassword(), + ], + ), + ), + )); + } +} diff --git a/pubspec.lock b/pubspec.lock index 90ac402c..555d8260 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -91,14 +91,14 @@ packages: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" build_runner_core: dependency: transitive description: name: build_runner_core url: "https://pub.dartlang.org" source: hosted - version: "4.5.3" + version: "5.0.0" build_web_compilers: dependency: "direct dev" description: From 6090816dc36f844cf2e9185830fb9214fc2d62da Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Sun, 5 Apr 2020 10:53:48 +0300 Subject: [PATCH 7/7] fix project id --- lib/widgets/auth/login_form.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/widgets/auth/login_form.dart b/lib/widgets/auth/login_form.dart index ae2bf55b..de2bfdec 100644 --- a/lib/widgets/auth/login_form.dart +++ b/lib/widgets/auth/login_form.dart @@ -155,7 +155,10 @@ class _LoginFormState extends State { ); }).toList(), onChanged: (value) { - userInfo.ProjectID = value; + print(value); + setState(() { + userInfo.ProjectID = value; + }); }), buildSizedBox(), Row( @@ -187,7 +190,7 @@ class _LoginFormState extends State { side: BorderSide(width: 0.5, color: Hexcolor('#CCCCCC'))), child: Container( padding: const EdgeInsets.all(10.0), - height:50, + height: 50, width: SizeConfig.widthMultiplier * 30, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween,