style: 调整聊天界面侧滑按钮的样式细节
This commit is contained in:
parent
d56c57b963
commit
563ee0f701
|
|
@ -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<TIMUIKitConversation> {
|
|||
label: TIM_t("清除"),
|
||||
spacing: 0,
|
||||
autoClose: true,
|
||||
fontSize: 14.0,
|
||||
),
|
||||
ConversationItemSlidePanel(
|
||||
onPressed: (context) {
|
||||
|
|
@ -289,6 +355,7 @@ class _TIMUIKitConversationState extends TIMUIKitState<TIMUIKitConversation> {
|
|||
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<TIMUIKitConversation> {
|
|||
theme.conversationItemSliderDeleteBgColor ?? Colors.red,
|
||||
foregroundColor: theme.conversationItemSliderTextColor,
|
||||
label: TIM_t("删除"),
|
||||
fontSize: 14.0,
|
||||
)
|
||||
];
|
||||
}
|
||||
|
|
@ -471,7 +539,7 @@ class _TIMUIKitConversationState extends TIMUIKitState<TIMUIKitConversation> {
|
|||
child: conversationLineItem(),
|
||||
endActionPane: ActionPane(
|
||||
extentRatio:
|
||||
slideChildren.length > 2 ? 0.77 : 0.5,
|
||||
slideChildren.length > 2 ? 0.6 : 0.45,
|
||||
motion: const DrawerMotion(),
|
||||
children: slideChildren)),
|
||||
));
|
||||
|
|
|
|||
Loading…
Reference in New Issue