import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; 

class UsernameField extends StatelessWidget {
  final TextEditingController controller;

  const UsernameField({
    super.key,
    required this.controller,
  });

  @override
  Widget build(BuildContext context) {
    return TextFormField(
      controller: controller,
      style: TextStyle(color: Color(0xFF333333), fontSize: 28.sp),
      validator: (val) {
        if (val == null || val.isEmpty) {
          return "用户名不能为空哦";
        }
        return null;
      },
      decoration: InputDecoration(
        filled: true,
        hintText: "admin",
        hintStyle: TextStyle(color: Color(0xFF999999), fontSize: 28.sp),
        prefixIcon: Icon(Icons.person, color: Color(0xFF999999), size: 40.w),
        prefixIconConstraints: BoxConstraints(minWidth: 80.w, minHeight: 80.w),
        contentPadding: EdgeInsets.symmetric(vertical: 20.h, horizontal: 24.w),
        helperText: " ",
        helperStyle: TextStyle(height: 1, fontSize: 24.sp),
        errorStyle: TextStyle(color: Colors.red, fontSize: 24.sp, height: 1),
        errorMaxLines: 1,
        fillColor: Colors.white,
        border: OutlineInputBorder(
          borderRadius: BorderRadius.circular(24.w),
          borderSide: BorderSide.none,
        ),
        enabledBorder: OutlineInputBorder(
          borderRadius: BorderRadius.circular(24.w),
          borderSide: BorderSide(color: Color(0xFFF5F7FA), width: 1),
        ),
        focusedBorder: OutlineInputBorder(
          borderRadius: BorderRadius.circular(24.w),
          borderSide: BorderSide(color: Color(0xFFF5F7FA), width: 1),
        ),
        errorBorder: OutlineInputBorder(
          borderRadius: BorderRadius.circular(24.w),
          borderSide: BorderSide(color: Colors.red, width: 1),
        ),
        focusedErrorBorder: OutlineInputBorder(
          borderRadius: BorderRadius.circular(24.w),
          borderSide: BorderSide(color: Colors.red, width: 1),
        ),
      ),
    );
  }
}