提交 e75e9cee authored 作者: yueweilu's avatar yueweilu

排序

上级 a0fe5e17
......@@ -361,12 +361,14 @@ class FilterModel {
FilterModel({
this.id,
this.name,
this.selected = false
this.selected = false,
this.up = true,
});
String? id;
String? name;
late bool selected = false;
late bool up = true;
}
......
......@@ -15,8 +15,10 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
late FilterModel selectedCategory = FilterModel();
// 选中是否收费
late FilterModel selectedFree = FilterModel();
// 选中排序的 方式
late FilterModel selectedDown = FilterModel();
late TabController tabController = TabController(length:categories.length, vsync: this);
final EasyRefreshController refreshController = EasyRefreshController(
......@@ -304,6 +306,7 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
/// 获取图书列表数据
Future<void> _getBooks([bool isRefresh = false]) async {
if (isRefresh) _page = 1;
// 网路请求
final result = await LibraryAPI.books(
......@@ -312,7 +315,8 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
categoryId: selectedCategory.id??'',
labelId: selectedLabel.id??'',
isFree: selectedFree.id??'',
sortField: selectedDown.id??''
sortField: selectedDown.id??'',
sort:selectedDown.id!.isEmpty?'':selectedDown.up ==true?'desc':'asc'
);
// 如果是刷新 清理数据
if (isRefresh) books.clear();
......
......@@ -122,6 +122,14 @@ class _FilterPageState extends State<FilterPage> {
model.selected = false;
}
model.selected = !model.selected;
if (model.name == '读过' || model.name == '评分'){
if(model.selected){
model.up = !model.up;
}
else{
model.up = true;
}
}
});
},
child: Container(
......@@ -137,7 +145,7 @@ class _FilterPageState extends State<FilterPage> {
mainAxisSize: MainAxisSize.min,
children: [
Text(model.name??'',style: TextStyle(fontSize: 13,height: 1.4,color: model.selected?AppTheme.primary: Colours.c3),textAlign: TextAlign.center,),
Image.asset(model.selected?'assets/images/filter_select.png':'assets/images/filter_unselect.png'),
Image.asset(model.selected?model.up?'assets/images/filter_up.png':'assets/images/filter_down.png':'assets/images/filter_unselect.png'),
],
):Padding(padding: EdgeInsets.only(top: 4.w),child: Text(model.name??'',style: TextStyle(fontSize: 13,height: 1.4,color: model.selected?AppTheme.primary: Colours.c3),textAlign: TextAlign.end,),),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论