2026-03-13 14:10:13 +08:00
|
|
|
import 'package:flutter/material.dart';
|
2026-03-19 18:42:05 +08:00
|
|
|
import 'package:flutter/services.dart';
|
2026-03-13 14:10:13 +08:00
|
|
|
|
|
|
|
|
import '../../../../core/theme/design_tokens.dart';
|
|
|
|
|
|
|
|
|
|
class AuthField extends StatelessWidget {
|
|
|
|
|
const AuthField({
|
|
|
|
|
super.key,
|
2026-03-19 18:42:05 +08:00
|
|
|
this.label,
|
2026-03-13 14:10:13 +08:00
|
|
|
required this.hint,
|
|
|
|
|
required this.controller,
|
|
|
|
|
this.keyboardType,
|
|
|
|
|
this.obscureText = false,
|
|
|
|
|
this.suffixIcon,
|
|
|
|
|
this.onChanged,
|
2026-03-19 18:42:05 +08:00
|
|
|
this.prefix,
|
|
|
|
|
this.inputFormatters,
|
2026-03-13 14:10:13 +08:00
|
|
|
});
|
|
|
|
|
|
2026-03-19 18:42:05 +08:00
|
|
|
final String? label;
|
2026-03-13 14:10:13 +08:00
|
|
|
final String hint;
|
|
|
|
|
final TextEditingController controller;
|
|
|
|
|
final TextInputType? keyboardType;
|
|
|
|
|
final bool obscureText;
|
|
|
|
|
final Widget? suffixIcon;
|
|
|
|
|
final ValueChanged<String>? onChanged;
|
2026-03-19 18:42:05 +08:00
|
|
|
final Widget? prefix;
|
|
|
|
|
final List<TextInputFormatter>? inputFormatters;
|
2026-03-13 14:10:13 +08:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2026-03-27 19:07:39 +08:00
|
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
|
|
|
|
2026-03-13 14:10:13 +08:00
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
2026-03-19 18:42:05 +08:00
|
|
|
if (label != null) ...[
|
|
|
|
|
Text(
|
|
|
|
|
label!,
|
2026-03-27 19:07:39 +08:00
|
|
|
style: TextStyle(
|
2026-03-19 18:42:05 +08:00
|
|
|
fontSize: 13,
|
|
|
|
|
fontWeight: FontWeight.w700,
|
2026-03-27 19:07:39 +08:00
|
|
|
color: colorScheme.onSurface,
|
2026-03-19 18:42:05 +08:00
|
|
|
),
|
2026-03-13 14:10:13 +08:00
|
|
|
),
|
2026-03-19 18:42:05 +08:00
|
|
|
SizedBox(height: AppSpacing.sm),
|
|
|
|
|
],
|
2026-03-13 14:10:13 +08:00
|
|
|
Semantics(
|
|
|
|
|
label: label,
|
|
|
|
|
textField: true,
|
|
|
|
|
child: TextField(
|
|
|
|
|
controller: controller,
|
|
|
|
|
keyboardType: keyboardType,
|
|
|
|
|
obscureText: obscureText,
|
|
|
|
|
onChanged: onChanged,
|
2026-03-19 18:42:05 +08:00
|
|
|
inputFormatters: inputFormatters,
|
2026-03-27 19:07:39 +08:00
|
|
|
style: TextStyle(fontSize: 16, color: colorScheme.onSurface),
|
2026-03-13 14:10:13 +08:00
|
|
|
decoration: InputDecoration(
|
|
|
|
|
hintText: hint,
|
2026-03-27 19:07:39 +08:00
|
|
|
hintStyle: TextStyle(
|
2026-03-13 14:10:13 +08:00
|
|
|
fontSize: 15,
|
2026-03-27 19:07:39 +08:00
|
|
|
color: colorScheme.onSurfaceVariant,
|
2026-03-13 14:10:13 +08:00
|
|
|
),
|
|
|
|
|
filled: true,
|
2026-03-27 19:07:39 +08:00
|
|
|
fillColor: colorScheme.surface,
|
2026-03-13 14:10:13 +08:00
|
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
|
|
|
horizontal: AppSpacing.lg,
|
|
|
|
|
vertical: AppSpacing.lg,
|
|
|
|
|
),
|
2026-03-19 18:42:05 +08:00
|
|
|
prefixIcon: prefix,
|
2026-03-13 14:10:13 +08:00
|
|
|
suffixIcon: suffixIcon,
|
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.lg),
|
|
|
|
|
borderSide: BorderSide.none,
|
|
|
|
|
),
|
|
|
|
|
enabledBorder: OutlineInputBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.lg),
|
2026-03-27 19:07:39 +08:00
|
|
|
borderSide: BorderSide(color: colorScheme.outlineVariant),
|
2026-03-13 14:10:13 +08:00
|
|
|
),
|
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.lg),
|
2026-03-27 19:07:39 +08:00
|
|
|
borderSide: BorderSide(color: colorScheme.primary),
|
2026-03-13 14:10:13 +08:00
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|