From b1432b5ff5353a58efd462ffe155c0f9555e54c5 Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Wed, 23 Jul 2025 16:15:04 +0800 Subject: [PATCH] opt action item Signed-off-by: bggRGjQaUbCoE --- .../introduction/ugc/widgets/action_item.dart | 51 ++++++++++--------- pubspec.yaml | 2 +- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/lib/pages/video/introduction/ugc/widgets/action_item.dart b/lib/pages/video/introduction/ugc/widgets/action_item.dart index ead2a4ea..80e485a7 100644 --- a/lib/pages/video/introduction/ugc/widgets/action_item.dart +++ b/lib/pages/video/introduction/ugc/widgets/action_item.dart @@ -17,7 +17,7 @@ class ActionItem extends StatefulWidget { final bool needAnim; final bool hasTriple; final ValueChanged? callBack; - final bool? expand; + final bool expand; const ActionItem({ super.key, @@ -31,7 +31,7 @@ class ActionItem extends StatefulWidget { this.hasTriple = false, this.callBack, required this.semanticsLabel, - this.expand, + this.expand = true, }); @override @@ -121,17 +121,29 @@ class ActionItemState extends State @override Widget build(BuildContext context) { final theme = Theme.of(context); - 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, - ), - ); + Widget? text; + if (widget.expand) { + final hasText = widget.text != null; + 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, + ), + ); + if (hasText) { + text = AnimatedSwitcher( + duration: const Duration(milliseconds: 300), + transitionBuilder: (Widget child, Animation animation) { + return ScaleTransition(scale: animation, child: child); + }, + child: text, + ); + } + } final child = Material( type: MaterialType.transparency, child: InkWell( @@ -177,21 +189,12 @@ class ActionItemState extends State ), ], ), - 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 + ?text, ], ), ), ); - return widget.expand == false ? child : Expanded(child: child); + return widget.expand ? Expanded(child: child) : child; } } diff --git a/pubspec.yaml b/pubspec.yaml index e07553c1..a1b63ed9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -20,7 +20,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev version: 1.1.3+1 environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.8.0 <4.0.0" flutter: 3.32.7 # Dependencies specify other packages that your package needs in order to work.