import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:pharmacy_mobile/widgets/dropdown_widget.dart';

class InputFormWidget extends StatelessWidget {
  final String label;
  final TextEditingController controller;
  final bool? password;
  final OnChangedCallback? onChanged;
  final String? placeholder;
  final ValueChanged<String>? onSubmitted;
  final FormFieldValidator? validator;

  const InputFormWidget(
      {super.key,
      required this.label,
      required this.controller,
      this.password,
      this.onChanged,
      this.placeholder,
      this.onSubmitted,
      this.validator});

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        if (label.isNotEmpty)
          Text('$label:',
              style: GoogleFonts.inter(
                textStyle:
                    const TextStyle(color: Color.fromRGBO(255, 255, 255, 1), fontSize: 12, fontWeight: FontWeight.w500),
              )),
        const Gap(8),
        TextFormField(
          textInputAction: TextInputAction.go,
          controller: controller,
          decoration: InputDecoration(
              filled: true,
              fillColor: const Color.fromRGBO(255, 255, 255, 1),
              border: OutlineInputBorder(borderRadius: BorderRadius.circular(4)),
              contentPadding: const EdgeInsets.symmetric(vertical: 0, horizontal: 14),
              prefixIcon: placeholder != null ? Icon(Icons.search, color: Colors.grey) : null,
              hintText: placeholder),
          style: GoogleFonts.inter(
              textStyle: const TextStyle(
            color: Color.fromRGBO(0, 0, 0, 1),
            fontSize: 16,
          )),
          obscureText: password ?? false,
          onChanged: onChanged,
          onFieldSubmitted: onSubmitted,
          validator: validator,
        ),
      ],
    );
  }
}
