import 'package:didvan/pages/authentication/authentication_state.dart'; import 'package:didvan/pages/authentication/widgets/authentication_layout.dart'; import 'package:didvan/widgets/didvan/button.dart'; import 'package:didvan/widgets/didvan/text_field.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class UsernameInput extends StatelessWidget { const UsernameInput({ Key? key, }) : super(key: key); @override Widget build(BuildContext context) { final AuthenticationState state = context.read(); return AuthenticationLayout( children: [ DidvanTextField( initialValue: state.username, title: 'نام کاربری یا شماره موبایل', hintText: 'نام کاربری یا شماره موبایل', textAlign: TextAlign.center, validator: (value) => value!.length < 4 ? 'نام کاربری نمی‌تواند از 4 کاراکتر کوچکتر باشد' : null, onChanged: (value) { state.username = value; }, ), const SizedBox( height: 20, ), DidvanButton( title: 'ورود', onPressed: state.confirmUsername, ), const Spacer(), Padding( padding: const EdgeInsets.symmetric(horizontal: 60), child: RichText( textAlign: TextAlign.center, text: TextSpan( style: Theme.of(context).textTheme.caption, children: [ const TextSpan(text: 'با ثبت نام و ورود به دیدوان،'), TextSpan( text: ' شرایط ', style: Theme.of(context) .textTheme .caption! .copyWith(color: Theme.of(context).colorScheme.primary), recognizer: TapGestureRecognizer()..onTap = () {}, ), const TextSpan(text: 'و\n'), TextSpan( text: ' قوانین حریم خصوصی ', style: Theme.of(context) .textTheme .caption! .copyWith(color: Theme.of(context).colorScheme.primary), recognizer: TapGestureRecognizer()..onTap = () {}, ), const TextSpan(text: 'را می‌پذیرم'), ], ), ), ), const SizedBox( height: 48, ), ], ); } }