From 4467da83b9a7f3c56a84d1c9417eff6a7b25d43e Mon Sep 17 00:00:00 2001 From: yaso Date: Wed, 23 Oct 2024 14:26:17 +0200 Subject: [PATCH] autofill signin details --- .../mih_pass_input.dart | 3 + .../mih_text_input.dart | 12 + .../mih_packages/authentication/signin.dart | 453 +++++++++--------- 3 files changed, 244 insertions(+), 224 deletions(-) diff --git a/Frontend/patient_manager/lib/mih_components/mih_inputs_and_buttons/mih_pass_input.dart b/Frontend/patient_manager/lib/mih_components/mih_inputs_and_buttons/mih_pass_input.dart index 1f9a1e24..78794a5d 100644 --- a/Frontend/patient_manager/lib/mih_components/mih_inputs_and_buttons/mih_pass_input.dart +++ b/Frontend/patient_manager/lib/mih_components/mih_inputs_and_buttons/mih_pass_input.dart @@ -6,6 +6,7 @@ class MIHPassField extends StatefulWidget { final String hintText; final bool required; final bool signIn; + final Iterable? autoFillHintGroup; const MIHPassField({ super.key, @@ -13,6 +14,7 @@ class MIHPassField extends StatefulWidget { required this.hintText, required this.required, required this.signIn, + this.autoFillHintGroup, }); @override @@ -128,6 +130,7 @@ class _MIHPassFieldState extends State { @override Widget build(BuildContext context) { return TextField( + autofillHints: widget.autoFillHintGroup, controller: widget.controller, style: TextStyle( color: MzanziInnovationHub.of(context)!.theme.secondaryColor()), diff --git a/Frontend/patient_manager/lib/mih_components/mih_inputs_and_buttons/mih_text_input.dart b/Frontend/patient_manager/lib/mih_components/mih_inputs_and_buttons/mih_text_input.dart index 223aaa3a..c5ee0a38 100644 --- a/Frontend/patient_manager/lib/mih_components/mih_inputs_and_buttons/mih_text_input.dart +++ b/Frontend/patient_manager/lib/mih_components/mih_inputs_and_buttons/mih_text_input.dart @@ -6,6 +6,7 @@ class MIHTextField extends StatefulWidget { final String hintText; final bool editable; final bool required; + final Iterable? autoFillHintGroup; const MIHTextField({ super.key, @@ -13,6 +14,7 @@ class MIHTextField extends StatefulWidget { required this.hintText, required this.editable, required this.required, + this.autoFillHintGroup, }); @override @@ -75,6 +77,15 @@ class _MIHTextFieldState extends State { }); } + // List getAutoFillDetails(){ + // if(widget.autoFillHintGroup == null){ + // return []; + // } + // else{ + // return widget.autoFillHintGroup!; + // } + // } + Widget setRequiredText() { if (widget.required) { return Row( @@ -116,6 +127,7 @@ class _MIHTextFieldState extends State { @override Widget build(BuildContext context) { return TextField( + autofillHints: widget.autoFillHintGroup, style: TextStyle( color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), ), diff --git a/Frontend/patient_manager/lib/mih_packages/authentication/signin.dart b/Frontend/patient_manager/lib/mih_packages/authentication/signin.dart index f80320aa..0727aaf1 100644 --- a/Frontend/patient_manager/lib/mih_packages/authentication/signin.dart +++ b/Frontend/patient_manager/lib/mih_packages/authentication/signin.dart @@ -168,6 +168,7 @@ class _SignInState extends State { } else { await signUserIn(); if (successfulSignIn) { + TextInput.finishAutofillContext(); Navigator.of(context).pushNamedAndRemoveUntil('/', (route) => false); } } @@ -313,245 +314,249 @@ class _SignInState extends State { physics: const BouncingScrollPhysics(), child: Padding( padding: const EdgeInsets.all(25.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - //logo - Icon( - Icons.lock, - size: 100, - color: MzanziInnovationHub.of(context)! - .theme - .secondaryColor(), - ), - //spacer - const SizedBox(height: 10), - //Heading - Text( - 'Sign In', - style: TextStyle( - fontSize: 25, - fontWeight: FontWeight.bold, + child: AutofillGroup( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + //logo + Icon( + Icons.lock, + size: 100, color: MzanziInnovationHub.of(context)! .theme .secondaryColor(), ), - ), - //spacer - const SizedBox(height: 25), + //spacer + const SizedBox(height: 10), + //Heading + Text( + 'Sign In', + style: TextStyle( + fontSize: 25, + fontWeight: FontWeight.bold, + color: MzanziInnovationHub.of(context)! + .theme + .secondaryColor(), + ), + ), + //spacer + const SizedBox(height: 25), - // SizedBox( - // width: 500.0, - // //height: 100.0, - // child: Row( - // mainAxisAlignment: MainAxisAlignment.start, - // children: [ - // GestureDetector( - // onTap: () { - // showSandboxProfiles(); - // }, - // child: Text( - // 'Sandbox Profile', - // style: TextStyle( - // fontSize: 18, - // color: MzanziInnovationHub.of(context)! - // .theme - // .secondaryColor(), - // fontWeight: FontWeight.bold, - // ), - // ), - // ), - // ], - // ), - // ), - // const SizedBox(height: 10), - //email input - SizedBox( - width: 500.0, - child: MIHTextField( - controller: emailController, - hintText: 'Email', - editable: true, - required: true, + // SizedBox( + // width: 500.0, + // //height: 100.0, + // child: Row( + // mainAxisAlignment: MainAxisAlignment.start, + // children: [ + // GestureDetector( + // onTap: () { + // showSandboxProfiles(); + // }, + // child: Text( + // 'Sandbox Profile', + // style: TextStyle( + // fontSize: 18, + // color: MzanziInnovationHub.of(context)! + // .theme + // .secondaryColor(), + // fontWeight: FontWeight.bold, + // ), + // ), + // ), + // ], + // ), + // ), + // const SizedBox(height: 10), + //email input + SizedBox( + width: 500.0, + child: MIHTextField( + controller: emailController, + hintText: 'Email', + editable: true, + required: true, + autoFillHintGroup: const [AutofillHints.email], + ), ), - ), - //spacer - const SizedBox(height: 10), - //password input - SizedBox( - width: 500.0, - child: MIHPassField( - controller: passwordController, - hintText: 'Password', - required: true, - signIn: true, + //spacer + const SizedBox(height: 10), + //password input + SizedBox( + width: 500.0, + child: MIHPassField( + controller: passwordController, + hintText: 'Password', + required: true, + signIn: true, + autoFillHintGroup: const [AutofillHints.password], + ), ), - ), - SizedBox( - width: 500.0, - //height: 100.0, - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - GestureDetector( - onTap: () { - Navigator.of(context).pushNamed( - '/forgot-password', - ); - }, - child: Text( - 'Forgot Password?', - style: TextStyle( - fontSize: 15, - color: MzanziInnovationHub.of(context)! - .theme - .secondaryColor(), - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ), - - //spacer - const SizedBox(height: 30), - // sign in button - SizedBox( - width: 500.0, - height: 50.0, - child: MIHButton( - buttonText: "Sign In", - buttonColor: MzanziInnovationHub.of(context)! - .theme - .secondaryColor(), - textColor: MzanziInnovationHub.of(context)! - .theme - .primaryColor(), - onTap: () async { - validateInput(); - }, - ), - ), - //spacer - const SizedBox(height: 10), - //register text - SizedBox( - width: 500.0, - //height: 100.0, - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Text( - 'New User?', - style: TextStyle( - fontSize: 18, - color: MzanziInnovationHub.of(context)! - .theme - .messageTextColor()), - ), - const SizedBox( - width: 6, - ), - GestureDetector( - onTap: widget.onTap, - child: Text( - 'Register Now', - style: TextStyle( - fontSize: 18, - color: MzanziInnovationHub.of(context)! - .theme - .secondaryColor(), - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ), - //spacer - const SizedBox(height: 15), - SizedBox( - width: 500.0, - //height: 100.0, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Flexible( - flex: 1, - child: Padding( - padding: EdgeInsets.only(right: 10.0), - child: Divider(), - ), - ), - Flexible( - flex: 1, - child: GestureDetector( - child: Text( - 'Use Sandox Profile', - textAlign: TextAlign.center, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 15, - color: MzanziInnovationHub.of(context)! - .theme - .secondaryColor()), - ), - onTap: () { - setState(() { - showProfiles = !showProfiles; - }); - }, - ), - ), - const Flexible( - flex: 1, - child: Padding( - padding: EdgeInsets.only(left: 10.0), - child: Divider(), - ), - ), - ], - ), - ), - const SizedBox(height: 10), - Visibility( - visible: showProfiles, - child: SizedBox( - width: 500, - child: Column( - //mainAxisSize: MainAxisSize.max, + SizedBox( + width: 500.0, + //height: 100.0, + child: Row( + mainAxisAlignment: MainAxisAlignment.end, children: [ - GridView.builder( - // physics: , - shrinkWrap: true, - itemCount: sandboxProfileList.length, - gridDelegate: - const SliverGridDelegateWithMaxCrossAxisExtent( - mainAxisSpacing: 10, - maxCrossAxisExtent: 100), - itemBuilder: (context, index) { - return sandboxProfileList[index]; + GestureDetector( + onTap: () { + Navigator.of(context).pushNamed( + '/forgot-password', + ); }, - ), - const SizedBox(height: 20), - Text( - "NB: These accounts are used for test purposes. Please do not store personal information on these profiles.", - textAlign: TextAlign.center, - style: TextStyle( - color: MzanziInnovationHub.of(context)! - .theme - .secondaryColor(), - fontSize: 15.0, - fontWeight: FontWeight.bold, + child: Text( + 'Forgot Password?', + style: TextStyle( + fontSize: 15, + color: MzanziInnovationHub.of(context)! + .theme + .secondaryColor(), + fontWeight: FontWeight.bold, + ), ), ), ], ), ), - ), - ], + + //spacer + const SizedBox(height: 30), + // sign in button + SizedBox( + width: 500.0, + height: 50.0, + child: MIHButton( + buttonText: "Sign In", + buttonColor: MzanziInnovationHub.of(context)! + .theme + .secondaryColor(), + textColor: MzanziInnovationHub.of(context)! + .theme + .primaryColor(), + onTap: () async { + validateInput(); + }, + ), + ), + //spacer + const SizedBox(height: 10), + //register text + SizedBox( + width: 500.0, + //height: 100.0, + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Text( + 'New User?', + style: TextStyle( + fontSize: 18, + color: MzanziInnovationHub.of(context)! + .theme + .messageTextColor()), + ), + const SizedBox( + width: 6, + ), + GestureDetector( + onTap: widget.onTap, + child: Text( + 'Register Now', + style: TextStyle( + fontSize: 18, + color: MzanziInnovationHub.of(context)! + .theme + .secondaryColor(), + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ), + //spacer + const SizedBox(height: 15), + SizedBox( + width: 500.0, + //height: 100.0, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Flexible( + flex: 1, + child: Padding( + padding: EdgeInsets.only(right: 10.0), + child: Divider(), + ), + ), + Flexible( + flex: 1, + child: GestureDetector( + child: Text( + 'Use Sandox Profile', + textAlign: TextAlign.center, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 15, + color: MzanziInnovationHub.of(context)! + .theme + .secondaryColor()), + ), + onTap: () { + setState(() { + showProfiles = !showProfiles; + }); + }, + ), + ), + const Flexible( + flex: 1, + child: Padding( + padding: EdgeInsets.only(left: 10.0), + child: Divider(), + ), + ), + ], + ), + ), + const SizedBox(height: 10), + Visibility( + visible: showProfiles, + child: SizedBox( + width: 500, + child: Column( + //mainAxisSize: MainAxisSize.max, + children: [ + GridView.builder( + // physics: , + shrinkWrap: true, + itemCount: sandboxProfileList.length, + gridDelegate: + const SliverGridDelegateWithMaxCrossAxisExtent( + mainAxisSpacing: 10, + maxCrossAxisExtent: 100), + itemBuilder: (context, index) { + return sandboxProfileList[index]; + }, + ), + const SizedBox(height: 20), + Text( + "NB: These accounts are used for test purposes. Please do not store personal information on these profiles.", + textAlign: TextAlign.center, + style: TextStyle( + color: MzanziInnovationHub.of(context)! + .theme + .secondaryColor(), + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + ), + ], + ), ), ), ),