fix: add validation form email
This commit is contained in:
parent
4461b78565
commit
59e046bd92
|
@ -15,41 +15,71 @@ import 'package:provider/provider.dart';
|
|||
class SubmitEmail extends StatelessWidget {
|
||||
const SubmitEmail({Key? key}) : super(key: key);
|
||||
|
||||
Widget _emailVerify() {
|
||||
return Column(
|
||||
children: [
|
||||
const ImageView(image: PathAssets.imgEmail),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(children: [
|
||||
const TextSpan(
|
||||
text:
|
||||
'We have sent a verification link to your e-mail. \nPlease check your email for ',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
decoration: TextDecoration.none,
|
||||
Widget _emailVerify(BuildContext context, SubmissionDataViewModel provider) {
|
||||
var textTheme = Theme.of(context).textTheme;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const TextCaption(title: 'Check your e-mail'),
|
||||
const ImageView(image: PathAssets.imgEmail),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(children: [
|
||||
TextSpan(
|
||||
text:
|
||||
'We have sent a verification link to your e-mail. \nPlease check your email for ',
|
||||
style: textTheme.displayMedium,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
recognizer: TapGestureRecognizer()..onTap = () {},
|
||||
text: 'verification',
|
||||
style: const TextStyle(
|
||||
color: Colors.blue,
|
||||
TextSpan(
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () async {
|
||||
await provider.next(context).then((value) {
|
||||
if (value) {
|
||||
routePush(context, page: const SubmissionParent());
|
||||
}
|
||||
});
|
||||
},
|
||||
text: 'verification',
|
||||
style: const TextStyle(
|
||||
color: Colors.blue,
|
||||
),
|
||||
),
|
||||
),
|
||||
const TextSpan(
|
||||
text: ' to \ncontinue registration.',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
decoration: TextDecoration.none,
|
||||
TextSpan(
|
||||
text: ' to \ncontinue registration.',
|
||||
style: textTheme.displayMedium,
|
||||
),
|
||||
),
|
||||
]),
|
||||
]),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
showEmailVerify(BuildContext context, SubmissionDataViewModel provider) {
|
||||
Navigator.pop(context);
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
enableDrag: false,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(
|
||||
top: Radius.zero,
|
||||
),
|
||||
],
|
||||
),
|
||||
builder: (context) {
|
||||
var flutterView = View.of(context);
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: MediaQueryData.fromView(flutterView).padding.top,
|
||||
),
|
||||
child: _emailVerify(context, provider),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -60,45 +90,41 @@ class SubmitEmail extends StatelessWidget {
|
|||
builder: (context, child) {
|
||||
return Consumer<SubmissionDataViewModel>(
|
||||
builder: (context, provider, child) {
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
!provider.isEmailVerify
|
||||
? const TextCaption(title: 'Enter your e-mail')
|
||||
: const TextCaption(title: 'Check your e-mail '),
|
||||
!provider.isEmailVerify
|
||||
? TextFormView(
|
||||
name: 'E-mail Address',
|
||||
hintText: 'Input e-mail address',
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
validator: (value) {
|
||||
if (value!.isEmpty) {
|
||||
return 'Filled cannot be empty';
|
||||
} else if (!StringUtils.emailValidation(value)) {
|
||||
return 'Format email wrong';
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
// onTap: () {
|
||||
// provider.submitEmail();
|
||||
// },
|
||||
)
|
||||
: _emailVerify(),
|
||||
SizedBox(height: SizeConfig.height * .42),
|
||||
ButtonView(
|
||||
name: 'Next',
|
||||
onPressed: () async {
|
||||
await provider.next(context).then((value) {
|
||||
if (value) {
|
||||
routePush(context, page: const SubmissionParent());
|
||||
return SizedBox(
|
||||
height: SizeConfig.height * .78,
|
||||
child: Form(
|
||||
key: provider.formKeySubmitEmail,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
const TextCaption(title: 'Enter your e-mail'),
|
||||
TextFormView(
|
||||
name: 'E-mail Address',
|
||||
hintText: 'Input e-mail address',
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
validator: (value) {
|
||||
if (value!.isEmpty) {
|
||||
return 'Filled cannot be empty';
|
||||
} else if (!StringUtils.emailValidation(value)) {
|
||||
return 'Format email wrong';
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
},
|
||||
)
|
||||
],
|
||||
},
|
||||
),
|
||||
SizedBox(height: SizeConfig.height * .43),
|
||||
ButtonView(
|
||||
name: 'Next',
|
||||
onPressed: () async {
|
||||
if (provider.formKeySubmitEmail.currentState!
|
||||
.validate()) {
|
||||
showEmailVerify(context, provider);
|
||||
}
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user