import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/retrofit/data/vip_benefit_list.dart'; import 'package:huixiang/utils/font_weight.dart'; class ItemInputWidget extends StatelessWidget { final String hintText; final String title; final TextStyle style; final int inputState; final TextEditingController controller; final Function(String value) onChanged; final Function() onTap; final double discount; final int inputLimit; final bool isShowBtn; final int btnState; final String btnText; final String errorText; final Color errorTextColor; final Color titleColor; final double radius; final EdgeInsets padding; final TextInputType textInputType; final TextInputFormatter textInputFormatter; ItemInputWidget( this.title, { this.hintText = "", this.inputState = 0, this.btnState = 0, this.inputLimit = 16, this.controller, this.onChanged, this.style = const TextStyle(), this.radius = 4, this.onTap, this.discount, this.textInputType, this.errorText = "", this.errorTextColor = const Color(0xFFFF441A), this.titleColor = Colors.black, this.padding = const EdgeInsets.only(left: 20, right: 21, top: 16, bottom: 4), this.btnText, this.textInputFormatter, this.isShowBtn = false, }); @override Widget build(BuildContext context) { var color = Color(0xFFF7F7F7); if (inputState == 0) { color = Color(0xFFF7F7F7); } else if (inputState == 1) { color = Color(0xFF37A546); } else { color = Color(0xFFFF441A); } var inputBorder = UnderlineInputBorder( borderSide: BorderSide(width: 1, color: color, style: BorderStyle.solid), ); return Container( // margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 12.h, bottom: 4.h), padding: padding, color: Colors.white, // decoration: BoxDecoration( // boxShadow: [ // BoxShadow( // color: Color(0x000000).withAlpha(25), // offset: Offset(0, 1), // blurRadius: 12.0, // ), // ], // color: Colors.white, // borderRadius: BorderRadius.circular(radius), // ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( title, style: TextStyle( fontSize: 14.sp, fontWeight: FontWeight.bold, color: titleColor, ), ), Container( margin: EdgeInsets.only(left: 5), width: 85, height: 20.h, alignment: Alignment.center, decoration: BoxDecoration( borderRadius: BorderRadius.only( topLeft: Radius.circular(9), topRight: Radius.circular(9), bottomLeft: Radius.circular(0), bottomRight: Radius.circular(9), ), color: Color(0xFF32A060), ), child: Text( "当前折扣:${discount.toString()}折", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.medium, color: Colors.white, ), ), ), ], ), SizedBox( height: 5.h, ), Container( alignment: Alignment.centerLeft, child: Stack( alignment: Alignment.centerLeft, children: [ Container( width: 20.w, alignment: Alignment.centerLeft, child: Text( "¥", style: TextStyle( fontWeight: MyFontWeight.medium, color: style.color, fontSize: 26.sp, ), ), margin: EdgeInsets.only(left: 5, bottom: 12.h), ), Container( height: 0.035.sh, child: TextField( controller: controller, style: style, onChanged: onChanged, keyboardType: textInputType, decoration: InputDecoration( errorBorder: inputBorder, focusedBorder: inputBorder, enabledBorder: inputBorder, hintText: hintText, contentPadding: EdgeInsets.only( top: 12.h, bottom: 12.h, left: 24.w, ), hintStyle: TextStyle( fontSize: 10.sp, color: Color(0xFFA29E9E), ), ), textInputAction: TextInputAction.next, inputFormatters: [ LengthLimitingTextInputFormatter(inputLimit), textInputFormatter ], cursorColor: Colors.grey, maxLines: 1, minLines: 1, ), ), ], ), ), Offstage( offstage: errorText == null || errorText == "", child: Text( errorText ?? "", style: TextStyle( color: errorTextColor, fontSize: 12.sp, ), ), ) ], ), ); } }