mirror of
https://github.com/ente-io/ente.git
synced 2025-05-29 05:51:19 +00:00
83 lines
2.2 KiB
Dart
83 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import "package:photos/l10n/l10n.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
|
|
State<ChangeEmailDialog> createState() => _ChangeEmailDialogState();
|
|
}
|
|
|
|
class _ChangeEmailDialogState extends State<ChangeEmailDialog> {
|
|
String? _email;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final l10n = context.l10n;
|
|
return AlertDialog(
|
|
title: Text(l10n.enterYourEmailAddress),
|
|
content: SingleChildScrollView(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
TextFormField(
|
|
decoration: InputDecoration(
|
|
hintText: l10n.email,
|
|
hintStyle: const TextStyle(
|
|
color: Colors.white30,
|
|
),
|
|
contentPadding: const EdgeInsets.all(12),
|
|
),
|
|
onChanged: (value) {
|
|
setState(() {
|
|
_email = value;
|
|
});
|
|
},
|
|
autocorrect: false,
|
|
keyboardType: TextInputType.emailAddress,
|
|
initialValue: _email,
|
|
autofocus: true,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
child: Text(
|
|
l10n.cancel,
|
|
style: const TextStyle(
|
|
color: Colors.redAccent,
|
|
),
|
|
),
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
TextButton(
|
|
child: Text(
|
|
l10n.verify,
|
|
style: const TextStyle(
|
|
color: Colors.green,
|
|
),
|
|
),
|
|
onPressed: () {
|
|
if (!isValidEmail(_email)) {
|
|
showErrorDialog(
|
|
context,
|
|
l10n.invalidEmailAddress,
|
|
l10n.enterValidEmail,
|
|
);
|
|
return;
|
|
}
|
|
UserService.instance.sendOtt(context, _email!, isChangeEmail: true);
|
|
},
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|