Changed callback type

This commit is contained in:
Deven Joshi
2021-06-01 17:46:12 +05:30
parent 5ed6932ef2
commit 23d992740f
@@ -12,6 +12,9 @@ import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
/// Callback called when tapping on a channel /// Callback called when tapping on a channel
typedef ChannelTapCallback = void Function(Channel, Widget?); typedef ChannelTapCallback = void Function(Channel, Widget?);
/// Callback called when tapping on a channel
typedef ChannelInfoCallback = void Function(Channel);
/// Builder used to create a custom [ChannelPreview] from a [Channel] /// Builder used to create a custom [ChannelPreview] from a [Channel]
typedef ChannelPreviewBuilder = Widget Function(BuildContext, Channel); typedef ChannelPreviewBuilder = Widget Function(BuildContext, Channel);
@@ -162,10 +165,10 @@ class ChannelListView extends StatefulWidget {
final WidgetBuilder? emptyBuilder; final WidgetBuilder? emptyBuilder;
/// Callback used when the more details slidable option is pressed /// Callback used when the more details slidable option is pressed
final VoidCallback? onMoreDetailsPressed; final ChannelInfoCallback? onMoreDetailsPressed;
/// Callback used when the delete slidable option is pressed /// Callback used when the delete slidable option is pressed
final VoidCallback? onDeletePressed; final ChannelInfoCallback? onDeletePressed;
/// List of actions for slidable /// List of actions for slidable
final List<SwipeAction>? swipeActions; final List<SwipeAction>? swipeActions;
@@ -481,15 +484,20 @@ class _ChannelListViewState extends State<ChannelListView> {
?.map((e) => IconSlideAction( ?.map((e) => IconSlideAction(
color: e.color, color: e.color,
iconWidget: e.iconWidget, iconWidget: e.iconWidget,
onTap: e.onTap, onTap: () {
e.onTap?.call(channel);
},
)) ))
.toList() ?? .toList() ??
<Widget>[ <Widget>[
IconSlideAction( IconSlideAction(
color: backgroundColor, color: backgroundColor,
icon: Icons.more_horiz, icon: Icons.more_horiz,
onTap: widget.onMoreDetailsPressed ?? onTap: widget.onMoreDetailsPressed != null
() { ? () {
widget.onMoreDetailsPressed!(channel);
}
: () {
showModalBottomSheet( showModalBottomSheet(
clipBehavior: Clip.hardEdge, clipBehavior: Clip.hardEdge,
shape: const RoundedRectangleBorder( shape: const RoundedRectangleBorder(
@@ -522,8 +530,11 @@ class _ChannelListViewState extends State<ChannelListView> {
iconWidget: StreamSvgIcon.delete( iconWidget: StreamSvgIcon.delete(
color: chatThemeData.colorTheme.accentRed, color: chatThemeData.colorTheme.accentRed,
), ),
onTap: widget.onDeletePressed ?? onTap: widget.onDeletePressed != null
() async { ? () {
widget.onDeletePressed!(channel);
}
: () async {
final res = await showConfirmationDialog( final res = await showConfirmationDialog(
context, context,
title: 'Delete Conversation', title: 'Delete Conversation',
@@ -679,5 +690,5 @@ class SwipeAction {
Widget iconWidget; Widget iconWidget;
/// Callback when icon is tapped /// Callback when icon is tapped
VoidCallback? onTap; ChannelInfoCallback? onTap;
} }