mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
@@ -1,14 +1,9 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/common/skeleton/video_reply.dart';
|
||||
import 'package:PiliPlus/common/widgets/badge.dart';
|
||||
import 'package:PiliPlus/common/widgets/custom_icon.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart'
|
||||
show ReplyInfo;
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/badge_type.dart';
|
||||
import 'package:PiliPlus/models/common/image_preview_type.dart';
|
||||
import 'package:PiliPlus/models/common/image_type.dart';
|
||||
@@ -19,7 +14,6 @@ import 'package:PiliPlus/pages/article/widgets/html_render.dart';
|
||||
import 'package:PiliPlus/pages/article/widgets/opus_content.dart';
|
||||
import 'package:PiliPlus/pages/common/dyn/common_dyn_page.dart';
|
||||
import 'package:PiliPlus/pages/dynamics_repost/view.dart';
|
||||
import 'package:PiliPlus/pages/video/reply/widgets/reply_item_grpc.dart';
|
||||
import 'package:PiliPlus/utils/date_utils.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
@@ -103,7 +97,7 @@ class _ArticlePageState extends CommonDynPageState<ArticlePage> {
|
||||
),
|
||||
),
|
||||
buildReplyHeader(theme),
|
||||
Obx(() => _buildReplyList(theme, controller.loadingState.value)),
|
||||
Obx(() => replyList(theme, controller.loadingState.value)),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -154,10 +148,7 @@ class _ArticlePageState extends CommonDynPageState<ArticlePage> {
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
buildReplyHeader(theme),
|
||||
Obx(
|
||||
() =>
|
||||
_buildReplyList(theme, controller.loadingState.value),
|
||||
),
|
||||
Obx(() => replyList(theme, controller.loadingState.value)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -399,67 +390,6 @@ class _ArticlePageState extends CommonDynPageState<ArticlePage> {
|
||||
),
|
||||
);
|
||||
|
||||
Widget _buildReplyList(
|
||||
ThemeData theme,
|
||||
LoadingState<List<ReplyInfo>?> loadingState,
|
||||
) {
|
||||
return switch (loadingState) {
|
||||
Loading() => SliverList.builder(
|
||||
itemCount: 12,
|
||||
itemBuilder: (context, index) => const VideoReplySkeleton(),
|
||||
),
|
||||
Success(:var response) =>
|
||||
response?.isNotEmpty == true
|
||||
? SliverList.builder(
|
||||
itemCount: response!.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == response.length) {
|
||||
controller.onLoadMore();
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
margin: EdgeInsets.only(bottom: padding.bottom),
|
||||
height: 125,
|
||||
child: Text(
|
||||
controller.isEnd ? '没有更多了' : '加载中...',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return ReplyItemGrpc(
|
||||
replyItem: response[index],
|
||||
replyLevel: 1,
|
||||
replyReply: (replyItem, id) =>
|
||||
replyReply(context, replyItem, id, theme),
|
||||
onReply: (replyItem) => controller.onReply(
|
||||
context,
|
||||
replyItem: replyItem,
|
||||
),
|
||||
onDelete: (item, subIndex) =>
|
||||
controller.onRemove(index, item, subIndex),
|
||||
upMid: controller.upMid,
|
||||
onCheckReply: (item) =>
|
||||
controller.onCheckReply(item, isManual: true),
|
||||
onToggleTop: (item) => controller.onToggleTop(
|
||||
item,
|
||||
index,
|
||||
controller.commentId,
|
||||
controller.commentType,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
)
|
||||
: HttpError(onReload: controller.onReload),
|
||||
Error(:var errMsg) => HttpError(
|
||||
errMsg: errMsg,
|
||||
onReload: controller.isLoaded.value ? controller.onReload : null,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
PreferredSizeWidget _buildAppBar() => AppBar(
|
||||
title: Obx(() {
|
||||
if (controller.isLoaded.value && controller.showTitle.value) {
|
||||
|
||||
@@ -24,5 +24,7 @@ abstract class CommonDynController extends ReplyController<MainListReply> {
|
||||
);
|
||||
|
||||
@override
|
||||
List<ReplyInfo>? getDataList(MainListReply response) => response.replies;
|
||||
List<ReplyInfo>? getDataList(MainListReply response) {
|
||||
return response.replies;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import 'package:PiliPlus/common/skeleton/video_reply.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/common/widgets/view_safe_area.dart';
|
||||
import 'package:PiliPlus/common/widgets/view_sliver_safe_area.dart';
|
||||
import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart'
|
||||
show ReplyInfo;
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
@@ -12,7 +9,6 @@ import 'package:PiliPlus/models_new/match/match_info/contest.dart';
|
||||
import 'package:PiliPlus/models_new/match/match_info/team.dart';
|
||||
import 'package:PiliPlus/pages/common/dyn/common_dyn_page.dart';
|
||||
import 'package:PiliPlus/pages/match_info/controller.dart';
|
||||
import 'package:PiliPlus/pages/video/reply/widgets/reply_item_grpc.dart';
|
||||
import 'package:PiliPlus/pages/video/reply_reply/view.dart';
|
||||
import 'package:PiliPlus/utils/date_utils.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
@@ -48,19 +44,18 @@ class _MatchInfoPageState extends CommonDynPageState<MatchInfoPage> {
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: AppBar(title: const Text('比赛详情')),
|
||||
body: refreshIndicator(
|
||||
onRefresh: controller.onRefresh,
|
||||
child: CustomScrollView(
|
||||
controller: scrollController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
Obx(() => _buildInfo(theme, controller.infoState.value)),
|
||||
ViewSliverSafeArea(
|
||||
sliver: Obx(
|
||||
() => _buildReply(theme, controller.loadingState.value),
|
||||
),
|
||||
),
|
||||
],
|
||||
body: ViewSafeArea(
|
||||
child: refreshIndicator(
|
||||
onRefresh: controller.onRefresh,
|
||||
child: CustomScrollView(
|
||||
controller: scrollController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
Obx(() => _buildInfo(theme, controller.infoState.value)),
|
||||
buildReplyHeader(theme),
|
||||
Obx(() => replyList(theme, controller.loadingState.value)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
floatingActionButton: SlideTransition(
|
||||
@@ -194,59 +189,6 @@ class _MatchInfoPageState extends CommonDynPageState<MatchInfoPage> {
|
||||
return const SliverToBoxAdapter();
|
||||
}
|
||||
|
||||
Widget _buildReply(
|
||||
ThemeData theme,
|
||||
LoadingState<List<ReplyInfo>?> loadingState,
|
||||
) {
|
||||
return switch (loadingState) {
|
||||
Loading() => SliverList.builder(
|
||||
itemBuilder: (context, index) => const VideoReplySkeleton(),
|
||||
itemCount: 8,
|
||||
),
|
||||
Success(:var response) =>
|
||||
response?.isNotEmpty == true
|
||||
? SliverMainAxisGroup(
|
||||
slivers: [
|
||||
buildReplyHeader(theme),
|
||||
SliverList.builder(
|
||||
itemCount: response!.length,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == response.length - 1) {
|
||||
controller.onLoadMore();
|
||||
}
|
||||
return ReplyItemGrpc(
|
||||
replyItem: response[index],
|
||||
replyLevel: 1,
|
||||
replyReply: (replyItem, id) =>
|
||||
replyReply(context, replyItem, id, theme),
|
||||
onReply: (replyItem) => controller.onReply(
|
||||
context,
|
||||
replyItem: replyItem,
|
||||
),
|
||||
onDelete: (item, subIndex) =>
|
||||
controller.onRemove(index, item, subIndex),
|
||||
upMid: controller.upMid,
|
||||
onCheckReply: (item) =>
|
||||
controller.onCheckReply(item, isManual: true),
|
||||
onToggleTop: (item) => controller.onToggleTop(
|
||||
item,
|
||||
index,
|
||||
controller.oid,
|
||||
controller.replyType,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
: HttpError(onReload: controller.onReload),
|
||||
Error(:var errMsg) => HttpError(
|
||||
errMsg: errMsg,
|
||||
onReload: controller.onReload,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
void replyReply(
|
||||
BuildContext context,
|
||||
|
||||
Reference in New Issue
Block a user