chore: clean up unused imports, update routing for authentication pages, and enhance UI components in the profile and captcha widgets

This commit is contained in:
2025-12-24 11:51:41 +03:30
parent 3eccf492ff
commit 60c58ef17e
17 changed files with 428 additions and 625 deletions

View File

@@ -132,6 +132,8 @@ class _RTextFieldState extends State<RTextField> {
late TextDirection textDirection;
Timer? _debounceTimer;
final GlobalKey<FormFieldState<String>> _formFieldKey =
GlobalKey<FormFieldState<String>>();
TextDirection _detectDirection(String text) {
final isPersian = RegExp(r'[\u0600-\u06FF]').hasMatch(text);
@@ -196,13 +198,29 @@ class _RTextFieldState extends State<RTextField> {
return widget.suffixIcon;
}
double _calculateHeight() {
if (!widget.isFullHeight) {
return widget.height;
}
// اگر خطا وجود دارد، ارتفاع اضافی برای نمایش خطا اضافه می‌کنیم
final hasError = _formFieldKey.currentState?.hasError ?? false;
if (hasError) {
// ارتفاع خطا تقریباً 20 پیکسل است (یک خط متن خطا)
return widget.height + 20;
}
return widget.height;
}
@override
Widget build(BuildContext context) {
return SizedBox(
height: (widget.height).h,
height: _calculateHeight().h,
child: Padding(
padding: widget.padding ?? EdgeInsets.zero,
child: TextFormField(
key: _formFieldKey,
textAlignVertical: TextAlignVertical.center,
controller: widget.controller,
focusNode: widget.focusNode,
@@ -210,8 +228,21 @@ class _RTextFieldState extends State<RTextField> {
readOnly: widget.readonly,
minLines: widget.minLines,
maxLines: widget.maxLines,
onChanged: widget.onChanged,
validator: widget.validator,
onChanged: (value) {
widget.onChanged?.call(value);
},
validator: (value) {
final error = widget.validator?.call(value);
if (widget.isFullHeight) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) {
setState(() {});
}
});
}
return error;
},
inputFormatters: widget.inputFormatters,
enabled: widget.enabled,
obscureText: obscure,