mod
This commit is contained in:
@ -2,6 +2,7 @@ import 'package:get/get.dart';
|
||||
import 'package:pilipala/http/reply.dart';
|
||||
import 'package:pilipala/models/common/reply_sort_type.dart';
|
||||
import 'package:pilipala/models/video/reply/item.dart';
|
||||
import 'package:pilipala/utils/feed_back.dart';
|
||||
|
||||
class DynamicDetailController extends GetxController {
|
||||
DynamicDetailController(this.oid, this.type);
|
||||
@ -41,32 +42,23 @@ class DynamicDetailController extends GetxController {
|
||||
sort: sortType.index,
|
||||
);
|
||||
if (res['status']) {
|
||||
List<ReplyItemModel> replies = res['data'].replies;
|
||||
acount.value = res['data'].page.acount;
|
||||
if (res['data'].replies.isNotEmpty) {
|
||||
currentPage = currentPage + 1;
|
||||
if (replies.isNotEmpty) {
|
||||
currentPage++;
|
||||
noMore.value = '加载中...';
|
||||
if (res['data'].replies.isEmpty) {
|
||||
if (replies.length < 20) {
|
||||
noMore.value = '没有更多了';
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (currentPage == 0) {
|
||||
noMore.value = '还没有评论';
|
||||
} else {
|
||||
noMore.value = '没有更多了';
|
||||
return;
|
||||
}
|
||||
noMore.value = currentPage == 0 ? '还没有评论' : '没有更多了';
|
||||
}
|
||||
List<ReplyItemModel> replies = res['data'].replies;
|
||||
if (reqType == 'init') {
|
||||
// 添加置顶回复
|
||||
if (res['data'].upper.top != null) {
|
||||
bool flag = false;
|
||||
for (var i = 0; i < res['data'].topReplies.length; i++) {
|
||||
if (res['data'].topReplies[i].rpid == res['data'].upper.top.rpid) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
bool flag = res['data']
|
||||
.topReplies
|
||||
.any((reply) => reply.rpid == res['data'].upper.top.rpid);
|
||||
if (!flag) {
|
||||
replies.insert(0, res['data'].upper.top);
|
||||
}
|
||||
@ -76,9 +68,6 @@ class DynamicDetailController extends GetxController {
|
||||
} else {
|
||||
replyList.addAll(replies);
|
||||
}
|
||||
if (replyList.length == acount.value) {
|
||||
noMore.value = '没有更多了';
|
||||
}
|
||||
}
|
||||
isLoadingMore = false;
|
||||
return res;
|
||||
@ -86,6 +75,7 @@ class DynamicDetailController extends GetxController {
|
||||
|
||||
// 排序搜索评论
|
||||
queryBySort() {
|
||||
feedBack();
|
||||
switch (sortType) {
|
||||
case ReplySortType.time:
|
||||
sortType = ReplySortType.like;
|
||||
|
||||
@ -143,7 +143,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage> {
|
||||
),
|
||||
),
|
||||
height: 45,
|
||||
padding: const EdgeInsets.only(left: 15, right: 12),
|
||||
padding: const EdgeInsets.only(left: 12, right: 6),
|
||||
child: Row(
|
||||
children: [
|
||||
Obx(
|
||||
@ -168,9 +168,11 @@ class _DynamicDetailPageState extends State<DynamicDetailPage> {
|
||||
child: TextButton.icon(
|
||||
onPressed: () =>
|
||||
_dynamicDetailController!.queryBySort(),
|
||||
icon: const Icon(Icons.sort, size: 17),
|
||||
icon: const Icon(Icons.sort, size: 16),
|
||||
label: Obx(() => Text(
|
||||
_dynamicDetailController!.sortTypeLabel.value)),
|
||||
_dynamicDetailController!.sortTypeLabel.value,
|
||||
style: const TextStyle(fontSize: 13),
|
||||
)),
|
||||
),
|
||||
)
|
||||
],
|
||||
@ -187,7 +189,8 @@ class _DynamicDetailPageState extends State<DynamicDetailPage> {
|
||||
if (snapshot.data['status']) {
|
||||
// 请求成功
|
||||
return Obx(
|
||||
() => _dynamicDetailController!.replyList.isEmpty
|
||||
() => _dynamicDetailController!.replyList.isEmpty &&
|
||||
_dynamicDetailController!.isLoadingMore
|
||||
? SliverList(
|
||||
delegate:
|
||||
SliverChildBuilderDelegate((context, index) {
|
||||
@ -210,9 +213,18 @@ class _DynamicDetailPageState extends State<DynamicDetailPage> {
|
||||
.bottom +
|
||||
100,
|
||||
child: Center(
|
||||
child: Obx(() => Text(
|
||||
child: Obx(
|
||||
() => Text(
|
||||
_dynamicDetailController!
|
||||
.noMore.value)),
|
||||
.noMore.value,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user