D1APP-43 username validation added
This commit is contained in:
parent
07e009f5bd
commit
ba321e4233
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in New Issue