first commit
This commit is contained in:
64
lib/screens/auth/widgets/auth_text_field.dart
Normal file
64
lib/screens/auth/widgets/auth_text_field.dart
Normal file
@@ -0,0 +1,64 @@
|
||||
// Flutter imports:
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:remever/common/resources.dart';
|
||||
import 'package:remever/common/typography.dart';
|
||||
import 'package:remever/components/extensions/context.dart';
|
||||
|
||||
class AuthTextField extends StatelessWidget {
|
||||
const AuthTextField({required this.email, super.key, this.autofocus = true});
|
||||
|
||||
final TextEditingController email;
|
||||
final bool autofocus;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final OutlineInputBorder border = OutlineInputBorder(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)).r,
|
||||
borderSide: BorderSide(color: AppColors.gray),
|
||||
);
|
||||
|
||||
return TextFormField(
|
||||
autofocus: autofocus,
|
||||
controller: email,
|
||||
validator: (String? value) {
|
||||
if (value == null || value == '') return 'Поле не может быть пустым';
|
||||
if (!value.contains('@') || !value.contains('.')) {
|
||||
return 'Неверный e-mail';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
cursorColor: AppColors.primary,
|
||||
|
||||
decoration: InputDecoration(
|
||||
filled: true,
|
||||
fillColor: AppColors.white,
|
||||
focusedBorder: border,
|
||||
enabledBorder: border,
|
||||
errorBorder: border,
|
||||
focusedErrorBorder: border,
|
||||
hintText: 'Введите e-mail',
|
||||
hintStyle: const TextStyle(fontWeight: FontWeight.w400, height: 1.2),
|
||||
errorStyle: SemiBold12px().style.copyWith(color: AppColors.red),
|
||||
suffixIconConstraints: const BoxConstraints(minWidth: 0, minHeight: 0),
|
||||
suffixIcon: Padding(
|
||||
padding: const EdgeInsets.only(right: 12).r,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
email.clear();
|
||||
},
|
||||
child: SizedBox.square(
|
||||
dimension: 24.r,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.bg,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(Icons.close, color: AppColors.disabled, size: 16.r),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user