From 957fb5f26445862a2aa581344c36a9201090335c Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 15 Oct 2020 09:30:33 +0200 Subject: [PATCH 1/6] Ref #102: add separatorBuilder to ChannelListView --- lib/src/channel_list_view.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/src/channel_list_view.dart b/lib/src/channel_list_view.dart index 74a0cb92..ba71e854 100644 --- a/lib/src/channel_list_view.dart +++ b/lib/src/channel_list_view.dart @@ -61,6 +61,7 @@ class ChannelListView extends StatefulWidget { this.onChannelLongPress, this.channelWidget, this.channelPreviewBuilder, + this.separatorBuilder, this.errorBuilder, this.onImageTap, this.pullToRefresh = true, @@ -106,6 +107,9 @@ class ChannelListView extends StatefulWidget { /// Builder used to create a custom channel preview final ChannelPreviewBuilder channelPreviewBuilder; + /// Builder used to create a custom item separator + final Function(BuildContext, int) separatorBuilder; + /// The function called when the image is tapped final Function(Channel) onImageTap; @@ -266,6 +270,9 @@ class _ChannelListViewState extends State Widget _itemBuilder(context, int i, List channels) { if (i % 2 != 0) { + if (widget.separatorBuilder != null) { + return widget.separatorBuilder(context, i); + } return _separatorBuilder(context, i); } From 8331816eb32a14e4bac9e59a5c84f7ba8e24dd62 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 15 Oct 2020 09:31:19 +0200 Subject: [PATCH 2/6] bump version --- CHANGELOG.md | 5 +++++ pubspec.yaml | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5190ca38..86c4c623 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.2.10 + +- Update llc dependency +- Add `separatorBuilder` to `ChannelListView` + ## 0.2.9+1 - Update llc dependency diff --git a/pubspec.yaml b/pubspec.yaml index 0b5e34f6..f2deb2f8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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.9+1 +version: 0.2.10 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues @@ -23,7 +23,7 @@ dependencies: file_picker: ^2.0.0 image_picker: ^0.6.7+2 flutter_keyboard_visibility: ^3.2.1 - stream_chat: ^0.2.7+1 + stream_chat: ^0.2.8 mime: ^0.9.6+3 visibility_detector: ^0.1.5 http_parser: ^3.1.4 From 4a6acedafb5f2019162ec540d5a91f31c6bf015a Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 19 Oct 2020 15:36:20 +0200 Subject: [PATCH 3/6] fix single conversation example --- example/lib/single_conversation.dart | 15 +++++++++------ example/pubspec.yaml | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/example/lib/single_conversation.dart b/example/lib/single_conversation.dart index 5f5d03ea..2093d38a 100644 --- a/example/lib/single_conversation.dart +++ b/example/lib/single_conversation.dart @@ -52,12 +52,15 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( - home: StreamChat( - client: client, - child: StreamChannel( - channel: channel, - child: ChannelPage(), - ), + builder: (context, widget) { + return StreamChat( + child: widget, + client: client, + ); + }, + home: StreamChannel( + channel: channel, + child: ChannelPage(), ), ); } diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 2ecf9668..08e02e6e 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,6 +1,6 @@ name: example description: A new Flutter project. -version: 1.0.20+21 +version: 1.0.21+22 environment: sdk: ">=2.2.2 <3.0.0" From 00e9e796e4dcf17c5a9689ca4de1610e489c6ad1 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 21 Oct 2020 10:39:50 +0200 Subject: [PATCH 4/6] fix unread indicator --- lib/src/unread_indicator.dart | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/src/unread_indicator.dart b/lib/src/unread_indicator.dart index 96bf0a00..debe1d1b 100644 --- a/lib/src/unread_indicator.dart +++ b/lib/src/unread_indicator.dart @@ -12,17 +12,23 @@ class UnreadIndicator extends StatelessWidget { @override Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.only(left: 8.0), - child: CircleAvatar( - backgroundColor: - StreamChatTheme.of(context).channelPreviewTheme.unreadCounterColor, - radius: 8, - child: Text( - '${channel.state.unreadCount}', - style: TextStyle( - fontSize: 11, - color: Colors.white, + return Material( + borderRadius: BorderRadius.circular(8), + color: StreamChatTheme.of(context).channelPreviewTheme.unreadCounterColor, + child: Padding( + padding: const EdgeInsets.only( + left: 5.0, + right: 5.0, + top: 2, + bottom: 1, + ), + child: Center( + child: Text( + '${channel.state.unreadCount}', + style: TextStyle( + fontSize: 11, + color: Colors.white, + ), ), ), ), From 95802c1f31a0be772821947020da7c20f881d086 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 22 Oct 2020 11:12:55 +0200 Subject: [PATCH 5/6] Refs #109: update sample app gradle --- example/android/build.gradle | 2 +- example/android/gradle/wrapper/gradle-wrapper.properties | 4 ++-- example/pubspec.yaml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/android/build.gradle b/example/android/build.gradle index 70b3637d..e1cfea50 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -6,7 +6,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' + classpath 'com.android.tools.build:gradle:4.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:4.3.2' } diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 296b146b..4a4c2043 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Jun 23 08:50:38 CEST 2017 +#Thu Oct 22 11:03:39 CEST 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 08e02e6e..c56b9834 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,6 +1,6 @@ name: example description: A new Flutter project. -version: 1.0.21+22 +version: 1.0.22+23 environment: sdk: ">=2.2.2 <3.0.0" From 4a6c0624847a661829d50da2f007592e469c83c0 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Fri, 23 Oct 2020 16:03:03 +0200 Subject: [PATCH 6/6] use channe.state.unreacCountStream --- CHANGELOG.md | 5 +++++ lib/src/channel_list_view.dart | 6 ++---- lib/src/channel_preview.dart | 30 ++++++++++++++++++------------ lib/src/unread_indicator.dart | 33 +++++++++++++++++++++------------ pubspec.yaml | 4 ++-- 5 files changed, 48 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86c4c623..e51cb8bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.2.11 + +- Update llc dependency +- Update widget to use `channel.state.unreadCountStream` + ## 0.2.10 - Update llc dependency diff --git a/lib/src/channel_list_view.dart b/lib/src/channel_list_view.dart index ba71e854..f88eefbe 100644 --- a/lib/src/channel_list_view.dart +++ b/lib/src/channel_list_view.dart @@ -304,10 +304,8 @@ class _ChannelListViewState extends State return StreamChannel( key: ValueKey('CHANNEL-${channel.id}'), channel: channel, - child: StreamBuilder( - initialData: channel.updatedAt, - stream: channel.updatedAtStream, - builder: (context, snapshot) { + child: Builder( + builder: (context) { Widget child; if (widget.channelPreviewBuilder != null) { child = Stack( diff --git a/lib/src/channel_preview.dart b/lib/src/channel_preview.dart index 5a3432aa..95fa4a3d 100644 --- a/lib/src/channel_preview.dart +++ b/lib/src/channel_preview.dart @@ -6,7 +6,6 @@ import 'package:stream_chat_flutter/src/unread_indicator.dart'; import '../stream_chat_flutter.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_paint.png) @@ -103,17 +102,24 @@ class ChannelPreview extends StatelessWidget { } Widget _buildSubtitle(BuildContext context) { - final opacity = channel.state.unreadCount > 0 ? 1.0 : 0.5; - return TypingIndicator( - channel: channel, - alternativeWidget: _buildLastMessage(context, opacity), - style: StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( - color: StreamChatTheme.of(context) - .channelPreviewTheme - .subtitle - .color - .withOpacity(opacity), - ), + 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( + channel: channel, + alternativeWidget: _buildLastMessage(context, opacity), + style: + StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( + color: StreamChatTheme.of(context) + .channelPreviewTheme + .subtitle + .color + .withOpacity(opacity), + ), + ); + }, ); } diff --git a/lib/src/unread_indicator.dart b/lib/src/unread_indicator.dart index 73f57d05..1b711de7 100644 --- a/lib/src/unread_indicator.dart +++ b/lib/src/unread_indicator.dart @@ -12,17 +12,26 @@ class UnreadIndicator extends StatelessWidget { @override Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.only(left: 8.0), - child: CircleAvatar( - backgroundColor: - StreamChatTheme.of(context).channelPreviewTheme.unreadCounterColor, - radius: 6, - child: Text( - '${channel.state.unreadCount}', - style: TextStyle(fontSize: 8), - ), - ), - ); + return StreamBuilder( + stream: channel.state.unreadCountStream, + initialData: channel.state.unreadCount, + builder: (context, snapshot) { + if (!snapshot.hasData || snapshot.data == 0) { + return SizedBox(); + } + return Padding( + padding: const EdgeInsets.only(left: 8.0), + child: CircleAvatar( + backgroundColor: StreamChatTheme.of(context) + .channelPreviewTheme + .unreadCounterColor, + radius: 6, + child: Text( + '${snapshot.data}', + style: TextStyle(fontSize: 8), + ), + ), + ); + }); } } diff --git a/pubspec.yaml b/pubspec.yaml index f2deb2f8..56d2270d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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.10 +version: 0.2.11 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues @@ -23,7 +23,7 @@ dependencies: file_picker: ^2.0.0 image_picker: ^0.6.7+2 flutter_keyboard_visibility: ^3.2.1 - stream_chat: ^0.2.8 + stream_chat: ^0.2.10 mime: ^0.9.6+3 visibility_detector: ^0.1.5 http_parser: ^3.1.4