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 {
|
class ConversationItemSlidePanel extends TIMUIKitStatelessWidget {
|
||||||
ConversationItemSlidePanel({
|
ConversationItemSlidePanel({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
|
@ -107,6 +167,7 @@ class ConversationItemSlidePanel extends TIMUIKitStatelessWidget {
|
||||||
this.icon,
|
this.icon,
|
||||||
this.spacing = 4,
|
this.spacing = 4,
|
||||||
this.label,
|
this.label,
|
||||||
|
this.fontSize = 14.0,
|
||||||
}) : assert(flex > 0),
|
}) : assert(flex > 0),
|
||||||
assert(icon != null || label != null),
|
assert(icon != null || label != null),
|
||||||
super(key: key);
|
super(key: key);
|
||||||
|
|
@ -137,9 +198,12 @@ class ConversationItemSlidePanel extends TIMUIKitStatelessWidget {
|
||||||
/// A label to display below the [icon].
|
/// A label to display below the [icon].
|
||||||
final String? label;
|
final String? label;
|
||||||
|
|
||||||
|
/// Font size for the label text.
|
||||||
|
final double fontSize;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
return SlidableAction(
|
return CustomSlidableAction(
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
flex: flex,
|
flex: flex,
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
|
|
@ -147,6 +211,7 @@ class ConversationItemSlidePanel extends TIMUIKitStatelessWidget {
|
||||||
autoClose: autoClose,
|
autoClose: autoClose,
|
||||||
label: label,
|
label: label,
|
||||||
spacing: spacing,
|
spacing: spacing,
|
||||||
|
fontSize: fontSize,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -280,6 +345,7 @@ class _TIMUIKitConversationState extends TIMUIKitState<TIMUIKitConversation> {
|
||||||
label: TIM_t("清除"),
|
label: TIM_t("清除"),
|
||||||
spacing: 0,
|
spacing: 0,
|
||||||
autoClose: true,
|
autoClose: true,
|
||||||
|
fontSize: 14.0,
|
||||||
),
|
),
|
||||||
ConversationItemSlidePanel(
|
ConversationItemSlidePanel(
|
||||||
onPressed: (context) {
|
onPressed: (context) {
|
||||||
|
|
@ -289,6 +355,7 @@ class _TIMUIKitConversationState extends TIMUIKitState<TIMUIKitConversation> {
|
||||||
theme.conversationItemSliderPinBgColor ?? CommonColor.infoColor,
|
theme.conversationItemSliderPinBgColor ?? CommonColor.infoColor,
|
||||||
foregroundColor: theme.conversationItemSliderTextColor,
|
foregroundColor: theme.conversationItemSliderTextColor,
|
||||||
label: conversationItem.isPinned! ? TIM_t("取消置顶") : TIM_t("置顶"),
|
label: conversationItem.isPinned! ? TIM_t("取消置顶") : TIM_t("置顶"),
|
||||||
|
fontSize: 14.0,
|
||||||
),
|
),
|
||||||
ConversationItemSlidePanel(
|
ConversationItemSlidePanel(
|
||||||
onPressed: (context) {
|
onPressed: (context) {
|
||||||
|
|
@ -298,6 +365,7 @@ class _TIMUIKitConversationState extends TIMUIKitState<TIMUIKitConversation> {
|
||||||
theme.conversationItemSliderDeleteBgColor ?? Colors.red,
|
theme.conversationItemSliderDeleteBgColor ?? Colors.red,
|
||||||
foregroundColor: theme.conversationItemSliderTextColor,
|
foregroundColor: theme.conversationItemSliderTextColor,
|
||||||
label: TIM_t("删除"),
|
label: TIM_t("删除"),
|
||||||
|
fontSize: 14.0,
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
@ -471,7 +539,7 @@ class _TIMUIKitConversationState extends TIMUIKitState<TIMUIKitConversation> {
|
||||||
child: conversationLineItem(),
|
child: conversationLineItem(),
|
||||||
endActionPane: ActionPane(
|
endActionPane: ActionPane(
|
||||||
extentRatio:
|
extentRatio:
|
||||||
slideChildren.length > 2 ? 0.77 : 0.5,
|
slideChildren.length > 2 ? 0.6 : 0.45,
|
||||||
motion: const DrawerMotion(),
|
motion: const DrawerMotion(),
|
||||||
children: slideChildren)),
|
children: slideChildren)),
|
||||||
));
|
));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue