2022-09-07 08:30:09 +00:00
|
|
|
// @dart=2.9
|
|
|
|
|
2021-07-28 18:06:30 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:photos/services/user_service.dart';
|
|
|
|
import 'package:photos/utils/dialog_util.dart';
|
|
|
|
import 'package:photos/utils/email_util.dart';
|
|
|
|
|
|
|
|
class ChangeEmailDialog extends StatefulWidget {
|
|
|
|
const ChangeEmailDialog({Key key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
2022-07-03 09:45:00 +00:00
|
|
|
State<ChangeEmailDialog> createState() => _ChangeEmailDialogState();
|
2021-07-28 18:06:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class _ChangeEmailDialogState extends State<ChangeEmailDialog> {
|
|
|
|
String _email;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return AlertDialog(
|
2022-07-04 06:02:17 +00:00
|
|
|
title: const Text("Enter your email address"),
|
2021-07-28 18:06:30 +00:00
|
|
|
content: SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
TextFormField(
|
2022-07-04 06:02:17 +00:00
|
|
|
decoration: const InputDecoration(
|
2022-05-30 11:08:15 +00:00
|
|
|
hintText: 'Email',
|
2021-07-28 18:06:30 +00:00
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: Colors.white30,
|
|
|
|
),
|
|
|
|
contentPadding: EdgeInsets.all(12),
|
|
|
|
),
|
|
|
|
onChanged: (value) {
|
|
|
|
setState(() {
|
|
|
|
_email = value;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
autocorrect: false,
|
|
|
|
keyboardType: TextInputType.emailAddress,
|
|
|
|
initialValue: _email,
|
|
|
|
autofocus: true,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
actions: [
|
|
|
|
TextButton(
|
2022-07-04 06:02:17 +00:00
|
|
|
child: const Text(
|
2022-05-17 11:38:21 +00:00
|
|
|
"Cancel",
|
2021-07-28 18:06:30 +00:00
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.redAccent,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
TextButton(
|
2022-07-04 06:02:17 +00:00
|
|
|
child: const Text(
|
2022-05-17 11:38:21 +00:00
|
|
|
"Verify",
|
2021-07-28 18:06:30 +00:00
|
|
|
style: TextStyle(
|
2022-05-16 20:38:11 +00:00
|
|
|
color: Colors.green,
|
2021-07-28 18:06:30 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
if (!isValidEmail(_email)) {
|
2022-06-11 08:23:52 +00:00
|
|
|
showErrorDialog(
|
|
|
|
context,
|
|
|
|
"Invalid email address",
|
|
|
|
"Please enter a valid email address.",
|
|
|
|
);
|
2021-07-28 18:06:30 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-07-06 16:57:31 +00:00
|
|
|
UserService.instance.sendOtt(context, _email, isChangeEmail: true);
|
2021-07-28 18:06:30 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|