|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:huixiang/view_widget/border_text.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 int inputType;
|
|
|
|
final double heightPercentage;
|
|
|
|
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.heightPercentage,
|
|
|
|
this.padding =
|
|
|
|
const EdgeInsets.only(left: 20, right: 21, top: 16, bottom: 4),
|
|
|
|
this.btnText,
|
|
|
|
this.inputType = 0,
|
|
|
|
this.textInputFormatter,
|
|
|
|
this.isShowBtn = false,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
var color = Color(0xFFA29E9E);
|
|
|
|
if (inputState == 0) {
|
|
|
|
color = Color(0xFFA29E9E);
|
|
|
|
} 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(
|
|
|
|
height: heightPercentage,
|
|
|
|
margin: EdgeInsets.only(left: 20, right: 20, top: 12, bottom: 4),
|
|
|
|
padding: padding,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
color: Color(0x000000).withAlpha(25),
|
|
|
|
offset: Offset(0, 1),
|
|
|
|
blurRadius: 12.0,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
color: Colors.white,
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
Radius.circular(radius),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14.sp,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: titleColor,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (inputType == 1)
|
|
|
|
SizedBox(
|
|
|
|
height: 5,
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
height: inputType == 1 ? 30 : 0.03.sh,
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Stack(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
children: [
|
|
|
|
if (inputType == 1)
|
|
|
|
Container(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
"¥",
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: style.color,
|
|
|
|
fontSize: 26.sp,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
margin: EdgeInsets.only(left: 5),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
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,
|
|
|
|
bottom: 12,
|
|
|
|
left: inputType == 1 ? 22 : 0,
|
|
|
|
),
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
fontSize: 10,
|
|
|
|
color: Color(0xFFA29E9E),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
textInputAction: TextInputAction.next,
|
|
|
|
inputFormatters: [
|
|
|
|
LengthLimitingTextInputFormatter(inputLimit),
|
|
|
|
textInputFormatter
|
|
|
|
],
|
|
|
|
cursorColor: Colors.grey,
|
|
|
|
maxLines: 1,
|
|
|
|
minLines: 1,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
flex: 5,
|
|
|
|
),
|
|
|
|
if (isShowBtn)
|
|
|
|
Expanded(
|
|
|
|
flex: 3,
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
children: [
|
|
|
|
InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Container(
|
|
|
|
margin: EdgeInsets.only(left: 20),
|
|
|
|
child: BorderText(
|
|
|
|
text: btnText,
|
|
|
|
borderColor: btnState == 0
|
|
|
|
? Color(0xFF32A060)
|
|
|
|
: Color(0xFFFE951E),
|
|
|
|
borderWidth: 1,
|
|
|
|
radius: 2,
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: 8, right: 8, top: 4, bottom: 4),
|
|
|
|
fontSize: 10,
|
|
|
|
textColor: btnState == 0
|
|
|
|
? Color(0xFF32A060)
|
|
|
|
: Color(0xFFFE951E),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Offstage(
|
|
|
|
offstage: errorText == null || errorText == "",
|
|
|
|
child: Text(
|
|
|
|
errorText ?? "",
|
|
|
|
style: TextStyle(
|
|
|
|
color: errorTextColor,
|
|
|
|
fontSize: 12,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|