mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 00:28:18 +08:00
opt: load more
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -8,6 +8,7 @@ abstract class CommonController extends GetxController {
|
|||||||
|
|
||||||
int currentPage = 1;
|
int currentPage = 1;
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
|
bool isEnd = false;
|
||||||
Rx<LoadingState> loadingState = LoadingState.loading().obs;
|
Rx<LoadingState> loadingState = LoadingState.loading().obs;
|
||||||
|
|
||||||
Future<LoadingState> customGetData();
|
Future<LoadingState> customGetData();
|
||||||
@@ -23,7 +24,7 @@ abstract class CommonController extends GetxController {
|
|||||||
void handleSuccess(List currentList, List dataList) {}
|
void handleSuccess(List currentList, List dataList) {}
|
||||||
|
|
||||||
Future queryData([bool isRefresh = true]) async {
|
Future queryData([bool isRefresh = true]) async {
|
||||||
if (isLoading) return;
|
if (isLoading || (isRefresh.not && isEnd)) return;
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
LoadingState response = await customGetData();
|
LoadingState response = await customGetData();
|
||||||
if (response is Success) {
|
if (response is Success) {
|
||||||
@@ -50,6 +51,7 @@ abstract class CommonController extends GetxController {
|
|||||||
|
|
||||||
Future onRefresh() async {
|
Future onRefresh() async {
|
||||||
currentPage = 1;
|
currentPage = 1;
|
||||||
|
isEnd = false;
|
||||||
await queryData();
|
await queryData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import 'package:PiliPalaX/http/loading_state.dart';
|
|||||||
import 'package:PiliPalaX/models/common/reply_type.dart';
|
import 'package:PiliPalaX/models/common/reply_type.dart';
|
||||||
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
||||||
import 'package:PiliPalaX/pages/video/detail/reply_new/reply_page.dart';
|
import 'package:PiliPalaX/pages/video/detail/reply_new/reply_page.dart';
|
||||||
import 'package:PiliPalaX/utils/extension.dart';
|
|
||||||
import 'package:PiliPalaX/utils/utils.dart';
|
import 'package:PiliPalaX/utils/utils.dart';
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -17,7 +16,6 @@ import 'package:get/get_navigation/src/dialog/dialog_route.dart';
|
|||||||
abstract class ReplyController extends CommonController {
|
abstract class ReplyController extends CommonController {
|
||||||
String nextOffset = "";
|
String nextOffset = "";
|
||||||
bool isLoadingMore = false;
|
bool isLoadingMore = false;
|
||||||
RxString noMore = ''.obs;
|
|
||||||
RxInt count = (-1).obs;
|
RxInt count = (-1).obs;
|
||||||
// 当前回复的回复
|
// 当前回复的回复
|
||||||
ReplyItemModel? currentReplyItem;
|
ReplyItemModel? currentReplyItem;
|
||||||
@@ -52,16 +50,9 @@ abstract class ReplyController extends CommonController {
|
|||||||
Future onRefresh() {
|
Future onRefresh() {
|
||||||
cursor = null;
|
cursor = null;
|
||||||
nextOffset = '';
|
nextOffset = '';
|
||||||
noMore.value = '';
|
|
||||||
return super.onRefresh();
|
return super.onRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Future queryData([bool isRefresh = true]) {
|
|
||||||
if (isRefresh.not && noMore.value == '没有更多了') return Future.value();
|
|
||||||
return super.queryData(isRefresh);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool customHandleResponse(Success response) {
|
bool customHandleResponse(Success response) {
|
||||||
MainListReply replies = response.response;
|
MainListReply replies = response.response;
|
||||||
@@ -79,15 +70,9 @@ abstract class ReplyController extends CommonController {
|
|||||||
: <ReplyInfo>[];
|
: <ReplyInfo>[];
|
||||||
replies.replies.insertAll(0, list);
|
replies.replies.insertAll(0, list);
|
||||||
}
|
}
|
||||||
if (replies.replies.isNotEmpty) {
|
isEnd = replies.replies.isEmpty ||
|
||||||
noMore.value = '加载中...';
|
replies.cursor.isEnd ||
|
||||||
if (replies.cursor.isEnd || replies.replies.length >= count.value) {
|
replies.replies.length >= count.value;
|
||||||
noMore.value = '没有更多了';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 未登录状态replies可能返回null
|
|
||||||
noMore.value = currentPage == 1 ? '还没有评论' : '没有更多了';
|
|
||||||
}
|
|
||||||
loadingState.value = LoadingState.success(replies);
|
loadingState.value = LoadingState.success(replies);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -110,7 +95,6 @@ abstract class ReplyController extends CommonController {
|
|||||||
sortTypeTitle.value = sortType.titles;
|
sortTypeTitle.value = sortType.titles;
|
||||||
sortTypeLabel.value = sortType.labels;
|
sortTypeLabel.value = sortType.labels;
|
||||||
nextOffset = "";
|
nextOffset = "";
|
||||||
noMore.value = '';
|
|
||||||
loadingState.value = LoadingState.loading();
|
loadingState.value = LoadingState.loading();
|
||||||
onRefresh();
|
onRefresh();
|
||||||
});
|
});
|
||||||
@@ -170,6 +154,7 @@ abstract class ReplyController extends CommonController {
|
|||||||
} else {
|
} else {
|
||||||
response.replies[index].replies.add(replyInfo);
|
response.replies[index].replies.add(replyInfo);
|
||||||
}
|
}
|
||||||
|
count.value += 1;
|
||||||
loadingState.value = LoadingState.success(response);
|
loadingState.value = LoadingState.success(response);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -191,6 +176,7 @@ abstract class ReplyController extends CommonController {
|
|||||||
}
|
}
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
count.value -= 1;
|
||||||
loadingState.value = LoadingState.success(response);
|
loadingState.value = LoadingState.success(response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'dart:math';
|
|||||||
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/pages/video/detail/reply/widgets/reply_item_grpc.dart';
|
import 'package:PiliPalaX/pages/video/detail/reply/widgets/reply_item_grpc.dart';
|
||||||
|
import 'package:PiliPalaX/utils/extension.dart';
|
||||||
import 'package:PiliPalaX/utils/utils.dart';
|
import 'package:PiliPalaX/utils/utils.dart';
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -376,18 +377,19 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
(context, index) {
|
(context, index) {
|
||||||
if (index == loadingState.response.replies.length) {
|
if (index == loadingState.response.replies.length) {
|
||||||
return Container(
|
return Container(
|
||||||
|
alignment: Alignment.center,
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
bottom: MediaQuery.of(context).padding.bottom),
|
bottom: MediaQuery.of(context).padding.bottom),
|
||||||
height: MediaQuery.of(context).padding.bottom + 100,
|
height: MediaQuery.of(context).padding.bottom + 100,
|
||||||
child: Center(
|
child: Text(
|
||||||
child: Obx(
|
_dynamicDetailController.isEnd.not
|
||||||
() => Text(
|
? '加载中...'
|
||||||
_dynamicDetailController.noMore.value,
|
: loadingState.response.replies.isEmpty
|
||||||
style: TextStyle(
|
? '还没有评论'
|
||||||
fontSize: 12,
|
: '没有更多了',
|
||||||
color: Theme.of(context).colorScheme.outline,
|
style: TextStyle(
|
||||||
),
|
fontSize: 12,
|
||||||
),
|
color: Theme.of(context).colorScheme.outline,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'package:PiliPalaX/http/fan.dart';
|
import 'package:PiliPalaX/http/fan.dart';
|
||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
||||||
import 'package:PiliPalaX/utils/extension.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:PiliPalaX/utils/storage.dart';
|
import 'package:PiliPalaX/utils/storage.dart';
|
||||||
@@ -14,7 +13,6 @@ class FansController extends CommonController {
|
|||||||
late String? name;
|
late String? name;
|
||||||
dynamic userInfo;
|
dynamic userInfo;
|
||||||
RxBool isOwner = false.obs;
|
RxBool isOwner = false.obs;
|
||||||
bool isEnd = false;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@@ -29,20 +27,6 @@ class FansController extends CommonController {
|
|||||||
queryData();
|
queryData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Future onRefresh() {
|
|
||||||
isEnd = false;
|
|
||||||
return super.onRefresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future queryData([bool isRefresh = true]) {
|
|
||||||
if (isRefresh.not && isEnd) {
|
|
||||||
return Future.value();
|
|
||||||
}
|
|
||||||
return super.queryData(isRefresh);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool customHandleResponse(Success response) {
|
bool customHandleResponse(Success response) {
|
||||||
if ((currentPage == 1 && response.response.total < ps) ||
|
if ((currentPage == 1 && response.response.total < ps) ||
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:PiliPalaX/common/widgets/article_content.dart';
|
|||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/pages/video/detail/reply/widgets/reply_item_grpc.dart';
|
import 'package:PiliPalaX/pages/video/detail/reply/widgets/reply_item_grpc.dart';
|
||||||
|
import 'package:PiliPalaX/utils/extension.dart';
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
@@ -334,18 +335,19 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
if (index == loadingState.response.replies.length) {
|
if (index == loadingState.response.replies.length) {
|
||||||
return Container(
|
return Container(
|
||||||
|
alignment: Alignment.center,
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
bottom: MediaQuery.of(context).padding.bottom),
|
bottom: MediaQuery.of(context).padding.bottom),
|
||||||
height: MediaQuery.of(context).padding.bottom + 100,
|
height: MediaQuery.of(context).padding.bottom + 100,
|
||||||
child: Center(
|
child: Text(
|
||||||
child: Obx(
|
_htmlRenderCtr.isEnd.not
|
||||||
() => Text(
|
? '加载中...'
|
||||||
_htmlRenderCtr.noMore.value,
|
: loadingState.response.replies.isEmpty
|
||||||
style: TextStyle(
|
? '还没有评论'
|
||||||
fontSize: 12,
|
: '没有更多了',
|
||||||
color: Theme.of(context).colorScheme.outline,
|
style: TextStyle(
|
||||||
),
|
fontSize: 12,
|
||||||
),
|
color: Theme.of(context).colorScheme.outline,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import 'package:PiliPalaX/http/loading_state.dart';
|
|||||||
import 'package:PiliPalaX/http/member.dart';
|
import 'package:PiliPalaX/http/member.dart';
|
||||||
import 'package:PiliPalaX/models/space_article/data.dart';
|
import 'package:PiliPalaX/models/space_article/data.dart';
|
||||||
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
||||||
import 'package:PiliPalaX/utils/extension.dart';
|
|
||||||
|
|
||||||
class MemberArticleCtr extends CommonController {
|
class MemberArticleCtr extends CommonController {
|
||||||
MemberArticleCtr({
|
MemberArticleCtr({
|
||||||
@@ -11,7 +10,6 @@ class MemberArticleCtr extends CommonController {
|
|||||||
|
|
||||||
final int mid;
|
final int mid;
|
||||||
|
|
||||||
bool isEnd = false;
|
|
||||||
int count = -1;
|
int count = -1;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -20,18 +18,6 @@ class MemberArticleCtr extends CommonController {
|
|||||||
queryData();
|
queryData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Future onRefresh() async {
|
|
||||||
isEnd = false;
|
|
||||||
return super.onRefresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future queryData([bool isRefresh = true]) {
|
|
||||||
if (isRefresh.not && isEnd) return Future.value();
|
|
||||||
return super.queryData(isRefresh);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool customHandleResponse(Success response) {
|
bool customHandleResponse(Success response) {
|
||||||
Data data = response.response;
|
Data data = response.response;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import 'package:PiliPalaX/pages/common/common_controller.dart';
|
|||||||
import 'package:PiliPalaX/pages/member/new/content/member_contribute/member_contribute.dart'
|
import 'package:PiliPalaX/pages/member/new/content/member_contribute/member_contribute.dart'
|
||||||
show ContributeType;
|
show ContributeType;
|
||||||
import 'package:PiliPalaX/pages/member/new/controller.dart';
|
import 'package:PiliPalaX/pages/member/new/controller.dart';
|
||||||
import 'package:PiliPalaX/utils/extension.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
class MemberBangumiCtr extends CommonController {
|
class MemberBangumiCtr extends CommonController {
|
||||||
@@ -16,7 +15,6 @@ class MemberBangumiCtr extends CommonController {
|
|||||||
|
|
||||||
final int mid;
|
final int mid;
|
||||||
final String? heroTag;
|
final String? heroTag;
|
||||||
bool isEnd = false;
|
|
||||||
late final int count;
|
late final int count;
|
||||||
late final _ctr = Get.find<MemberControllerNew>(tag: heroTag);
|
late final _ctr = Get.find<MemberControllerNew>(tag: heroTag);
|
||||||
|
|
||||||
@@ -32,17 +30,10 @@ class MemberBangumiCtr extends CommonController {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future onRefresh() async {
|
Future onRefresh() async {
|
||||||
isEnd = false;
|
|
||||||
currentPage = 1;
|
currentPage = 1;
|
||||||
await queryData();
|
await queryData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Future queryData([bool isRefresh = true]) {
|
|
||||||
if (isRefresh.not && isEnd) return Future.value();
|
|
||||||
return super.queryData(isRefresh);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool customHandleResponse(Success response) {
|
bool customHandleResponse(Success response) {
|
||||||
Data data = response.response;
|
Data data = response.response;
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import 'package:PiliPalaX/models/space_archive/data.dart';
|
|||||||
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
||||||
import 'package:PiliPalaX/pages/member/new/content/member_contribute/member_contribute.dart'
|
import 'package:PiliPalaX/pages/member/new/content/member_contribute/member_contribute.dart'
|
||||||
show ContributeType;
|
show ContributeType;
|
||||||
import 'package:PiliPalaX/utils/extension.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
class MemberVideoCtr extends CommonController {
|
class MemberVideoCtr extends CommonController {
|
||||||
@@ -22,13 +21,11 @@ class MemberVideoCtr extends CommonController {
|
|||||||
String? aid;
|
String? aid;
|
||||||
RxString order = 'pubdate'.obs;
|
RxString order = 'pubdate'.obs;
|
||||||
RxString sort = 'desc'.obs;
|
RxString sort = 'desc'.obs;
|
||||||
bool isEnd = false;
|
|
||||||
RxInt count = (-1).obs;
|
RxInt count = (-1).obs;
|
||||||
int? next;
|
int? next;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future onRefresh() async {
|
Future onRefresh() async {
|
||||||
isEnd = false;
|
|
||||||
aid = null;
|
aid = null;
|
||||||
next = null;
|
next = null;
|
||||||
currentPage = 0;
|
currentPage = 0;
|
||||||
@@ -42,12 +39,6 @@ class MemberVideoCtr extends CommonController {
|
|||||||
queryData();
|
queryData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Future queryData([bool isRefresh = true]) {
|
|
||||||
if (isRefresh.not && isEnd) return Future.value();
|
|
||||||
return super.queryData(isRefresh);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool customHandleResponse(Success response) {
|
bool customHandleResponse(Success response) {
|
||||||
Data data = response.response;
|
Data data = response.response;
|
||||||
|
|||||||
@@ -2,32 +2,12 @@ import 'package:PiliPalaX/grpc/app/dynamic/v2/dynamic.pb.dart';
|
|||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/http/member.dart';
|
import 'package:PiliPalaX/http/member.dart';
|
||||||
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
||||||
import 'package:PiliPalaX/utils/extension.dart';
|
|
||||||
|
|
||||||
class MemberDynamicCtr extends CommonController {
|
class MemberDynamicCtr extends CommonController {
|
||||||
MemberDynamicCtr({
|
MemberDynamicCtr({
|
||||||
required this.mid,
|
required this.mid,
|
||||||
});
|
});
|
||||||
int mid;
|
int mid;
|
||||||
bool isEnd = false;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void onInit() {
|
|
||||||
super.onInit();
|
|
||||||
// queryData();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future onRefresh() {
|
|
||||||
isEnd = false;
|
|
||||||
return super.onRefresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future queryData([bool isRefresh = true]) {
|
|
||||||
if (isRefresh.not && isEnd) return Future.value();
|
|
||||||
return super.queryData(isRefresh);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool customHandleResponse(Success response) {
|
bool customHandleResponse(Success response) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
|||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/pages/video/detail/reply/widgets/reply_item_grpc.dart';
|
import 'package:PiliPalaX/pages/video/detail/reply/widgets/reply_item_grpc.dart';
|
||||||
|
import 'package:PiliPalaX/utils/extension.dart';
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
@@ -215,17 +216,18 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
|||||||
_videoReplyController.onLoadMore();
|
_videoReplyController.onLoadMore();
|
||||||
});
|
});
|
||||||
return Container(
|
return Container(
|
||||||
|
alignment: Alignment.center,
|
||||||
padding: EdgeInsets.only(bottom: bottom),
|
padding: EdgeInsets.only(bottom: bottom),
|
||||||
height: bottom + 100,
|
height: bottom + 100,
|
||||||
child: Center(
|
child: Text(
|
||||||
child: Obx(
|
_videoReplyController.isEnd.not
|
||||||
() => Text(
|
? '加载中...'
|
||||||
_videoReplyController.noMore.value,
|
: loadingState.response.replies.isEmpty
|
||||||
style: TextStyle(
|
? '还没有评论'
|
||||||
fontSize: 12,
|
: '没有更多了',
|
||||||
color: Theme.of(context).colorScheme.outline,
|
style: TextStyle(
|
||||||
),
|
fontSize: 12,
|
||||||
),
|
color: Theme.of(context).colorScheme.outline,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart';
|
|||||||
import 'package:PiliPalaX/grpc/grpc_repo.dart';
|
import 'package:PiliPalaX/grpc/grpc_repo.dart';
|
||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
||||||
import 'package:PiliPalaX/utils/extension.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPalaX/http/reply.dart';
|
import 'package:PiliPalaX/http/reply.dart';
|
||||||
@@ -44,8 +43,6 @@ class VideoReplyReplyController extends CommonController
|
|||||||
|
|
||||||
ReplyInfo? firstFloor;
|
ReplyInfo? firstFloor;
|
||||||
|
|
||||||
bool isEnd = false;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
@@ -82,7 +79,6 @@ class VideoReplyReplyController extends CommonController
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future queryData([bool isRefresh = true]) async {
|
Future queryData([bool isRefresh = true]) async {
|
||||||
if (isRefresh.not && isEnd) return Future.value();
|
|
||||||
if (!isDialogue &&
|
if (!isDialogue &&
|
||||||
currentPage == 1 &&
|
currentPage == 1 &&
|
||||||
!hasRoot &&
|
!hasRoot &&
|
||||||
@@ -110,7 +106,6 @@ class VideoReplyReplyController extends CommonController
|
|||||||
@override
|
@override
|
||||||
Future onRefresh() {
|
Future onRefresh() {
|
||||||
cursor = null;
|
cursor = null;
|
||||||
isEnd = false;
|
|
||||||
return super.onRefresh();
|
return super.onRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,24 +154,13 @@ class VideoReplyReplyController extends CommonController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isDialogue) {
|
if (isDialogue) {
|
||||||
if (replies.replies.isNotEmpty) {
|
isEnd = replies.replies.isEmpty ||
|
||||||
if (replies.cursor.isEnd || replies.replies.length >= count.value) {
|
replies.cursor.isEnd ||
|
||||||
isEnd = true;
|
replies.replies.length >= count.value;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 未登录状态replies可能返回null
|
|
||||||
isEnd = true;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (replies.root.replies.isNotEmpty) {
|
isEnd = replies.root.replies.isEmpty ||
|
||||||
if (replies.cursor.isEnd ||
|
replies.cursor.isEnd ||
|
||||||
replies.root.replies.length >= count.value) {
|
replies.root.replies.length >= count.value;
|
||||||
isEnd = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 未登录状态replies可能返回null
|
|
||||||
isEnd = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (isDialogue) {
|
if (isDialogue) {
|
||||||
loadingState.value = LoadingState.success(replies.replies);
|
loadingState.value = LoadingState.success(replies.replies);
|
||||||
|
|||||||
@@ -149,9 +149,9 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
itemBuilder: (_, index) {
|
itemBuilder: (_, index) {
|
||||||
if (widget.isDialogue) {
|
if (widget.isDialogue) {
|
||||||
return Obx(() => _buildBody(
|
return _buildBody(
|
||||||
_videoReplyReplyController.loadingState.value,
|
_videoReplyReplyController.loadingState.value,
|
||||||
index));
|
index);
|
||||||
} else if (firstFloor != null) {
|
} else if (firstFloor != null) {
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
return ReplyItemGrpc(
|
return ReplyItemGrpc(
|
||||||
@@ -176,17 +176,17 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
} else if (index == 2) {
|
} else if (index == 2) {
|
||||||
return _sortWidget;
|
return _sortWidget;
|
||||||
} else {
|
} else {
|
||||||
return Obx(() => _buildBody(
|
return _buildBody(
|
||||||
_videoReplyReplyController.loadingState.value,
|
_videoReplyReplyController.loadingState.value,
|
||||||
index - 3));
|
index - 3);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
return _sortWidget;
|
return _sortWidget;
|
||||||
} else {
|
} else {
|
||||||
return Obx(() => _buildBody(
|
return _buildBody(
|
||||||
_videoReplyReplyController.loadingState.value,
|
_videoReplyReplyController.loadingState.value,
|
||||||
index - 1));
|
index - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -285,6 +285,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
?.response ??
|
?.response ??
|
||||||
<ReplyInfo>[];
|
<ReplyInfo>[];
|
||||||
list.insert(index + 1, replyInfo);
|
list.insert(index + 1, replyInfo);
|
||||||
|
_videoReplyReplyController.count.value += 1;
|
||||||
_videoReplyReplyController.loadingState.value =
|
_videoReplyReplyController.loadingState.value =
|
||||||
LoadingState.success(list);
|
LoadingState.success(list);
|
||||||
}
|
}
|
||||||
@@ -314,22 +315,19 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
_videoReplyReplyController.onLoadMore();
|
_videoReplyReplyController.onLoadMore();
|
||||||
});
|
});
|
||||||
return Container(
|
return Container(
|
||||||
|
alignment: Alignment.center,
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
bottom: MediaQuery.of(context).padding.bottom),
|
bottom: MediaQuery.of(context).padding.bottom),
|
||||||
height: MediaQuery.of(context).padding.bottom + 100,
|
height: MediaQuery.of(context).padding.bottom + 100,
|
||||||
child: Center(
|
child: Text(
|
||||||
child: Obx(
|
_videoReplyReplyController.isEnd.not
|
||||||
() => Text(
|
? '加载中...'
|
||||||
_videoReplyReplyController.isEnd.not
|
: loadingState.response.isEmpty
|
||||||
? '加载中...'
|
? '还没有评论'
|
||||||
: loadingState.response.isEmpty
|
: '没有更多了',
|
||||||
? '还没有评论'
|
style: TextStyle(
|
||||||
: '没有更多了',
|
fontSize: 12,
|
||||||
style: TextStyle(
|
color: Theme.of(context).colorScheme.outline,
|
||||||
fontSize: 12,
|
|
||||||
color: Theme.of(context).colorScheme.outline,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -376,6 +374,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
List list =
|
List list =
|
||||||
(_videoReplyReplyController.loadingState.value as Success).response;
|
(_videoReplyReplyController.loadingState.value as Success).response;
|
||||||
list = list.where((item) => item.id != rpid).toList();
|
list = list.where((item) => item.id != rpid).toList();
|
||||||
|
_videoReplyReplyController.count.value -= 1;
|
||||||
_videoReplyReplyController.loadingState.value =
|
_videoReplyReplyController.loadingState.value =
|
||||||
LoadingState.success(list);
|
LoadingState.success(list);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user