D1APP-43 username validation added

This commit is contained in:
MohammadTaha Basiri 2022-01-05 14:21:49 +03:30
parent 07e009f5bd
commit ba321e4233
1 changed files with 26 additions and 13 deletions

View File

@ -6,17 +6,25 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class UsernameInput extends StatelessWidget {
class UsernameInput extends StatefulWidget {
const UsernameInput({
Key? key,
}) : super(key: key);
@override
State<UsernameInput> createState() => _UsernameInputState();
}
class _UsernameInputState extends State<UsernameInput> {
final _formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
final AuthenticationState state = context.read<AuthenticationState>();
return AuthenticationLayout(
children: [
DidvanTextField(
Form(
key: _formKey,
child: DidvanTextField(
initialValue: state.username,
title: 'نام کاربری یا شماره موبایل',
hintText: 'نام کاربری یا شماره موبایل',
@ -28,12 +36,17 @@ class UsernameInput extends StatelessWidget {
state.username = value;
},
),
),
const SizedBox(
height: 20,
),
DidvanButton(
title: 'ورود',
onPressed: state.confirmUsername,
onPressed: () {
if (_formKey.currentState!.validate()) {
state.confirmUsername();
}
},
),
const Spacer(),
Padding(