提交 85a7a09e authored 作者: yueweilu's avatar yueweilu

筛选

上级 6172ac79
...@@ -21,7 +21,7 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{ ...@@ -21,7 +21,7 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
late FilterModel selectedDown = FilterModel(); late FilterModel selectedDown = FilterModel();
late TabController tabController = TabController(length:categories.length, vsync: this); // late TabController tabController = TabController(length:categories.length, vsync: this);
final EasyRefreshController refreshController = EasyRefreshController( final EasyRefreshController refreshController = EasyRefreshController(
controlFinishLoad: true, controlFinishLoad: true,
...@@ -107,7 +107,7 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{ ...@@ -107,7 +107,7 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
@override @override
void onClose() { void onClose() {
tabController.dispose(); // tabController.dispose();
refreshController.dispose(); refreshController.dispose();
super.onClose(); super.onClose();
} }
...@@ -144,10 +144,10 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{ ...@@ -144,10 +144,10 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
/// 确定 /// 确定
void sureFilter(){ void sureFilter(){
WidgetsBinding.instance!.addPostFrameCallback((_) { // WidgetsBinding.instance!.addPostFrameCallback((_) {
tabController.animateTo(3); // 你想要的标签索引 // tabController.animateTo(3); // 你想要的标签索引
}); // });
update(); // update();
for(FilterModel model in filterCategories){ for(FilterModel model in filterCategories){
if (model.selected){ if (model.selected){
selectedCategory = model; selectedCategory = model;
...@@ -203,8 +203,8 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{ ...@@ -203,8 +203,8 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
void _getTabs() async { void _getTabs() async {
categories = await LibraryAPI.categories(); categories = await LibraryAPI.categories();
tabController.dispose(); // tabController.dispose();
tabController = TabController(length:categories.length, vsync: this); // tabController = TabController(length:categories.length, vsync: this);
filterCategories = categories.map((model) { filterCategories = categories.map((model) {
return FilterModel(id: model.categoryId.toString(), name: model.name??'',selected: model.selected); return FilterModel(id: model.categoryId.toString(), name: model.name??'',selected: model.selected);
...@@ -328,6 +328,11 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{ ...@@ -328,6 +328,11 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
sortField = selectedDown.id ??''; sortField = selectedDown.id ??'';
} }
String isFree = '';
if (selectedFree.selected == true){
isFree = selectedFree.id??'';
}
if (isRefresh) _page = 1; if (isRefresh) _page = 1;
// 网路请求 // 网路请求
final result = await LibraryAPI.books( final result = await LibraryAPI.books(
...@@ -335,7 +340,7 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{ ...@@ -335,7 +340,7 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
limit: _limit, limit: _limit,
categoryId: selectedCategory.id??'', categoryId: selectedCategory.id??'',
labelId: selectedLabel.id??'', labelId: selectedLabel.id??'',
isFree: selectedFree.id??'', isFree: isFree,
sortField: sortField, sortField: sortField,
sort :sort sort :sort
// sort:selectedDown.id!.isEmpty?'':selectedDown.up ==true?'desc':'asc' // sort:selectedDown.id!.isEmpty?'':selectedDown.up ==true?'desc':'asc'
......
...@@ -178,63 +178,63 @@ class _LibraryPageState extends State<LibraryPage> { ...@@ -178,63 +178,63 @@ class _LibraryPageState extends State<LibraryPage> {
} }
PreferredSizeWidget _buildTab(LibraryController controller){ // PreferredSizeWidget _buildTab(LibraryController controller){
return PreferredSize( // return PreferredSize(
preferredSize: Size.fromHeight(48.w), // preferredSize: Size.fromHeight(48.w),
child: Container( // child: Container(
color: Colors.white, // color: Colors.white,
child: Row( // child: Row(
children: [ // children: [
// TabBar放在左侧 // // TabBar放在左侧
Expanded( // Expanded(
child: TabBar( // child: TabBar(
indicator: BoxDecoration( // indicator: BoxDecoration(
border: const Border(bottom: BorderSide(color: Colors.transparent, width: 0.0)), // 将指示器的底边框颜色设置为透明 // border: const Border(bottom: BorderSide(color: Colors.transparent, width: 0.0)), // 将指示器的底边框颜色设置为透明
color: const Color(0xFFC02D55).withOpacity(0.08) // color: const Color(0xFFC02D55).withOpacity(0.08)
), // ),
labelStyle: TextStyle(color: AppTheme.primary,fontSize: 14.w,height: 1.5,fontWeight: Fonts.medium), // labelStyle: TextStyle(color: AppTheme.primary,fontSize: 14.w,height: 1.5,fontWeight: Fonts.medium),
unselectedLabelColor: Colours.c9, // unselectedLabelColor: Colours.c9,
unselectedLabelStyle: TextStyle(color: Colours.c9,fontSize: 14.w,height: 1.5), // unselectedLabelStyle: TextStyle(color: Colours.c9,fontSize: 14.w,height: 1.5),
controller: controller.tabController, // controller: controller.tabController,
isScrollable: true, // isScrollable: true,
tabs: controller.filterCategories.map((model){ // tabs: controller.filterCategories.map((model){
return Tab(text: model.name); // return Tab(text: model.name);
}).toList(), // }).toList(),
), // ),
), // ),
// 筛选按钮放在右侧 // // 筛选按钮放在右侧
GestureDetector( // GestureDetector(
onTap: (){ // onTap: (){
controller.setShow(controller.show); // controller.setShow(controller.show);
}, // },
child: Container( // child: Container(
padding: EdgeInsets.symmetric(horizontal: 10.w), // padding: EdgeInsets.symmetric(horizontal: 10.w),
alignment: Alignment.center, // alignment: Alignment.center,
height: 38.w, // height: 38.w,
child: Row( // child: Row(
mainAxisAlignment: MainAxisAlignment.center, // mainAxisAlignment: MainAxisAlignment.center,
children: [ // children: [
Container( // Container(
width: 12.w, // width: 12.w,
height: 12.w, // height: 12.w,
// color: Colors.red, // // color: Colors.red,
alignment: Alignment.center, // alignment: Alignment.center,
child: Image.asset( // child: Image.asset(
'assets/images/filter.png', // 'assets/images/filter.png',
), // ),
), // ),
Gaps.hGaps5, // Gaps.hGaps5,
Text('筛选',style: TextStyle(color: Colours.c9,fontSize: 14.w,height: 1.5),) // Text('筛选',style: TextStyle(color: Colours.c9,fontSize: 14.w,height: 1.5),)
], // ],
), // ),
// width: 75, // // width: 75,
), // ),
) // )
], // ],
), // ),
), // ),
); // );
} // }
// @override // @override
// bool get wantKeepAlive => true; // bool get wantKeepAlive => true;
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论