import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:qyuota/config/colors.dart';
import 'package:qyuota/config/text_style.dart';

class CustomTextField extends StatelessWidget {
  final String title;
  final String hintText;
  final TextEditingController textEditingController;
  final Widget? suffix;
  const CustomTextField(
      {super.key,
      required this.title,
      required this.hintText,
      required this.textEditingController,
      this.suffix});

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          title,
          style: pRegular14.copyWith(
            fontSize: 12,
            color: ConstColors.lightColor,
          ),
        ),
        const SizedBox(height: 10),
        SizedBox(
          height: 42,
          width: Get.width,
          child: TextFormField(
            controller: textEditingController,
            style: pRegular14.copyWith(
              fontSize: 14,
            ),
            decoration: InputDecoration(
              filled: true,
              suffixIcon: suffix ?? const SizedBox(),
              hintText: hintText,
              fillColor: ConstColors.lightColor.withOpacity(0.05),
              contentPadding:
                  const EdgeInsets.only(bottom: 5, left: 14, right: 14),
              hintStyle: pRegular14.copyWith(
                color: ConstColors.lightColor,
              ),
              enabledBorder: OutlineInputBorder(
                borderRadius: BorderRadius.circular(8),
                borderSide: BorderSide(
                  color: ConstColors.lightColor.withOpacity(0.2),
                ),
              ),
              disabledBorder: OutlineInputBorder(
                borderRadius: BorderRadius.circular(8),
                borderSide: BorderSide(
                  color: ConstColors.lightColor.withOpacity(0.2),
                ),
              ),
              focusedBorder: OutlineInputBorder(
                borderRadius: BorderRadius.circular(8),
                borderSide: const BorderSide(
                  color: ConstColors.skyColor,
                ),
              ),
            ),
          ),
        ),
      ],
    );
  }
}

class CustomTextFieldWithSufix extends StatelessWidget {
  final String title;
  final String hintText;
  final TextEditingController textEditingController;
  final Widget widget;
  const CustomTextFieldWithSufix(
      {super.key,
      required this.title,
      required this.hintText,
      required this.textEditingController,
      required this.widget});

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          title,
          style: pRegular14.copyWith(
            fontSize: 12,
            color: ConstColors.lightColor,
          ),
        ),
        const SizedBox(height: 10),
        SizedBox(
          height: 42,
          width: Get.width,
          child: TextFormField(
            controller: textEditingController,
            style: pRegular14.copyWith(
              fontSize: 14,
            ),
            decoration: InputDecoration(
              prefixIcon: widget,
              filled: true,
              hintText: hintText,
              fillColor: ConstColors.lightColor.withOpacity(0.05),
              contentPadding:
                  const EdgeInsets.only(bottom: 5, left: 14, right: 14),
              hintStyle: pRegular14.copyWith(
                color: ConstColors.lightColor,
              ),
              enabledBorder: OutlineInputBorder(
                borderRadius: BorderRadius.circular(8),
                borderSide: BorderSide(
                  color: ConstColors.lightColor.withOpacity(0.2),
                ),
              ),
              disabledBorder: OutlineInputBorder(
                borderRadius: BorderRadius.circular(8),
                borderSide: BorderSide(
                  color: ConstColors.lightColor.withOpacity(0.2),
                ),
              ),
              focusedBorder: OutlineInputBorder(
                borderRadius: BorderRadius.circular(8),
                borderSide: BorderSide(
                  color: ConstColors.skyColor.withOpacity(0.2),
                ),
              ),
            ),
          ),
        ),
      ],
    );
  }
}
