From 5f93867657ee3c7610fdf367459d2cde9d249bad Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Tue, 22 Mar 2022 15:09:00 +0530 Subject: [PATCH] feat(ui): Calculate slidable extentRatio in case of custom actions Signed-off-by: xsahil03x --- .../stream_chat_flutter/lib/src/channel_list_view.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/stream_chat_flutter/lib/src/channel_list_view.dart b/packages/stream_chat_flutter/lib/src/channel_list_view.dart index 7280d826..819ed40f 100644 --- a/packages/stream_chat_flutter/lib/src/channel_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/channel_list_view.dart @@ -513,13 +513,19 @@ class _ChannelListViewState extends State { final canDeleteChannel = channel.ownCapabilities.contains(PermissionType.deleteChannel); + final actionPaneChildren = + widget.swipeActions?.length ?? (canDeleteChannel ? 2 : 1); + final actionPaneExtentRatio = actionPaneChildren > 5 + ? 1 / actionPaneChildren + : actionPaneChildren * 0.2; + return StreamChannel( key: ValueKey('CHANNEL-${channel.cid}'), channel: channel, child: Slidable( enabled: widget.swipeToAction, endActionPane: ActionPane( - extentRatio: canDeleteChannel ? 0.4 : 0.2, + extentRatio: actionPaneExtentRatio, motion: const BehindMotion(), children: widget.swipeActions ?.map((e) => CustomSlidableAction(