120 lines
4.3 KiB
Dart
120 lines
4.3 KiB
Dart
import 'package:didvan/config/theme_data.dart';
|
|
import 'package:didvan/utils/extension.dart';
|
|
import 'package:didvan/views/authentication/authentication_state.dart';
|
|
import 'package:didvan/views/authentication/widgets/authentication_layout.dart';
|
|
import 'package:didvan/views/widgets/didvan/button.dart';
|
|
import 'package:didvan/views/widgets/didvan/text_field.dart';
|
|
import 'package:flutter/gestures.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:url_launcher/url_launcher_string.dart';
|
|
|
|
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: [
|
|
Form(
|
|
key: _formKey,
|
|
child: DidvanTextField(
|
|
initialValue: state.username,
|
|
title: 'نام کاربری یا شماره موبایل',
|
|
hintText: 'نام کاربری یا شماره موبایل',
|
|
textAlign: TextAlign.center,
|
|
prefixSvgPath: 'lib/assets/icons/mobile.svg',
|
|
acceptSpace: false,
|
|
onSubmitted: (value) => state.confirmUsername(),
|
|
validator: (value) {
|
|
if (value.contains(' ')) {
|
|
return 'نام کاربری باید بدون فاصله باشد';
|
|
}
|
|
if (value.length < 4) {
|
|
return 'نام کاربری نمیتواند از 4 کاراکتر کمتر باشد';
|
|
}
|
|
return null;
|
|
},
|
|
onChanged: (value) {
|
|
state.username = value.convertToEnglishNumber();
|
|
},
|
|
),
|
|
),
|
|
// Padding(
|
|
// padding: const EdgeInsets.all(8.0),
|
|
// child: DidvanText(
|
|
// 'نام کاربری میتواند شامل کاراکترهای انگلیسی و اعداد باشد.',
|
|
// style: Theme.of(context).textTheme.labelSmall,
|
|
// ),
|
|
// ),
|
|
|
|
const SizedBox(
|
|
height: 70,
|
|
),
|
|
DidvanButton(
|
|
title: 'ادامه',
|
|
onPressed: () {
|
|
if (_formKey.currentState!.validate()) {
|
|
state.confirmUsername();
|
|
}
|
|
},
|
|
),
|
|
const SizedBox(
|
|
height: 20,
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
child: RichText(
|
|
textAlign: TextAlign.center,
|
|
text: TextSpan(
|
|
style: Theme.of(context)
|
|
.textTheme
|
|
.bodySmall
|
|
?.copyWith(color: Theme.of(context).colorScheme.caption),
|
|
children: [
|
|
const TextSpan(text: 'با ورود به اپلیکیشن دیدوان،'),
|
|
TextSpan(
|
|
text: ' شرایط ',
|
|
style: Theme.of(context)
|
|
.textTheme
|
|
.bodySmall!
|
|
.copyWith(color: Theme.of(context).colorScheme.primary),
|
|
recognizer: TapGestureRecognizer()
|
|
..onTap = () => launchUrlString(
|
|
'https://didvan.com/terms-of-use#conditions',
|
|
mode: LaunchMode.inAppWebView),
|
|
),
|
|
const TextSpan(text: 'و\n'),
|
|
TextSpan(
|
|
text: ' قوانین حریم خصوصی ',
|
|
style: Theme.of(context)
|
|
.textTheme
|
|
.bodySmall!
|
|
.copyWith(color: Theme.of(context).colorScheme.primary),
|
|
recognizer: TapGestureRecognizer()
|
|
..onTap = () => launchUrlString(
|
|
'https://didvan.com/terms-of-use#privacy',
|
|
mode: LaunchMode.inAppWebView),
|
|
),
|
|
const TextSpan(text: 'را میپذیرم'),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(
|
|
height: 48,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|