Skip to content

基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。

fix comments scroll issue

ErBW_s35b84012a88d
diff --git a/lib/pages/player/episode_comments_sheet.dart b/lib/pages/player/episode_comments_sheet.dart
index f82a3f7e..f34bd49a 100644
--- a/lib/pages/player/episode_comments_sheet.dart
+++ b/lib/pages/player/episode_comments_sheet.dart
@@ -15,7 +15,8 @@ class EpisodeCommentsSheet extends StatefulWidget {
State<EpisodeCommentsSheet> createState() => _EpisodeCommentsSheetState();
}
-class _EpisodeCommentsSheetState extends State<EpisodeCommentsSheet> {
+class _EpisodeCommentsSheetState extends State<EpisodeCommentsSheet>
+ with AutomaticKeepAliveClientMixin {
final infoController = Modular.get<InfoController>();
bool isLoading = false;
bool commentsQueryTimeout = false;
@@ -56,39 +57,54 @@ class _EpisodeCommentsSheetState extends State<EpisodeCommentsSheet> {
}
Widget get episodeCommentsBody {
- return SelectionArea(
- child: CustomScrollView(
- slivers: [
- SliverPadding(
- padding: const EdgeInsets.fromLTRB(4, 0, 4, 4),
- sliver: Observer(builder: (context) {
- if (isLoading) {
- return const SliverFillRemaining(
- child: Center(
- child: CircularProgressIndicator(),
- ),
- );
- }
- if (commentsQueryTimeout) {
- return const SliverFillRemaining(
- child: Center(
- child: Text('空空如也'),
- ),
- );
- }
- return SliverList(
- delegate: SliverChildBuilderDelegate(
- (context, index) {
- return EpisodeCommentsCard(
- commentItem: infoController.episodeCommentsList[index]);
- },
- childCount: infoController.episodeCommentsList.length,
+ return CustomScrollView(
+ // Scrollbars' movement is not linear so hide it.
+ scrollBehavior: const ScrollBehavior().copyWith(scrollbars: false),
+ slivers: [
+ SliverPadding(
+ padding: const EdgeInsets.fromLTRB(4, 0, 4, 4),
+ sliver: Observer(builder: (context) {
+ if (isLoading) {
+ return const SliverFillRemaining(
+ child: Center(
+ child: CircularProgressIndicator(),
),
);
- }),
- ),
- ],
- ),
+ }
+ if (commentsQueryTimeout) {
+ return const SliverFillRemaining(
+ child: Center(
+ child: Text('空空如也'),
+ ),
+ );
+ }
+ return SliverList(
+ delegate: SliverChildBuilderDelegate(
+ (context, index) {
+ // Fix scroll issue caused by height change of network images
+ // by keeping loaded cards alive.
+ return KeepAlive(
+ keepAlive: true,
+ child: IndexedSemantics(
+ index: index,
+ child: SelectionArea(
+ child: EpisodeCommentsCard(
+ commentItem:
+ infoController.episodeCommentsList[index],
+ ),
+ ),
+ ),
+ );
+ },
+ childCount: infoController.episodeCommentsList.length,
+ addAutomaticKeepAlives: false,
+ addRepaintBoundaries: false,
+ addSemanticIndexes: false,
+ ),
+ );
+ }),
+ ),
+ ],
);
}
@@ -192,6 +208,7 @@ class _EpisodeCommentsSheetState extends State<EpisodeCommentsSheet> {
@override
Widget build(BuildContext context) {
+ super.build(context);
return Scaffold(
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -199,4 +216,7 @@ class _EpisodeCommentsSheetState extends State<EpisodeCommentsSheet> {
),
);
}
+
+ @override
+ bool get wantKeepAlive => true;
}