import 'package:flutter/material.dart';
import 'package:tangheem/extensions/int_extensions.dart';
import 'package:tangheem/extensions/widget_extensions.dart';

class LoginTextFieldWidget extends StatelessWidget {
  final String hint;
  final TextEditingController controller;
  final bool isPassword;
  final IconData iconData;
  final bool isForChangePassword;

  LoginTextFieldWidget({@required this.hint, @required this.controller, this.isForChangePassword = false, this.isPassword = false, @required this.iconData, Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    bool isPortrait = MediaQuery.of(context).orientation == Orientation.portrait;

    return isForChangePassword
        ? SizedBox(
            height: 45,
            child: TextField(
              textAlignVertical: TextAlignVertical.center,
              controller: controller,
              obscureText: isPassword,
              textInputAction: TextInputAction.next,
              style: TextStyle(color: Colors.white, fontSize: 11, fontFamily: "Montserrat"),
              cursorColor: Colors.white,
              cursorWidth: 1,
              maxLines: 1,
              scrollPhysics: BouncingScrollPhysics(),
              decoration: InputDecoration(
                contentPadding: EdgeInsets.only(top: 15, bottom: 15, right: 17, left: 4),
                alignLabelWithHint: true,
                fillColor: Color(0xff598A8D),
                filled: true,
                hintStyle: TextStyle(color: Colors.white, fontSize: 11, fontFamily: "Montserrat"),
                hintText: hint,
                suffixIcon: Row(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    Container(
                      width: 1,
                      height: 14,
                      color: Colors.white.withOpacity(.6),
                    ),
                    12.width,
                    Icon(
                      iconData,
                      color: Colors.white.withOpacity(0.6),
                      size: 20,
                    ),
                  ],
                ).paddingOnly(left: 17),
                suffixIconConstraints: BoxConstraints(),
                focusedBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(25),
                  borderSide: BorderSide(color: Colors.transparent, width: 1),
                ),
                enabledBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(25),
                  borderSide: BorderSide(color: Colors.transparent, width: 1),
                ),
              ),
            ),
          )
        : TextField(
            textAlignVertical: TextAlignVertical.center,
            controller: controller,
            obscureText: isPassword,
            textInputAction: TextInputAction.next,
            style: TextStyle(color: Colors.white, fontSize: 14, fontFamily: "Montserrat"),
            cursorColor: Colors.white,
            maxLines: 1,
            scrollPhysics: BouncingScrollPhysics(),
            decoration: InputDecoration(
              contentPadding: EdgeInsets.only(top: isPortrait ? 19 : 0, bottom: isPortrait ? 19 : 0, right: 32, left: 4),
              alignLabelWithHint: true,
              fillColor: Color(0xff598A8D),
              filled: true,
              hintStyle: TextStyle(color: Colors.white, fontSize: 14, fontFamily: "Montserrat"),
              hintText: hint,
              suffixIcon: Row(
                mainAxisSize: MainAxisSize.min,
                children: [
                  Container(
                    width: 1,
                    height: 14,
                    color: Colors.white.withOpacity(.6),
                  ),
                  14.width,
                  Icon(
                    iconData,
                    color: Colors.white.withOpacity(0.6),
                    size: 20,
                  ),
                ],
              ).paddingOnly(left: 24),
              suffixIconConstraints: BoxConstraints(),
              focusedBorder: OutlineInputBorder(
                borderRadius: BorderRadius.circular(10),
                borderSide: BorderSide(color: Colors.transparent, width: 1),
              ),
              enabledBorder: OutlineInputBorder(
                borderRadius: BorderRadius.circular(10),
                borderSide: BorderSide(color: Colors.transparent, width: 1),
              ),
            ),
          );
  }
}
