diff --git a/assets/icon_user_minus.svg b/assets/icon_user_minus.svg
new file mode 100644
index 00000000..47210701
--- /dev/null
+++ b/assets/icon_user_minus.svg
@@ -0,0 +1,5 @@
+
diff --git a/lib/src/channel_bottom_sheet.dart b/lib/src/channel_bottom_sheet.dart
index c3057d31..a2f124fc 100644
--- a/lib/src/channel_bottom_sheet.dart
+++ b/lib/src/channel_bottom_sheet.dart
@@ -1,6 +1,9 @@
+import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
+import 'package:flutter_svg/flutter_svg.dart';
import 'package:line_awesome_icons/line_awesome_icons.dart';
import 'package:stream_chat/stream_chat.dart';
+import 'package:stream_chat_flutter/src/utils.dart';
import 'channel_info.dart';
import 'channel_name.dart';
@@ -70,26 +73,74 @@ class ChannelBottomSheet extends StatelessWidget {
stream: channel.isMutedStream,
initialData: channel.isMuted,
builder: (context, snapshot) {
- return SwitchListTile(
- onChanged: (bool muted) async {
- if (muted) {
- await channel.mute();
- } else {
- await channel.unmute();
- }
- },
- value: snapshot.data,
- title: Row(
- children: [
- Padding(
- padding: const EdgeInsets.only(right: 22.0),
- child: Icon(LineAwesomeIcons.volume_off),
- ),
- Text('Mute'),
- ],
+ return ListTile(
+ leading: Icon(
+ LineAwesomeIcons.volume_off,
+ size: 22,
+ color: StreamChatTheme.of(context).primaryIconTheme.color,
+ ),
+ title: Text('Mute ${channel.isGroup ? 'group' : 'user'}'),
+ trailing: Switch(
+ onChanged: (bool muted) async {
+ if (muted) {
+ await channel.mute();
+ } else {
+ await channel.unmute();
+ }
+ },
+ value: snapshot.data,
),
);
}),
+ Divider(),
+ if (channel.isGroup && !channel.isDistinct)
+ ListTile(
+ leading: SvgPicture.asset(
+ 'assets/icon_user_minus.svg',
+ package: 'stream_chat_flutter',
+ width: 22,
+ ),
+ title: Text('Leave Group'),
+ onTap: () async {
+ final confirm = await showConfirmationDialog(
+ context,
+ 'Do you want to leave the group?',
+ );
+ if (confirm == true) {
+ await channel.removeMembers(channel.state.members
+ .where((element) =>
+ element.userId == StreamChat.of(context).user.id)
+ .toList());
+ Navigator.pop(context);
+ }
+ },
+ ),
+ if (!channel.isGroup && !channel.isDistinct)
+ ListTile(
+ leading: Icon(
+ Icons.delete_outline,
+ color: Color(0xFFFF3742),
+ ),
+ title: Text(
+ 'Delete chat',
+ style: TextStyle(
+ color: Color(0xFFFF3742),
+ ),
+ ),
+ onTap: () async {
+ final confirm = await showConfirmationDialog(
+ context,
+ 'Do you want to delete the chat?',
+ );
+ if (confirm == true) {
+ await channel.removeMembers(channel.state.members
+ .where((element) =>
+ element.userId == StreamChat.of(context).user.id)
+ .toList());
+ Navigator.pop(context);
+ }
+ },
+ ),
],
),
),
diff --git a/lib/src/channel_list_view.dart b/lib/src/channel_list_view.dart
index 3329382f..4b77f784 100644
--- a/lib/src/channel_list_view.dart
+++ b/lib/src/channel_list_view.dart
@@ -1,7 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
+import 'package:flutter_svg/flutter_svg.dart';
+import 'package:line_awesome_icons/line_awesome_icons.dart';
import 'package:stream_chat/stream_chat.dart';
import 'package:stream_chat_flutter/src/channels_bloc.dart';
+import 'package:stream_chat_flutter/src/utils.dart';
import '../stream_chat_flutter.dart';
import 'channel_bottom_sheet.dart';
@@ -307,12 +310,55 @@ class _ChannelListViewState extends State
),
IconSlideAction(
color: Color(0xffEBEBEB),
- icon: Icons.notifications_none,
- ),
- IconSlideAction(
- color: Color(0xffEBEBEB),
- icon: Icons.delete,
+ icon: LineAwesomeIcons.volume_off,
+ onTap: () async {
+ if (!channel.isMuted) {
+ await channel.mute();
+ } else {
+ await channel.unmute();
+ }
+ },
),
+ if (channel.isGroup && !channel.isDistinct)
+ IconSlideAction(
+ color: Color(0xffEBEBEB),
+ iconWidget: SvgPicture.asset(
+ 'assets/icon_user_minus.svg',
+ package: 'stream_chat_flutter',
+ width: 22,
+ ),
+ onTap: () async {
+ final confirm = await showConfirmationDialog(
+ context,
+ 'Do you want to leave the group?',
+ );
+ if (confirm == true) {
+ await channel.removeMembers(channel.state.members
+ .where((element) =>
+ element.userId ==
+ StreamChat.of(context).user.id)
+ .toList());
+ }
+ },
+ ),
+ if (!channel.isGroup && !channel.isDistinct)
+ IconSlideAction(
+ color: Color(0xffEBEBEB),
+ icon: Icons.delete_outline,
+ onTap: () async {
+ final confirm = await showConfirmationDialog(
+ context,
+ 'Do you want to delete the chat?',
+ );
+ if (confirm == true) {
+ await channel.removeMembers(channel.state.members
+ .where((element) =>
+ element.userId ==
+ StreamChat.of(context).user.id)
+ .toList());
+ }
+ },
+ ),
],
child: Container(
color: StreamChatTheme.of(context).backgroundColor,
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index c427099b..b20e5f59 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -12,3 +12,33 @@ Future launchURL(BuildContext context, String url) async {
);
}
}
+
+Future showConfirmationDialog(
+ BuildContext context,
+ String question,
+) {
+ return showDialog(
+ context: context,
+ builder: (context) {
+ return AlertDialog(
+ title: Text(question),
+ actions: [
+ FlatButton(
+ child: Text('Ok'),
+ onPressed: () => Navigator.pop(
+ context,
+ true,
+ ),
+ ),
+ FlatButton(
+ child: Text('Cancel'),
+ onPressed: () => Navigator.pop(
+ context,
+ false,
+ ),
+ ),
+ ],
+ );
+ },
+ );
+}