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