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
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]
typedef ChannelPreviewBuilder = Widget Function(BuildContext, Channel);
@@ -162,10 +165,10 @@ class ChannelListView extends StatefulWidget {
final WidgetBuilder? emptyBuilder;
/// 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
final VoidCallback? onDeletePressed;
final ChannelInfoCallback? onDeletePressed;
/// List of actions for slidable
final List<SwipeAction>? swipeActions;
@@ -481,15 +484,20 @@ class _ChannelListViewState extends State<ChannelListView> {
?.map((e) => IconSlideAction(
color: e.color,
iconWidget: e.iconWidget,
onTap: e.onTap,
onTap: () {
e.onTap?.call(channel);
},
))
.toList() ??
<Widget>[
IconSlideAction(
color: backgroundColor,
icon: Icons.more_horiz,
onTap: widget.onMoreDetailsPressed ??
() {
onTap: widget.onMoreDetailsPressed != null
? () {
widget.onMoreDetailsPressed!(channel);
}
: () {
showModalBottomSheet(
clipBehavior: Clip.hardEdge,
shape: const RoundedRectangleBorder(
@@ -522,8 +530,11 @@ class _ChannelListViewState extends State<ChannelListView> {
iconWidget: StreamSvgIcon.delete(
color: chatThemeData.colorTheme.accentRed,
),
onTap: widget.onDeletePressed ??
() async {
onTap: widget.onDeletePressed != null
? () {
widget.onDeletePressed!(channel);
}
: () async {
final res = await showConfirmationDialog(
context,
title: 'Delete Conversation',
@@ -679,5 +690,5 @@ class SwipeAction {
Widget iconWidget;
/// Callback when icon is tapped
VoidCallback? onTap;
ChannelInfoCallback? onTap;
}