From 55bed2e830772649b91da4f74a7423703d22952f Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Tue, 22 Jul 2025 18:19:20 +0800 Subject: [PATCH] opt ugc intro Signed-off-by: bggRGjQaUbCoE --- .../widgets/video_card/video_card_v.dart | 2 +- lib/pages/common/common_intro_controller.dart | 3 +- lib/pages/video/introduction/ugc/view.dart | 53 ++++--- .../introduction/ugc/widgets/action_item.dart | 138 +++++++++--------- 4 files changed, 98 insertions(+), 98 deletions(-) diff --git a/lib/common/widgets/video_card/video_card_v.dart b/lib/common/widgets/video_card/video_card_v.dart index 1a4d2d37..2c1f0cd9 100644 --- a/lib/common/widgets/video_card/video_card_v.dart +++ b/lib/common/widgets/video_card/video_card_v.dart @@ -43,8 +43,8 @@ class VideoCardV extends StatelessWidget { PageUtils.toVideoPage( 'bvid=$bvid&cid=$cid', arguments: { - 'pic': videoItem.cover, 'heroTag': heroTag, + 'videoItem': videoItem, }, ); } diff --git a/lib/pages/common/common_intro_controller.dart b/lib/pages/common/common_intro_controller.dart index c39879e7..607cd437 100644 --- a/lib/pages/common/common_intro_controller.dart +++ b/lib/pages/common/common_intro_controller.dart @@ -54,10 +54,11 @@ abstract class CommonIntroController extends GetxController { } Future queryVideoTags() async { - videoTags.value = null; var result = await UserHttp.videoTags(bvid: bvid); if (result['status']) { videoTags.value = result['data']; + } else { + videoTags.value = null; } } } diff --git a/lib/pages/video/introduction/ugc/view.dart b/lib/pages/video/introduction/ugc/view.dart index 2f24dd90..4b039747 100644 --- a/lib/pages/video/introduction/ugc/view.dart +++ b/lib/pages/video/introduction/ugc/view.dart @@ -164,25 +164,28 @@ class _VideoIntroPanelState extends State ), ), const SizedBox(height: 8), - ExpandablePanel( - controller: introController.expandableCtr, - collapsed: GestureDetector( - onLongPress: () { - Feedback.forLongPress(context); - Utils.copyText(videoDetail.title ?? ''); - }, - child: _buildVideoTitle(theme, videoDetail), + if (isLoading) + _buildVideoTitle(theme, videoDetail) + else + ExpandablePanel( + controller: introController.expandableCtr, + collapsed: GestureDetector( + onLongPress: () { + Feedback.forLongPress(context); + Utils.copyText(videoDetail.title ?? ''); + }, + child: _buildVideoTitle(theme, videoDetail), + ), + expanded: GestureDetector( + onLongPress: () { + Feedback.forLongPress(context); + Utils.copyText(videoDetail.title ?? ''); + }, + child: _buildVideoTitle(theme, videoDetail, + isExpand: true), + ), + theme: expandTheme, ), - expanded: GestureDetector( - onLongPress: () { - Feedback.forLongPress(context); - Utils.copyText(videoDetail.title ?? ''); - }, - child: _buildVideoTitle(theme, videoDetail, - isExpand: true), - ), - theme: expandTheme, - ), const SizedBox(height: 8), Stack( clipBehavior: Clip.none, @@ -508,8 +511,9 @@ class _VideoIntroPanelState extends State handleState(videoIntroController.actionOneThree), selectStatus: videoIntroController.hasLike.value, semanticsLabel: '点赞', - text: - !isLoading ? NumUtil.numFormat(videoDetail.stat!.like!) : '-', + text: !isLoading + ? NumUtil.numFormat(videoDetail.stat!.like!) + : null, needAnim: true, hasTriple: videoIntroController.hasLike.value && videoIntroController.hasCoin && @@ -544,8 +548,9 @@ class _VideoIntroPanelState extends State onTap: () => handleState(videoIntroController.actionCoinVideo), selectStatus: videoIntroController.hasCoin, semanticsLabel: '投币', - text: - !isLoading ? NumUtil.numFormat(videoDetail.stat!.coin!) : '-', + text: !isLoading + ? NumUtil.numFormat(videoDetail.stat!.coin!) + : null, needAnim: true, ), ), @@ -561,7 +566,7 @@ class _VideoIntroPanelState extends State semanticsLabel: '收藏', text: !isLoading ? NumUtil.numFormat(videoDetail.stat!.favorite!) - : '-', + : null, needAnim: true, ), ), @@ -581,7 +586,7 @@ class _VideoIntroPanelState extends State selectStatus: false, semanticsLabel: '分享', text: - !isLoading ? NumUtil.numFormat(videoDetail.stat!.share!) : '分享', + !isLoading ? NumUtil.numFormat(videoDetail.stat!.share!) : null, ), ], ), diff --git a/lib/pages/video/introduction/ugc/widgets/action_item.dart b/lib/pages/video/introduction/ugc/widgets/action_item.dart index 79075132..ead2a4ea 100644 --- a/lib/pages/video/introduction/ugc/widgets/action_item.dart +++ b/lib/pages/video/introduction/ugc/widgets/action_item.dart @@ -121,84 +121,78 @@ class ActionItemState extends State @override Widget build(BuildContext context) { final theme = Theme.of(context); - return widget.expand == false - ? _buildItem(theme) - : Expanded(child: _buildItem(theme)); - } - - Widget _buildItem(ThemeData theme) => Semantics( - label: (widget.text ?? "") + - (widget.selectStatus ? "已" : "") + - widget.semanticsLabel, - child: Material( - type: MaterialType.transparency, - child: InkWell( - borderRadius: const BorderRadius.all(Radius.circular(6)), - onTap: _isThumbsUp - ? null - : () { - feedBack(); - widget.onTap?.call(); - }, - onLongPress: _isThumbsUp ? null : widget.onLongPress, - onTapDown: _isThumbsUp ? (details) => _startLongPress() : null, - onTapUp: _isThumbsUp ? (details) => _cancelLongPress() : null, - onTapCancel: _isThumbsUp ? () => _cancelLongPress(true) : null, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, + final hasText = widget.text != null; + final text = Text( + hasText ? widget.text! : '-', + key: hasText ? ValueKey(widget.text!) : null, + style: TextStyle( + color: widget.selectStatus + ? theme.colorScheme.primary + : theme.colorScheme.outline, + fontSize: theme.textTheme.labelSmall!.fontSize, + ), + ); + final child = Material( + type: MaterialType.transparency, + child: InkWell( + borderRadius: const BorderRadius.all(Radius.circular(6)), + onTap: _isThumbsUp + ? null + : () { + feedBack(); + widget.onTap?.call(); + }, + onLongPress: _isThumbsUp ? null : widget.onLongPress, + onTapDown: _isThumbsUp ? (details) => _startLongPress() : null, + onTapUp: _isThumbsUp ? (details) => _cancelLongPress() : null, + onTapCancel: _isThumbsUp ? () => _cancelLongPress(true) : null, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Stack( + clipBehavior: Clip.none, + alignment: Alignment.center, children: [ - Stack( - clipBehavior: Clip.none, - alignment: Alignment.center, - children: [ - if (widget.needAnim) - AnimatedBuilder( - animation: _animation!, - builder: (context, child) => CustomPaint( - size: const Size(28, 28), - painter: _ArcPainter( - color: theme.colorScheme.primary, - sweepAngle: _animation!.value, - ), - ), - ) - else - const SizedBox(width: 28, height: 28), - Icon( - widget.selectStatus - ? widget.selectIcon!.icon! - : widget.icon.icon, - size: 18, - color: widget.selectStatus - ? theme.colorScheme.primary - : widget.icon.color ?? theme.colorScheme.outline, - ), - ], - ), - if (widget.text != null) - AnimatedSwitcher( - duration: const Duration(milliseconds: 300), - transitionBuilder: - (Widget child, Animation animation) { - return ScaleTransition(scale: animation, child: child); - }, - child: Text( - widget.text!, - key: ValueKey(widget.text!), - style: TextStyle( - color: widget.selectStatus - ? theme.colorScheme.primary - : theme.colorScheme.outline, - fontSize: theme.textTheme.labelSmall!.fontSize, + if (widget.needAnim) + AnimatedBuilder( + animation: _animation!, + builder: (context, child) => CustomPaint( + size: const Size(28, 28), + painter: _ArcPainter( + color: theme.colorScheme.primary, + sweepAngle: _animation!.value, ), - semanticsLabel: "", ), - ), + ) + else + const SizedBox(width: 28, height: 28), + Icon( + widget.selectStatus + ? widget.selectIcon!.icon! + : widget.icon.icon, + size: 18, + color: widget.selectStatus + ? theme.colorScheme.primary + : widget.icon.color ?? theme.colorScheme.outline, + ), ], ), - ), + if (widget.text != null) + AnimatedSwitcher( + duration: const Duration(milliseconds: 300), + transitionBuilder: (Widget child, Animation animation) { + return ScaleTransition(scale: animation, child: child); + }, + child: text, + ) + else + text + ], ), - ); + ), + ); + return widget.expand == false ? child : Expanded(child: child); + } } class _ArcPainter extends CustomPainter {