mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: load more replies
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:PiliPalaX/http/loading_state.dart';
|
|||||||
import 'package:PiliPalaX/models/space_article/item.dart';
|
import 'package:PiliPalaX/models/space_article/item.dart';
|
||||||
import 'package:PiliPalaX/pages/member/new/content/member_contribute/content/article/member_article_ctr.dart';
|
import 'package:PiliPalaX/pages/member/new/content/member_contribute/content/article/member_article_ctr.dart';
|
||||||
import 'package:PiliPalaX/utils/app_scheme.dart';
|
import 'package:PiliPalaX/utils/app_scheme.dart';
|
||||||
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
@@ -54,7 +55,11 @@ class _MemberArticleState extends State<MemberArticle>
|
|||||||
itemCount: loadingState.response.length,
|
itemCount: loadingState.response.length,
|
||||||
itemBuilder: (_, index) {
|
itemBuilder: (_, index) {
|
||||||
if (index == loadingState.response.length - 1) {
|
if (index == loadingState.response.length - 1) {
|
||||||
_controller.onLoadMore();
|
EasyThrottle.throttle(
|
||||||
|
'memberArticle', const Duration(milliseconds: 500),
|
||||||
|
() {
|
||||||
|
_controller.onLoadMore();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
Item item = loadingState.response[index];
|
Item item = loadingState.response[index];
|
||||||
return ListTile(
|
return ListTile(
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:PiliPalaX/http/loading_state.dart';
|
|||||||
import 'package:PiliPalaX/pages/bangumi/widgets/bangumi_card_v_member_home.dart';
|
import 'package:PiliPalaX/pages/bangumi/widgets/bangumi_card_v_member_home.dart';
|
||||||
import 'package:PiliPalaX/pages/member/new/content/member_contribute/content/bangumi/member_bangumi_ctr.dart';
|
import 'package:PiliPalaX/pages/member/new/content/member_contribute/content/bangumi/member_bangumi_ctr.dart';
|
||||||
import 'package:PiliPalaX/utils/grid.dart';
|
import 'package:PiliPalaX/utils/grid.dart';
|
||||||
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
@@ -71,7 +72,10 @@ class _MemberBangumiState extends State<MemberBangumi>
|
|||||||
delegate: SliverChildBuilderDelegate(
|
delegate: SliverChildBuilderDelegate(
|
||||||
(context, index) {
|
(context, index) {
|
||||||
if (index == loadingState.response.length - 1) {
|
if (index == loadingState.response.length - 1) {
|
||||||
_controller.onLoadMore();
|
EasyThrottle.throttle('memberBangumi',
|
||||||
|
const Duration(milliseconds: 500), () {
|
||||||
|
_controller.onLoadMore();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return BangumiCardVMemberHome(
|
return BangumiCardVMemberHome(
|
||||||
bangumiItem: loadingState.response[index],
|
bangumiItem: loadingState.response[index],
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ 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/dynamics/widgets/dynamic_panel_grpc.dart';
|
import 'package:PiliPalaX/pages/dynamics/widgets/dynamic_panel_grpc.dart';
|
||||||
import 'package:PiliPalaX/pages/member/new/content/member_dynamic/member_dynamic_ctr.dart';
|
import 'package:PiliPalaX/pages/member/new/content/member_dynamic/member_dynamic_ctr.dart';
|
||||||
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
@@ -43,7 +44,10 @@ class _MemberDynamicState extends State<MemberDynamic>
|
|||||||
itemCount: loadingState.response.length,
|
itemCount: loadingState.response.length,
|
||||||
itemBuilder: (_, index) {
|
itemBuilder: (_, index) {
|
||||||
if (index == loadingState.response.length - 1) {
|
if (index == loadingState.response.length - 1) {
|
||||||
_controller.onLoadMore();
|
EasyThrottle.throttle(
|
||||||
|
'memberDynamic', const Duration(milliseconds: 500), () {
|
||||||
|
_controller.onLoadMore();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return DynamicPanelGrpc(
|
return DynamicPanelGrpc(
|
||||||
item: loadingState.response[index],
|
item: loadingState.response[index],
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:PiliPalaX/common/widgets/video_card_h.dart';
|
|||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
import 'package:PiliPalaX/pages/member_search/controller.dart';
|
import 'package:PiliPalaX/pages/member_search/controller.dart';
|
||||||
import 'package:PiliPalaX/utils/grid.dart';
|
import 'package:PiliPalaX/utils/grid.dart';
|
||||||
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart';
|
import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart';
|
||||||
|
|
||||||
@@ -50,7 +51,10 @@ class SearchArchive extends StatelessWidget {
|
|||||||
delegate: SliverChildBuilderDelegate(
|
delegate: SliverChildBuilderDelegate(
|
||||||
(context, index) {
|
(context, index) {
|
||||||
if (index == loadingState.response.length - 1) {
|
if (index == loadingState.response.length - 1) {
|
||||||
ctr.searchArchives(false);
|
EasyThrottle.throttle('searchArchives',
|
||||||
|
const Duration(milliseconds: 500), () {
|
||||||
|
ctr.searchArchives(false);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return VideoCardH(
|
return VideoCardH(
|
||||||
videoItem: loadingState.response[index],
|
videoItem: loadingState.response[index],
|
||||||
|
|||||||
@@ -79,15 +79,6 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
|||||||
void scrollListener() {
|
void scrollListener() {
|
||||||
_videoReplyController.scrollController.addListener(
|
_videoReplyController.scrollController.addListener(
|
||||||
() {
|
() {
|
||||||
if (_videoReplyController.scrollController.position.pixels >=
|
|
||||||
_videoReplyController.scrollController.position.maxScrollExtent -
|
|
||||||
300) {
|
|
||||||
EasyThrottle.throttle('replylist', const Duration(milliseconds: 200),
|
|
||||||
() {
|
|
||||||
_videoReplyController.onLoadMore();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
final ScrollDirection direction =
|
final ScrollDirection direction =
|
||||||
_videoReplyController.scrollController.position.userScrollDirection;
|
_videoReplyController.scrollController.position.userScrollDirection;
|
||||||
if (direction == ScrollDirection.forward) {
|
if (direction == ScrollDirection.forward) {
|
||||||
@@ -219,6 +210,10 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
|||||||
(BuildContext context, index) {
|
(BuildContext context, index) {
|
||||||
double bottom = MediaQuery.of(context).padding.bottom;
|
double bottom = MediaQuery.of(context).padding.bottom;
|
||||||
if (index == loadingState.response.replies.length) {
|
if (index == loadingState.response.replies.length) {
|
||||||
|
EasyThrottle.throttle(
|
||||||
|
'replylist', const Duration(milliseconds: 200), () {
|
||||||
|
_videoReplyController.onLoadMore();
|
||||||
|
});
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.only(bottom: bottom),
|
padding: EdgeInsets.only(bottom: bottom),
|
||||||
height: bottom + 100,
|
height: bottom + 100,
|
||||||
@@ -259,6 +254,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
: HttpError(
|
: HttpError(
|
||||||
|
errMsg: '还没有评论',
|
||||||
callback: _videoReplyController.onReload,
|
callback: _videoReplyController.onReload,
|
||||||
),
|
),
|
||||||
Error() => HttpError(
|
Error() => HttpError(
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ 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';
|
||||||
@@ -29,8 +30,6 @@ class VideoReplyReplyController extends CommonController
|
|||||||
// rpid 请求楼中楼回复
|
// rpid 请求楼中楼回复
|
||||||
int? rpid;
|
int? rpid;
|
||||||
ReplyType replyType; // = ReplyType.video;
|
ReplyType replyType; // = ReplyType.video;
|
||||||
// 当前页
|
|
||||||
RxString noMore = ''.obs;
|
|
||||||
// 当前回复的回复
|
// 当前回复的回复
|
||||||
ReplyInfo? currentReplyItem;
|
ReplyInfo? currentReplyItem;
|
||||||
|
|
||||||
@@ -45,6 +44,8 @@ class VideoReplyReplyController extends CommonController
|
|||||||
|
|
||||||
ReplyInfo? firstFloor;
|
ReplyInfo? firstFloor;
|
||||||
|
|
||||||
|
bool isEnd = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
@@ -81,7 +82,7 @@ class VideoReplyReplyController extends CommonController
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future queryData([bool isRefresh = true]) async {
|
Future queryData([bool isRefresh = true]) async {
|
||||||
if (['没有更多了', '还没有评论'].contains(noMore.value)) return Future.value();
|
if (isRefresh.not && isEnd) return Future.value();
|
||||||
if (!isDialogue &&
|
if (!isDialogue &&
|
||||||
currentPage == 1 &&
|
currentPage == 1 &&
|
||||||
!hasRoot &&
|
!hasRoot &&
|
||||||
@@ -109,6 +110,7 @@ class VideoReplyReplyController extends CommonController
|
|||||||
@override
|
@override
|
||||||
Future onRefresh() {
|
Future onRefresh() {
|
||||||
cursor = null;
|
cursor = null;
|
||||||
|
isEnd = false;
|
||||||
return super.onRefresh();
|
return super.onRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,24 +160,22 @@ class VideoReplyReplyController extends CommonController
|
|||||||
}
|
}
|
||||||
if (isDialogue) {
|
if (isDialogue) {
|
||||||
if (replies.replies.isNotEmpty) {
|
if (replies.replies.isNotEmpty) {
|
||||||
noMore.value = '加载中...';
|
|
||||||
if (replies.cursor.isEnd || replies.replies.length >= count.value) {
|
if (replies.cursor.isEnd || replies.replies.length >= count.value) {
|
||||||
noMore.value = '没有更多了';
|
isEnd = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 未登录状态replies可能返回null
|
// 未登录状态replies可能返回null
|
||||||
noMore.value = currentPage == 1 ? '还没有评论' : '没有更多了';
|
isEnd = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (replies.root.replies.isNotEmpty) {
|
if (replies.root.replies.isNotEmpty) {
|
||||||
noMore.value = '加载中...';
|
|
||||||
if (replies.cursor.isEnd ||
|
if (replies.cursor.isEnd ||
|
||||||
replies.root.replies.length >= count.value) {
|
replies.root.replies.length >= count.value) {
|
||||||
noMore.value = '没有更多了';
|
isEnd = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 未登录状态replies可能返回null
|
// 未登录状态replies可能返回null
|
||||||
noMore.value = currentPage == 1 ? '还没有评论' : '没有更多了';
|
isEnd = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isDialogue) {
|
if (isDialogue) {
|
||||||
@@ -210,7 +210,6 @@ class VideoReplyReplyController extends CommonController
|
|||||||
);
|
);
|
||||||
|
|
||||||
queryBySort() {
|
queryBySort() {
|
||||||
noMore.value = '';
|
|
||||||
mode.value = mode.value == Mode.MAIN_LIST_HOT
|
mode.value = mode.value == Mode.MAIN_LIST_HOT
|
||||||
? Mode.MAIN_LIST_TIME
|
? Mode.MAIN_LIST_TIME
|
||||||
: Mode.MAIN_LIST_HOT;
|
: Mode.MAIN_LIST_HOT;
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.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/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:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPalaX/common/skeleton/video_reply.dart';
|
import 'package:PiliPalaX/common/skeleton/video_reply.dart';
|
||||||
@@ -290,66 +292,75 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBody(LoadingState loadingState, int index) {
|
Widget _buildBody(LoadingState loadingState, int index) {
|
||||||
if (loadingState is Success) {
|
return switch (loadingState) {
|
||||||
if (index == loadingState.response.length) {
|
Loading() => CustomScrollView(
|
||||||
_videoReplyReplyController.onLoadMore();
|
shrinkWrap: true,
|
||||||
return Container(
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
padding:
|
slivers: [
|
||||||
EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
|
SliverList(
|
||||||
height: MediaQuery.of(context).padding.bottom + 100,
|
delegate: SliverChildBuilderDelegate(
|
||||||
child: Center(
|
(BuildContext context, int index) {
|
||||||
child: Obx(
|
return const VideoReplySkeleton();
|
||||||
() => Text(
|
},
|
||||||
_videoReplyReplyController.noMore.value,
|
childCount: 8,
|
||||||
style: TextStyle(
|
),
|
||||||
fontSize: 12,
|
)
|
||||||
color: Theme.of(context).colorScheme.outline,
|
],
|
||||||
|
),
|
||||||
|
Success() => () {
|
||||||
|
if (index == loadingState.response.length) {
|
||||||
|
EasyThrottle.throttle(
|
||||||
|
'replylist', const Duration(milliseconds: 200), () {
|
||||||
|
_videoReplyReplyController.onLoadMore();
|
||||||
|
});
|
||||||
|
return Container(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
bottom: MediaQuery.of(context).padding.bottom),
|
||||||
|
height: MediaQuery.of(context).padding.bottom + 100,
|
||||||
|
child: Center(
|
||||||
|
child: Obx(
|
||||||
|
() => Text(
|
||||||
|
_videoReplyReplyController.isEnd.not
|
||||||
|
? '加载中...'
|
||||||
|
: loadingState.response.isEmpty
|
||||||
|
? '还没有评论'
|
||||||
|
: '没有更多了',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: Theme.of(context).colorScheme.outline,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
),
|
} else {
|
||||||
);
|
return _videoReplyReplyController.index == index
|
||||||
} else {
|
? AnimatedBuilder(
|
||||||
return _videoReplyReplyController.index == index
|
animation: _videoReplyReplyController.colorAnimation!,
|
||||||
? AnimatedBuilder(
|
builder: (context, child) {
|
||||||
animation: _videoReplyReplyController.colorAnimation!,
|
return ColoredBox(
|
||||||
builder: (context, child) {
|
color: _videoReplyReplyController
|
||||||
return ColoredBox(
|
.colorAnimation?.value ??
|
||||||
color: _videoReplyReplyController.colorAnimation?.value ??
|
Theme.of(Get.context!).colorScheme.onInverseSurface,
|
||||||
Theme.of(Get.context!).colorScheme.onInverseSurface,
|
child: _replyItem(loadingState.response[index], index),
|
||||||
child: _replyItem(loadingState.response[index], index),
|
);
|
||||||
);
|
},
|
||||||
},
|
)
|
||||||
)
|
: _replyItem(loadingState.response[index], index);
|
||||||
: _replyItem(loadingState.response[index], index);
|
}
|
||||||
}
|
}(),
|
||||||
} else if (loadingState is Error) {
|
Error() => CustomScrollView(
|
||||||
return CustomScrollView(
|
shrinkWrap: true,
|
||||||
shrinkWrap: true,
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
slivers: [
|
||||||
slivers: [
|
HttpError(
|
||||||
HttpError(
|
errMsg: loadingState.errMsg,
|
||||||
errMsg: loadingState.errMsg,
|
callback: _videoReplyReplyController.onReload,
|
||||||
callback: _videoReplyReplyController.onReload,
|
)
|
||||||
)
|
],
|
||||||
],
|
),
|
||||||
);
|
LoadingState() => throw UnimplementedError(),
|
||||||
} else {
|
};
|
||||||
return CustomScrollView(
|
|
||||||
shrinkWrap: true,
|
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
|
||||||
slivers: [
|
|
||||||
SliverList(
|
|
||||||
delegate: SliverChildBuilderDelegate(
|
|
||||||
(BuildContext context, int index) {
|
|
||||||
return const VideoReplySkeleton();
|
|
||||||
},
|
|
||||||
childCount: 8,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _replyItem(replyItem, index) {
|
Widget _replyItem(replyItem, index) {
|
||||||
|
|||||||
@@ -1564,9 +1564,9 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
!plPlayerController.isOpenDanmu.value;
|
!plPlayerController.isOpenDanmu.value;
|
||||||
setting.put(SettingBoxKey.enableShowDanmaku,
|
setting.put(SettingBoxKey.enableShowDanmaku,
|
||||||
plPlayerController.isOpenDanmu.value);
|
plPlayerController.isOpenDanmu.value);
|
||||||
SmartDialog.showToast(
|
// SmartDialog.showToast(
|
||||||
"已${plPlayerController.isOpenDanmu.value ? '开启' : '关闭'}弹幕",
|
// "已${plPlayerController.isOpenDanmu.value ? '开启' : '关闭'}弹幕",
|
||||||
displayTime: const Duration(seconds: 1));
|
// displayTime: const Duration(seconds: 1));
|
||||||
},
|
},
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
plPlayerController.isOpenDanmu.value
|
plPlayerController.isOpenDanmu.value
|
||||||
|
|||||||
Reference in New Issue
Block a user