add onLongPress to channel preview

This commit is contained in:
Salvatore Giordano
2020-05-06 10:34:29 +02:00
parent aadb5277bd
commit daf0989f2d
4 changed files with 22 additions and 5 deletions
+5
View File
@@ -55,6 +55,7 @@ class ChannelListView extends StatefulWidget {
this.sort,
this.pagination,
this.onChannelTap,
this.onChannelLongPress,
this.channelWidget,
this.channelPreviewBuilder,
this.errorBuilder,
@@ -92,6 +93,9 @@ class ChannelListView extends StatefulWidget {
/// with the widget [channelWidget] as child.
final ChannelTapCallback onChannelTap;
/// Function called when long pressing on a channel
final Function(Channel) onChannelLongPress;
/// Widget used when opening a channel
final Widget channelWidget;
@@ -271,6 +275,7 @@ class _ChannelListViewState extends State<ChannelListView>
);
} else {
child = ChannelPreview(
onLongPress: widget.onChannelLongPress,
channel: channel,
onImageTap: widget.onImageTap != null
? () {
+12 -1
View File
@@ -23,6 +23,9 @@ class ChannelPreview extends StatelessWidget {
/// Function called when tapping this widget
final void Function(Channel) onTap;
/// Function called when long pressing this widget
final void Function(Channel) onLongPress;
/// Channel displayed
final Channel channel;
@@ -33,6 +36,7 @@ class ChannelPreview extends StatelessWidget {
@required this.channel,
Key key,
this.onTap,
this.onLongPress,
this.onImageTap,
}) : super(key: key);
@@ -40,7 +44,14 @@ class ChannelPreview extends StatelessWidget {
Widget build(BuildContext context) {
return ListTile(
onTap: () {
onTap(channel);
if (onTap != null) {
onTap(channel);
}
},
onLongPress: () {
if (onLongPress != null) {
onLongPress(channel);
}
},
leading: ChannelImage(
onTap: onImageTap,