add onLongPress to channel preview
This commit is contained in:
@@ -68,6 +68,7 @@ void main() async {
|
|||||||
's2dxdhpxd94g',
|
's2dxdhpxd94g',
|
||||||
logLevel: Level.INFO,
|
logLevel: Level.INFO,
|
||||||
showLocalNotification: Platform.isAndroid ? showLocalNotification : null,
|
showLocalNotification: Platform.isAndroid ? showLocalNotification : null,
|
||||||
|
backgroundKeepAlive: Duration.zero,
|
||||||
);
|
);
|
||||||
|
|
||||||
await client.setUser(
|
await client.setUser(
|
||||||
@@ -87,13 +88,12 @@ class MyApp extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = ThemeData();
|
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
theme: theme,
|
theme: ThemeData.light(),
|
||||||
|
darkTheme: ThemeData.dark(),
|
||||||
themeMode: ThemeMode.system,
|
themeMode: ThemeMode.system,
|
||||||
home: Container(
|
home: Container(
|
||||||
child: StreamChat(
|
child: StreamChat(
|
||||||
streamChatThemeData: StreamChatThemeData.fromTheme(theme),
|
|
||||||
client: client,
|
client: client,
|
||||||
child: ChannelListPage(),
|
child: ChannelListPage(),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ class ChannelListView extends StatefulWidget {
|
|||||||
this.sort,
|
this.sort,
|
||||||
this.pagination,
|
this.pagination,
|
||||||
this.onChannelTap,
|
this.onChannelTap,
|
||||||
|
this.onChannelLongPress,
|
||||||
this.channelWidget,
|
this.channelWidget,
|
||||||
this.channelPreviewBuilder,
|
this.channelPreviewBuilder,
|
||||||
this.errorBuilder,
|
this.errorBuilder,
|
||||||
@@ -92,6 +93,9 @@ class ChannelListView extends StatefulWidget {
|
|||||||
/// with the widget [channelWidget] as child.
|
/// with the widget [channelWidget] as child.
|
||||||
final ChannelTapCallback onChannelTap;
|
final ChannelTapCallback onChannelTap;
|
||||||
|
|
||||||
|
/// Function called when long pressing on a channel
|
||||||
|
final Function(Channel) onChannelLongPress;
|
||||||
|
|
||||||
/// Widget used when opening a channel
|
/// Widget used when opening a channel
|
||||||
final Widget channelWidget;
|
final Widget channelWidget;
|
||||||
|
|
||||||
@@ -271,6 +275,7 @@ class _ChannelListViewState extends State<ChannelListView>
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
child = ChannelPreview(
|
child = ChannelPreview(
|
||||||
|
onLongPress: widget.onChannelLongPress,
|
||||||
channel: channel,
|
channel: channel,
|
||||||
onImageTap: widget.onImageTap != null
|
onImageTap: widget.onImageTap != null
|
||||||
? () {
|
? () {
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ class ChannelPreview extends StatelessWidget {
|
|||||||
/// Function called when tapping this widget
|
/// Function called when tapping this widget
|
||||||
final void Function(Channel) onTap;
|
final void Function(Channel) onTap;
|
||||||
|
|
||||||
|
/// Function called when long pressing this widget
|
||||||
|
final void Function(Channel) onLongPress;
|
||||||
|
|
||||||
/// Channel displayed
|
/// Channel displayed
|
||||||
final Channel channel;
|
final Channel channel;
|
||||||
|
|
||||||
@@ -33,6 +36,7 @@ class ChannelPreview extends StatelessWidget {
|
|||||||
@required this.channel,
|
@required this.channel,
|
||||||
Key key,
|
Key key,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
|
this.onLongPress,
|
||||||
this.onImageTap,
|
this.onImageTap,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@@ -40,7 +44,14 @@ class ChannelPreview extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
onTap(channel);
|
if (onTap != null) {
|
||||||
|
onTap(channel);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLongPress: () {
|
||||||
|
if (onLongPress != null) {
|
||||||
|
onLongPress(channel);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
leading: ChannelImage(
|
leading: ChannelImage(
|
||||||
onTap: onImageTap,
|
onTap: onImageTap,
|
||||||
|
|||||||
+2
-1
@@ -20,7 +20,8 @@ dependencies:
|
|||||||
file_picker: ^1.8.0+2
|
file_picker: ^1.8.0+2
|
||||||
image_picker: ^0.6.5+3
|
image_picker: ^0.6.5+3
|
||||||
flutter_keyboard_visibility: ^2.0.0
|
flutter_keyboard_visibility: ^2.0.0
|
||||||
stream_chat: ^0.2.0-alpha+8
|
stream_chat:
|
||||||
|
path: ../stream_chat_dart
|
||||||
mime: ^0.9.6+3
|
mime: ^0.9.6+3
|
||||||
visibility_detector: ^0.1.4
|
visibility_detector: ^0.1.4
|
||||||
http_parser: ^3.1.4
|
http_parser: ^3.1.4
|
||||||
|
|||||||
Reference in New Issue
Block a user