|  |  |  | import 'package:flutter/material.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/core/utils/utils.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class TextInputWidget extends StatelessWidget { | 
					
						
							|  |  |  |   final String labelText; | 
					
						
							|  |  |  |   final String hintText; | 
					
						
							|  |  |  |   final TextEditingController? controller; | 
					
						
							|  |  |  |   final Function(String?)? onChange; | 
					
						
							|  |  |  |   final String? prefix; | 
					
						
							|  |  |  |   final bool isEnable; | 
					
						
							|  |  |  |   final bool isBorderAllowed; | 
					
						
							|  |  |  |   final bool isAllowRadius; | 
					
						
							|  |  |  |   final bool isReadOnly; | 
					
						
							|  |  |  |   final TextInputType keyboardType; | 
					
						
							|  |  |  |   final FocusNode? focusNode; | 
					
						
							|  |  |  |   final bool autoFocus; | 
					
						
							|  |  |  |   final EdgeInsetsGeometry? padding; | 
					
						
							|  |  |  |   final bool isAllowLeadingIcon; | 
					
						
							|  |  |  |   final String? leadingIcon; | 
					
						
							|  |  |  |   final bool isCountryDropDown; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // final List<Country> countryList;
 | 
					
						
							|  |  |  |   // final Function(Country)? onCountryChange;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const TextInputWidget({ | 
					
						
							|  |  |  |     Key? key, | 
					
						
							|  |  |  |     required this.labelText, | 
					
						
							|  |  |  |     required this.hintText, | 
					
						
							|  |  |  |     this.controller, | 
					
						
							|  |  |  |     this.onChange, | 
					
						
							|  |  |  |     this.prefix, | 
					
						
							|  |  |  |     this.isEnable = true, | 
					
						
							|  |  |  |     this.isBorderAllowed = true, | 
					
						
							|  |  |  |     this.isAllowRadius = true, | 
					
						
							|  |  |  |     this.isReadOnly = false, | 
					
						
							|  |  |  |     this.keyboardType = TextInputType.number, | 
					
						
							|  |  |  |     this.focusNode, | 
					
						
							|  |  |  |     this.autoFocus = false, | 
					
						
							|  |  |  |     this.padding, | 
					
						
							|  |  |  |     this.isAllowLeadingIcon = false, | 
					
						
							|  |  |  |     this.leadingIcon, | 
					
						
							|  |  |  |     this.isCountryDropDown = false, | 
					
						
							|  |  |  |     // this.countryList = const [],
 | 
					
						
							|  |  |  |     // this.onCountryChange,
 | 
					
						
							|  |  |  |   }) : super(key: key); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   Widget build(BuildContext context) { | 
					
						
							|  |  |  |     return Container( | 
					
						
							|  |  |  |       padding: padding, | 
					
						
							|  |  |  |       alignment: Alignment.center, | 
					
						
							|  |  |  |       decoration: RoundedRectangleBorder().toSmoothCornerDecoration( | 
					
						
							|  |  |  |         color: Colors.white, | 
					
						
							|  |  |  |         borderRadius: isAllowRadius ? 15 : null, | 
					
						
							|  |  |  |         side: isBorderAllowed ? BorderSide(color: const Color(0xffefefef), width: 1) : null, | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |       child: Row( | 
					
						
							|  |  |  |         textDirection: Directionality.of(context), | 
					
						
							|  |  |  |         children: [ | 
					
						
							|  |  |  |           if (isAllowLeadingIcon && leadingIcon != null) _buildLeadingIcon(context), | 
					
						
							|  |  |  |           Expanded( | 
					
						
							|  |  |  |             child: Column( | 
					
						
							|  |  |  |               mainAxisSize: MainAxisSize.min, | 
					
						
							|  |  |  |               crossAxisAlignment: CrossAxisAlignment.start, | 
					
						
							|  |  |  |               children: [ | 
					
						
							|  |  |  |                 _buildLabelText(), | 
					
						
							|  |  |  |                 _buildTextField(context), | 
					
						
							|  |  |  |               ], | 
					
						
							|  |  |  |             ), | 
					
						
							|  |  |  |           ), | 
					
						
							|  |  |  |         ], | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Widget _buildLeadingIcon(BuildContext context) { | 
					
						
							|  |  |  |     return Container( | 
					
						
							|  |  |  |         height: 40, | 
					
						
							|  |  |  |         width: 40, | 
					
						
							|  |  |  |         margin: const EdgeInsets.only(right: 10), | 
					
						
							|  |  |  |         padding: const EdgeInsets.all(8), | 
					
						
							|  |  |  |         decoration: const BoxDecoration(color: Color(0xFFEFEFF0), borderRadius: BorderRadius.all(Radius.circular(10))), | 
					
						
							|  |  |  |         child: Utils.buildSvgWithAssets(icon: leadingIcon!)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Widget _buildLabelText() { | 
					
						
							|  |  |  |     return Text( | 
					
						
							|  |  |  |       labelText, | 
					
						
							|  |  |  |       style: const TextStyle( | 
					
						
							|  |  |  |         fontSize: 12, | 
					
						
							|  |  |  |         fontWeight: FontWeight.w500, | 
					
						
							|  |  |  |         color: Color(0xff898A8D), | 
					
						
							|  |  |  |         letterSpacing: -0.2, | 
					
						
							|  |  |  |         height: 18 / 12, | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Widget _buildTextField(BuildContext context) { | 
					
						
							|  |  |  |     return TextField( | 
					
						
							|  |  |  |       enabled: isEnable, | 
					
						
							|  |  |  |       scrollPadding: EdgeInsets.zero, | 
					
						
							|  |  |  |       keyboardType: keyboardType, | 
					
						
							|  |  |  |       controller: controller, | 
					
						
							|  |  |  |       readOnly: isReadOnly, | 
					
						
							|  |  |  |       textAlignVertical: TextAlignVertical.top, | 
					
						
							|  |  |  |       textAlign: TextAlign.left, | 
					
						
							|  |  |  |       textDirection: TextDirection.ltr, | 
					
						
							|  |  |  |       onChanged: onChange, | 
					
						
							|  |  |  |       focusNode: focusNode, | 
					
						
							|  |  |  |       autofocus: autoFocus, | 
					
						
							|  |  |  |       style: const TextStyle( | 
					
						
							|  |  |  |         fontSize: 14, | 
					
						
							|  |  |  |         height: 21 / 14, | 
					
						
							|  |  |  |         fontWeight: FontWeight.w500, | 
					
						
							|  |  |  |         color: Color(0xff2E3039), | 
					
						
							|  |  |  |         letterSpacing: -0.2, | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |       decoration: InputDecoration( | 
					
						
							|  |  |  |         isDense: true, | 
					
						
							|  |  |  |         hintText: hintText, | 
					
						
							|  |  |  |         hintStyle: const TextStyle( | 
					
						
							|  |  |  |           fontSize: 14, | 
					
						
							|  |  |  |           height: 21 / 16, | 
					
						
							|  |  |  |           fontWeight: FontWeight.w500, | 
					
						
							|  |  |  |           color: Color(0xff898A8D), | 
					
						
							|  |  |  |           letterSpacing: -0.2, | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         prefixIconConstraints: const BoxConstraints(minWidth: 45), | 
					
						
							|  |  |  |         prefixIcon: prefix == null | 
					
						
							|  |  |  |             ? null | 
					
						
							|  |  |  |             : Text( | 
					
						
							|  |  |  |                 "+" + prefix!, | 
					
						
							|  |  |  |                 style: const TextStyle( | 
					
						
							|  |  |  |                   fontSize: 14, | 
					
						
							|  |  |  |                   height: 21 / 14, | 
					
						
							|  |  |  |                   fontWeight: FontWeight.w500, | 
					
						
							|  |  |  |                   color: Color(0xff2E303A), | 
					
						
							|  |  |  |                   letterSpacing: -0.2, | 
					
						
							|  |  |  |                 ), | 
					
						
							|  |  |  |               ), | 
					
						
							|  |  |  |         contentPadding: EdgeInsets.zero, | 
					
						
							|  |  |  |         border: InputBorder.none, | 
					
						
							|  |  |  |         focusedBorder: InputBorder.none, | 
					
						
							|  |  |  |         enabledBorder: InputBorder.none, | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |