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 hint;
  double width;
  String label;
  bool enabled;
  TextInputType textInputType;
  int maxLines;
  Color colorBorder;
  var onChanged;

  InputText({
    required this.controller,
    required this.width,
    this.obscure = false,
    this.fontSize = 15.0,
    this.hint = '',
    this.label = '',
    this.enabled = true,
    this.textInputType = TextInputType.text,
    this.maxLines = 1,
    this.colorBorder = ColorPalette.black54,
    this.onChanged = null,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      color: enabled?ColorPalette.white:ColorPalette.disable,
      margin: EdgeInsets.only(top: 5),
      width: width,
      child: TextFormField(
        keyboardType: textInputType,
        maxLines: maxLines,
        onChanged: onChanged,
        inputFormatters: [
          FormatText()
        ],
        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,
          )
        )
      ),
    );
  }
}
