Merge pull request #112 from GetStream/hotfix/unreadCount

use channe.state.unreacCountStream
This commit is contained in:
Salvatore Giordano
2020-10-23 16:06:45 +02:00
committed by GitHub
5 changed files with 48 additions and 30 deletions
+5
View File
@@ -1,3 +1,8 @@
## 0.2.11
- Update llc dependency
- Update widget to use `channel.state.unreadCountStream`
## 0.2.10 ## 0.2.10
- Update llc dependency - Update llc dependency
+2 -4
View File
@@ -304,10 +304,8 @@ class _ChannelListViewState extends State<ChannelListView>
return StreamChannel( return StreamChannel(
key: ValueKey<String>('CHANNEL-${channel.id}'), key: ValueKey<String>('CHANNEL-${channel.id}'),
channel: channel, channel: channel,
child: StreamBuilder<DateTime>( child: Builder(
initialData: channel.updatedAt, builder: (context) {
stream: channel.updatedAtStream,
builder: (context, snapshot) {
Widget child; Widget child;
if (widget.channelPreviewBuilder != null) { if (widget.channelPreviewBuilder != null) {
child = Stack( child = Stack(
+9 -3
View File
@@ -6,7 +6,6 @@ import 'package:stream_chat_flutter/src/unread_indicator.dart';
import '../stream_chat_flutter.dart'; import '../stream_chat_flutter.dart';
import 'channel_name.dart'; import 'channel_name.dart';
import 'typing_indicator.dart';
/// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/screenshots/channel_preview.png) /// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/screenshots/channel_preview.png)
/// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/screenshots/channel_preview_paint.png) /// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/screenshots/channel_preview_paint.png)
@@ -103,11 +102,16 @@ class ChannelPreview extends StatelessWidget {
} }
Widget _buildSubtitle(BuildContext context) { Widget _buildSubtitle(BuildContext context) {
final opacity = channel.state.unreadCount > 0 ? 1.0 : 0.5; return StreamBuilder(
initialData: channel.state.unreadCount,
stream: channel.state.unreadCountStream,
builder: (context, snapshot) {
final opacity = (snapshot.data ?? 0) > 0 ? 1.0 : 0.5;
return TypingIndicator( return TypingIndicator(
channel: channel, channel: channel,
alternativeWidget: _buildLastMessage(context, opacity), alternativeWidget: _buildLastMessage(context, opacity),
style: StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( style:
StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith(
color: StreamChatTheme.of(context) color: StreamChatTheme.of(context)
.channelPreviewTheme .channelPreviewTheme
.subtitle .subtitle
@@ -115,6 +119,8 @@ class ChannelPreview extends StatelessWidget {
.withOpacity(opacity), .withOpacity(opacity),
), ),
); );
},
);
} }
Widget _buildLastMessage(BuildContext context, double opacity) { Widget _buildLastMessage(BuildContext context, double opacity) {
+12 -3
View File
@@ -12,17 +12,26 @@ class UnreadIndicator extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return StreamBuilder<int>(
stream: channel.state.unreadCountStream,
initialData: channel.state.unreadCount,
builder: (context, snapshot) {
if (!snapshot.hasData || snapshot.data == 0) {
return SizedBox();
}
return Padding( return Padding(
padding: const EdgeInsets.only(left: 8.0), padding: const EdgeInsets.only(left: 8.0),
child: CircleAvatar( child: CircleAvatar(
backgroundColor: backgroundColor: StreamChatTheme.of(context)
StreamChatTheme.of(context).channelPreviewTheme.unreadCounterColor, .channelPreviewTheme
.unreadCounterColor,
radius: 6, radius: 6,
child: Text( child: Text(
'${channel.state.unreadCount}', '${snapshot.data}',
style: TextStyle(fontSize: 8), style: TextStyle(fontSize: 8),
), ),
), ),
); );
});
} }
} }
+2 -2
View File
@@ -1,7 +1,7 @@
name: stream_chat_flutter name: stream_chat_flutter
homepage: https://github.com/GetStream/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. description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter.
version: 0.2.10 version: 0.2.11
repository: https://github.com/GetStream/stream-chat-flutter repository: https://github.com/GetStream/stream-chat-flutter
issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues
@@ -23,7 +23,7 @@ dependencies:
file_picker: ^2.0.0 file_picker: ^2.0.0
image_picker: ^0.6.7+2 image_picker: ^0.6.7+2
flutter_keyboard_visibility: ^3.2.1 flutter_keyboard_visibility: ^3.2.1
stream_chat: ^0.2.8 stream_chat: ^0.2.10
mime: ^0.9.6+3 mime: ^0.9.6+3
visibility_detector: ^0.1.5 visibility_detector: ^0.1.5
http_parser: ^3.1.4 http_parser: ^3.1.4