forked from eatvio/eatvio_app
82 lines
2.4 KiB
Dart
82 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
||
|
||
class VerifyEmailScreen extends StatefulWidget {
|
||
const VerifyEmailScreen({super.key});
|
||
|
||
@override
|
||
State<VerifyEmailScreen> createState() => _VerifyEmailScreenState();
|
||
}
|
||
|
||
class _VerifyEmailScreenState extends State<VerifyEmailScreen> {
|
||
final List<FocusNode> _focusNodes = List.generate(4, (_) => FocusNode());
|
||
final List<TextEditingController> _controllers = List.generate(4, (_) => TextEditingController());
|
||
|
||
@override
|
||
void dispose() {
|
||
for (var controller in _controllers) {
|
||
controller.dispose();
|
||
}
|
||
for (var node in _focusNodes) {
|
||
node.dispose();
|
||
}
|
||
super.dispose();
|
||
}
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Scaffold(
|
||
appBar: AppBar(title: Text("Подтвердите почту")),
|
||
body: Padding(
|
||
padding: const EdgeInsets.all(24.0),
|
||
child: Column(
|
||
mainAxisAlignment: MainAxisAlignment.center,
|
||
children: [
|
||
Text("Код отправлен на почту\nnazvanie@mail.com", textAlign: TextAlign.center),
|
||
SizedBox(height: 20),
|
||
Row(
|
||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||
children: List.generate(4, (index) => _buildCodeField(index)),
|
||
),
|
||
SizedBox(height: 20),
|
||
Text("Запросить код повторно", style: TextStyle(color: Colors.grey)),
|
||
TextButton(
|
||
onPressed: () {
|
||
// логика запроса нового кода
|
||
},
|
||
child: Text("Не приходит код?"),
|
||
)
|
||
],
|
||
),
|
||
),
|
||
);
|
||
}
|
||
|
||
Widget _buildCodeField(int index) {
|
||
return SizedBox(
|
||
width: 50,
|
||
child: TextField(
|
||
controller: _controllers[index],
|
||
focusNode: _focusNodes[index],
|
||
keyboardType: TextInputType.number,
|
||
textAlign: TextAlign.center,
|
||
maxLength: 1,
|
||
style: TextStyle(fontSize: 24),
|
||
decoration: InputDecoration(
|
||
counterText: "",
|
||
border: OutlineInputBorder(
|
||
borderRadius: BorderRadius.circular(8.0),
|
||
),
|
||
),
|
||
onChanged: (value) {
|
||
if (value.isNotEmpty && index < 3) {
|
||
FocusScope.of(context).requestFocus(_focusNodes[index + 1]);
|
||
}
|
||
if (value.isEmpty && index > 0) {
|
||
FocusScope.of(context).requestFocus(_focusNodes[index - 1]);
|
||
}
|
||
},
|
||
),
|
||
);
|
||
}
|
||
}
|