import 'package:flutter/material.dart';


class CustomeTextField extends StatelessWidget {
  final String title;
  final bool obscureText;
  final String? value;
  final TextEditingController? controller;
  final bool isShowTitle;
  final Function(String)? onChanged;
  final Function(String)? onSave;
  final String? Function(String?)? validator;
  final String? keyboardType;
  final String? hinText;
  final String? initialValue;
  const CustomeTextField({
    super.key,
    required this.title,
    this.value,
    this.obscureText = false,
    this.controller,
    this.onChanged,
    this.isShowTitle = true,
    this.validator,
    this.keyboardType,
    this.onSave,
    this.hinText,
    this.initialValue,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        if (isShowTitle)
          Text(
            title,
            style: TextStyle(fontSize: 14, fontWeight: FontWeight.w700),
          ),
        if (isShowTitle)
          const SizedBox(
            height: 8,
          ),
        TextFormField(
          controller: controller,
          initialValue: initialValue,
          keyboardType: (obscureText == false)
              ? TextInputType.text
              : TextInputType.number,
          validator: validator,
          onChanged: onChanged != null ? (value) => onChanged!(value) : null,
          onSaved: onSave != null ? (value) => onSave!(value.toString()) : null,
          obscureText: obscureText,
          decoration: InputDecoration(
            hintText: hinText,
            hintStyle: const TextStyle(color: Colors.amber),
            border: OutlineInputBorder(
              borderRadius: BorderRadius.circular(14),
              borderSide: BorderSide(color: Colors.grey.shade300),
            ),
            contentPadding: const EdgeInsets.all(12),
          ),
        ),
      ],
    );
  }
}
