autofill signin details

This commit is contained in:
2024-10-23 14:26:17 +02:00
parent 013baa22bd
commit 4467da83b9
3 changed files with 244 additions and 224 deletions

View File

@@ -6,6 +6,7 @@ class MIHPassField extends StatefulWidget {
final String hintText; final String hintText;
final bool required; final bool required;
final bool signIn; final bool signIn;
final Iterable<String>? autoFillHintGroup;
const MIHPassField({ const MIHPassField({
super.key, super.key,
@@ -13,6 +14,7 @@ class MIHPassField extends StatefulWidget {
required this.hintText, required this.hintText,
required this.required, required this.required,
required this.signIn, required this.signIn,
this.autoFillHintGroup,
}); });
@override @override
@@ -128,6 +130,7 @@ class _MIHPassFieldState extends State<MIHPassField> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return TextField( return TextField(
autofillHints: widget.autoFillHintGroup,
controller: widget.controller, controller: widget.controller,
style: TextStyle( style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()), color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),

View File

@@ -6,6 +6,7 @@ class MIHTextField extends StatefulWidget {
final String hintText; final String hintText;
final bool editable; final bool editable;
final bool required; final bool required;
final Iterable<String>? autoFillHintGroup;
const MIHTextField({ const MIHTextField({
super.key, super.key,
@@ -13,6 +14,7 @@ class MIHTextField extends StatefulWidget {
required this.hintText, required this.hintText,
required this.editable, required this.editable,
required this.required, required this.required,
this.autoFillHintGroup,
}); });
@override @override
@@ -75,6 +77,15 @@ class _MIHTextFieldState extends State<MIHTextField> {
}); });
} }
// List<AutofillGroup> getAutoFillDetails(){
// if(widget.autoFillHintGroup == null){
// return [];
// }
// else{
// return widget.autoFillHintGroup!;
// }
// }
Widget setRequiredText() { Widget setRequiredText() {
if (widget.required) { if (widget.required) {
return Row( return Row(
@@ -116,6 +127,7 @@ class _MIHTextFieldState extends State<MIHTextField> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return TextField( return TextField(
autofillHints: widget.autoFillHintGroup,
style: TextStyle( style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
), ),

View File

@@ -168,6 +168,7 @@ class _SignInState extends State<SignIn> {
} else { } else {
await signUserIn(); await signUserIn();
if (successfulSignIn) { if (successfulSignIn) {
TextInput.finishAutofillContext();
Navigator.of(context).pushNamedAndRemoveUntil('/', (route) => false); Navigator.of(context).pushNamedAndRemoveUntil('/', (route) => false);
} }
} }
@@ -313,245 +314,249 @@ class _SignInState extends State<SignIn> {
physics: const BouncingScrollPhysics(), physics: const BouncingScrollPhysics(),
child: Padding( child: Padding(
padding: const EdgeInsets.all(25.0), padding: const EdgeInsets.all(25.0),
child: Column( child: AutofillGroup(
mainAxisAlignment: MainAxisAlignment.center, child: Column(
children: [ mainAxisAlignment: MainAxisAlignment.center,
//logo children: [
Icon( //logo
Icons.lock, Icon(
size: 100, Icons.lock,
color: MzanziInnovationHub.of(context)! size: 100,
.theme
.secondaryColor(),
),
//spacer
const SizedBox(height: 10),
//Heading
Text(
'Sign In',
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
color: MzanziInnovationHub.of(context)! color: MzanziInnovationHub.of(context)!
.theme .theme
.secondaryColor(), .secondaryColor(),
), ),
), //spacer
//spacer const SizedBox(height: 10),
const SizedBox(height: 25), //Heading
Text(
'Sign In',
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
color: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
),
),
//spacer
const SizedBox(height: 25),
// SizedBox( // SizedBox(
// width: 500.0, // width: 500.0,
// //height: 100.0, // //height: 100.0,
// child: Row( // child: Row(
// mainAxisAlignment: MainAxisAlignment.start, // mainAxisAlignment: MainAxisAlignment.start,
// children: [ // children: [
// GestureDetector( // GestureDetector(
// onTap: () { // onTap: () {
// showSandboxProfiles(); // showSandboxProfiles();
// }, // },
// child: Text( // child: Text(
// 'Sandbox Profile', // 'Sandbox Profile',
// style: TextStyle( // style: TextStyle(
// fontSize: 18, // fontSize: 18,
// color: MzanziInnovationHub.of(context)! // color: MzanziInnovationHub.of(context)!
// .theme // .theme
// .secondaryColor(), // .secondaryColor(),
// fontWeight: FontWeight.bold, // fontWeight: FontWeight.bold,
// ), // ),
// ), // ),
// ), // ),
// ], // ],
// ), // ),
// ), // ),
// const SizedBox(height: 10), // const SizedBox(height: 10),
//email input //email input
SizedBox( SizedBox(
width: 500.0, width: 500.0,
child: MIHTextField( child: MIHTextField(
controller: emailController, controller: emailController,
hintText: 'Email', hintText: 'Email',
editable: true, editable: true,
required: true, required: true,
autoFillHintGroup: const [AutofillHints.email],
),
), ),
),
//spacer //spacer
const SizedBox(height: 10), const SizedBox(height: 10),
//password input //password input
SizedBox( SizedBox(
width: 500.0, width: 500.0,
child: MIHPassField( child: MIHPassField(
controller: passwordController, controller: passwordController,
hintText: 'Password', hintText: 'Password',
required: true, required: true,
signIn: true, signIn: true,
autoFillHintGroup: const [AutofillHints.password],
),
), ),
), SizedBox(
SizedBox( width: 500.0,
width: 500.0, //height: 100.0,
//height: 100.0, child: Row(
child: Row( mainAxisAlignment: MainAxisAlignment.end,
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,
children: [ children: [
GridView.builder( GestureDetector(
// physics: , onTap: () {
shrinkWrap: true, Navigator.of(context).pushNamed(
itemCount: sandboxProfileList.length, '/forgot-password',
gridDelegate: );
const SliverGridDelegateWithMaxCrossAxisExtent(
mainAxisSpacing: 10,
maxCrossAxisExtent: 100),
itemBuilder: (context, index) {
return sandboxProfileList[index];
}, },
), child: Text(
const SizedBox(height: 20), 'Forgot Password?',
Text( style: TextStyle(
"NB: These accounts are used for test purposes. Please do not store personal information on these profiles.", fontSize: 15,
textAlign: TextAlign.center, color: MzanziInnovationHub.of(context)!
style: TextStyle( .theme
color: MzanziInnovationHub.of(context)! .secondaryColor(),
.theme fontWeight: FontWeight.bold,
.secondaryColor(), ),
fontSize: 15.0,
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,
),
),
],
),
),
),
],
),
), ),
), ),
), ),