From de3390148ec56616e0997690b126ceb45ff116f7 Mon Sep 17 00:00:00 2001 From: naveen-egov <83631045+naveen-egov@users.noreply.github.com> Date: Fri, 12 Nov 2021 10:06:17 +0530 Subject: [PATCH] patch-IFIX-654 (#55) --- .../screeens/AddExpense/ExpenseDetails.dart | 112 +++++---- .../ChangePassword/Changepassword.dart | 55 +++-- .../ConnectionResults/SearchConnection.dart | 6 +- .../ConsumerDetails/ConsumerDetails.dart | 6 +- .../lib/screeens/Feedback/feed_back.dart | 18 +- .../ForgotPassword/ForgotPassword.dart | 6 +- .../screeens/GenerateBill/GenerateBill.dart | 81 +++--- .../mgramseva/lib/screeens/Login/Login.dart | 32 ++- .../lib/screeens/Profile/EditProfile.dart | 6 +- .../screeens/ResetPassword/Resetpassword.dart | 227 ++++++++--------- .../ResetPassword/Updatepassword.dart | 233 +++++++++--------- .../lib/screeens/common/collect_payment.dart | 6 +- .../lib/screeens/expense/search_expense.dart | 16 +- .../lib/widgets/TextFieldBuilder.dart | 155 ++++++------ frontend/mgramseva/pubspec.lock | 7 + frontend/mgramseva/pubspec.yaml | 1 + 16 files changed, 512 insertions(+), 455 deletions(-) diff --git a/frontend/mgramseva/lib/screeens/AddExpense/ExpenseDetails.dart b/frontend/mgramseva/lib/screeens/AddExpense/ExpenseDetails.dart index 4077da6de..8c8f57d7a 100644 --- a/frontend/mgramseva/lib/screeens/AddExpense/ExpenseDetails.dart +++ b/frontend/mgramseva/lib/screeens/AddExpense/ExpenseDetails.dart @@ -1,6 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_focus_watcher/flutter_focus_watcher.dart'; import 'package:mgramseva/model/expensesDetails/expenses_details.dart'; import 'package:mgramseva/providers/expenses_details_provider.dart'; import 'package:mgramseva/screeens/AddExpense/AddExpenseWalkThrough/expenseWalkThrough.dart'; @@ -80,7 +81,7 @@ class _ExpenseDetailsState extends State { if (!_numberFocus.hasFocus) { Provider.of(context, listen: false) ..phoneNumberAutoValidation = true - ..callNotifyer(); + ..callNotifyer(); } } @@ -88,59 +89,60 @@ class _ExpenseDetailsState extends State { Widget build(BuildContext context) { var expensesDetailsProvider = Provider.of(context, listen: false); - return Scaffold( - appBar: CustomAppBar(), - drawer: DrawerWrapper( - Drawer(child: SideBar()), - ), - body: SingleChildScrollView( - child: Column(children: [ - StreamBuilder( - stream: expensesDetailsProvider.streamController.stream, - builder: (context, AsyncSnapshot snapshot) { - if (snapshot.hasData) { - if (snapshot.data is String) { - return CommonWidgets.buildEmptyMessage( - snapshot.data, context); - } - return _buildUserView(snapshot.data); - } else if (snapshot.hasError) { - return Notifiers.networkErrorPage( - context, - () => expensesDetailsProvider.getExpensesDetails( - context, widget.expensesDetails, widget.id)); - } else { - switch (snapshot.connectionState) { - case ConnectionState.waiting: - return Loaders.CircularLoader(); - case ConnectionState.active: - return Loaders.CircularLoader(); - default: - return Container(); - } - } - }), - Footer() - ])), - bottomNavigationBar: Consumer( - builder: (_, expensesDetailsProvider, child) => BottomButtonBar( - i18.common.SUBMIT, - (isUpdate && - (expensesDetailsProvider - .expenditureDetails.allowEdit ?? - false)) || - ((isUpdate && - !(expensesDetailsProvider - .expenditureDetails.allowEdit ?? - false) && + return FocusWatcher( + child: Scaffold( + appBar: CustomAppBar(), + drawer: DrawerWrapper( + Drawer(child: SideBar()), + ), + body: SingleChildScrollView( + child: Column(children: [ + StreamBuilder( + stream: expensesDetailsProvider.streamController.stream, + builder: (context, AsyncSnapshot snapshot) { + if (snapshot.hasData) { + if (snapshot.data is String) { + return CommonWidgets.buildEmptyMessage( + snapshot.data, context); + } + return _buildUserView(snapshot.data); + } else if (snapshot.hasError) { + return Notifiers.networkErrorPage( + context, + () => expensesDetailsProvider.getExpensesDetails( + context, widget.expensesDetails, widget.id)); + } else { + switch (snapshot.connectionState) { + case ConnectionState.waiting: + return Loaders.CircularLoader(); + case ConnectionState.active: + return Loaders.CircularLoader(); + default: + return Container(); + } + } + }), + Footer() + ])), + bottomNavigationBar: Consumer( + builder: (_, expensesDetailsProvider, child) => BottomButtonBar( + i18.common.SUBMIT, + (isUpdate && (expensesDetailsProvider - .expenditureDetails.isBillCancelled ?? + .expenditureDetails.allowEdit ?? false)) || - !isUpdate) - ? () => expensesDetailsProvider.validateExpensesDetails( - context, isUpdate) - : null), - )); + ((isUpdate && + !(expensesDetailsProvider + .expenditureDetails.allowEdit ?? + false) && + (expensesDetailsProvider + .expenditureDetails.isBillCancelled ?? + false)) || + !isUpdate) + ? () => expensesDetailsProvider.validateExpensesDetails( + context, isUpdate) + : null), + ))); } saveInput(context) async { @@ -246,7 +248,8 @@ class _ExpenseDetailsState extends State { textInputType: TextInputType.number, validator: Validators.mobileNumberValidator, focusNode: _numberFocus, - autoValidation: expensesDetailsProvider.phoneNumberAutoValidation + autoValidation: expensesDetailsProvider + .phoneNumberAutoValidation ? AutovalidateMode.always : AutovalidateMode.disabled, maxLength: 10, @@ -254,7 +257,8 @@ class _ExpenseDetailsState extends State { FilteringTextInputFormatter.allow( RegExp("[0-9]")) ], - onChange: expensesDetailsProvider.onChangeOfMobileNumber, + onChange: expensesDetailsProvider + .onChangeOfMobileNumber, ), BuildTextField( '${i18.expense.AMOUNT}', diff --git a/frontend/mgramseva/lib/screeens/ChangePassword/Changepassword.dart b/frontend/mgramseva/lib/screeens/ChangePassword/Changepassword.dart index 5a5c20732..a882dd80f 100644 --- a/frontend/mgramseva/lib/screeens/ChangePassword/Changepassword.dart +++ b/frontend/mgramseva/lib/screeens/ChangePassword/Changepassword.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_focus_watcher/flutter_focus_watcher.dart'; import 'package:mgramseva/model/changePasswordDetails/changePassword_details.dart'; import 'package:mgramseva/providers/common_provider.dart'; import 'package:mgramseva/providers/changePassword_details_provider.dart'; @@ -93,7 +94,9 @@ class _ChangePasswordState extends State { isRequired: true, maxLines: 1, validator: (val) => Validators.passwordComparision( - val, ApplicationLocalizations.of(context).translate(i18.password.NEW_PASSWORD_ENTER)), + val, + ApplicationLocalizations.of(context) + .translate(i18.password.NEW_PASSWORD_ENTER)), onChange: (value) => saveInput(value), ), BuildTextField( @@ -104,7 +107,8 @@ class _ChangePasswordState extends State { maxLines: 1, validator: (val) => Validators.passwordComparision( val, - ApplicationLocalizations.of(context).translate(i18.password.CONFIRM_PASSWORD_ENTER), + ApplicationLocalizations.of(context) + .translate(i18.password.CONFIRM_PASSWORD_ENTER), passwordDetails.newpasswordCtrl.text), onChange: (value) => saveInput(value), ), @@ -128,28 +132,29 @@ class _ChangePasswordState extends State { Widget build(BuildContext context) { var changePasswordProvider = Provider.of(context, listen: false); - return Scaffold( - backgroundColor: Theme.of(context).backgroundColor, - appBar: BaseAppBar( - Text(i18.common.MGRAM_SEVA), - AppBar(), - [Icon(Icons.more_vert)], - ), - drawer: DrawerWrapper( - Drawer(child: SideBar()), - ), - body: SingleChildScrollView( - child: Column( - children: [ - builduserView(changePasswordProvider.changePasswordDetails), - Footer() - ], - )), - bottomNavigationBar: BottomButtonBar( - i18.password.CHANGE_PASSWORD, - () => saveInputandchangepass( - context, - changePasswordProvider.changePasswordDetails.getText(), - changePasswordProvider.changePasswordDetails))); + return FocusWatcher( + child: Scaffold( + backgroundColor: Theme.of(context).backgroundColor, + appBar: BaseAppBar( + Text(i18.common.MGRAM_SEVA), + AppBar(), + [Icon(Icons.more_vert)], + ), + drawer: DrawerWrapper( + Drawer(child: SideBar()), + ), + body: SingleChildScrollView( + child: Column( + children: [ + builduserView(changePasswordProvider.changePasswordDetails), + Footer() + ], + )), + bottomNavigationBar: BottomButtonBar( + i18.password.CHANGE_PASSWORD, + () => saveInputandchangepass( + context, + changePasswordProvider.changePasswordDetails.getText(), + changePasswordProvider.changePasswordDetails)))); } } diff --git a/frontend/mgramseva/lib/screeens/ConnectionResults/SearchConnection.dart b/frontend/mgramseva/lib/screeens/ConnectionResults/SearchConnection.dart index 009cb36f4..52848c2ec 100644 --- a/frontend/mgramseva/lib/screeens/ConnectionResults/SearchConnection.dart +++ b/frontend/mgramseva/lib/screeens/ConnectionResults/SearchConnection.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; +import 'package:flutter_focus_watcher/flutter_focus_watcher.dart'; import 'package:mgramseva/model/connection/search_connection.dart'; import 'package:mgramseva/providers/search_connection_provider.dart'; import 'package:mgramseva/widgets/customAppbar.dart'; @@ -40,7 +41,8 @@ class _SearchConsumerConnectionState extends State { Widget build(BuildContext context) { var searchConnectionProvider = Provider.of(context, listen: false); - return Scaffold( + return FocusWatcher( + child: Scaffold( backgroundColor: Theme.of(context).backgroundColor, appBar: CustomAppBar(), drawer: DrawerWrapper( @@ -192,6 +194,6 @@ class _SearchConsumerConnectionState extends State { i18.searchWaterConnection.SEARCH_CONNECTION_BUTTON, () => searchConnectionProvider.validatesearchConnectionDetails( context, widget.arguments)), - ); + )); } } diff --git a/frontend/mgramseva/lib/screeens/ConsumerDetails/ConsumerDetails.dart b/frontend/mgramseva/lib/screeens/ConsumerDetails/ConsumerDetails.dart index 0a1650efc..cb5312995 100644 --- a/frontend/mgramseva/lib/screeens/ConsumerDetails/ConsumerDetails.dart +++ b/frontend/mgramseva/lib/screeens/ConsumerDetails/ConsumerDetails.dart @@ -1,6 +1,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_focus_watcher/flutter_focus_watcher.dart'; import 'package:mgramseva/model/connection/property.dart'; import 'package:mgramseva/model/connection/water_connection.dart'; import 'package:mgramseva/providers/common_provider.dart'; @@ -485,7 +486,8 @@ class _ConsumerDetailsState extends State { @override Widget build(BuildContext context) { var userProvider = Provider.of(context, listen: false); - return Scaffold( + return FocusWatcher( + child: Scaffold( backgroundColor: Theme.of(context).backgroundColor, appBar: CustomAppBar(), drawer: DrawerWrapper( @@ -516,6 +518,6 @@ class _ConsumerDetailsState extends State { ]))), bottomNavigationBar: BottomButtonBar(i18.common.SUBMIT, () => {userProvider.validateConsumerDetails(context)}), - ); + )); } } diff --git a/frontend/mgramseva/lib/screeens/Feedback/feed_back.dart b/frontend/mgramseva/lib/screeens/Feedback/feed_back.dart index d3514adfc..f49dd524b 100644 --- a/frontend/mgramseva/lib/screeens/Feedback/feed_back.dart +++ b/frontend/mgramseva/lib/screeens/Feedback/feed_back.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_focus_watcher/flutter_focus_watcher.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:mgramseva/model/localization/language.dart'; import 'package:mgramseva/model/success_handler.dart'; @@ -56,14 +57,15 @@ class _PaymentFeedBackState extends State { @override Widget build(BuildContext context) { - return Scaffold( - backgroundColor: Theme.of(context).backgroundColor, - appBar: AppBar( - title: Text('mGramSeva'), - automaticallyImplyLeading: false, - actions: [_buildDropDown()], - ), - body: _buildLocalizationData()); + return FocusWatcher( + child: Scaffold( + backgroundColor: Theme.of(context).backgroundColor, + appBar: AppBar( + title: Text('mGramSeva'), + automaticallyImplyLeading: false, + actions: [_buildDropDown()], + ), + body: _buildLocalizationData())); } Widget _buildView() { diff --git a/frontend/mgramseva/lib/screeens/ForgotPassword/ForgotPassword.dart b/frontend/mgramseva/lib/screeens/ForgotPassword/ForgotPassword.dart index fddfdcc1b..490748d1e 100644 --- a/frontend/mgramseva/lib/screeens/ForgotPassword/ForgotPassword.dart +++ b/frontend/mgramseva/lib/screeens/ForgotPassword/ForgotPassword.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_focus_watcher/flutter_focus_watcher.dart'; import 'package:mgramseva/providers/forgot_password_provider.dart'; import 'package:mgramseva/utils/Constants/I18KeyConstants.dart'; @@ -113,12 +114,13 @@ class _ForgotPasswordState extends State { @override Widget build(BuildContext context) { - return Scaffold(body: LayoutBuilder(builder: (context, constraints) { + return FocusWatcher( + child: Scaffold(body: LayoutBuilder(builder: (context, constraints) { if (constraints.maxWidth < 760) { return MobileView(getForgotPasswordCard()); } else { return DesktopView(getForgotPasswordCard()); } - })); + }))); } } diff --git a/frontend/mgramseva/lib/screeens/GenerateBill/GenerateBill.dart b/frontend/mgramseva/lib/screeens/GenerateBill/GenerateBill.dart index 68d69618b..48855e7e7 100644 --- a/frontend/mgramseva/lib/screeens/GenerateBill/GenerateBill.dart +++ b/frontend/mgramseva/lib/screeens/GenerateBill/GenerateBill.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_focus_watcher/flutter_focus_watcher.dart'; import 'package:mgramseva/model/bill/bill_generation_details/bill_generation_details.dart'; import 'package:mgramseva/model/connection/water_connection.dart'; import 'package:mgramseva/providers/bill_generation_details_provider.dart'; @@ -196,7 +197,12 @@ class _GenerateBillState extends State { .billGenerateDetails .om_5Ctrl, isRequired: true, - isDisabled: billgenerationprovider.readingExist == false ? true : false, + isDisabled: + billgenerationprovider + .readingExist == + false + ? true + : false, ), MeterReading( i18.demandGenerate @@ -295,41 +301,42 @@ class _GenerateBillState extends State { Widget build(BuildContext context) { var billgenerateProvider = Provider.of(context, listen: false); - return Scaffold( - backgroundColor: Theme.of(context).backgroundColor, - appBar: BaseAppBar( - Text(i18.common.MGRAM_SEVA), - AppBar(), - [Icon(Icons.more_vert)], - ), - drawer: DrawerWrapper( - Drawer(child: SideBar()), - ), - body: SingleChildScrollView( - child: Container( - child: Column(children: [ - StreamBuilder( - stream: billgenerateProvider.streamController.stream, - builder: (context, AsyncSnapshot snapshot) { - if (snapshot.hasData) { - return buildview(snapshot.data); - } else if (snapshot.hasError) { - return Notifiers.networkErrorPage(context, () {}); - } else { - switch (snapshot.connectionState) { - case ConnectionState.waiting: - return Loaders.CircularLoader(); - case ConnectionState.active: - return Loaders.CircularLoader(); - default: - return Container(); - } - } - }), - Footer() - ]))), - bottomNavigationBar: BottomButtonBar( - '${widget.id == null ? i18.demandGenerate.GENERATE_DEMAND_BUTTON : i18.demandGenerate.GENERATE_BILL_BUTTON}', - () => {billgenerateProvider.onSubmit(context)})); + return FocusWatcher( + child: Scaffold( + backgroundColor: Theme.of(context).backgroundColor, + appBar: BaseAppBar( + Text(i18.common.MGRAM_SEVA), + AppBar(), + [Icon(Icons.more_vert)], + ), + drawer: DrawerWrapper( + Drawer(child: SideBar()), + ), + body: SingleChildScrollView( + child: Container( + child: Column(children: [ + StreamBuilder( + stream: billgenerateProvider.streamController.stream, + builder: (context, AsyncSnapshot snapshot) { + if (snapshot.hasData) { + return buildview(snapshot.data); + } else if (snapshot.hasError) { + return Notifiers.networkErrorPage(context, () {}); + } else { + switch (snapshot.connectionState) { + case ConnectionState.waiting: + return Loaders.CircularLoader(); + case ConnectionState.active: + return Loaders.CircularLoader(); + default: + return Container(); + } + } + }), + Footer() + ]))), + bottomNavigationBar: BottomButtonBar( + '${widget.id == null ? i18.demandGenerate.GENERATE_DEMAND_BUTTON : i18.demandGenerate.GENERATE_BILL_BUTTON}', + () => {billgenerateProvider.onSubmit(context)}))); } } diff --git a/frontend/mgramseva/lib/screeens/Login/Login.dart b/frontend/mgramseva/lib/screeens/Login/Login.dart index 4a42ca330..6fc259123 100644 --- a/frontend/mgramseva/lib/screeens/Login/Login.dart +++ b/frontend/mgramseva/lib/screeens/Login/Login.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_focus_watcher/flutter_focus_watcher.dart'; import 'package:mgramseva/providers/authentication.dart'; import 'package:mgramseva/routers/Routers.dart'; import 'package:mgramseva/utils/Constants/I18KeyConstants.dart'; @@ -36,22 +37,21 @@ class _LoginState extends State { } @override - dispose(){ + dispose() { _numberFocus.removeListener(_onFocusChange); super.dispose(); } - void _onFocusChange(){ - if(!_numberFocus.hasFocus){ + void _onFocusChange() { + if (!_numberFocus.hasFocus) { setState(() { phoneNumberAutoValidation = true; }); } } - void onChangeOfInput(){ - setState(() { - }); + void onChangeOfInput() { + setState(() {}); } saveandLogin(context) async { @@ -89,7 +89,9 @@ class _LoginState extends State { FilteringTextInputFormatter.allow(RegExp("[0-9]")) ], focusNode: _numberFocus, - autoValidation: phoneNumberAutoValidation ? AutovalidateMode.always : AutovalidateMode.disabled, + autoValidation: phoneNumberAutoValidation + ? AutovalidateMode.always + : AutovalidateMode.disabled, maxLength: 10, validator: Validators.mobileNumberValidator, textInputType: TextInputType.phone, @@ -117,9 +119,10 @@ class _LoginState extends State { ))), ), Padding( - padding: EdgeInsets.only(top: 15, bottom: 15, left: 8, right: 8), - child: Button( - i18.common.CONTINUE, buttonStatus ? () => saveandLogin(context) : null)), + padding: + EdgeInsets.only(top: 15, bottom: 15, left: 8, right: 8), + child: Button(i18.common.CONTINUE, + buttonStatus ? () => saveandLogin(context) : null)), SizedBox( height: 10, ) @@ -129,14 +132,17 @@ class _LoginState extends State { @override Widget build(BuildContext context) { - return Scaffold(body: LayoutBuilder(builder: (context, constraints) { + return FocusWatcher( + child: Scaffold(body: LayoutBuilder(builder: (context, constraints) { if (constraints.maxWidth < 760) { return MobileView(getLoginCard()); } else { return DesktopView(getLoginCard()); } - })); + }))); } - bool get buttonStatus => userNamecontroller.text.trim().length == 10 && passwordcontroller.text.trim().length > 1; + bool get buttonStatus => + userNamecontroller.text.trim().length == 10 && + passwordcontroller.text.trim().length > 1; } diff --git a/frontend/mgramseva/lib/screeens/Profile/EditProfile.dart b/frontend/mgramseva/lib/screeens/Profile/EditProfile.dart index 5f37b604a..da3921f14 100644 --- a/frontend/mgramseva/lib/screeens/Profile/EditProfile.dart +++ b/frontend/mgramseva/lib/screeens/Profile/EditProfile.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_focus_watcher/flutter_focus_watcher.dart'; import 'package:mgramseva/model/userProfile/user_profile.dart'; import 'package:mgramseva/providers/user_edit_profile_provider.dart'; @@ -137,7 +138,8 @@ class _EditProfileState extends State { Widget build(BuildContext context) { var userProvider = Provider.of(context, listen: false); - return Scaffold( + return FocusWatcher( + child: Scaffold( backgroundColor: Theme.of(context).backgroundColor, appBar: BaseAppBar( Text(i18.common.MGRAM_SEVA), @@ -175,7 +177,7 @@ class _EditProfileState extends State { Footer() ])), ), - ); + )); } Map get query { diff --git a/frontend/mgramseva/lib/screeens/ResetPassword/Resetpassword.dart b/frontend/mgramseva/lib/screeens/ResetPassword/Resetpassword.dart index 80f7c0fd9..eb8b18bef 100644 --- a/frontend/mgramseva/lib/screeens/ResetPassword/Resetpassword.dart +++ b/frontend/mgramseva/lib/screeens/ResetPassword/Resetpassword.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_countdown_timer/index.dart'; +import 'package:flutter_focus_watcher/flutter_focus_watcher.dart'; import 'package:mgramseva/providers/language.dart'; import 'package:mgramseva/repository/forgot_password_repo.dart'; import 'package:mgramseva/repository/reset_password_repo.dart'; @@ -73,24 +74,36 @@ class _ResetPasswordState extends State { @override Widget build(BuildContext context) { - return Scaffold( - body: BackgroundContainer(new Container( - width: MediaQuery.of(context).size.width, - padding: const EdgeInsets.all(8.0), - child: SingleChildScrollView( - child: Form( - key: formKey, - autovalidateMode: autoValidate - ? AutovalidateMode.always - : AutovalidateMode.disabled, - child: new Column(children: [ - Align( - alignment: Alignment.topLeft, - child: MediaQuery.of(context).size.width > 720 - ? Padding( - padding: EdgeInsets.only( - left: MediaQuery.of(context).size.width / 4), - child: IconButton( + return FocusWatcher( + child: Scaffold( + body: BackgroundContainer(new Container( + width: MediaQuery.of(context).size.width, + padding: const EdgeInsets.all(8.0), + child: SingleChildScrollView( + child: Form( + key: formKey, + autovalidateMode: autoValidate + ? AutovalidateMode.always + : AutovalidateMode.disabled, + child: new Column(children: [ + Align( + alignment: Alignment.topLeft, + child: MediaQuery.of(context).size.width > 720 + ? Padding( + padding: EdgeInsets.only( + left: MediaQuery.of(context).size.width / + 4), + child: IconButton( + icon: Icon( + Icons.arrow_back, + ), + iconSize: 25, + color: Colors.white, + splashColor: Colors.purple, + onPressed: () => Navigator.of(context, + rootNavigator: true) + .maybePop())) + : IconButton( icon: Icon( Icons.arrow_back, ), @@ -99,99 +112,91 @@ class _ResetPasswordState extends State { splashColor: Colors.purple, onPressed: () => Navigator.of(context, rootNavigator: true) - .maybePop())) - : IconButton( - icon: Icon( - Icons.arrow_back, - ), - iconSize: 25, - color: Colors.white, - splashColor: Colors.purple, - onPressed: () => - Navigator.of(context, rootNavigator: true) - .maybePop())), - Container( - padding: EdgeInsets.all(8), - child: Card( - child: Container( - width: MediaQuery.of(context).size.width > 720 - ? MediaQuery.of(context).size.width / 3 - : MediaQuery.of(context).size.width, - child: (Column( - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Logo(), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - '${ApplicationLocalizations.of(context).translate(i18.password.CORE_COMMON_RESET_PASSWORD)}', - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.w700)), - ), - _buildOtpView(), - Container( - padding: - EdgeInsets.symmetric(horizontal: 20), - alignment: Alignment.centerLeft, - child: Text( - '${ApplicationLocalizations.of(context).translate(i18.password.UPDATE_PASSWORD_TO_CONTINUE)}', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18)), - ), - BuildTextField( - i18.password.CORE_COMMON_NEW_PASSWORD, - newPassword, - obscureText: true, - maxLines: 1, - isRequired: true, - validator: (val) => - Validators.passwordComparision( - val, - ApplicationLocalizations.of(context) - .translate(i18.password - .NEW_PASSWORD_ENTER)), - onChange: saveInput, - ), - BuildTextField( - i18.password - .CORE_COMMON_CONFIRM_NEW_PASSWORD, - confirmPassword, - obscureText: true, - maxLines: 1, - isRequired: true, - validator: (val) => - Validators.passwordComparision( - val, - ApplicationLocalizations.of(context) - .translate(i18.password - .CONFIRM_PASSWORD_ENTER), - newPassword.text), - onChange: saveInput, - ), - SizedBox( - height: 10, - ), - BottomButtonBar( - ApplicationLocalizations.of(context) - .translate( - i18.password.CHANGE_PASSWORD), - _pinEditingController.text - .trim() - .length != - pinLength - ? null - : updatePassword), - PasswordHint(password) - ], - ))))), - FooterBanner() - ]), - ), - )))); + .maybePop())), + Container( + padding: EdgeInsets.all(8), + child: Card( + child: Container( + width: MediaQuery.of(context).size.width > 720 + ? MediaQuery.of(context).size.width / 3 + : MediaQuery.of(context).size.width, + child: (Column( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Logo(), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + '${ApplicationLocalizations.of(context).translate(i18.password.CORE_COMMON_RESET_PASSWORD)}', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w700)), + ), + _buildOtpView(), + Container( + padding: EdgeInsets.symmetric( + horizontal: 20), + alignment: Alignment.centerLeft, + child: Text( + '${ApplicationLocalizations.of(context).translate(i18.password.UPDATE_PASSWORD_TO_CONTINUE)}', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18)), + ), + BuildTextField( + i18.password.CORE_COMMON_NEW_PASSWORD, + newPassword, + obscureText: true, + maxLines: 1, + isRequired: true, + validator: (val) => + Validators.passwordComparision( + val, + ApplicationLocalizations.of( + context) + .translate(i18.password + .NEW_PASSWORD_ENTER)), + onChange: saveInput, + ), + BuildTextField( + i18.password + .CORE_COMMON_CONFIRM_NEW_PASSWORD, + confirmPassword, + obscureText: true, + maxLines: 1, + isRequired: true, + validator: (val) => + Validators.passwordComparision( + val, + ApplicationLocalizations.of( + context) + .translate(i18.password + .CONFIRM_PASSWORD_ENTER), + newPassword.text), + onChange: saveInput, + ), + SizedBox( + height: 10, + ), + BottomButtonBar( + ApplicationLocalizations.of(context) + .translate( + i18.password.CHANGE_PASSWORD), + _pinEditingController.text + .trim() + .length != + pinLength + ? null + : updatePassword), + PasswordHint(password) + ], + ))))), + FooterBanner() + ]), + ), + ))))); } Widget _buildOtpView() { diff --git a/frontend/mgramseva/lib/screeens/ResetPassword/Updatepassword.dart b/frontend/mgramseva/lib/screeens/ResetPassword/Updatepassword.dart index e210737a2..9d9e055b9 100644 --- a/frontend/mgramseva/lib/screeens/ResetPassword/Updatepassword.dart +++ b/frontend/mgramseva/lib/screeens/ResetPassword/Updatepassword.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter/services.dart'; import 'package:flutter_countdown_timer/index.dart'; +import 'package:flutter_focus_watcher/flutter_focus_watcher.dart'; import 'package:mgramseva/model/mdms/tenants.dart'; import 'package:mgramseva/model/success_handler.dart'; import 'package:mgramseva/model/user/user_details.dart'; @@ -97,24 +98,36 @@ class _UpdatePasswordState extends State { @override Widget build(BuildContext context) { - return Scaffold( - body: BackgroundContainer(new Container( - width: MediaQuery.of(context).size.width, - padding: const EdgeInsets.all(8.0), - child: SingleChildScrollView( - child: Form( - key: formKey, - autovalidateMode: autoValidate - ? AutovalidateMode.always - : AutovalidateMode.disabled, - child: new Column(children: [ - Align( - alignment: Alignment.topLeft, - child: MediaQuery.of(context).size.width > 720 - ? Padding( - padding: EdgeInsets.only( - left: MediaQuery.of(context).size.width / 4), - child: IconButton( + return FocusWatcher( + child: Scaffold( + body: BackgroundContainer(new Container( + width: MediaQuery.of(context).size.width, + padding: const EdgeInsets.all(8.0), + child: SingleChildScrollView( + child: Form( + key: formKey, + autovalidateMode: autoValidate + ? AutovalidateMode.always + : AutovalidateMode.disabled, + child: new Column(children: [ + Align( + alignment: Alignment.topLeft, + child: MediaQuery.of(context).size.width > 720 + ? Padding( + padding: EdgeInsets.only( + left: MediaQuery.of(context).size.width / + 4), + child: IconButton( + icon: Icon( + Icons.arrow_back, + ), + iconSize: 25, + color: Colors.white, + splashColor: Colors.purple, + onPressed: () => Navigator.of(context, + rootNavigator: true) + .maybePop())) + : IconButton( icon: Icon( Icons.arrow_back, ), @@ -123,101 +136,95 @@ class _UpdatePasswordState extends State { splashColor: Colors.purple, onPressed: () => Navigator.of(context, rootNavigator: true) - .maybePop())) - : IconButton( - icon: Icon( - Icons.arrow_back, - ), - iconSize: 25, - color: Colors.white, - splashColor: Colors.purple, - onPressed: () => - Navigator.of(context, rootNavigator: true) - .maybePop())), - Container( - padding: EdgeInsets.all(0), - child: Card( - child: Container( - width: MediaQuery.of(context).size.width > 720 - ? MediaQuery.of(context).size.width / 3 - : MediaQuery.of(context).size.width, - child: (Column( - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Logo(), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - '${ApplicationLocalizations.of(context).translate(i18.password.UPDATE_PASSWORD)}', - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.w700), - textAlign: TextAlign.start, - ), - ), - _buildWelcomeMsg(), - _buildTenantDetails(), - _buildOtpView(), - Container( - padding: - EdgeInsets.symmetric(horizontal: 20), - alignment: Alignment.centerLeft, - child: Text( - '${ApplicationLocalizations.of(context).translate(i18.password.UPDATE_PASSWORD_TO_CONTINUE)}', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 16)), - ), - BuildTextField( - i18.password.CORE_COMMON_NEW_PASSWORD, - newPassword, - isRequired: true, - obscureText: true, - maxLines: 1, - validator: (val) => - Validators.passwordComparision( - val, - ApplicationLocalizations.of(context) - .translate(i18.password.NEW_PASSWORD_ENTER)), - onChange: saveInput, - ), - BuildTextField( - i18.password - .CORE_COMMON_CONFIRM_NEW_PASSWORD, - confirmPassword, - isRequired: true, - obscureText: true, - maxLines: 1, - validator: (val) => - Validators.passwordComparision( - val, - ApplicationLocalizations.of(context) - .translate(i18.password.CONFIRM_PASSWORD_ENTER), - newPassword.text), - onChange: saveInput, - ), - SizedBox( - height: 10, - ), - BottomButtonBar( - ApplicationLocalizations.of(context) - .translate( - i18.password.CHANGE_PASSWORD), - _pinEditingController.text - .trim() - .length != - pinLength - ? null - : updatePassword), - PasswordHint(password) - ], - ))))), - FooterBanner() - ]), - ), - )))); + .maybePop())), + Container( + padding: EdgeInsets.all(0), + child: Card( + child: Container( + width: MediaQuery.of(context).size.width > 720 + ? MediaQuery.of(context).size.width / 3 + : MediaQuery.of(context).size.width, + child: (Column( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Logo(), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + '${ApplicationLocalizations.of(context).translate(i18.password.UPDATE_PASSWORD)}', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w700), + textAlign: TextAlign.start, + ), + ), + _buildWelcomeMsg(), + _buildTenantDetails(), + _buildOtpView(), + Container( + padding: EdgeInsets.symmetric( + horizontal: 20), + alignment: Alignment.centerLeft, + child: Text( + '${ApplicationLocalizations.of(context).translate(i18.password.UPDATE_PASSWORD_TO_CONTINUE)}', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 16)), + ), + BuildTextField( + i18.password.CORE_COMMON_NEW_PASSWORD, + newPassword, + isRequired: true, + obscureText: true, + maxLines: 1, + validator: (val) => + Validators.passwordComparision( + val, + ApplicationLocalizations.of( + context) + .translate(i18.password + .NEW_PASSWORD_ENTER)), + onChange: saveInput, + ), + BuildTextField( + i18.password + .CORE_COMMON_CONFIRM_NEW_PASSWORD, + confirmPassword, + isRequired: true, + obscureText: true, + maxLines: 1, + validator: (val) => + Validators.passwordComparision( + val, + ApplicationLocalizations.of( + context) + .translate(i18.password + .CONFIRM_PASSWORD_ENTER), + newPassword.text), + onChange: saveInput, + ), + SizedBox( + height: 10, + ), + BottomButtonBar( + ApplicationLocalizations.of(context) + .translate( + i18.password.CHANGE_PASSWORD), + _pinEditingController.text + .trim() + .length != + pinLength + ? null + : updatePassword), + PasswordHint(password) + ], + ))))), + FooterBanner() + ]), + ), + ))))); } Widget _buildTenantDetails() { diff --git a/frontend/mgramseva/lib/screeens/common/collect_payment.dart b/frontend/mgramseva/lib/screeens/common/collect_payment.dart index de2aefa16..753d85cb7 100644 --- a/frontend/mgramseva/lib/screeens/common/collect_payment.dart +++ b/frontend/mgramseva/lib/screeens/common/collect_payment.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_focus_watcher/flutter_focus_watcher.dart'; import 'package:http/http.dart'; import 'package:mgramseva/model/common/fetch_bill.dart' as billDetails; import 'package:mgramseva/model/common/fetch_bill.dart'; @@ -48,7 +49,8 @@ class _ConnectionPaymentViewState extends State { var consumerPaymentProvider = Provider.of(context, listen: false); FetchBill? fetchBill; - return Scaffold( + return FocusWatcher( + child: Scaffold( drawer: DrawerWrapper( Drawer(child: SideBar()), ), @@ -85,7 +87,7 @@ class _ConnectionPaymentViewState extends State { '${ApplicationLocalizations.of(context).translate(i18.common.COLLECT_PAYMENT)}', () => paymentInfo(fetchBill!, context))), ), - ); + )); } Widget _buildView(FetchBill fetchBill) { diff --git a/frontend/mgramseva/lib/screeens/expense/search_expense.dart b/frontend/mgramseva/lib/screeens/expense/search_expense.dart index 6c0f8bc22..7503e27a7 100644 --- a/frontend/mgramseva/lib/screeens/expense/search_expense.dart +++ b/frontend/mgramseva/lib/screeens/expense/search_expense.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_focus_watcher/flutter_focus_watcher.dart'; import 'package:mgramseva/providers/common_provider.dart'; import 'package:mgramseva/providers/expenses_details_provider.dart'; import 'package:mgramseva/utils/Locilization/application_localizations.dart'; @@ -41,7 +42,8 @@ class _SearchExpenseState extends State { @override Widget build(BuildContext context) { - return Scaffold( + return FocusWatcher( + child: Scaffold( backgroundColor: Theme.of(context).backgroundColor, appBar: CustomAppBar(), drawer: DrawerWrapper( @@ -133,7 +135,7 @@ class _SearchExpenseState extends State { Footer() ])), bottomNavigationBar: BottomButtonBar(i18.common.SEARCH, onSubmit), - ); + )); } void onChangeOfExpense(val) { @@ -158,8 +160,6 @@ class _SearchExpenseState extends State { query.removeWhere((key, value) => value == null || value.trim().isEmpty); - - Provider.of(context, listen: false) .searchExpense(query, () => getCrteria(query), context); } else { @@ -167,22 +167,22 @@ class _SearchExpenseState extends State { } } - String getCrteria(Map query){ + String getCrteria(Map query) { var criteria = ''; query.forEach((key, value) { switch (key) { case 'expenseType': criteria += - '${ApplicationLocalizations.of(context).translate(i18.expense.EXPENSE_TYPE)} ${ApplicationLocalizations.of(context).translate(expenseType ?? '')} \t'; + '${ApplicationLocalizations.of(context).translate(i18.expense.EXPENSE_TYPE)} ${ApplicationLocalizations.of(context).translate(expenseType ?? '')} \t'; break; case 'challanNo': criteria += - '${ApplicationLocalizations.of(context).translate(i18.common.BILL_ID)} ${billIdCtrl.text}'; + '${ApplicationLocalizations.of(context).translate(i18.common.BILL_ID)} ${billIdCtrl.text}'; break; case 'vendorName': criteria += - '${ApplicationLocalizations.of(context).translate(i18.expense.VENDOR_NAME)} ${vendorNameCtrl.text} \t'; + '${ApplicationLocalizations.of(context).translate(i18.expense.VENDOR_NAME)} ${vendorNameCtrl.text} \t'; break; } }); diff --git a/frontend/mgramseva/lib/widgets/TextFieldBuilder.dart b/frontend/mgramseva/lib/widgets/TextFieldBuilder.dart index 4df46cb61..aebca6e75 100644 --- a/frontend/mgramseva/lib/widgets/TextFieldBuilder.dart +++ b/frontend/mgramseva/lib/widgets/TextFieldBuilder.dart @@ -1,6 +1,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_focus_watcher/flutter_focus_watcher.dart'; import 'package:mgramseva/utils/Locilization/application_localizations.dart'; import 'package:mgramseva/utils/common_widgets.dart'; @@ -70,83 +71,85 @@ class _BuildTextField extends State { @override Widget build(BuildContext context) { // TextForm - Widget textFormwidget = TextFormField( - style: TextStyle( - fontWeight: FontWeight.w400, - fontSize: 16, - color: widget.isDisabled != null && widget.isDisabled! - ? Colors.grey - : Theme.of(context).primaryColorDark), - enabled: widget.isDisabled != null - ? (widget.isDisabled == true) - ? false - : true - : true, - controller: widget.controller, - keyboardType: widget.textInputType ?? TextInputType.text, - inputFormatters: widget.inputFormatter, - autofocus: false, - maxLength: widget.maxLength, - maxLines: widget.maxLines, - focusNode: widget.focusNode, - autovalidateMode: widget.autoValidation, - textCapitalization: - widget.textCapitalization ?? TextCapitalization.none, - obscureText: widget.obscureText ?? false, - readOnly: widget.readOnly ?? false, - validator: widget.validator != null - ? (val) => widget.validator!(val) - : (value) { - if (value!.trim().isEmpty && widget.isRequired) { - return ApplicationLocalizations.of(context).translate( - widget.requiredMessage ?? '${widget.labelText}_REQUIRED'); - } else if (widget.pattern != null && widget.pattern != '') { - return (new RegExp(widget.pattern!).hasMatch(value)) - ? null - : ApplicationLocalizations.of(context) - .translate(widget.message); - } - return null; - }, - decoration: InputDecoration( - hintText: widget.placeHolder != null - ? ApplicationLocalizations.of(context) - .translate((widget.placeHolder!)) - : "", - border: widget.inputBorder, - enabledBorder: widget.inputBorder, - errorMaxLines: 2, - enabled: widget.isDisabled ?? true, - filled: widget.isFilled, - fillColor: widget.isDisabled != null && widget.isDisabled! - ? Colors.grey - : Colors.white, - prefixIconConstraints: BoxConstraints(minWidth: 0, minHeight: 0), - prefixStyle: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w400, - color: - widget.isDisabled != null && widget.isDisabled! + Widget textFormwidget = ForceFocusWatcher( + child: TextFormField( + style: TextStyle( + fontWeight: FontWeight.w400, + fontSize: 16, + color: widget.isDisabled != null && widget.isDisabled! + ? Colors.grey + : Theme.of(context).primaryColorDark), + enabled: widget.isDisabled != null + ? (widget.isDisabled == true) + ? false + : true + : true, + controller: widget.controller, + keyboardType: widget.textInputType ?? TextInputType.text, + inputFormatters: widget.inputFormatter, + autofocus: false, + maxLength: widget.maxLength, + maxLines: widget.maxLines, + focusNode: widget.focusNode, + autovalidateMode: widget.autoValidation, + textCapitalization: + widget.textCapitalization ?? TextCapitalization.none, + obscureText: widget.obscureText ?? false, + readOnly: widget.readOnly ?? false, + validator: widget.validator != null + ? (val) => widget.validator!(val) + : (value) { + if (value!.trim().isEmpty && widget.isRequired) { + return ApplicationLocalizations.of(context).translate( + widget.requiredMessage ?? + '${widget.labelText}_REQUIRED'); + } else if (widget.pattern != null && widget.pattern != '') { + return (new RegExp(widget.pattern!).hasMatch(value)) + ? null + : ApplicationLocalizations.of(context) + .translate(widget.message); + } + return null; + }, + decoration: InputDecoration( + hintText: widget.placeHolder != null + ? ApplicationLocalizations.of(context) + .translate((widget.placeHolder!)) + : "", + border: widget.inputBorder, + enabledBorder: widget.inputBorder, + errorMaxLines: 2, + enabled: widget.isDisabled ?? true, + filled: widget.isFilled, + fillColor: widget.isDisabled != null && widget.isDisabled! ? Colors.grey - : Theme.of(context).primaryColorDark), - prefixIcon: widget.prefixIcon ?? - (widget.prefixText == '' - ? null - : Padding( - padding: const EdgeInsets.only(top: 10, left: 10, bottom: 10, right: 0), - child: Text( - widget.prefixText, - style: TextStyle( - fontSize: kIsWeb ? 15 : 16, - fontWeight: FontWeight.w400, - color: - widget.isDisabled != null && widget.isDisabled! - ? Colors.grey - : Theme.of(context).primaryColorDark), - ), - )), - ), - onChanged: widget.onChange); + : Colors.white, + prefixIconConstraints: BoxConstraints(minWidth: 0, minHeight: 0), + prefixStyle: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w400, + color: widget.isDisabled != null && widget.isDisabled! + ? Colors.grey + : Theme.of(context).primaryColorDark), + prefixIcon: widget.prefixIcon ?? + (widget.prefixText == '' + ? null + : Padding( + padding: const EdgeInsets.only( + top: 10, left: 10, bottom: 10, right: 0), + child: Text( + widget.prefixText, + style: TextStyle( + fontSize: kIsWeb ? 15 : 16, + fontWeight: FontWeight.w400, + color: widget.isDisabled != null && + widget.isDisabled! + ? Colors.grey + : Theme.of(context).primaryColorDark), + ), + )), + ), + onChanged: widget.onChange)); // Label Text Widget textLabelwidget = Wrap(direction: Axis.horizontal, children: [ diff --git a/frontend/mgramseva/pubspec.lock b/frontend/mgramseva/pubspec.lock index e5ab48021..50296abc8 100644 --- a/frontend/mgramseva/pubspec.lock +++ b/frontend/mgramseva/pubspec.lock @@ -258,6 +258,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.7.0" + flutter_focus_watcher: + dependency: "direct main" + description: + name: flutter_focus_watcher + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" flutter_keyboard_visibility: dependency: transitive description: diff --git a/frontend/mgramseva/pubspec.yaml b/frontend/mgramseva/pubspec.yaml index b64f19b8c..9de768709 100644 --- a/frontend/mgramseva/pubspec.yaml +++ b/frontend/mgramseva/pubspec.yaml @@ -49,6 +49,7 @@ dependencies: flutter_rating_bar: ^4.0.0 collection: ^1.15.0 image_picker: ^0.8.4 + flutter_focus_watcher: ^2.0.0 path: ^1.8.0 dev_dependencies: