基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。
fix(info): separate review and playback actions
Predidit9b7d645833ee
diff --git a/lib/bean/card/comments_card.dart b/lib/bean/card/comments_card.dartindex fb1c1c16..f117c630 100644--- a/lib/bean/card/comments_card.dart+++ b/lib/bean/card/comments_card.dart@@ -6,37 +6,27 @@ import 'package:skeletonizer/skeletonizer.dart';import 'package:kazumi/utils/date_time.dart';class CommentsCard extends StatelessWidget {- CommentsCard({+ const CommentsCard({super.key,- required this.commentItem,- }) {- isBone = false;- isOwn = false;- }+ required CommentItem this.commentItem,+ }) : _isOwn = false;- CommentsCard.bone({- super.key,- }) {- isBone = true;- commentItem = null;- isOwn = false;- }+ const CommentsCard.bone({super.key})+ : commentItem = null,+ _isOwn = false;- CommentsCard.own({+ const CommentsCard.own({super.key,- required this.commentItem,- }) {- isBone = false;- isOwn = true;- }+ required CommentItem this.commentItem,+ }) : _isOwn = true;- late final CommentItem? commentItem;- late final bool isBone;- late final bool isOwn;+ final CommentItem? commentItem;+ final bool _isOwn;@overrideWidget build(BuildContext context) {- if (isBone) {+ final item = commentItem;+ if (item == null) {return Skeletonizer.zone(enabled: true,child: Column(@@ -74,41 +64,45 @@ class CommentsCard extends StatelessWidget {crossAxisAlignment: CrossAxisAlignment.start,children: [BangumiAvatar(- imageUrl: commentItem!.user.avatar.large,+ imageUrl: item.user.avatar.large,),const SizedBox(width: 8),- Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Row(- spacing: 5,- children: [- Text(commentItem!.user.nickname),- if (isOwn)- Container(- padding:- const EdgeInsets.symmetric(horizontal: 2),- decoration: BoxDecoration(- color: Theme.of(context).colorScheme.primary,- borderRadius: BorderRadius.circular(4),- ),- child: Text(- '我的吐槽',- style: TextStyle(- fontSize: 12,- color: Theme.of(context)- .colorScheme- .primaryContainer),- ))- ],- ),- Text(dateFormat(commentItem!.comment.updatedAt)),- ],+ Expanded(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Wrap(+ spacing: 5,+ runSpacing: 4,+ crossAxisAlignment: WrapCrossAlignment.center,+ children: [+ Text(item.user.nickname),+ if (_isOwn)+ Container(+ padding:+ const EdgeInsets.symmetric(horizontal: 2),+ decoration: BoxDecoration(+ color: Theme.of(context).colorScheme.primary,+ borderRadius: BorderRadius.circular(4),+ ),+ child: Text(+ '我的吐槽',+ style: TextStyle(+ fontSize: 12,+ color: Theme.of(context)+ .colorScheme+ .primaryContainer),+ ))+ ],+ ),+ Text(dateFormat(item.comment.updatedAt)),+ ],+ ),),- Expanded(child: Container(height: 10)),+ const SizedBox(width: 8),RatingBarIndicator(itemCount: 5,- rating: commentItem!.comment.rate.toDouble() / 2,+ rating: item.comment.rate.toDouble() / 2,itemBuilder: (context, index) => const Icon(Icons.star_rounded,),@@ -117,7 +111,7 @@ class CommentsCard extends StatelessWidget {],),const SizedBox(height: 8),- Text(commentItem!.comment.comment),+ Text(item.comment.comment),],),),diff --git a/lib/pages/info/info_comments_view.dart b/lib/pages/info/info_comments_view.dartnew file mode 100644index 00000000..4857453f--- /dev/null+++ b/lib/pages/info/info_comments_view.dart@@ -0,0 +1,198 @@+import 'package:flutter/material.dart';+import 'package:kazumi/bean/card/comments_card.dart';+import 'package:kazumi/bean/widget/empty_state_widget.dart';+import 'package:kazumi/bean/widget/error_widget.dart';+import 'package:kazumi/modules/bangumi/bangumi_interest.dart';+import 'package:kazumi/modules/comments/comment_item.dart';++class InfoCommentsView extends StatelessWidget {+ const InfoCommentsView({+ super.key,+ required this.interest,+ required this.comments,+ required this.isLoading,+ required this.hasLoaded,+ required this.hasError,+ required this.onReviewTap,+ required this.onRetry,+ required this.onLoadMore,+ });++ static const _writeReviewLabel = '下面我简单喵两句';+ static const _maxWidth = 950.0;++ final BangumiInterest? interest;+ final List<CommentItem> comments;+ final bool isLoading;+ final bool hasLoaded;+ final bool hasError;+ final VoidCallback onReviewTap;+ final VoidCallback onRetry;+ final VoidCallback onLoadMore;++ CommentItem? get _ownComment {+ final review = interest;+ final user = review?.user;+ if (review == null || !review.hasReviewContent || user == null) return null;+ return CommentItem(+ user: user,+ comment: Comment(+ rate: review.rate,+ comment: review.comment,+ updatedAt: review.updatedAt,+ ),+ );+ }++ bool _onScrollEnd(ScrollEndNotification notification) {+ // Nested error views must not trigger pagination.+ if (notification.depth == 0 &&+ notification.metrics.axis == Axis.vertical &&+ !isLoading &&+ comments.isNotEmpty &&+ notification.metrics.extentAfter < 200) {+ onLoadMore();+ }+ return false;+ }++ @override+ Widget build(BuildContext context) {+ final ownComment = _ownComment;+ final hasReview = interest?.hasReviewContent ?? false;+ final showEmpty =+ hasLoaded && !isLoading && !hasError && comments.isEmpty && !hasReview;+ return SafeArea(+ top: false,+ bottom: false,+ child: LayoutBuilder(builder: (context, constraints) {+ final gutter = ((constraints.maxWidth - _maxWidth) / 2)+ .clamp(16.0, double.infinity);+ return NotificationListener<ScrollEndNotification>(+ onNotification: _onScrollEnd,+ child: CustomScrollView(+ key: const PageStorageKey<String>('吐槽'),+ scrollBehavior: const ScrollBehavior().copyWith(scrollbars: false),+ slivers: [+ SliverOverlapInjector(+ handle:+ NestedScrollView.sliverOverlapAbsorberHandleFor(context),+ ),+ if (ownComment == null && !showEmpty)+ SliverPadding(+ padding: EdgeInsets.fromLTRB(gutter, 12, gutter, 8),+ sliver: SliverToBoxAdapter(+ child: _reviewEntry(context, editing: hasReview),+ ),+ ),+ if (ownComment != null || comments.isNotEmpty)+ SliverPadding(+ padding: EdgeInsets.symmetric(horizontal: gutter),+ sliver: SliverList.separated(+ addAutomaticKeepAlives: false,+ itemCount: comments.length + (ownComment == null ? 0 : 1),+ itemBuilder: (context, index) {+ if (ownComment != null && index == 0) {+ return _ownReview(ownComment);+ }+ return CommentsCard(+ commentItem:+ comments[index - (ownComment == null ? 0 : 1)],+ );+ },+ separatorBuilder: (_, __) => const Divider(+ thickness: 0.5,+ indent: 10,+ endIndent: 10,+ ),+ ),+ )+ else if (hasError)+ SliverFillRemaining(+ hasScrollBody: false,+ child: GeneralErrorWidget(+ title: '评论加载失败',+ errMsg: '请检查网络连接后重试。',+ onRetry: onRetry,+ ),+ )+ else if (showEmpty)+ SliverFillRemaining(+ hasScrollBody: false,+ child: GeneralEmptyState(+ icon: Icons.chat_bubble_outline_rounded,+ title: '暂无吐槽',+ actions: [+ TextButton(+ onPressed: onReviewTap,+ style: TextButton.styleFrom(+ minimumSize: const Size(48, 48),+ ),+ child: const Text(_writeReviewLabel),+ ),+ ],+ ),+ )+ else if (isLoading || !hasLoaded)+ SliverPadding(+ padding: EdgeInsets.symmetric(horizontal: gutter),+ sliver: SliverList.builder(+ itemCount: 4,+ itemBuilder: (_, __) => const Padding(+ padding: EdgeInsets.symmetric(vertical: 16),+ child: CommentsCard.bone(),+ ),+ ),+ ),+ if (ownComment != null || comments.isNotEmpty)+ SliverToBoxAdapter(+ child: SizedBox(+ height: 96 + MediaQuery.paddingOf(context).bottom,+ ),+ ),+ ],+ ),+ );+ }),+ );+ }++ Widget _reviewEntry(BuildContext context, {required bool editing}) {+ final colors = Theme.of(context).colorScheme;+ return TextButton(+ onPressed: onReviewTap,+ style: TextButton.styleFrom(+ minimumSize: const Size(48, 48),+ padding: const EdgeInsets.all(16),+ backgroundColor: colors.surfaceContainerLow,+ foregroundColor: colors.onSurfaceVariant,+ shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),+ ),+ child: Row(children: [+ Expanded(child: Text(editing ? '编辑' : _writeReviewLabel)),+ const SizedBox(width: 8),+ const Icon(Icons.chevron_right_rounded, size: 20),+ ]),+ );+ }++ Widget _ownReview(CommentItem comment) {+ return Card.filled(+ margin: const EdgeInsets.symmetric(vertical: 12),+ child: Column(mainAxisSize: MainAxisSize.min, children: [+ CommentsCard.own(commentItem: comment),+ Padding(+ padding: const EdgeInsets.fromLTRB(8, 0, 8, 8),+ child: Align(+ alignment: Alignment.centerRight,+ child: TextButton(+ onPressed: onReviewTap,+ style: TextButton.styleFrom(minimumSize: const Size(48, 48)),+ child: const Text('编辑'),+ ),+ ),+ ),+ ]),+ );+ }+}diff --git a/lib/pages/info/info_module.dart b/lib/pages/info/info_module.dartindex 94062d81..9e29e6b3 100644--- a/lib/pages/info/info_module.dart+++ b/lib/pages/info/info_module.dart@@ -3,7 +3,6 @@ import 'package:kazumi/modules/bangumi/bangumi_item.dart';import 'package:kazumi/pages/info/info_controller.dart';import 'package:kazumi/pages/info/info_page.dart';import 'package:kazumi/pages/route_error_page.dart';-import 'package:kazumi/plugins/plugins_controller.dart';final infoModule = createModule(path: '/info',@@ -19,7 +18,6 @@ final infoModule = createModule(return InfoPage(inputBangumiItem: bangumiItem,infoController: context.read<InfoController>(),- pluginsController: inject<PluginsController>(),);},);diff --git a/lib/pages/info/info_page.dart b/lib/pages/info/info_page.dartindex f2c0b1c4..710d8de7 100644--- a/lib/pages/info/info_page.dart+++ b/lib/pages/info/info_page.dart@@ -19,7 +19,6 @@ import 'package:kazumi/pages/info/info_controller.dart';import 'package:kazumi/pages/info/info_tabview.dart';import 'package:kazumi/pages/info/rating_review_dialog.dart';import 'package:kazumi/pages/info/source_sheet.dart';-import 'package:kazumi/plugins/plugins_controller.dart';import 'package:kazumi/services/logging/logger.dart';import 'package:kazumi/services/storage/storage.dart';import 'package:kazumi/utils/device.dart';@@ -29,18 +28,17 @@ class InfoPage extends StatefulWidget {super.key,required this.inputBangumiItem,required this.infoController,- required this.pluginsController,});final BangumiItem inputBangumiItem;final InfoController infoController;- final PluginsController pluginsController;@overrideState<InfoPage> createState() => _InfoPageState();}-class _InfoPageState extends State<InfoPage> with TickerProviderStateMixin {+class _InfoPageState extends State<InfoPage>+ with SingleTickerProviderStateMixin {static const List<String> _infoTabs = <String>['概览','吐槽',@@ -48,28 +46,23 @@ class _InfoPageState extends State<InfoPage> with TickerProviderStateMixin {'关联','制作人员',];- static const int _commentsTabIndex = 1;static const Duration _minimumBangumiInfoLoadingDuration =Duration(milliseconds: 600);InfoController get infoController => widget.infoController;- PluginsController get pluginsController => widget.pluginsController;- late TabController infoTabController;- late bool showRating;+ late final TabController infoTabController;+ late final bool showRating;bool commentsIsLoading = false;bool charactersIsLoading = false;bool commentsQueryTimeout = false;- bool commentsIsEmpty = false;+ bool commentsHasLoaded = false;bool charactersQueryTimeout = false;bool charactersIsEmpty = false;bool staffIsLoading = false;bool staffQueryTimeout = false;bool staffIsEmpty = false;bool _showBangumiInfoSkeleton = false;- int _fabTabIndex = 0;-- BangumiItem get inputBangumiIten => widget.inputBangumiItem;bool get _isShowingBangumiInfoSkeleton =>infoController.isLoading || _showBangumiInfoSkeleton;@@ -153,7 +146,6 @@ class _InfoPageState extends State<InfoPage> with TickerProviderStateMixin {setState(() {commentsIsLoading = true;commentsQueryTimeout = false;- commentsIsEmpty = false;});try {await infoController.queryBangumiCommentsByID(@@ -162,11 +154,7 @@ class _InfoPageState extends State<InfoPage> with TickerProviderStateMixin {if (mounted) {setState(() {commentsIsLoading = false;- if (infoController.commentsList.isEmpty &&- !(infoController.bangumiItem.interest?.hasReviewContent ??- false)) {- commentsIsEmpty = true;- }+ commentsHasLoaded = true;});}} catch (e) {@@ -180,7 +168,7 @@ class _InfoPageState extends State<InfoPage> with TickerProviderStateMixin {}}- Future<void> onBangumiRatingTap() async {+ Future<void> _openReviewEditor() async {final token =GStorage.getSetting(SettingsKeys.bangumiAccessToken).toString().trim();if (token.isEmpty) {@@ -193,7 +181,8 @@ class _InfoPageState extends State<InfoPage> with TickerProviderStateMixin {KazumiDialog.showToast(message: '请先追番');return;}- final editing = infoController.bangumiItem.interest?.hasReviewContent ?? false;+ final editing =+ infoController.bangumiItem.interest?.hasReviewContent ?? false;final submitted = await KazumiDialog.show<bool>(context: context,builder: (context) => RatingReviewDialog(@@ -214,31 +203,26 @@ class _InfoPageState extends State<InfoPage> with TickerProviderStateMixin {@overridevoid initState() {super.initState();- infoController.bangumiItem = inputBangumiIten;+ infoController.bangumiItem = widget.inputBangumiItem;infoController.characterList.clear();infoController.clearComments();infoController.staffList.clear();infoController.clearRelations();infoController.pluginSearchResponseList.clear();- // Preserve rendered image URLs when filling missing metadata.if (_needsBangumiInfoRefresh(infoController.bangumiItem)) {_showBangumiInfoSkeleton = true;- queryBangumiInfoByID(- infoController.bangumiItem.id,- type: 'attach',- enforceMinimumLoadingDuration: true,- );+ _loadBangumiInfo();}infoTabController = TabController(length: _infoTabs.length, vsync: this);- _fabTabIndex = infoTabController.index;showRating = GStorage.getSetting(SettingsKeys.showRating);infoTabController.addListener(onInfoTabChanged);- infoTabController.addListener(_syncFabTabIndex);- infoTabController.animation?.addListener(_syncFabTabIndex);}void onInfoTabChanged() {final index = infoTabController.index;+ if (index == 1) {+ onCommentsTabSelected();+ }if (index == 2 &&infoController.characterList.isEmpty &&!charactersIsLoading &&@@ -258,38 +242,20 @@ class _InfoPageState extends State<InfoPage> with TickerProviderStateMixin {}}- void _syncFabTabIndex() {- final animation = infoTabController.animation;- final targetIndex = infoTabController.indexIsChanging- ? infoTabController.index- : (animation?.value.round() ?? infoTabController.index);- final nextIndex =- targetIndex.clamp(0, infoTabController.length - 1).toInt();-- if (_fabTabIndex == nextIndex) {- return;- }- if (!mounted) {- return;- }- setState(() {- _fabTabIndex = nextIndex;- });- }-Future<void> onCommentsTabSelected() async {final interest = infoController.bangumiItem.interest;final token =GStorage.getSetting(SettingsKeys.bangumiAccessToken).toString().trim();if (interest != null && token.isNotEmpty) {final updated = await infoController.fillInterestUserProfileIfNeeded();- if (updated && mounted) {+ if (!mounted) return;+ if (updated) {setState(() {});}}if (infoController.commentsList.isEmpty &&!commentsIsLoading &&- !commentsIsEmpty &&+ !commentsHasLoaded &&!commentsQueryTimeout) {loadMoreComments();}@@ -298,8 +264,6 @@ class _InfoPageState extends State<InfoPage> with TickerProviderStateMixin {@overridevoid dispose() {infoTabController.removeListener(onInfoTabChanged);- infoTabController.removeListener(_syncFabTabIndex);- infoTabController.animation?.removeListener(_syncFabTabIndex);infoController.characterList.clear();infoController.clearComments();infoController.staffList.clear();@@ -309,19 +273,19 @@ class _InfoPageState extends State<InfoPage> with TickerProviderStateMixin {super.dispose();}- Future<void> queryBangumiInfoByID(- int id, {- String type = "init",- bool enforceMinimumLoadingDuration = false,- }) async {+ Future<void> _loadBangumiInfo() async {final loadingStartedAt = DateTime.now();try {- await infoController.queryBangumiInfoByID(id, type: type);+ // Attach metadata without replacing rendered image URLs.+ await infoController.queryBangumiInfoByID(+ infoController.bangumiItem.id,+ type: 'attach',+ );} catch (e) {KazumiLogger().e('InfoPage: failed to query bangumi info by ID', error: e);} finally {- if (enforceMinimumLoadingDuration && mounted) {+ if (mounted) {await _waitForMinimumBangumiInfoLoadingDuration(loadingStartedAt);}if (mounted) {@@ -345,189 +309,168 @@ class _InfoPageState extends State<InfoPage> with TickerProviderStateMixin {Widget build(BuildContext context) {final bool showWindowButton =GStorage.getSetting(SettingsKeys.showWindowButton);- final bool showRatingFab = _fabTabIndex == _commentsTabIndex;- final reviewActionLabel =- infoController.bangumiItem.interest?.hasReviewContent == true- ? '编辑吐槽'- : '发表吐槽';- return PopScope(- canPop: true,- child: DefaultTabController(- length: _infoTabs.length,- child: Scaffold(- body: NestedScrollView(- headerSliverBuilder:- (BuildContext context, bool innerBoxIsScrolled) {- return <Widget>[- SliverOverlapAbsorber(- handle:- NestedScrollView.sliverOverlapAbsorberHandleFor(context),- sliver: SliverAppBar.medium(- title: EmbeddedNativeControlArea(- child: dtb.DragToMoveArea(- child: Container(- width: double.infinity,- alignment: Alignment.centerLeft,- child: Text(- infoController.bangumiItem.nameCn == ''- ? infoController.bangumiItem.name- : infoController.bangumiItem.nameCn,- ),- ),+ return Scaffold(+ body: NestedScrollView(+ headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {+ return <Widget>[+ SliverOverlapAbsorber(+ handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),+ sliver: SliverAppBar.medium(+ title: EmbeddedNativeControlArea(+ child: dtb.DragToMoveArea(+ child: Container(+ width: double.infinity,+ alignment: Alignment.centerLeft,+ child: Text(+ infoController.bangumiItem.nameCn == ''+ ? infoController.bangumiItem.name+ : infoController.bangumiItem.nameCn,),),- automaticallyImplyLeading: false,- scrolledUnderElevation: 0.0,- leading: EmbeddedNativeControlArea(- child: IconButton(- onPressed: () {- context.maybePop();- },- icon: Icon(Icons.arrow_back),+ ),+ ),+ automaticallyImplyLeading: false,+ scrolledUnderElevation: 0.0,+ leading: EmbeddedNativeControlArea(+ child: IconButton(+ onPressed: () {+ context.maybePop();+ },+ icon: Icon(Icons.arrow_back),+ ),+ ),+ actions: [+ if (innerBoxIsScrolled)+ EmbeddedNativeControlArea(+ child: CollectButton(+ bangumiItem: infoController.bangumiItem,+ color: Theme.of(context).colorScheme.onSurfaceVariant,),),- actions: [- if (innerBoxIsScrolled)- EmbeddedNativeControlArea(- child: CollectButton(- bangumiItem: infoController.bangumiItem,- color:- Theme.of(context).colorScheme.onSurfaceVariant,- ),- ),- EmbeddedNativeControlArea(- child: IconButton(- onPressed: () {- launchUrl(- Uri.parse(- 'https://bangumi.tv/subject/${infoController.bangumiItem.id}'),- mode: LaunchMode.externalApplication,- );- },- icon: const Icon(Icons.open_in_browser_rounded),- ),- ),- if (!showWindowButton && isDesktop())- CloseButton(onPressed: () => windowManager.close()),- SizedBox(width: 8),- ],- toolbarHeight: (Platform.isMacOS && showWindowButton)- ? kToolbarHeight + 22- : kToolbarHeight,- stretch: true,- centerTitle: false,- expandedHeight: (Platform.isMacOS && showWindowButton)- ? 308 + kTextTabBarHeight + kToolbarHeight + 22- : 308 + kTextTabBarHeight + kToolbarHeight,- collapsedHeight: (Platform.isMacOS && showWindowButton)- ? kTextTabBarHeight +- kToolbarHeight +- MediaQuery.paddingOf(context).top +- 22- : kTextTabBarHeight +- kToolbarHeight +- MediaQuery.paddingOf(context).top,- flexibleSpace: FlexibleSpaceBar(- collapseMode: CollapseMode.pin,- background: Observer(builder: (context) {- final showBangumiInfoSkeleton =- _isShowingBangumiInfoSkeleton;- return Stack(- children: [- if (!showBangumiInfoSkeleton)- Positioned.fill(- bottom: kTextTabBarHeight,- child: IgnorePointer(- child: _InfoHeaderBackground(- imageUrl: infoController- .bangumiItem.images['large'] ??- '',- ),- ),+ EmbeddedNativeControlArea(+ child: IconButton(+ onPressed: () {+ launchUrl(+ Uri.parse(+ 'https://bangumi.tv/subject/${infoController.bangumiItem.id}'),+ mode: LaunchMode.externalApplication,+ );+ },+ icon: const Icon(Icons.open_in_browser_rounded),+ ),+ ),+ if (!showWindowButton && isDesktop())+ CloseButton(onPressed: () => windowManager.close()),+ SizedBox(width: 8),+ ],+ toolbarHeight: (Platform.isMacOS && showWindowButton)+ ? kToolbarHeight + 22+ : kToolbarHeight,+ stretch: true,+ centerTitle: false,+ expandedHeight: (Platform.isMacOS && showWindowButton)+ ? 308 + kTextTabBarHeight + kToolbarHeight + 22+ : 308 + kTextTabBarHeight + kToolbarHeight,+ collapsedHeight: (Platform.isMacOS && showWindowButton)+ ? kTextTabBarHeight ++ kToolbarHeight ++ MediaQuery.paddingOf(context).top ++ 22+ : kTextTabBarHeight ++ kToolbarHeight ++ MediaQuery.paddingOf(context).top,+ flexibleSpace: FlexibleSpaceBar(+ collapseMode: CollapseMode.pin,+ background: Observer(builder: (context) {+ final showBangumiInfoSkeleton =+ _isShowingBangumiInfoSkeleton;+ return Stack(+ children: [+ if (!showBangumiInfoSkeleton)+ Positioned.fill(+ bottom: kTextTabBarHeight,+ child: IgnorePointer(+ child: _InfoHeaderBackground(+ imageUrl: infoController+ .bangumiItem.images['large'] ??+ '',),- SafeArea(- bottom: false,- child: EmbeddedNativeControlArea(- child: Align(- alignment: Alignment.topCenter,- child: Padding(- padding: const EdgeInsets.fromLTRB(- 16, kToolbarHeight, 16, 0),- child: BangumiInfoCardV(- bangumiItem: infoController.bangumiItem,- isLoading: showBangumiInfoSkeleton,- showRating: showRating,- ),- ),+ ),+ ),+ SafeArea(+ bottom: false,+ child: EmbeddedNativeControlArea(+ child: Align(+ alignment: Alignment.topCenter,+ child: Padding(+ padding: const EdgeInsets.fromLTRB(+ 16, kToolbarHeight, 16, 0),+ child: BangumiInfoCardV(+ bangumiItem: infoController.bangumiItem,+ isLoading: showBangumiInfoSkeleton,+ showRating: showRating,),),),- ],- );- }),- ),- forceElevated: innerBoxIsScrolled,- bottom: TabBar(- controller: infoTabController,- isScrollable: true,- tabAlignment: TabAlignment.center,- dividerHeight: 0,- tabs: _infoTabs.map((name) => Tab(text: name)).toList(),- ),- ),- ),- ];- },- body: Observer(builder: (context) {- final showBangumiInfoSkeleton = _isShowingBangumiInfoSkeleton;- return InfoTabView(- tabController: infoTabController,- bangumiItem: infoController.bangumiItem,- commentsQueryTimeout: commentsQueryTimeout,- commentsIsEmpty: commentsIsEmpty,- charactersQueryTimeout: charactersQueryTimeout,- charactersIsEmpty: charactersIsEmpty,- staffQueryTimeout: staffQueryTimeout,- staffIsEmpty: staffIsEmpty,- loadMoreComments: loadMoreComments,- loadCharacters: loadCharacters,- loadStaff: loadStaff,- commentsList: infoController.commentsList,- commentsIsLoading: commentsIsLoading,- onCommentsTabSelected: onCommentsTabSelected,- characterList: infoController.characterList,- staffList: infoController.staffList,- relationList: infoController.relationList,- relationsIsLoading: infoController.relationsIsLoading,- relationsQueryTimeout: infoController.relationsQueryTimeout,- relationsHasLoaded: infoController.relationsHasLoaded,- loadRelations: loadRelations,- isLoading: showBangumiInfoSkeleton,- );- }),- ),- floatingActionButton: showRatingFab- ? FloatingActionButton.extended(- tooltip: reviewActionLabel,- onPressed: onBangumiRatingTap,- label: Text(reviewActionLabel),- icon: const Icon(Icons.rate_review_rounded),- )- : FloatingActionButton.extended(- tooltip: '开始观看',- onPressed: () {- showAdaptiveBottomSheet<void>(- context: context,- maxHeightFactor: 0.88,- builder: (context) {- return SourceSheet(infoController: infoController);- },+ ),+ ),+ ],);- },- label: const Text('开始观看'),- icon: const Icon(Icons.play_arrow_rounded),+ }),+ ),+ forceElevated: innerBoxIsScrolled,+ bottom: TabBar(+ controller: infoTabController,+ isScrollable: true,+ tabAlignment: TabAlignment.center,+ dividerHeight: 0,+ tabs: _infoTabs.map((name) => Tab(text: name)).toList(),),- ),+ ),+ ),+ ];+ },+ body: Observer(builder: (context) {+ final showBangumiInfoSkeleton = _isShowingBangumiInfoSkeleton;+ return InfoTabView(+ tabController: infoTabController,+ bangumiItem: infoController.bangumiItem,+ commentsQueryTimeout: commentsQueryTimeout,+ commentsHasLoaded: commentsHasLoaded,+ charactersQueryTimeout: charactersQueryTimeout,+ charactersIsEmpty: charactersIsEmpty,+ staffQueryTimeout: staffQueryTimeout,+ staffIsEmpty: staffIsEmpty,+ loadMoreComments: loadMoreComments,+ loadCharacters: loadCharacters,+ loadStaff: loadStaff,+ commentsList: infoController.commentsList.toList(growable: false),+ commentsIsLoading: commentsIsLoading,+ onWriteReview: _openReviewEditor,+ characterList: infoController.characterList,+ staffList: infoController.staffList,+ relationList: infoController.relationList,+ relationsIsLoading: infoController.relationsIsLoading,+ relationsQueryTimeout: infoController.relationsQueryTimeout,+ relationsHasLoaded: infoController.relationsHasLoaded,+ loadRelations: loadRelations,+ isLoading: showBangumiInfoSkeleton,+ );+ }),+ ),+ floatingActionButton: FloatingActionButton.extended(+ tooltip: '开始观看',+ onPressed: () {+ showAdaptiveBottomSheet<void>(+ context: context,+ maxHeightFactor: 0.88,+ builder: (context) {+ return SourceSheet(infoController: infoController);+ },+ );+ },+ label: const Text('开始观看'),+ icon: const Icon(Icons.play_arrow_rounded),),);}diff --git a/lib/pages/info/info_tabview.dart b/lib/pages/info/info_tabview.dartindex 88e5e064..4366094f 100644--- a/lib/pages/info/info_tabview.dart+++ b/lib/pages/info/info_tabview.dart@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';import 'package:flutter_modular/flutter_modular.dart';import 'package:kazumi/bean/widget/error_widget.dart';import 'package:kazumi/bean/widget/empty_state_widget.dart';-import 'package:kazumi/bean/card/comments_card.dart';+import 'package:kazumi/pages/info/info_comments_view.dart';import 'package:kazumi/bean/card/character_card.dart';import 'package:kazumi/bean/card/staff_card.dart';import 'package:kazumi/bean/card/network_img_layer.dart';@@ -20,7 +20,7 @@ class InfoTabView extends StatefulWidget {const InfoTabView({super.key,required this.commentsQueryTimeout,- required this.commentsIsEmpty,+ required this.commentsHasLoaded,required this.charactersQueryTimeout,required this.charactersIsEmpty,required this.staffQueryTimeout,@@ -36,7 +36,7 @@ class InfoTabView extends StatefulWidget {required this.bangumiItem,required this.commentsList,required this.commentsIsLoading,- this.onCommentsTabSelected,+ required this.onWriteReview,required this.characterList,required this.staffList,required this.relationList,@@ -44,9 +44,9 @@ class InfoTabView extends StatefulWidget {});final bool commentsQueryTimeout;- final bool commentsIsEmpty;+ final bool commentsHasLoaded;final bool commentsIsLoading;- final VoidCallback? onCommentsTabSelected;+ final VoidCallback onWriteReview;final bool charactersQueryTimeout;final bool charactersIsEmpty;final bool staffQueryTimeout;@@ -75,27 +75,6 @@ class _InfoTabViewState extends State<InfoTabView> {bool fullIntro = false;bool fullTag = false;- @override- void initState() {- super.initState();- widget.tabController.addListener(_onTabChanged);- if (widget.tabController.index == 1) {- widget.onCommentsTabSelected?.call();- }- }-- @override- void dispose() {- widget.tabController.removeListener(_onTabChanged);- super.dispose();- }-- void _onTabChanged() {- if (widget.tabController.index == 1) {- widget.onCommentsTabSelected?.call();- }- }-Widget get infoBody {return Center(child: Padding(@@ -332,145 +311,6 @@ class _InfoTabViewState extends State<InfoTabView> {);}- Widget get commentsListBody {- return Builder(- builder: (BuildContext context) {- return NotificationListener<ScrollEndNotification>(- onNotification: (scrollEnd) {- // Scrolling a long error message must not trigger pagination.- if (scrollEnd.depth != 0) {- return false;- }- final metrics = scrollEnd.metrics;- if (metrics.pixels >= metrics.maxScrollExtent - 200) {- widget.loadMoreComments(loadMore: widget.commentsList.isNotEmpty);- }- return true;- },- child: CustomScrollView(- scrollBehavior: const ScrollBehavior().copyWith(- scrollbars: false,- ),- key: PageStorageKey<String>('吐槽'),- slivers: <Widget>[- SliverOverlapInjector(- handle:- NestedScrollView.sliverOverlapAbsorberHandleFor(context),- ),- SliverLayoutBuilder(builder: (context, _) {- final myInterest = widget.bangumiItem.interest;- final showMyReview = !widget.commentsIsLoading &&- myInterest != null &&- myInterest.hasUserProfile &&- myInterest.hasReviewContent;- final listItemCount =- widget.commentsList.length + (showMyReview ? 1 : 0);-- if (listItemCount > 0) {- return SliverList.separated(- addAutomaticKeepAlives: false,- itemCount: listItemCount,- itemBuilder: (context, index) {- final commentIndex = showMyReview ? index - 1 : index;- final myUser = myInterest?.user;- final card = showMyReview && index == 0 && myUser != null- ? CommentsCard.own(- commentItem: CommentItem(- user: myUser,- comment: Comment(- rate: myInterest.rate,- comment: myInterest.comment,- updatedAt: myInterest.updatedAt,- ),- ),- )- : CommentsCard(- commentItem: widget.commentsList[commentIndex],- );- return SafeArea(- top: false,- bottom: false,- child: Center(- child: Padding(- padding:- const EdgeInsets.symmetric(horizontal: 16.0),- child: SizedBox(- width: MediaQuery.sizeOf(context).width > maxWidth- ? maxWidth- : MediaQuery.sizeOf(context).width - 32,- child: card,- ),- ),- ),- );- },- separatorBuilder: (BuildContext context, int index) {- return SafeArea(- top: false,- bottom: false,- child: Center(- child: Padding(- padding:- const EdgeInsets.symmetric(horizontal: 16.0),- child: SizedBox(- width: MediaQuery.sizeOf(context).width > maxWidth- ? maxWidth- : MediaQuery.sizeOf(context).width - 32,- child: Divider(- thickness: 0.5, indent: 10, endIndent: 10),- ),- ),- ),- );- },- );- }- if (widget.commentsQueryTimeout) {- return SliverFillRemaining(- child: GeneralErrorWidget(- title: '评论加载失败',- errMsg: '请检查网络连接后重试。',- onRetry: () => widget.loadMoreComments(loadMore: false),- ),- );- }- if (widget.commentsIsEmpty) {- return const SliverFillRemaining(- hasScrollBody: false,- child: GeneralEmptyState(- icon: Icons.chat_bubble_outline_rounded,- title: '还没有评论',- ),- );- }- return SliverList.builder(- itemCount: 4,- itemBuilder: (context, _) {- return SafeArea(- top: false,- bottom: false,- child: Center(- child: Padding(- padding: const EdgeInsets.all(16),- child: SizedBox(- width: MediaQuery.sizeOf(context).width > maxWidth- ? maxWidth- : MediaQuery.sizeOf(context).width - 32,- child: CommentsCard.bone(),- ),- ),- ),- );- },- );- })- ],- ),- );- },- );- }-Widget get staffListBody {return Builder(builder: (BuildContext context) {@@ -656,7 +496,16 @@ class _InfoTabViewState extends State<InfoTabView> {);},),- commentsListBody,+ InfoCommentsView(+ interest: widget.bangumiItem.interest,+ comments: widget.commentsList,+ isLoading: widget.commentsIsLoading,+ hasLoaded: widget.commentsHasLoaded,+ hasError: widget.commentsQueryTimeout,+ onReviewTap: widget.onWriteReview,+ onRetry: () => widget.loadMoreComments(loadMore: false),+ onLoadMore: () => widget.loadMoreComments(loadMore: true),+ ),charactersListBody,relationsListBody,staffListBody,