import 'package:agrilink_vocpro/core/constant/app_color.dart';
import 'package:agrilink_vocpro/core/constant/app_theme.dart';
import 'package:flutter/material.dart';

class AppTextfield extends StatelessWidget {
  const AppTextfield({
    super.key,
    required this.controller,
    this.hintText = 'Enter Here',
    this.suffixIcon,
    this.obscureText = false,
  });

  final TextEditingController controller;
  final String hintText;
  final Widget? suffixIcon;
  final bool obscureText;

  @override
  Widget build(BuildContext context) {
    return TextField(
      controller: controller,
      decoration: InputDecoration(
        enabledBorder: OutlineInputBorder(
          borderSide: const BorderSide(color: AppColor.textDisable, width: 1),
          borderRadius: BorderRadius.circular(8),
        ),
        focusedBorder: OutlineInputBorder(
          borderSide: const BorderSide(color: AppColor.primary, width: 1),
          borderRadius: BorderRadius.circular(8),
        ),
        hintText: hintText,
        hintStyle: AppTheme.hintStyle,
        suffixIcon: (suffixIcon != null) ? suffixIcon : null,
      ),
      onTapOutside: (event) => FocusScope.of(context).unfocus(),
      obscureText: obscureText,
    );
  }
}
