From 60f48177e46d284c359b7ad6445b0ecd5aad9457 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 22 Apr 2020 17:09:00 +0200 Subject: [PATCH 01/11] version bump --- CHANGELOG.md | 4 ++++ pubspec.yaml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a79a2b66..21576f44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.32 + +- Update llc version + ## 0.1.31 - Add `initialMessage` property to `MessageInput` diff --git a/pubspec.yaml b/pubspec.yaml index 148745a0..8418da15 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.1.31 +version: 0.1.32 environment: sdk: ">=2.3.0 <3.0.0" @@ -19,7 +19,7 @@ dependencies: file_picker: ^1.6.3+2 image_picker: ^0.6.5 flutter_keyboard_visibility: ^2.0.0 - stream_chat: ^0.1.27 + stream_chat: ^0.1.28 mime: ^0.9.6+3 visibility_detector: ^0.1.4 http_parser: ^3.1.4 From 019d0aded8b475bc26518298335190d4f17221bf Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 23 Apr 2020 12:02:24 +0200 Subject: [PATCH 02/11] add default channel image to theme --- example/lib/main.dart | 7 +++++++ lib/src/channel_header.dart | 2 +- lib/src/channel_image.dart | 3 ++- lib/src/stream_chat.dart | 1 + lib/src/stream_chat_theme.dart | 8 ++++++++ 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 32af2bd3..80ea02b3 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -28,6 +28,13 @@ class MyApp extends StatelessWidget { themeMode: ThemeMode.system, home: Container( child: StreamChat( + streamChatThemeData: StreamChatThemeData( + defaultChannelImage: (context, channel) { + return Center( + child: Text('AAA'), + ); + }, + ), client: client, child: ChannelListPage(), ), diff --git a/lib/src/channel_header.dart b/lib/src/channel_header.dart index 659a24eb..5a7a146c 100644 --- a/lib/src/channel_header.dart +++ b/lib/src/channel_header.dart @@ -128,7 +128,7 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget { .channelHeaderTheme .lastMessageAt, ) - : Container(); + : SizedBox(); }, ); } diff --git a/lib/src/channel_image.dart b/lib/src/channel_image.dart index 7d674ac1..a3918d9d 100644 --- a/lib/src/channel_image.dart +++ b/lib/src/channel_image.dart @@ -111,7 +111,8 @@ class ChannelImage extends StatelessWidget { }, fit: BoxFit.cover, ) - : SizedBox(), + : StreamChatTheme.of(context) + .defaultChannelImage(context, channel), Material( color: Colors.transparent, child: InkWell( diff --git a/lib/src/stream_chat.dart b/lib/src/stream_chat.dart index 19d1608d..17f3ff40 100644 --- a/lib/src/stream_chat.dart +++ b/lib/src/stream_chat.dart @@ -114,6 +114,7 @@ class StreamChatState extends State final defaultTheme = StreamChatThemeData.getDefaultTheme(Theme.of(context)); final theme = defaultTheme.copyWith( primaryColor: themeData?.primaryColor, + defaultChannelImage: themeData?.defaultChannelImage, channelTheme: defaultTheme.channelTheme.copyWith( channelHeaderTheme: defaultTheme.channelTheme.channelHeaderTheme.copyWith( diff --git a/lib/src/stream_chat_theme.dart b/lib/src/stream_chat_theme.dart index e6053939..84f8a8f2 100644 --- a/lib/src/stream_chat_theme.dart +++ b/lib/src/stream_chat_theme.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:stream_chat/stream_chat.dart'; import 'package:stream_chat_flutter/src/channel_header.dart'; import 'package:stream_chat_flutter/src/channel_preview.dart'; import 'package:stream_chat_flutter/src/message_input.dart'; @@ -50,6 +51,9 @@ class StreamChatThemeData { /// Theme of other users messages final MessageTheme otherMessageTheme; + /// The widget that will be built when the channel image is unavailable + final Widget Function(BuildContext, Channel) defaultChannelImage; + /// Create a theme from scratch StreamChatThemeData({ this.primaryColor, @@ -59,6 +63,7 @@ class StreamChatThemeData { this.channelTheme, this.otherMessageTheme, this.ownMessageTheme, + this.defaultChannelImage, }); /// Create a theme from a Material [Theme] @@ -97,11 +102,13 @@ class StreamChatThemeData { ChannelTheme channelTheme, MessageTheme ownMessageTheme, MessageTheme otherMessageTheme, + Widget Function(BuildContext, Channel) defaultChannelImage, }) => StreamChatThemeData( primaryColor: primaryColor ?? this.primaryColor, secondaryColor: secondaryColor ?? this.secondaryColor, accentColor: accentColor ?? this.accentColor, + defaultChannelImage: defaultChannelImage ?? this.defaultChannelImage, channelPreviewTheme: channelPreviewTheme?.copyWith( title: channelPreviewTheme.title ?? this.channelPreviewTheme.title, @@ -170,6 +177,7 @@ class StreamChatThemeData { return StreamChatThemeData( accentColor: accentColor, primaryColor: isDark ? Colors.black : Colors.white, + defaultChannelImage: (context, channel) => SizedBox(), channelPreviewTheme: ChannelPreviewTheme( avatarTheme: AvatarTheme( borderRadius: BorderRadius.circular(20), From 3d40193f9ab0983a44c9c8a2e5e26e3815621bd2 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 23 Apr 2020 15:26:55 +0200 Subject: [PATCH 03/11] add default user image to theme --- example/lib/main.dart | 7 ------- lib/src/stream_chat.dart | 1 + lib/src/stream_chat_theme.dart | 12 ++++++++++++ lib/src/user_avatar.dart | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 80ea02b3..32af2bd3 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -28,13 +28,6 @@ class MyApp extends StatelessWidget { themeMode: ThemeMode.system, home: Container( child: StreamChat( - streamChatThemeData: StreamChatThemeData( - defaultChannelImage: (context, channel) { - return Center( - child: Text('AAA'), - ); - }, - ), client: client, child: ChannelListPage(), ), diff --git a/lib/src/stream_chat.dart b/lib/src/stream_chat.dart index 17f3ff40..258a308f 100644 --- a/lib/src/stream_chat.dart +++ b/lib/src/stream_chat.dart @@ -115,6 +115,7 @@ class StreamChatState extends State final theme = defaultTheme.copyWith( primaryColor: themeData?.primaryColor, defaultChannelImage: themeData?.defaultChannelImage, + defaultUserImage: themeData?.defaultUserImage, channelTheme: defaultTheme.channelTheme.copyWith( channelHeaderTheme: defaultTheme.channelTheme.channelHeaderTheme.copyWith( diff --git a/lib/src/stream_chat_theme.dart b/lib/src/stream_chat_theme.dart index 84f8a8f2..289f477d 100644 --- a/lib/src/stream_chat_theme.dart +++ b/lib/src/stream_chat_theme.dart @@ -54,6 +54,9 @@ class StreamChatThemeData { /// The widget that will be built when the channel image is unavailable final Widget Function(BuildContext, Channel) defaultChannelImage; + /// The widget that will be built when the user image is unavailable + final Widget Function(BuildContext, User) defaultUserImage; + /// Create a theme from scratch StreamChatThemeData({ this.primaryColor, @@ -64,6 +67,7 @@ class StreamChatThemeData { this.otherMessageTheme, this.ownMessageTheme, this.defaultChannelImage, + this.defaultUserImage, }); /// Create a theme from a Material [Theme] @@ -103,12 +107,14 @@ class StreamChatThemeData { MessageTheme ownMessageTheme, MessageTheme otherMessageTheme, Widget Function(BuildContext, Channel) defaultChannelImage, + Widget Function(BuildContext, User) defaultUserImage, }) => StreamChatThemeData( primaryColor: primaryColor ?? this.primaryColor, secondaryColor: secondaryColor ?? this.secondaryColor, accentColor: accentColor ?? this.accentColor, defaultChannelImage: defaultChannelImage ?? this.defaultChannelImage, + defaultUserImage: defaultUserImage ?? this.defaultUserImage, channelPreviewTheme: channelPreviewTheme?.copyWith( title: channelPreviewTheme.title ?? this.channelPreviewTheme.title, @@ -178,6 +184,12 @@ class StreamChatThemeData { accentColor: accentColor, primaryColor: isDark ? Colors.black : Colors.white, defaultChannelImage: (context, channel) => SizedBox(), + defaultUserImage: (context, user) => Center( + child: Text( + user.name?.substring(0, 1) ?? '', + style: TextStyle(color: Colors.white), + ), + ), channelPreviewTheme: ChannelPreviewTheme( avatarTheme: AvatarTheme( borderRadius: BorderRadius.circular(20), diff --git a/lib/src/user_avatar.dart b/lib/src/user_avatar.dart index aaaa6a27..2377411e 100644 --- a/lib/src/user_avatar.dart +++ b/lib/src/user_avatar.dart @@ -43,7 +43,7 @@ class UserAvatar extends StatelessWidget { }, fit: BoxFit.cover, ) - : SizedBox(), + : StreamChatTheme.of(context).defaultUserImage(context, user), ), ); } From 1542675c8c6ec15ee74c2a1c51ed5fa3563212c4 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 23 Apr 2020 15:41:33 +0200 Subject: [PATCH 04/11] version bump --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21576f44..cb8ffe41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.33 + +- Add default user and channel image to `StreamChatTheme` + ## 0.1.32 - Update llc version diff --git a/pubspec.yaml b/pubspec.yaml index 8418da15..902c422c 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.1.32 +version: 0.1.33 environment: sdk: ">=2.3.0 <3.0.0" From 061962ea8bd0263895441867674699622475470d Mon Sep 17 00:00:00 2001 From: Luis Pulido Date: Thu, 23 Apr 2020 11:41:07 -0400 Subject: [PATCH 05/11] Added onUserAvatarTap --- lib/src/message_list_view.dart | 8 ++++++++ lib/src/message_widget.dart | 13 ++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/src/message_list_view.dart b/lib/src/message_list_view.dart index 468bf054..13ea7233 100644 --- a/lib/src/message_list_view.dart +++ b/lib/src/message_list_view.dart @@ -65,6 +65,7 @@ class MessageListView extends StatefulWidget { this.showOtherMessageUsername = false, this.showVideoFullScreen = true, this.onMentionTap, + this.onUserAvatarTap, this.onMessageActions, }) : super(key: key); @@ -93,6 +94,9 @@ class MessageListView extends StatefulWidget { /// Function called on message mention tap final void Function(User) onMentionTap; + /// Function called on User Avatar tap + final void Function(User) onUserAvatarTap; + /// Function called on message long press final Function(BuildContext, Message) onMessageActions; @@ -154,6 +158,7 @@ class _MessageListViewState extends State { showOtherMessageUsername: widget.showOtherMessageUsername, onMentionTap: widget.onMentionTap, + onUserAvatarTap: widget.onUserAvatarTap, onMessageActions: widget.onMessageActions, ), Padding( @@ -216,6 +221,7 @@ class _MessageListViewState extends State { showOtherMessageUsername: widget.showOtherMessageUsername, showVideoFullScreen: widget.showVideoFullScreen, onMentionTap: widget.onMentionTap, + onUserAvatarTap: widget.onUserAvatarTap, onMessageActions: widget.onMessageActions, ); } @@ -363,6 +369,7 @@ class _MessageListViewState extends State { showVideoFullScreen: widget.showVideoFullScreen, showOtherMessageUsername: widget.showOtherMessageUsername, onMentionTap: widget.onMentionTap, + onUserAvatarTap: widget.onUserAvatarTap, onMessageActions: widget.onMessageActions, ); } @@ -402,6 +409,7 @@ class _MessageListViewState extends State { showVideoFullScreen: widget.showVideoFullScreen, showOtherMessageUsername: widget.showOtherMessageUsername, onMentionTap: widget.onMentionTap, + onUserAvatarTap: widget.onUserAvatarTap, onMessageActions: widget.onMessageActions, ); } diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index 18a8cfdd..43def300 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -35,6 +35,7 @@ class MessageWidget extends StatefulWidget { @required this.message, @required this.nextMessage, this.onThreadTap, + this.onUserAvatarTap, this.onMessageActions, this.isParent = false, this.onMentionTap, @@ -63,6 +64,9 @@ class MessageWidget extends StatefulWidget { /// The function called when tapping on replies final void Function(Message) onThreadTap; + /// The function called when tapping on UserAvatar + final void Function(User) onUserAvatarTap; + /// True if this is the parent of the thread being showed final bool isParent; @@ -151,7 +155,14 @@ class _MessageWidgetState extends State ), child: Row( children: [ - UserAvatar(user: widget.message.user), + GestureDetector( + onTap: () { + if (widget.onUserAvatarTap != null) { + widget.onUserAvatarTap(widget.message.user); + } + }, + child: UserAvatar(user: widget.message.user), + ), if (_isMyMessage && widget.nextMessage == null && (widget.message.status == MessageSendingStatus.SENT || From c5ba6dc3902fbc1e36e45675b420f1fa98012a53 Mon Sep 17 00:00:00 2001 From: Luis Pulido Date: Thu, 23 Apr 2020 12:31:01 -0400 Subject: [PATCH 06/11] moved tap logic to UserAvatar Widget --- lib/src/message_widget.dart | 10 ++---- lib/src/user_avatar.dart | 68 ++++++++++++++++++++++--------------- 2 files changed, 44 insertions(+), 34 deletions(-) diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index 43def300..806a666a 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -155,13 +155,9 @@ class _MessageWidgetState extends State ), child: Row( children: [ - GestureDetector( - onTap: () { - if (widget.onUserAvatarTap != null) { - widget.onUserAvatarTap(widget.message.user); - } - }, - child: UserAvatar(user: widget.message.user), + UserAvatar( + user: widget.message.user, + onUserAvatarTap: widget.onUserAvatarTap, ), if (_isMyMessage && widget.nextMessage == null && diff --git a/lib/src/user_avatar.dart b/lib/src/user_avatar.dart index 2377411e..94a5533d 100644 --- a/lib/src/user_avatar.dart +++ b/lib/src/user_avatar.dart @@ -9,41 +9,55 @@ class UserAvatar extends StatelessWidget { Key key, @required this.user, this.constraints, + this.onUserAvatarTap, }) : super(key: key); final User user; final BoxConstraints constraints; + final void Function(User) onUserAvatarTap; @override Widget build(BuildContext context) { - return ClipRRect( - borderRadius: - StreamChatTheme.of(context).ownMessageTheme.avatarTheme.borderRadius, - child: Container( - constraints: constraints ?? - StreamChatTheme.of(context).ownMessageTheme.avatarTheme.constraints, - decoration: BoxDecoration( - color: StreamChatTheme.of(context).accentColor, - ), - child: user.extraData?.containsKey('image') ?? false - ? CachedNetworkImage( - imageUrl: user.extraData['image'], - errorWidget: (_, __, ___) { - return Center( - child: Text( - user.extraData?.containsKey('name') ?? false - ? user.extraData['name'][0] - : '', - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, + return GestureDetector( + onTap: () { + if (onUserAvatarTap != null) { + onUserAvatarTap(user); + } + }, + child: ClipRRect( + borderRadius: StreamChatTheme.of(context) + .ownMessageTheme + .avatarTheme + .borderRadius, + child: Container( + constraints: constraints ?? + StreamChatTheme.of(context) + .ownMessageTheme + .avatarTheme + .constraints, + decoration: BoxDecoration( + color: StreamChatTheme.of(context).accentColor, + ), + child: user.extraData?.containsKey('image') ?? false + ? CachedNetworkImage( + imageUrl: user.extraData['image'], + errorWidget: (_, __, ___) { + return Center( + child: Text( + user.extraData?.containsKey('name') ?? false + ? user.extraData['name'][0] + : '', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + ), ), - ), - ); - }, - fit: BoxFit.cover, - ) - : StreamChatTheme.of(context).defaultUserImage(context, user), + ); + }, + fit: BoxFit.cover, + ) + : StreamChatTheme.of(context).defaultUserImage(context, user), + ), ), ); } From c88ae78ced8351f464f0c2263952f2129e846492 Mon Sep 17 00:00:00 2001 From: Luis Pulido Date: Fri, 24 Apr 2020 09:13:02 -0400 Subject: [PATCH 07/11] renamed method to onTap --- lib/src/message_widget.dart | 2 +- lib/src/user_avatar.dart | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index 806a666a..5445fc59 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -157,7 +157,7 @@ class _MessageWidgetState extends State children: [ UserAvatar( user: widget.message.user, - onUserAvatarTap: widget.onUserAvatarTap, + onTap: widget.onUserAvatarTap, ), if (_isMyMessage && widget.nextMessage == null && diff --git a/lib/src/user_avatar.dart b/lib/src/user_avatar.dart index 94a5533d..8ea9a525 100644 --- a/lib/src/user_avatar.dart +++ b/lib/src/user_avatar.dart @@ -9,19 +9,19 @@ class UserAvatar extends StatelessWidget { Key key, @required this.user, this.constraints, - this.onUserAvatarTap, + this.onTap, }) : super(key: key); final User user; final BoxConstraints constraints; - final void Function(User) onUserAvatarTap; + final void Function(User) onTap; @override Widget build(BuildContext context) { return GestureDetector( onTap: () { - if (onUserAvatarTap != null) { - onUserAvatarTap(user); + if (onTap != null) { + onTap(user); } }, child: ClipRRect( From 8b677e97acc559594097205bd36aa3263b0018b7 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Fri, 24 Apr 2020 16:58:19 +0200 Subject: [PATCH 08/11] bump version --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb8ffe41..d097942c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.34 + +- Add `onUserAvatarTap` + ## 0.1.33 - Add default user and channel image to `StreamChatTheme` diff --git a/pubspec.yaml b/pubspec.yaml index 902c422c..35a04b0b 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.1.33 +version: 0.1.34 environment: sdk: ">=2.3.0 <3.0.0" From 144e3fd4dd9c2c0babff999e6758f995a9f165a2 Mon Sep 17 00:00:00 2001 From: Matheus Cardoso Date: Mon, 4 May 2020 20:50:47 -0300 Subject: [PATCH 09/11] Tweak design and spelling in README --- README.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 073e2bee..dc828ad6 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,18 @@ -# Flutter Chat Components +# Official Flutter SDK for [Stream Chat](https://getstream.io/chat/) -Flutter Chat +

+ Flutter Chat +

> The official Flutter components for Stream Chat, a service for > building chat applications. [![Pub](https://img.shields.io/pub/v/stream_chat_flutter.svg)](https://pub.dartlang.org/packages/stream_chat_flutter) ![](https://img.shields.io/badge/platform-flutter%20%7C%20flutter%20web-ff69b4.svg?style=flat-square) -![CI](https://github.com/GetStream/stream-chat-flutter/workflows/CI/badge.svg?branch=master) -[![codecov](https://codecov.io/gh/GetStream/stream-chat-flutter/branch/master/graph/badge.svg)](https://codecov.io/gh/GetStream/stream-chat-flutter) [![Gitter](https://badges.gitter.im/GetStream/stream-chat-flutter.svg)](https://gitter.im/GetStream/stream-chat-flutter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) + + **Quick Links** - [Register](https://getstream.io/chat/trial/) to get an API key for Stream Chat @@ -20,7 +22,7 @@ ## Flutter Chat Tutorial The best place to start is the [Flutter Chat Tutorial](https://getstream.io/chat/flutter/tutorial/). -It teaches you how to use this SDK and also shows how to make common changes. +It teaches you how to use this SDK and also shows how to make frequently required changes. ## Example App @@ -40,7 +42,7 @@ You should then run `flutter packages get` Use version `^0.2.0-alpha+1` to use the latest available version. -Note that this is still an alpha version. There may be some bugs and the api can change in breaking ways. +Note that this is still an alpha version. There may be some bugs, and the API can change in breaking ways. Thanks to whoever tries these versions and reports bugs or suggestions. @@ -56,7 +58,7 @@ Follow [this wiki](https://github.com/miguelpruivo/flutter_file_picker/wiki/Setu We also use [video_player](https://pub.dev/packages/video_player) to reproduce videos. Follow [this guide](https://pub.dev/packages/video_player#installation) to fulfill the requirements. -To pick images from the camera we use the [image_picker](https://pub.dev/packages/image_picker) plugin. +To pick images from the camera, we use the [image_picker](https://pub.dev/packages/image_picker) plugin. Follow [these instructions](https://pub.dev/packages/image_picker#ios) to check the requirements. ## Docs @@ -86,10 +88,10 @@ Every widget uses the `StreamChat` or `StreamChannel` widgets to manage the stat ### Customizing styles -The Flutter SDK comes with a fully designed set of widgets which you can customize to fit with your application style and typography. +The Flutter SDK comes with a fully designed set of widgets that you can customize to fit with your application style and typography. Changing the theme of Chat widgets works in a very similar way that `MaterialApp` and `Theme` do. -Out of the box all chat widgets use their own default styling, there are two ways to change the styling: +Out of the box, all chat widgets use their default styling, and there are two ways to change the styling: 1. Initialize the `StreamChatTheme` from your existing `MaterialApp` style ```dart @@ -159,6 +161,6 @@ Out of the box all chat widgets use their own default styling, there are two way We welcome code changes that improve this library or fix a problem, please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. -We are very happy to merge your code in the official repository. +We are pleased to merge your code into the official repository. Make sure to sign our [Contributor License Agreement (CLA)](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) first. See our license file for more details. From 9bb5e06c96c71205926dbe056f2e1a2d4284e0fb Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 6 May 2020 09:28:47 +0200 Subject: [PATCH 10/11] Refs #46: add background color as part of StreamChatThemeData --- lib/src/stream_chat.dart | 8 ++++---- lib/src/stream_chat_theme.dart | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/src/stream_chat.dart b/lib/src/stream_chat.dart index 258a308f..acd829ff 100644 --- a/lib/src/stream_chat.dart +++ b/lib/src/stream_chat.dart @@ -74,12 +74,11 @@ class StreamChatState extends State child: Builder( builder: (context) { final materialTheme = Theme.of(context); - final isDark = materialTheme.brightness == Brightness.dark; + final streamChatTheme = StreamChatTheme.of(context); return Theme( data: materialTheme.copyWith( - accentColor: StreamChatTheme.of(context).accentColor, - scaffoldBackgroundColor: isDark ? Colors.black : Colors.white, - backgroundColor: isDark ? Colors.black : Colors.white, + accentColor: streamChatTheme.accentColor, + scaffoldBackgroundColor: streamChatTheme.backgroundColor, ), child: WillPopScope( onWillPop: () async { @@ -116,6 +115,7 @@ class StreamChatState extends State primaryColor: themeData?.primaryColor, defaultChannelImage: themeData?.defaultChannelImage, defaultUserImage: themeData?.defaultUserImage, + backgroundColor: themeData?.backgroundColor, channelTheme: defaultTheme.channelTheme.copyWith( channelHeaderTheme: defaultTheme.channelTheme.channelHeaderTheme.copyWith( diff --git a/lib/src/stream_chat_theme.dart b/lib/src/stream_chat_theme.dart index 289f477d..ca574716 100644 --- a/lib/src/stream_chat_theme.dart +++ b/lib/src/stream_chat_theme.dart @@ -39,6 +39,9 @@ class StreamChatThemeData { /// Accent color of the chat widgets final Color accentColor; + /// Background color of the chat widgets + final Color backgroundColor; + /// Theme of the [ChannelPreview] final ChannelPreviewTheme channelPreviewTheme; @@ -62,6 +65,7 @@ class StreamChatThemeData { this.primaryColor, this.secondaryColor, this.accentColor, + this.backgroundColor, this.channelPreviewTheme, this.channelTheme, this.otherMessageTheme, @@ -78,6 +82,7 @@ class StreamChatThemeData { accentColor: theme.accentColor, primaryColor: theme.colorScheme.primary, secondaryColor: theme.colorScheme.secondary, + backgroundColor: theme.scaffoldBackgroundColor, channelTheme: ChannelTheme( inputGradient: LinearGradient(colors: [ theme.accentColor.withOpacity(.5), @@ -102,6 +107,7 @@ class StreamChatThemeData { Color primaryColor, Color secondaryColor, Color accentColor, + Color backgroundColor, ChannelPreviewTheme channelPreviewTheme, ChannelTheme channelTheme, MessageTheme ownMessageTheme, @@ -115,6 +121,7 @@ class StreamChatThemeData { accentColor: accentColor ?? this.accentColor, defaultChannelImage: defaultChannelImage ?? this.defaultChannelImage, defaultUserImage: defaultUserImage ?? this.defaultUserImage, + backgroundColor: backgroundColor ?? this.backgroundColor, channelPreviewTheme: channelPreviewTheme?.copyWith( title: channelPreviewTheme.title ?? this.channelPreviewTheme.title, @@ -184,6 +191,7 @@ class StreamChatThemeData { accentColor: accentColor, primaryColor: isDark ? Colors.black : Colors.white, defaultChannelImage: (context, channel) => SizedBox(), + backgroundColor: isDark ? Colors.black : Colors.white, defaultUserImage: (context, user) => Center( child: Text( user.name?.substring(0, 1) ?? '', From 874300cb376c17ddb7ed0beb664050101da6d976 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 6 May 2020 09:30:33 +0200 Subject: [PATCH 11/11] version bump --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d097942c..dd92e9a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.35 + +- Add backgroundColor as part of StreamChatThemeData + ## 0.1.34 - Add `onUserAvatarTap` diff --git a/pubspec.yaml b/pubspec.yaml index 35a04b0b..e81a8654 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.1.34 +version: 0.1.35 environment: sdk: ">=2.3.0 <3.0.0"