forked from yaso_meth/mih-project
autofill signin details
This commit is contained in:
@@ -6,6 +6,7 @@ class MIHPassField extends StatefulWidget {
|
||||
final String hintText;
|
||||
final bool required;
|
||||
final bool signIn;
|
||||
final Iterable<String>? 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<MIHPassField> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextField(
|
||||
autofillHints: widget.autoFillHintGroup,
|
||||
controller: widget.controller,
|
||||
style: TextStyle(
|
||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
|
||||
|
||||
@@ -6,6 +6,7 @@ class MIHTextField extends StatefulWidget {
|
||||
final String hintText;
|
||||
final bool editable;
|
||||
final bool required;
|
||||
final Iterable<String>? 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<MIHTextField> {
|
||||
});
|
||||
}
|
||||
|
||||
// List<AutofillGroup> 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<MIHTextField> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextField(
|
||||
autofillHints: widget.autoFillHintGroup,
|
||||
style: TextStyle(
|
||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
),
|
||||
|
||||
@@ -168,6 +168,7 @@ class _SignInState extends State<SignIn> {
|
||||
} else {
|
||||
await signUserIn();
|
||||
if (successfulSignIn) {
|
||||
TextInput.finishAutofillContext();
|
||||
Navigator.of(context).pushNamedAndRemoveUntil('/', (route) => false);
|
||||
}
|
||||
}
|
||||
@@ -313,245 +314,249 @@ class _SignInState extends State<SignIn> {
|
||||
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,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user