diff --git a/CHANGELOG.md b/CHANGELOG.md index 5190ca38..e51cb8bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## 0.2.11 + +- Update llc dependency +- Update widget to use `channel.state.unreadCountStream` + +## 0.2.10 + +- Update llc dependency +- Add `separatorBuilder` to `ChannelListView` + ## 0.2.9+1 - Update llc dependency 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/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 a5a2f73f..9a6554e6 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,7 +1,6 @@ name: example description: A new Flutter project. - -version: 1.0.30+32 +version: 1.0.31+33 environment: sdk: ">=2.2.2 <3.0.0" diff --git a/lib/src/channel_list_view.dart b/lib/src/channel_list_view.dart index 2c24a1f4..3b698782 100644 --- a/lib/src/channel_list_view.dart +++ b/lib/src/channel_list_view.dart @@ -64,6 +64,7 @@ class ChannelListView extends StatefulWidget { this.onChannelLongPress, this.channelWidget, this.channelPreviewBuilder, + this.separatorBuilder, this.errorBuilder, this.onImageTap, this.swipeToAction = false, @@ -113,6 +114,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; @@ -273,6 +277,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); } @@ -304,10 +311,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 de1daab8..8ed15657 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) @@ -71,10 +70,9 @@ class ChannelPreview extends StatelessWidget { StreamChatTheme.of(context).channelPreviewTheme.title, ), ), - if (channel.state.unreadCount > 0) - UnreadIndicator( - channel: channel, - ), + UnreadIndicator( + channel: channel, + ), ], ), subtitle: Row( diff --git a/lib/src/unread_indicator.dart b/lib/src/unread_indicator.dart index 96bf0a00..7e49e202 100644 --- a/lib/src/unread_indicator.dart +++ b/lib/src/unread_indicator.dart @@ -12,20 +12,36 @@ 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 StreamBuilder( + stream: channel.state.unreadCountStream, + initialData: channel.state.unreadCount, + builder: (context, snapshot) { + if (!snapshot.hasData || snapshot.data == 0) { + return SizedBox(); + } + 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( + '${snapshot.data}', + style: TextStyle( + fontSize: 11, + color: Colors.white, + ), + ), + ), + ), + ); + }); } } diff --git a/pubspec.yaml b/pubspec.yaml index 2c1158ae..4ae31b50 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.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