You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
166 lines
4.7 KiB
166 lines
4.7 KiB
import 'package:flutter/material.dart'; |
|
import 'package:flutter/services.dart'; |
|
import 'package:flutter_screenutil/flutter_screenutil.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 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.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, |
|
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: [ |
|
Text( |
|
title, |
|
style: TextStyle( |
|
fontSize: 14.sp, |
|
fontWeight: FontWeight.bold, |
|
color: titleColor, |
|
), |
|
), |
|
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, |
|
), |
|
), |
|
) |
|
], |
|
), |
|
); |
|
} |
|
}
|
|
|