提交 0076ac32 authored 作者: yueweilu's avatar yueweilu

1、分类 标签为空展示逻辑

上级 55e4b047
...@@ -121,12 +121,18 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{ ...@@ -121,12 +121,18 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
for(FilterModel model in filterCategories){ for(FilterModel model in filterCategories){
model.selected = false; model.selected = false;
} }
filterCategories.first.selected = true; if(filterCategories.isNotEmpty){
selectedCategory = filterCategories.first;
selectedCategory.selected = true;
}
for(FilterModel model in filterLabels){ for(FilterModel model in filterLabels){
model.selected = false; model.selected = false;
} }
filterLabels.first.selected = true; if(filterLabels.isNotEmpty){
selectedLabel = filterLabels.first;
selectedLabel.selected = true;
}
for(FilterModel model in filterFree){ for(FilterModel model in filterFree){
model.selected = false; model.selected = false;
...@@ -135,8 +141,9 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{ ...@@ -135,8 +141,9 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
for(FilterModel model in filterDown){ for(FilterModel model in filterDown){
model.selected = false; model.selected = false;
} }
update();
// onRefresh();
update();
} }
/// 确定 /// 确定
...@@ -206,8 +213,10 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{ ...@@ -206,8 +213,10 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
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);
}).toList(); }).toList();
if(filterCategories.isNotEmpty){
selectedCategory = filterCategories.first; selectedCategory = filterCategories.first;
selectedCategory.selected = true; selectedCategory.selected = true;
}
update(); update();
} }
...@@ -218,8 +227,10 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{ ...@@ -218,8 +227,10 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
filterLabels = labels.map((model) { filterLabels = labels.map((model) {
return FilterModel(id: model.labelId.toString(), name: model.name??'',selected: model.selected); return FilterModel(id: model.labelId.toString(), name: model.name??'',selected: model.selected);
}).toList(); }).toList();
if (filterLabels.isNotEmpty){
selectedLabel = filterLabels.first; selectedLabel = filterLabels.first;
selectedLabel.selected = true; selectedLabel.selected = true;
}
update(['label']); update(['label']);
......
...@@ -41,8 +41,8 @@ class _LibraryPageState extends State<LibraryPage> { ...@@ -41,8 +41,8 @@ class _LibraryPageState extends State<LibraryPage> {
Row( Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Expanded(child: _buildCategory()), controller.filterCategories.isEmpty?const SizedBox():Expanded(child: _buildCategory()),
GestureDetector( controller.filterCategories.isEmpty?const SizedBox():GestureDetector(
onTap: (){ onTap: (){
controller.setShow(controller.show); controller.setShow(controller.show);
}, },
...@@ -115,7 +115,8 @@ class _LibraryPageState extends State<LibraryPage> { ...@@ -115,7 +115,8 @@ class _LibraryPageState extends State<LibraryPage> {
controller.sureFilter(); controller.sureFilter();
}, },
resetTap: (){ resetTap: (){
// controller.setShow(controller.show);
controller.resetFilter();
},), },),
), ),
], ],
......
...@@ -41,8 +41,8 @@ class _FilterPageState extends State<FilterPage> { ...@@ -41,8 +41,8 @@ class _FilterPageState extends State<FilterPage> {
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
_buildWrapWidget('分类', widget.controller.filterCategories), widget.controller.filterCategories.isEmpty?const SizedBox():_buildWrapWidget('分类', widget.controller.filterCategories),
_buildWrapWidget('标签', widget.controller.filterLabels), widget.controller.filterLabels.isEmpty?const SizedBox():_buildWrapWidget('标签', widget.controller.filterLabels),
_buildWrapWidget('是否收费', widget.controller.filterFree), _buildWrapWidget('是否收费', widget.controller.filterFree),
_buildWrapWidget('排序', widget.controller.filterDown), _buildWrapWidget('排序', widget.controller.filterDown),
], ],
...@@ -60,9 +60,7 @@ class _FilterPageState extends State<FilterPage> { ...@@ -60,9 +60,7 @@ class _FilterPageState extends State<FilterPage> {
children: [ children: [
Expanded( Expanded(
child: GestureDetector( child: GestureDetector(
onTap: (){ onTap: widget.resetTap,
widget.controller.resetFilter();
},
child: Container( child: Container(
alignment: Alignment.center, alignment: Alignment.center,
height: 35.w, height: 35.w,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论