import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:rkm/config/color_palette.dart';
import '../controllers/format_txt.dart';

class InputText extends StatelessWidget {
  bool obscure;
  var controller;
  double fontSize;
  String title;
  double width;
  bool enabled;
  TextInputType textInputType;
  int maxLines;
  Color colorBorder;
  var onChanged;
  int maxLength;
  List<TextInputFormatter> inputFormatters;

  InputText({
    required this.controller,
    required this.width,
    this.obscure = false,
    this.fontSize = 15.0,
    this.title = '',
    this.enabled = true,
    this.textInputType = TextInputType.text,
    this.maxLines = 1,
    this.colorBorder = ColorPalette.black54,
    this.onChanged = null,
    this.maxLength = 200,
    List<TextInputFormatter>? inputFormatters, // Alteração aqui
  }) : inputFormatters = inputFormatters ?? [FormatText()];

  @override
  Widget build(BuildContext context) {
    return Container(
      color: enabled?Colors.grey[200]:ColorPalette.disable,
      width: width,
      margin: EdgeInsets.only(bottom: 5),
      child: TextFormField(
        keyboardType: textInputType,
        maxLines: maxLines,
        onChanged: onChanged,
        maxLength: maxLength,
        inputFormatters: inputFormatters,
        obscureText: this.obscure,
        controller: this.controller,
        style: TextStyle(
          color: Colors.black,
          fontSize: this.fontSize,
        ),
        decoration: InputDecoration(
          fillColor: ColorPalette.appBar,
          // labelText: label,
          border: OutlineInputBorder(
            borderSide: BorderSide(width: 1,color: colorBorder)
          ),
          focusedBorder: OutlineInputBorder(
            borderSide: BorderSide(width: 1, color: colorBorder),
            borderRadius: BorderRadius.circular(3),
          ),
          enabledBorder: OutlineInputBorder(
            borderSide: BorderSide(width: 1, color: colorBorder),
            borderRadius: BorderRadius.circular(3),
          ),
          disabledBorder: OutlineInputBorder(
            borderSide: BorderSide(width: 1, color: colorBorder),
            borderRadius: BorderRadius.circular(3),
          ),
          // hintText: this.hint,
          enabled: enabled,
          hintStyle: TextStyle(
            color: Colors.black,
            fontSize: this.fontSize,
          )
        )
      ),
    );
  }
}
