import 'package:flutter/material.dart';

class InputBoxContainer extends StatefulWidget {
  InputBoxContainer({Key key, this.onChange, this.icon, this.type, this.value = "", this.submit,
    this.password = false, this.iconColor = Colors.grey, this.hintText, this.focusNode, this.action }) : super(key: key);

  final onChange;
  final String value;
  final IconData icon;
  final bool password;
  final Color iconColor;
  final String hintText;
  final Function submit;
  final TextInputAction action;
  final FocusNode focusNode;
  final TextInputType type;

  @override
  State<StatefulWidget> createState() {
    return InputBoxContainerBuilder();
  }
}

class InputBoxContainerBuilder extends State<InputBoxContainer> {
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(left: 10.0, right: 10.0, top: 2.0, bottom: 2.0),
      margin: EdgeInsets.only(bottom: 30.0),
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(100.0),
          border: Border.all(
              width: 1.0,
              style: BorderStyle.solid,
              color: Color.fromRGBO(0, 0, 0, 0.1))),
      child: TextField(
        focusNode: widget.focusNode,
        onSubmitted: widget.submit,
        textInputAction: widget.action,
        controller: TextEditingController.fromValue(TextEditingValue(text: widget.value)),
        keyboardType: widget.type,
        obscureText: widget.password,
        onChanged: widget.onChange,
        decoration: InputDecoration(
            border: InputBorder.none,
            hintText: widget.hintText,
            icon: widget.icon != null ? Icon(widget.icon, color: widget.iconColor) : null),
      ),
    );
  }
}