import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; class InputWidget extends StatelessWidget { final String labelText; final String hintText; final TextEditingController controller; final VoidCallback? suffixTap; final bool isEnable; final bool hasSelection; final int? lines; final bool isInputTypeNum; final bool isObscureText; final bool isBackgroundEnable; final bool isEnableBorder; final double verticalPadding; final double horizontalPadding; final Function(String)? onChange; InputWidget( this.labelText, this.hintText, this.controller, { this.isObscureText = false, this.suffixTap, this.isEnable = true, this.hasSelection = false, this.isEnableBorder = true, this.lines = 1, this.onChange, this.isInputTypeNum = false, this.isBackgroundEnable = false, this.verticalPadding = 15, this.horizontalPadding = 16, }); @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.only(left: horizontalPadding, right: horizontalPadding, bottom: verticalPadding, top: verticalPadding), alignment: Alignment.center, decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), color: isBackgroundEnable ? Color(0xffF7F7F7) : Colors.white, border: Border.all( color: isEnableBorder ? Color(0xffefefef) : Colors.transparent, width: 1, ), ), child: InkWell( onTap: hasSelection ? () {} : null, child: Row( children: [ Expanded( child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( labelText, style: const TextStyle( fontSize: 11, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.44, ), ), TextField( enabled: isEnable, scrollPadding: EdgeInsets.zero, keyboardType: isInputTypeNum ? TextInputType.number : TextInputType.text, controller: controller, maxLines: lines, obscuringCharacter: "*", obscureText: isObscureText, onChanged: onChange, style: const TextStyle( fontSize: 14, height: 21 / 14, fontWeight: FontWeight.w400, color: Color(0xff2B353E), letterSpacing: -0.44, ), decoration: InputDecoration( isDense: true, hintText: hintText, hintStyle: const TextStyle( fontSize: 14, height: 21 / 14, fontWeight: FontWeight.w400, color: Color(0xff575757), letterSpacing: -0.56, ), suffixIconConstraints: const BoxConstraints(minWidth: 50), suffixIcon: suffixTap == null ? null : IconButton(icon: const Icon(Icons.mic, color: MyColors.darkTextColor), onPressed: suffixTap), contentPadding: EdgeInsets.zero, border: InputBorder.none, focusedBorder: InputBorder.none, enabledBorder: InputBorder.none, ), ), ], ), ), if (hasSelection) Icon(Icons.keyboard_arrow_down_outlined), ], ), ), ); } }