merge master

This commit is contained in:
Salvatore Giordano
2020-08-07 16:53:58 +02:00
parent b95efa0ea5
commit bab5565964
6 changed files with 69 additions and 29 deletions
+14
View File
@@ -1,3 +1,17 @@
## 0.2.3
- Add `lockChannelsOrder` parameter to `ChannelsBloc`
## 0.2.2+3
- Fix `ChannelListView` channel hidden behaviour
- Refresh `ChannelListView` on new message from hidden channel
## 0.2.2+1
- Fix some components to implement a splitview example
## 0.2.2
- Add `messageLinks` property to `MessageTheme` to customize links color
+4 -8
View File
@@ -107,10 +107,8 @@ class ChannelBottomSheet extends StatelessWidget {
'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());
await channel
.removeMembers([StreamChat.of(context).user.id]);
Navigator.pop(context);
}
},
@@ -133,10 +131,8 @@ class ChannelBottomSheet extends StatelessWidget {
'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());
await channel
.removeMembers([StreamChat.of(context).user.id]);
Navigator.pop(context);
}
},
+5 -10
View File
@@ -339,11 +339,8 @@ class _ChannelListViewState extends State<ChannelListView>
'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());
await channel
.removeMembers([StreamChat.of(context).user.id]);
}
},
),
@@ -357,11 +354,8 @@ class _ChannelListViewState extends State<ChannelListView>
'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());
await channel
.removeMembers([StreamChat.of(context).user.id]);
}
},
),
@@ -472,6 +466,7 @@ class _ChannelListViewState extends State<ChannelListView>
.on(
EventType.connectionRecovered,
EventType.notificationAddedToChannel,
EventType.notificationMessageNew,
EventType.channelVisible,
)
.listen((event) {
+32 -6
View File
@@ -4,16 +4,21 @@ import 'package:flutter/material.dart';
import 'package:rxdart/rxdart.dart';
import 'package:stream_chat/stream_chat.dart';
import 'package:stream_chat_flutter/src/stream_chat.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
/// Widget dedicated to the management of a channel list with pagination
class ChannelsBloc extends StatefulWidget {
/// The widget child
final Widget child;
/// Set this to false to prevent channels to be brought to the top of the list when a new message arrives
final bool lockChannelsOrder;
/// Instantiate a new ChannelsBloc
const ChannelsBloc({
Key key,
this.child,
this.lockChannelsOrder = false,
}) : super(key: key);
@override
@@ -58,6 +63,8 @@ class ChannelsBlocState extends State<ChannelsBloc>
Stream<bool> get queryChannelsLoading =>
_queryChannelsLoadingController.stream;
final List<Channel> _hiddenChannels = [];
/// Calls [client.queryChannels] updating [queryChannelsLoading] stream
Future<void> queryChannels({
Map<String, dynamic> filter,
@@ -112,12 +119,31 @@ class ChannelsBlocState extends State<ChannelsBloc>
final client = StreamChat.of(context).client;
_subscriptions.add(client.on(EventType.messageNew).listen((e) {
final newChannels = List<Channel>.from(channels ?? []);
final index = newChannels.indexWhere((c) => c.cid == e.cid);
if (index > 0) {
final channel = newChannels.removeAt(index);
newChannels.insert(0, channel);
if (!widget.lockChannelsOrder) {
_subscriptions.add(client.on(EventType.messageNew).listen((e) {
final newChannels = List<Channel>.from(channels ?? []);
final index = newChannels.indexWhere((c) => c.cid == e.cid);
if (index > 0) {
final channel = newChannels.removeAt(index);
newChannels.insert(0, channel);
_channelsController.add(newChannels);
} else {
final hiddenIndex = _hiddenChannels.indexWhere((c) => c.cid == e.cid);
if (hiddenIndex > -1) {
newChannels.insert(0, _hiddenChannels[hiddenIndex]);
_hiddenChannels.removeAt(hiddenIndex);
_channelsController.add(newChannels);
}
}
}));
}
_subscriptions.add(client.on(EventType.channelHidden).listen((event) async {
final newChannels = List<Channel>.from(channels);
final channelIndex = newChannels.indexWhere((c) => c.cid == event.cid);
if (channelIndex > -1) {
final channel = newChannels.removeAt(channelIndex);
_hiddenChannels.add(channel);
_channelsController.add(newChannels);
}
}));
+11 -2
View File
@@ -208,8 +208,8 @@ class _MessageWidgetState extends State<MessageWidget> {
@override
Widget build(BuildContext context) {
var leftPadding = widget.showUserAvatar != DisplayWidget.gone
? widget.messageTheme.avatarTheme.constraints.maxWidth + 16.0
: 6.0;
? widget.messageTheme.avatarTheme.constraints.maxWidth + 24.0
: 16.0;
return Portal(
child: Padding(
padding: widget.padding ?? EdgeInsets.all(8),
@@ -232,6 +232,15 @@ class _MessageWidgetState extends State<MessageWidget> {
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
if (widget.showSendingIndicator == DisplayWidget.show)
_buildSendingIndicator(),
SizedBox(
width: 2,
),
if (widget.showSendingIndicator == DisplayWidget.hide)
SizedBox(
width: 8,
),
if (widget.showUserAvatar == DisplayWidget.show)
_buildUserAvatar(),
SizedBox(
+3 -3
View File
@@ -1,7 +1,7 @@
name: stream_chat_flutter
homepage: https://github.com/GetStream/stream-chat-flutter
description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter.
version: 0.2.2
version: 0.2.3
repository: https://github.com/GetStream/stream-chat-flutter
issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues
@@ -23,8 +23,8 @@ dependencies:
file_picker: ^1.12.0
image_picker: ^0.6.7+2
flutter_keyboard_visibility: ^3.2.1
stream_chat: ^0.2.1
flutter_svg: ^0.17.0
flutter_svg: ^0.18.0
stream_chat: ^0.2.2
mime: ^0.9.6+3
visibility_detector: ^0.1.5
line_awesome_icons: ^1.0.4+2