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.
273 lines
8.6 KiB
273 lines
8.6 KiB
import 'package:flutter/material.dart'; |
|
import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; |
|
import 'package:huixiang/utils/font_weight.dart'; |
|
import 'package:huixiang/view_widget/classic_header.dart'; |
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
import 'package:pull_to_refresh/pull_to_refresh.dart'; |
|
import '../../view_widget/my_appbar.dart'; |
|
|
|
class GoodsSearchPage extends StatefulWidget { |
|
final Map<String, dynamic> arguments; |
|
|
|
GoodsSearchPage({this.arguments}); |
|
|
|
@override |
|
State<StatefulWidget> createState() { |
|
return _GoodsSearchPage(); |
|
} |
|
} |
|
|
|
class _GoodsSearchPage extends State<GoodsSearchPage> |
|
with WidgetsBindingObserver { |
|
final TextEditingController editingController = TextEditingController(); |
|
final RefreshController refreshController = RefreshController(); |
|
final ScrollController scrollController = ScrollController(); |
|
int optionIndex = 0; |
|
bool isKeyBoardShow = false; |
|
List<ProductListBean> productListBeans = []; |
|
List<String> hotSearch = []; |
|
List<String> historySearch = []; |
|
FocusNode _focusNode = FocusNode(); |
|
bool hasFocus = true; |
|
int priceOrder = 0; |
|
|
|
@override |
|
void didChangeMetrics() { |
|
super.didChangeMetrics(); |
|
WidgetsBinding.instance.addPostFrameCallback((_) { |
|
setState(() { |
|
print("object: ${MediaQuery.of(context).viewInsets.bottom}"); |
|
if (MediaQuery.of(context).viewInsets.bottom == 0) { |
|
if (isKeyBoardShow) { |
|
isKeyBoardShow = false; |
|
//关闭键盘 软键盘关闭了, 清除输入控件的焦点, 否则重新进入页面会导致软键盘再弹出问题 |
|
FocusScope.of(context).requestFocus(FocusNode()); |
|
} |
|
} else { |
|
isKeyBoardShow = true; |
|
} |
|
}); |
|
}); |
|
} |
|
|
|
///离开页面记着销毁和清除 |
|
@override |
|
void dispose() { |
|
_focusNode.unfocus(); |
|
super.dispose(); |
|
} |
|
|
|
@override |
|
void initState() { |
|
super.initState(); |
|
_focusNode.addListener(() { |
|
setState(() { |
|
hasFocus = _focusNode.hasFocus; |
|
}); |
|
}); |
|
} |
|
|
|
_onRefresh() { |
|
} |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
return GestureDetector( |
|
behavior: HitTestBehavior.translucent, |
|
onTap: (){ |
|
FocusScope.of(context).requestFocus(FocusNode()); |
|
}, |
|
child: Scaffold( |
|
appBar: MyAppBar( |
|
title: "搜索", |
|
titleColor: Colors.black, |
|
leadingColor: Colors.black, |
|
background: Colors.white, |
|
), |
|
body: Column( |
|
children: [ |
|
Container( |
|
color: Colors.white, |
|
margin: EdgeInsets.only(bottom:16.h), |
|
child: Container( |
|
height: 40.h, |
|
margin: EdgeInsets.only(left: 18.w,right: 18.w,top:17.h,bottom: 10.h), |
|
decoration: BoxDecoration( |
|
color: Color(0xFFF7F8FA), |
|
borderRadius: BorderRadius.circular(2), |
|
), |
|
child: TextField( |
|
focusNode: _focusNode, |
|
textInputAction: TextInputAction.search, |
|
onEditingComplete: () { |
|
FocusScope.of(context).requestFocus(FocusNode()); |
|
}, |
|
style: TextStyle( |
|
fontSize: 15.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0xFF808080), |
|
), |
|
controller: editingController, |
|
decoration: InputDecoration( |
|
hintText: "请输入搜索内容", |
|
hintStyle: TextStyle( |
|
color: Color(0xFF808080), |
|
fontSize: 15.sp, |
|
fontWeight: MyFontWeight.regular |
|
), |
|
prefixIcon: Image.asset( |
|
"assets/image/bs_goods_search.webp", |
|
width: 20, |
|
height: 20, |
|
), |
|
border: InputBorder.none, |
|
), |
|
), |
|
),), |
|
Expanded(child: Container( |
|
child: SmartRefresher( |
|
controller:refreshController, |
|
enablePullUp: false, |
|
enablePullDown: true, |
|
physics: BouncingScrollPhysics(), |
|
header: MyHeader(), |
|
onRefresh:(){ |
|
_onRefresh(); |
|
}, |
|
child:ListView.builder( |
|
padding: EdgeInsets.zero, |
|
itemCount:5, |
|
scrollDirection: Axis.vertical, |
|
shrinkWrap: true, |
|
physics: NeverScrollableScrollPhysics(), |
|
itemBuilder: (context, position) { |
|
return GestureDetector( |
|
onTap: () { |
|
}, |
|
child: searchGoodsItem(), |
|
); |
|
}, |
|
), |
|
), |
|
),) |
|
|
|
], |
|
), |
|
), |
|
); |
|
} |
|
|
|
Widget searchGoodsItem(){ |
|
return Container( |
|
decoration: BoxDecoration( |
|
color: Colors.white, |
|
borderRadius: BorderRadius.circular(8), |
|
boxShadow: [ |
|
BoxShadow( |
|
color: Color(0x0F06152E).withAlpha(12), |
|
offset: Offset(0, 2), |
|
blurRadius: 4, |
|
spreadRadius: 0, |
|
) |
|
], |
|
), |
|
margin: EdgeInsets.only(bottom:12.h,left: 16.w,right: 16.w), |
|
padding: EdgeInsets.only(left: 12.w,top: 12.h,bottom: 12.h,right:24.w), |
|
child: Row( |
|
children: [ |
|
Image.asset( |
|
"assets/image/hot_list.webp", |
|
width: 70, |
|
height: 70, |
|
fit: BoxFit.fill, |
|
), |
|
SizedBox(width:12.w,), |
|
Expanded(child:Column( |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Padding(padding:EdgeInsets.only(bottom:11.h,top: 2.h), |
|
child: Text( |
|
"台湾甄选手抓饺子三生", |
|
maxLines:1, |
|
overflow: TextOverflow.ellipsis, |
|
style: TextStyle( |
|
fontSize: 14.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF000000), |
|
), |
|
),), |
|
Row( |
|
children: [ |
|
Text( |
|
"库存4321", |
|
style: TextStyle( |
|
fontSize: 10.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0xFFA29E9E), |
|
), |
|
), |
|
SizedBox(width: 8.w,), |
|
Text( |
|
"销量4321", |
|
style: TextStyle( |
|
fontSize: 10.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0xFF999999), |
|
), |
|
), |
|
], |
|
), |
|
SizedBox(height:7.h,), |
|
Row( |
|
children: [ |
|
Expanded(child:Text.rich( |
|
TextSpan( |
|
children: [ |
|
TextSpan( |
|
text: "¥", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFFF4524D), |
|
), |
|
), |
|
TextSpan( |
|
text: "19", |
|
style: TextStyle( |
|
fontSize: 14.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFFF4524D), |
|
), |
|
), |
|
], |
|
), |
|
)), |
|
Container( |
|
decoration: BoxDecoration( |
|
color: Colors.white, |
|
borderRadius: BorderRadius.circular(33), |
|
border: Border.all( |
|
color: Color(0xFF30415B), |
|
width: 1, |
|
), |
|
), |
|
padding: EdgeInsets.symmetric(vertical: 2.h,horizontal:12.w), |
|
child: Text( |
|
"下架", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0xFF30415B), |
|
), |
|
), |
|
) |
|
], |
|
) |
|
], |
|
)), |
|
], |
|
), |
|
); |
|
} |
|
|
|
}
|
|
|