From 563ee0f701ce38a40633f3986ad6de610d8ae51a Mon Sep 17 00:00:00 2001 From: Zeew Date: Thu, 14 Aug 2025 16:06:11 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E8=B0=83=E6=95=B4=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E4=BE=A7=E6=BB=91=E6=8C=89=E9=92=AE=E7=9A=84?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tim_uikit_conversation.dart | 72 ++++++++++++++++++- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/lib/ui/views/TIMUIKitConversation/tim_uikit_conversation.dart b/lib/ui/views/TIMUIKitConversation/tim_uikit_conversation.dart index a9be768..8bf172f 100644 --- a/lib/ui/views/TIMUIKitConversation/tim_uikit_conversation.dart +++ b/lib/ui/views/TIMUIKitConversation/tim_uikit_conversation.dart @@ -96,6 +96,66 @@ class TIMUIKitConversation extends StatefulWidget { } } +class CustomSlidableAction extends StatelessWidget { + const CustomSlidableAction({ + Key? key, + required this.onPressed, + this.flex = 1, + this.backgroundColor = Colors.white, + this.foregroundColor, + this.autoClose = true, + this.icon, + this.spacing = 4, + this.label, + this.fontSize = 14.0, + }) : super(key: key); + + final SlidableActionCallback? onPressed; + final int flex; + final Color backgroundColor; + final Color? foregroundColor; + final bool autoClose; + final IconData? icon; + final double spacing; + final String? label; + final double fontSize; + + @override + Widget build(BuildContext context) { + return Expanded( + flex: flex, + child: SizedBox.expand( + child: Material( + color: backgroundColor, + child: InkWell( + onTap: () => onPressed?.call(context), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + if (icon != null) ...[ + Icon( + icon, + color: foregroundColor, + ), + SizedBox(height: spacing), + ], + if (label != null) + Text( + label!, + style: TextStyle( + color: foregroundColor, + fontSize: fontSize, + ), + ), + ], + ), + ), + ), + ), + ); + } +} + class ConversationItemSlidePanel extends TIMUIKitStatelessWidget { ConversationItemSlidePanel({ Key? key, @@ -107,6 +167,7 @@ class ConversationItemSlidePanel extends TIMUIKitStatelessWidget { this.icon, this.spacing = 4, this.label, + this.fontSize = 14.0, }) : assert(flex > 0), assert(icon != null || label != null), super(key: key); @@ -137,9 +198,12 @@ class ConversationItemSlidePanel extends TIMUIKitStatelessWidget { /// A label to display below the [icon]. final String? label; + /// Font size for the label text. + final double fontSize; + @override Widget tuiBuild(BuildContext context, TUIKitBuildValue value) { - return SlidableAction( + return CustomSlidableAction( onPressed: onPressed, flex: flex, backgroundColor: backgroundColor, @@ -147,6 +211,7 @@ class ConversationItemSlidePanel extends TIMUIKitStatelessWidget { autoClose: autoClose, label: label, spacing: spacing, + fontSize: fontSize, ); } } @@ -280,6 +345,7 @@ class _TIMUIKitConversationState extends TIMUIKitState { label: TIM_t("清除"), spacing: 0, autoClose: true, + fontSize: 14.0, ), ConversationItemSlidePanel( onPressed: (context) { @@ -289,6 +355,7 @@ class _TIMUIKitConversationState extends TIMUIKitState { theme.conversationItemSliderPinBgColor ?? CommonColor.infoColor, foregroundColor: theme.conversationItemSliderTextColor, label: conversationItem.isPinned! ? TIM_t("取消置顶") : TIM_t("置顶"), + fontSize: 14.0, ), ConversationItemSlidePanel( onPressed: (context) { @@ -298,6 +365,7 @@ class _TIMUIKitConversationState extends TIMUIKitState { theme.conversationItemSliderDeleteBgColor ?? Colors.red, foregroundColor: theme.conversationItemSliderTextColor, label: TIM_t("删除"), + fontSize: 14.0, ) ]; } @@ -471,7 +539,7 @@ class _TIMUIKitConversationState extends TIMUIKitState { child: conversationLineItem(), endActionPane: ActionPane( extentRatio: - slideChildren.length > 2 ? 0.77 : 0.5, + slideChildren.length > 2 ? 0.6 : 0.45, motion: const DrawerMotion(), children: slideChildren)), ));