84 lines
3.2 KiB
Dart
Executable File
84 lines
3.2 KiB
Dart
Executable File
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import '../app_settings/app_colors.dart';
|
|
import '../app_settings/app_settings.dart';
|
|
|
|
class KeySearchWidget extends StatelessWidget {
|
|
|
|
KeySearchWidget(
|
|
{required this.editingController, required this.onSubmittedAction, Key? key,
|
|
this.backgroundColor})
|
|
: super(key: key);
|
|
TextEditingController editingController;
|
|
Function() onSubmittedAction;
|
|
Color? backgroundColor;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
height: 60.h,
|
|
margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 20.w),
|
|
padding: EdgeInsets.only(top: 5.h,right: 10.w),
|
|
decoration: BoxDecoration(
|
|
color: backgroundColor ?? Colors.white, borderRadius: BorderRadius.circular(5)),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: <Widget>[
|
|
Padding(
|
|
padding: EdgeInsets.only(top: 15.h, bottom: 15.h, right: 5.w, left: 10.w),
|
|
child: Image.asset(
|
|
'images/main/icon_main_search.png',
|
|
width: 40.w,
|
|
height: 40.w,
|
|
),
|
|
),
|
|
Expanded(
|
|
child: SizedBox(
|
|
height: 60.h,
|
|
// width: 1.sw,
|
|
// color: Colors.red,
|
|
child: TextField(
|
|
//输入框一行
|
|
maxLines: 1,
|
|
inputFormatters: <TextInputFormatter>[
|
|
FilteringTextInputFormatter.deny('\n'),
|
|
LengthLimitingTextInputFormatter(18),
|
|
],
|
|
style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
|
controller: editingController,
|
|
autofocus: false,
|
|
textAlign: TextAlign.start,
|
|
textInputAction: TextInputAction.search,
|
|
onChanged: (String value) {
|
|
AppLog.log('onChanged:$value');
|
|
},
|
|
onEditingComplete: () {
|
|
AppLog.log('onEditingComplete:');
|
|
},
|
|
onSubmitted: (String value) {
|
|
FocusScope.of(context).unfocus(); // 收起键盘
|
|
onSubmittedAction!();
|
|
},
|
|
decoration: InputDecoration(
|
|
//输入里面输入文字内边距设置
|
|
hintText:'搜索'.tr,
|
|
hintStyle: TextStyle(fontSize: 22.sp),
|
|
focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)),
|
|
disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)),
|
|
enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)),
|
|
border: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)),
|
|
contentPadding: const EdgeInsets.symmetric(vertical: 0),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
} |