import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import '../utils/cores.dart';

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

  InputText({
    required this.controller,
    required this.width,
    this.obscure = false,
    this.fontSize = 15.0,
    this.title = '',
    this.textInputType = TextInputType.text,
    this.maxLines = 1,
    this.colorBorder = PaletaCores.cinza,
    this.onChanged = null,
    this.enable = true,
    required this.inputFormatters
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Container(
            width: width,
            child: Text(title,style: TextStyle(fontWeight: FontWeight.bold,fontFamily: 'Nunito'),)
        ),
        Container(
          color:PaletaCores.cinzaInput,
          width: width,
          margin: EdgeInsets.only(bottom: 5),
          child: TextFormField(
            inputFormatters: inputFormatters,
            keyboardType: textInputType,
            maxLines: maxLines,
            onChanged: onChanged,
            obscureText: this.obscure,
            controller: this.controller,
            enabled: enable,
            style: TextStyle(
              color: Colors.black,
              fontSize: this.fontSize,
              fontFamily: 'Nunito'
            ),
            decoration: InputDecoration(
              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),
              ),
              hintStyle: TextStyle(
                color: Colors.black,
                fontSize: this.fontSize,
              )
            )
          ),
        ),
      ],
    );
  }
}
