feat: 动态筛选&UP主筛选

This commit is contained in:
guozhigq
2023-06-29 23:37:55 +08:00
parent eca48bc77e
commit b43b9549b9
9 changed files with 557 additions and 71 deletions

View File

@ -3,22 +3,53 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:pilipala/http/dynamics.dart';
import 'package:pilipala/http/search.dart';
import 'package:pilipala/models/common/dynamics_type.dart';
import 'package:pilipala/models/dynamics/result.dart';
import 'package:pilipala/models/dynamics/up.dart';
import 'package:pilipala/utils/utils.dart';
class DynamicsController extends GetxController {
int page = 1;
String? offset = '';
RxList<DynamicItemModel>? dynamicsList = [DynamicItemModel()].obs;
RxString dynamicsType = 'all'.obs;
Rx<DynamicsType> dynamicsType = DynamicsType.values[0].obs;
RxString dynamicsTypeLabel = '全部'.obs;
final ScrollController scrollController = ScrollController();
Rx<FollowUpModel> upData = FollowUpModel().obs;
// 默认获取全部动态
int mid = -1;
List filterTypeList = [
{
'label': DynamicsType.all.labels,
'value': DynamicsType.all,
'enabled': true
},
{
'label': DynamicsType.video.labels,
'value': DynamicsType.video,
'enabled': true
},
{
'label': DynamicsType.pgc.labels,
'value': DynamicsType.pgc,
'enabled': true
},
{
'label': DynamicsType.article.labels,
'value': DynamicsType.article,
'enabled': true
},
];
Future queryFollowDynamic({type = 'init'}) async {
// if (type == 'init') {
// dynamicsList!.value = [];
// }
var res = await DynamicsHttp.followDynamic(
page: type == 'init' ? 1 : page,
type: dynamicsType.value,
type: dynamicsType.value.values,
offset: offset,
mid: mid,
);
if (res['status']) {
if (type == 'init') {
@ -32,12 +63,10 @@ class DynamicsController extends GetxController {
return res;
}
onSelectType(value, label) async {
onSelectType(value) async {
dynamicsType.value = value;
dynamicsTypeLabel.value = label;
await queryFollowDynamic();
scrollController.animateTo(0,
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
scrollController.jumpTo(0);
}
pushDetail(item, floor, {action = 'all'}) async {
@ -86,4 +115,18 @@ class DynamicsController extends GetxController {
break;
}
}
Future queryFollowUp() async {
var res = await DynamicsHttp.followUp();
if (res['status']) {
upData.value = res['data'];
}
return res;
}
onSelectUp(mid) async {
dynamicsType.value = DynamicsType.values[0];
queryFollowDynamic();
}
}