This commit is contained in:
Phuoc Nguyen
2025-10-10 17:36:10 +07:00
parent 04f7042b8d
commit bdaf0b96c5
82 changed files with 4753 additions and 329 deletions

View File

@@ -0,0 +1,65 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
/// Custom text field for authentication forms
class AuthTextField extends StatelessWidget {
const AuthTextField({
super.key,
required this.controller,
required this.label,
this.hint,
this.validator,
this.keyboardType,
this.textInputAction,
this.onFieldSubmitted,
this.prefixIcon,
this.enabled = true,
this.autofocus = false,
this.inputFormatters,
});
final TextEditingController controller;
final String label;
final String? hint;
final String? Function(String?)? validator;
final TextInputType? keyboardType;
final TextInputAction? textInputAction;
final void Function(String)? onFieldSubmitted;
final IconData? prefixIcon;
final bool enabled;
final bool autofocus;
final List<TextInputFormatter>? inputFormatters;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return TextFormField(
controller: controller,
validator: validator,
keyboardType: keyboardType,
textInputAction: textInputAction,
onFieldSubmitted: onFieldSubmitted,
enabled: enabled,
autofocus: autofocus,
inputFormatters: inputFormatters,
style: theme.textTheme.bodyLarge,
decoration: InputDecoration(
labelText: label,
hintText: hint,
prefixIcon: prefixIcon != null
? Icon(prefixIcon, color: theme.colorScheme.primary)
: null,
labelStyle: theme.textTheme.bodyMedium?.copyWith(
color: theme.colorScheme.onSurface.withOpacity(0.7),
),
hintStyle: theme.textTheme.bodyMedium?.copyWith(
color: theme.colorScheme.onSurface.withOpacity(0.4),
),
errorStyle: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.error,
),
),
);
}
}