feat: up投稿排序
This commit is contained in:
@ -25,7 +25,7 @@ class MemberArchiveController extends GetxController {
|
||||
|
||||
// 获取用户投稿
|
||||
Future getMemberArchive(type) async {
|
||||
if (type == 'onRefresh') {
|
||||
if (type == 'init') {
|
||||
pn = 1;
|
||||
}
|
||||
var res = await MemberHttp.memberArchive(
|
||||
@ -34,7 +34,12 @@ class MemberArchiveController extends GetxController {
|
||||
order: currentOrder['type']!,
|
||||
);
|
||||
if (res['status']) {
|
||||
archivesList.addAll(res['data'].list.vlist);
|
||||
if (type == 'init') {
|
||||
archivesList.value = res['data'].list.vlist;
|
||||
}
|
||||
if (type == 'onLoad') {
|
||||
archivesList.addAll(res['data'].list.vlist);
|
||||
}
|
||||
count = res['data'].page['count'];
|
||||
pn += 1;
|
||||
}
|
||||
@ -42,13 +47,14 @@ class MemberArchiveController extends GetxController {
|
||||
}
|
||||
|
||||
toggleSort() async {
|
||||
pn = 1;
|
||||
int index = orderList.indexOf(currentOrder);
|
||||
List<String> typeList = orderList.map((e) => e['type']!).toList();
|
||||
int index = typeList.indexOf(currentOrder['type']!);
|
||||
if (index == orderList.length - 1) {
|
||||
currentOrder.value = orderList.first;
|
||||
} else {
|
||||
currentOrder.value = orderList[index + 1];
|
||||
}
|
||||
getMemberArchive('init');
|
||||
}
|
||||
|
||||
// 上拉加载
|
||||
|
@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/common/widgets/video_card_h.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
import '../../common/constants.dart';
|
||||
import 'controller.dart';
|
||||
|
||||
class MemberArchivePage extends StatefulWidget {
|
||||
@ -48,39 +49,16 @@ class _MemberArchivePageState extends State<MemberArchivePage> {
|
||||
titleSpacing: 0,
|
||||
centerTitle: false,
|
||||
title: Text('他的投稿', style: Theme.of(context).textTheme.titleMedium),
|
||||
// actions: [
|
||||
// Obx(
|
||||
// () => PopupMenuButton<String>(
|
||||
// padding: EdgeInsets.zero,
|
||||
// tooltip: '投稿排序',
|
||||
// icon: Icon(
|
||||
// Icons.more_vert_outlined,
|
||||
// color: Theme.of(context).colorScheme.outline,
|
||||
// ),
|
||||
// position: PopupMenuPosition.under,
|
||||
// onSelected: (String type) {},
|
||||
// itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
|
||||
// for (var i in _memberArchivesController.orderList) ...[
|
||||
// PopupMenuItem<String>(
|
||||
// onTap: () {},
|
||||
// value: _memberArchivesController.currentOrder['label'],
|
||||
// child: Row(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
// Text(i['label']!),
|
||||
// if (_memberArchivesController.currentOrder['label'] ==
|
||||
// i['label']) ...[
|
||||
// const SizedBox(width: 10),
|
||||
// const Icon(Icons.done, size: 20),
|
||||
// ],
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ]
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
actions: [
|
||||
Obx(
|
||||
() => TextButton.icon(
|
||||
icon: const Icon(Icons.sort, size: 20),
|
||||
onPressed: _memberArchivesController.toggleSort,
|
||||
label: Text(_memberArchivesController.currentOrder['label']!),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
],
|
||||
),
|
||||
body: CustomScrollView(
|
||||
controller: _memberArchivesController.scrollController,
|
||||
|
Reference in New Issue
Block a user