|
|
@ -12,7 +12,25 @@ class ASSearchTextField extends StatefulWidget implements PreferredSizeWidget {
|
|
|
|
this.focusNode,
|
|
|
|
this.focusNode,
|
|
|
|
this.onSubmitted,
|
|
|
|
this.onSubmitted,
|
|
|
|
this.margin,
|
|
|
|
this.margin,
|
|
|
|
}) : super(key: key);
|
|
|
|
this.onPressed,
|
|
|
|
|
|
|
|
}) : button = false,
|
|
|
|
|
|
|
|
super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
ASSearchTextField.button({
|
|
|
|
|
|
|
|
Key key,
|
|
|
|
|
|
|
|
this.controller,
|
|
|
|
|
|
|
|
this.hintText,
|
|
|
|
|
|
|
|
this.onChanged,
|
|
|
|
|
|
|
|
this.focusNode,
|
|
|
|
|
|
|
|
this.onSubmitted,
|
|
|
|
|
|
|
|
this.margin,
|
|
|
|
|
|
|
|
this.onPressed,
|
|
|
|
|
|
|
|
}) : button = true,
|
|
|
|
|
|
|
|
super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///渲染成按钮
|
|
|
|
|
|
|
|
final bool button;
|
|
|
|
|
|
|
|
|
|
|
|
///控制器
|
|
|
|
///控制器
|
|
|
|
final TextEditingController controller;
|
|
|
|
final TextEditingController controller;
|
|
|
@ -32,6 +50,8 @@ class ASSearchTextField extends StatefulWidget implements PreferredSizeWidget {
|
|
|
|
///margin
|
|
|
|
///margin
|
|
|
|
final EdgeInsets margin;
|
|
|
|
final EdgeInsets margin;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final VoidCallback onPressed;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
_ASSearchTextFieldState createState() => _ASSearchTextFieldState();
|
|
|
|
_ASSearchTextFieldState createState() => _ASSearchTextFieldState();
|
|
|
|
|
|
|
|
|
|
|
@ -44,11 +64,56 @@ class _ASSearchTextFieldState extends State<ASSearchTextField> {
|
|
|
|
borderRadius: BorderRadius.circular(21.w),
|
|
|
|
borderRadius: BorderRadius.circular(21.w),
|
|
|
|
borderSide: BorderSide(
|
|
|
|
borderSide: BorderSide(
|
|
|
|
color: Color(0xFF979797),
|
|
|
|
color: Color(0xFF979797),
|
|
|
|
|
|
|
|
width: 1.w,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_buildButton() {
|
|
|
|
|
|
|
|
return Padding(
|
|
|
|
|
|
|
|
padding: widget.margin ??
|
|
|
|
|
|
|
|
EdgeInsets.symmetric(
|
|
|
|
|
|
|
|
horizontal: 15.w,
|
|
|
|
|
|
|
|
vertical: 3.w,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
child: MaterialButton(
|
|
|
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
|
|
|
color: Color(0xFFF8F8F8),
|
|
|
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
|
|
|
borderRadius: BorderRadius.circular(21.w),
|
|
|
|
|
|
|
|
side: BorderSide(
|
|
|
|
|
|
|
|
color: Color(0xFF979797),
|
|
|
|
|
|
|
|
width: 1.w,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Padding(
|
|
|
|
|
|
|
|
padding: EdgeInsets.only(left: 13.w, right: 8.w),
|
|
|
|
|
|
|
|
child: Icon(
|
|
|
|
|
|
|
|
Icons.search,
|
|
|
|
|
|
|
|
size: 16.w,
|
|
|
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
|
|
widget.hintText ?? '',
|
|
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
|
|
color: kTextSubColor,
|
|
|
|
|
|
|
|
fontSize: 14.sp,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
onPressed: widget.onPressed,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
|
|
if (widget.button) return _buildButton();
|
|
|
|
return Container(
|
|
|
|
return Container(
|
|
|
|
height: 42.w,
|
|
|
|
height: 42.w,
|
|
|
|
padding: widget.margin ??
|
|
|
|
padding: widget.margin ??
|
|
|
@ -60,10 +125,13 @@ class _ASSearchTextFieldState extends State<ASSearchTextField> {
|
|
|
|
controller: widget.controller,
|
|
|
|
controller: widget.controller,
|
|
|
|
onChanged: widget.onChanged,
|
|
|
|
onChanged: widget.onChanged,
|
|
|
|
onSubmitted: widget.onSubmitted,
|
|
|
|
onSubmitted: widget.onSubmitted,
|
|
|
|
|
|
|
|
onTap: widget.onPressed,
|
|
|
|
focusNode: widget.focusNode,
|
|
|
|
focusNode: widget.focusNode,
|
|
|
|
cursorColor: kPrimaryColor,
|
|
|
|
cursorColor: kPrimaryColor,
|
|
|
|
textInputAction: TextInputAction.search,
|
|
|
|
textInputAction: TextInputAction.search,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
|
|
|
fillColor: Color(0xFFF8F8F8),
|
|
|
|
|
|
|
|
filled: true,
|
|
|
|
hintText: widget.hintText,
|
|
|
|
hintText: widget.hintText,
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: kTextSubColor,
|
|
|
|
color: kTextSubColor,
|
|
|
|