From 375450e5c10aacd8fca4a39d0e793def9f5deebc Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 6 Jan 2021 15:18:12 +0530 Subject: [PATCH 01/11] feat: Added bold mentions in previews, added file names for last message --- lib/src/channel_preview.dart | 59 +++++++++++++++++++++++++------- lib/src/message_search_item.dart | 45 +++++++++++++++++++++++- 2 files changed, 90 insertions(+), 14 deletions(-) diff --git a/lib/src/channel_preview.dart b/lib/src/channel_preview.dart index fe602b4a..840ff8c4 100644 --- a/lib/src/channel_preview.dart +++ b/lib/src/channel_preview.dart @@ -220,7 +220,9 @@ class ChannelPreview extends StatelessWidget { } else if (e.type == 'giphy') { return '[GIF]'; } - return null; + return e == lastMessage.attachments.last + ? e.title + : '${e.title}, '; }).where((e) => e != null), lastMessage.text ?? '', ]; @@ -228,22 +230,53 @@ class ChannelPreview extends StatelessWidget { text = parts.join(' '); } - return Text( - text, + return RichText( maxLines: 1, overflow: TextOverflow.ellipsis, - style: - StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( - color: StreamChatTheme.of(context) - .channelPreviewTheme - .subtitle - .color, - fontStyle: (lastMessage.isSystem || lastMessage.isDeleted) - ? FontStyle.italic - : FontStyle.normal, - ), + text: _getDisplayText( + text, + lastMessage.mentionedUsers, + StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( + color: StreamChatTheme.of(context) + .channelPreviewTheme + .subtitle + .color, + fontStyle: (lastMessage.isSystem || lastMessage.isDeleted) + ? FontStyle.italic + : FontStyle.normal), + StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( + color: StreamChatTheme.of(context) + .channelPreviewTheme + .subtitle + .color, + fontStyle: (lastMessage.isSystem || lastMessage.isDeleted) + ? FontStyle.italic + : FontStyle.normal, + fontWeight: FontWeight.bold), + ), ); }, ); } + + TextSpan _getDisplayText(String text, List mentions, + TextStyle normalTextStyle, TextStyle mentionsTextStyle) { + var textList = text.split(' '); + List resList = []; + for (var e in textList) { + if (mentions.any((element) => '@${element.name}' == e)) { + resList.add(TextSpan( + text: '$e ', + style: mentionsTextStyle, + )); + } else { + resList.add(TextSpan( + text: '$e ', + style: normalTextStyle, + )); + } + } + + return TextSpan(children: resList); + } } diff --git a/lib/src/message_search_item.dart b/lib/src/message_search_item.dart index 851659e1..be257578 100644 --- a/lib/src/message_search_item.dart +++ b/lib/src/message_search_item.dart @@ -113,7 +113,9 @@ class MessageSearchItem extends StatelessWidget { } else if (e.type == 'giphy') { return '[GIF]'; } - return null; + return e == message.attachments.last + ? (e.title ?? 'File') + : '${e.title ?? 'File'}, '; }).where((e) => e != null), message.text ?? '', ]; @@ -121,6 +123,26 @@ class MessageSearchItem extends StatelessWidget { text = parts.join(' '); } + return RichText( + maxLines: 1, + overflow: TextOverflow.ellipsis, + text: _getDisplayText( + text, + message.mentionedUsers, + StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( + fontStyle: (message.isSystem || message.isDeleted) + ? FontStyle.italic + : FontStyle.normal, + ), + StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( + fontStyle: (message.isSystem || message.isDeleted) + ? FontStyle.italic + : FontStyle.normal, + fontWeight: FontWeight.bold, + ), + ), + ); + return Text( text, maxLines: 1, @@ -132,4 +154,25 @@ class MessageSearchItem extends StatelessWidget { ), ); } + + TextSpan _getDisplayText(String text, List mentions, + TextStyle normalTextStyle, TextStyle mentionsTextStyle) { + var textList = text.split(' '); + List resList = []; + for (var e in textList) { + if (mentions.any((element) => '@${element.name}' == e)) { + resList.add(TextSpan( + text: '$e ', + style: mentionsTextStyle, + )); + } else { + resList.add(TextSpan( + text: '$e ', + style: normalTextStyle, + )); + } + } + + return TextSpan(children: resList); + } } From fc00acb8906c55e56cd9d82d17d190ba2065e9e8 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 6 Jan 2021 15:19:05 +0530 Subject: [PATCH 02/11] fix for preview --- lib/src/channel_preview.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/channel_preview.dart b/lib/src/channel_preview.dart index 840ff8c4..e325b04a 100644 --- a/lib/src/channel_preview.dart +++ b/lib/src/channel_preview.dart @@ -221,8 +221,8 @@ class ChannelPreview extends StatelessWidget { return '[GIF]'; } return e == lastMessage.attachments.last - ? e.title - : '${e.title}, '; + ? (e.title ?? 'File') + : '${e.title ?? 'File'}, '; }).where((e) => e != null), lastMessage.text ?? '', ]; From a8c60a848288828cb3ceb997bea4df4c307ff08f Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 6 Jan 2021 15:35:15 +0530 Subject: [PATCH 03/11] feat: Added file italics --- lib/src/channel_preview.dart | 18 +++++++++++++++--- lib/src/message_search_item.dart | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/lib/src/channel_preview.dart b/lib/src/channel_preview.dart index e325b04a..122e6a87 100644 --- a/lib/src/channel_preview.dart +++ b/lib/src/channel_preview.dart @@ -222,7 +222,7 @@ class ChannelPreview extends StatelessWidget { } return e == lastMessage.attachments.last ? (e.title ?? 'File') - : '${e.title ?? 'File'}, '; + : '${e.title ?? 'File'} , '; }).where((e) => e != null), lastMessage.text ?? '', ]; @@ -236,6 +236,7 @@ class ChannelPreview extends StatelessWidget { text: _getDisplayText( text, lastMessage.mentionedUsers, + lastMessage.attachments, StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( color: StreamChatTheme.of(context) .channelPreviewTheme @@ -259,8 +260,12 @@ class ChannelPreview extends StatelessWidget { ); } - TextSpan _getDisplayText(String text, List mentions, - TextStyle normalTextStyle, TextStyle mentionsTextStyle) { + TextSpan _getDisplayText( + String text, + List mentions, + List attachments, + TextStyle normalTextStyle, + TextStyle mentionsTextStyle) { var textList = text.split(' '); List resList = []; for (var e in textList) { @@ -269,6 +274,13 @@ class ChannelPreview extends StatelessWidget { text: '$e ', style: mentionsTextStyle, )); + } else if (attachments + .where((e) => e.title != null) + .any((element) => element.title == e)) { + resList.add(TextSpan( + text: '$e ', + style: normalTextStyle.copyWith(fontStyle: FontStyle.italic), + )); } else { resList.add(TextSpan( text: '$e ', diff --git a/lib/src/message_search_item.dart b/lib/src/message_search_item.dart index be257578..62e5f29d 100644 --- a/lib/src/message_search_item.dart +++ b/lib/src/message_search_item.dart @@ -115,7 +115,7 @@ class MessageSearchItem extends StatelessWidget { } return e == message.attachments.last ? (e.title ?? 'File') - : '${e.title ?? 'File'}, '; + : '${e.title ?? 'File'} , '; }).where((e) => e != null), message.text ?? '', ]; @@ -129,6 +129,7 @@ class MessageSearchItem extends StatelessWidget { text: _getDisplayText( text, message.mentionedUsers, + message.attachments, StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( fontStyle: (message.isSystem || message.isDeleted) ? FontStyle.italic @@ -155,8 +156,12 @@ class MessageSearchItem extends StatelessWidget { ); } - TextSpan _getDisplayText(String text, List mentions, - TextStyle normalTextStyle, TextStyle mentionsTextStyle) { + TextSpan _getDisplayText( + String text, + List mentions, + List attachments, + TextStyle normalTextStyle, + TextStyle mentionsTextStyle) { var textList = text.split(' '); List resList = []; for (var e in textList) { @@ -165,6 +170,13 @@ class MessageSearchItem extends StatelessWidget { text: '$e ', style: mentionsTextStyle, )); + } else if (attachments + .where((e) => e.title != null) + .any((element) => element.title == e)) { + resList.add(TextSpan( + text: '$e ', + style: normalTextStyle.copyWith(fontStyle: FontStyle.italic), + )); } else { resList.add(TextSpan( text: '$e ', From 1927a632e08a0c65d712ed91045e49b33c5c2ecd Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 6 Jan 2021 17:00:56 +0530 Subject: [PATCH 04/11] fix: fixed null sometimes popping up --- lib/src/channel_preview.dart | 12 ++++++++---- lib/src/message_search_item.dart | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/src/channel_preview.dart b/lib/src/channel_preview.dart index 122e6a87..1f64f16f 100644 --- a/lib/src/channel_preview.dart +++ b/lib/src/channel_preview.dart @@ -269,14 +269,18 @@ class ChannelPreview extends StatelessWidget { var textList = text.split(' '); List resList = []; for (var e in textList) { - if (mentions.any((element) => '@${element.name}' == e)) { + if (mentions != null && + mentions.isNotEmpty && + mentions.any((element) => '@${element.name}' == e)) { resList.add(TextSpan( text: '$e ', style: mentionsTextStyle, )); - } else if (attachments - .where((e) => e.title != null) - .any((element) => element.title == e)) { + } else if (attachments != null && + attachments.isNotEmpty && + attachments + .where((e) => e.title != null) + .any((element) => element.title == e)) { resList.add(TextSpan( text: '$e ', style: normalTextStyle.copyWith(fontStyle: FontStyle.italic), diff --git a/lib/src/message_search_item.dart b/lib/src/message_search_item.dart index 62e5f29d..35cec093 100644 --- a/lib/src/message_search_item.dart +++ b/lib/src/message_search_item.dart @@ -165,14 +165,18 @@ class MessageSearchItem extends StatelessWidget { var textList = text.split(' '); List resList = []; for (var e in textList) { - if (mentions.any((element) => '@${element.name}' == e)) { + if (mentions != null && + mentions.isNotEmpty && + mentions.any((element) => '@${element.name}' == e)) { resList.add(TextSpan( text: '$e ', style: mentionsTextStyle, )); - } else if (attachments - .where((e) => e.title != null) - .any((element) => element.title == e)) { + } else if (attachments != null && + attachments.isNotEmpty && + attachments + .where((e) => e.title != null) + .any((element) => element.title == e)) { resList.add(TextSpan( text: '$e ', style: normalTextStyle.copyWith(fontStyle: FontStyle.italic), From 9bbad0b9e2b2a098c1b383e560c56324f63029aa Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 6 Jan 2021 17:14:55 +0530 Subject: [PATCH 05/11] fix: fixed extra space error --- lib/src/channel_preview.dart | 2 +- lib/src/message_search_item.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/channel_preview.dart b/lib/src/channel_preview.dart index 1f64f16f..6c8d61fe 100644 --- a/lib/src/channel_preview.dart +++ b/lib/src/channel_preview.dart @@ -287,7 +287,7 @@ class ChannelPreview extends StatelessWidget { )); } else { resList.add(TextSpan( - text: '$e ', + text: e == textList.last ? '$e' : '$e ', style: normalTextStyle, )); } diff --git a/lib/src/message_search_item.dart b/lib/src/message_search_item.dart index 35cec093..a90b82c4 100644 --- a/lib/src/message_search_item.dart +++ b/lib/src/message_search_item.dart @@ -183,7 +183,7 @@ class MessageSearchItem extends StatelessWidget { )); } else { resList.add(TextSpan( - text: '$e ', + text: e == textList.last ? '$e' : '$e ', style: normalTextStyle, )); } From bfc9fc82f6ca85bc690fc08d5f1d35363a5d8e2c Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 6 Jan 2021 17:38:23 +0530 Subject: [PATCH 06/11] fix: Used text.rich instead of richtext to fix test --- lib/src/channel_preview.dart | 8 ++++---- lib/src/message_search_item.dart | 33 +++++++++++--------------------- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/lib/src/channel_preview.dart b/lib/src/channel_preview.dart index 6c8d61fe..d7c1a418 100644 --- a/lib/src/channel_preview.dart +++ b/lib/src/channel_preview.dart @@ -230,10 +230,8 @@ class ChannelPreview extends StatelessWidget { text = parts.join(' '); } - return RichText( - maxLines: 1, - overflow: TextOverflow.ellipsis, - text: _getDisplayText( + return Text.rich( + _getDisplayText( text, lastMessage.mentionedUsers, lastMessage.attachments, @@ -255,6 +253,8 @@ class ChannelPreview extends StatelessWidget { : FontStyle.normal, fontWeight: FontWeight.bold), ), + maxLines: 1, + overflow: TextOverflow.ellipsis, ); }, ); diff --git a/lib/src/message_search_item.dart b/lib/src/message_search_item.dart index a90b82c4..060fcee5 100644 --- a/lib/src/message_search_item.dart +++ b/lib/src/message_search_item.dart @@ -123,36 +123,25 @@ class MessageSearchItem extends StatelessWidget { text = parts.join(' '); } - return RichText( - maxLines: 1, - overflow: TextOverflow.ellipsis, - text: _getDisplayText( + return Text.rich( + _getDisplayText( text, message.mentionedUsers, message.attachments, StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( - fontStyle: (message.isSystem || message.isDeleted) - ? FontStyle.italic - : FontStyle.normal, - ), + fontStyle: (message.isSystem || message.isDeleted) + ? FontStyle.italic + : FontStyle.normal, + ), StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( - fontStyle: (message.isSystem || message.isDeleted) - ? FontStyle.italic - : FontStyle.normal, - fontWeight: FontWeight.bold, - ), + fontStyle: (message.isSystem || message.isDeleted) + ? FontStyle.italic + : FontStyle.normal, + fontWeight: FontWeight.bold, + ), ), - ); - - return Text( - text, maxLines: 1, overflow: TextOverflow.ellipsis, - style: StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( - fontStyle: (message.isSystem || message.isDeleted) - ? FontStyle.italic - : FontStyle.normal, - ), ); } From c9ee6bfb25b933eb5db2ae8864817c32fcd5f2d4 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 6 Jan 2021 17:38:51 +0530 Subject: [PATCH 07/11] darfmt --- lib/src/message_search_item.dart | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/src/message_search_item.dart b/lib/src/message_search_item.dart index 060fcee5..9c951a56 100644 --- a/lib/src/message_search_item.dart +++ b/lib/src/message_search_item.dart @@ -129,16 +129,16 @@ class MessageSearchItem extends StatelessWidget { message.mentionedUsers, message.attachments, StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( - fontStyle: (message.isSystem || message.isDeleted) - ? FontStyle.italic - : FontStyle.normal, - ), + fontStyle: (message.isSystem || message.isDeleted) + ? FontStyle.italic + : FontStyle.normal, + ), StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( - fontStyle: (message.isSystem || message.isDeleted) - ? FontStyle.italic - : FontStyle.normal, - fontWeight: FontWeight.bold, - ), + fontStyle: (message.isSystem || message.isDeleted) + ? FontStyle.italic + : FontStyle.normal, + fontWeight: FontWeight.bold, + ), ), maxLines: 1, overflow: TextOverflow.ellipsis, From ee0cdf567b8719561bfbcde9d692880dc07df180 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 6 Jan 2021 18:33:31 +0530 Subject: [PATCH 08/11] feat: Changed sending indicator icons to svg icons --- lib/src/channel_list_view.dart | 2 ++ lib/src/channel_preview.dart | 3 +-- lib/src/sending_indicator.dart | 6 ++---- lib/src/stream_chat_theme.dart | 34 +++++++++++++++++++--------------- lib/src/stream_svg_icon.dart | 12 ++++++++++++ 5 files changed, 36 insertions(+), 21 deletions(-) diff --git a/lib/src/channel_list_view.dart b/lib/src/channel_list_view.dart index 6c4e967e..4ffe4511 100644 --- a/lib/src/channel_list_view.dart +++ b/lib/src/channel_list_view.dart @@ -157,6 +157,7 @@ class ChannelListView extends StatefulWidget { class _ChannelListViewState extends State with WidgetsBindingObserver { final ScrollController _scrollController = ScrollController(); + final SlidableController _slideController = SlidableController(); @override Widget build(BuildContext context) { @@ -562,6 +563,7 @@ class _ChannelListViewState extends State final backgroundColor = StreamChatTheme.of(context).colorTheme.whiteSmoke; child = Slidable( + controller: _slideController, enabled: widget.swipeToAction, actionPane: SlidableBehindActionPane(), actionExtentRatio: 0.12, diff --git a/lib/src/channel_preview.dart b/lib/src/channel_preview.dart index d7c1a418..c1536653 100644 --- a/lib/src/channel_preview.dart +++ b/lib/src/channel_preview.dart @@ -104,8 +104,7 @@ class ChannelPreview extends StatelessWidget { message: channel.state.lastMessage, size: StreamChatTheme.of(context) .channelPreviewTheme - .lastMessageAt - .fontSize, + .indicatorIconSize, isMessageRead: channel.state.read ?.where((element) => element.user.id != diff --git a/lib/src/sending_indicator.dart b/lib/src/sending_indicator.dart index e3a9df06..83e02bb3 100644 --- a/lib/src/sending_indicator.dart +++ b/lib/src/sending_indicator.dart @@ -17,15 +17,13 @@ class SendingIndicator extends StatelessWidget { @override Widget build(BuildContext context) { if (isMessageRead) { - return Icon( - Icons.done_all_rounded, + return StreamSvgIcon.checkAll( size: size, color: StreamChatTheme.of(context).colorTheme.accentBlue, ); } if (message.status == MessageSendingStatus.SENT || message.status == null) { - return Icon( - Icons.done, + return StreamSvgIcon.check( size: size, color: IconTheme.of(context).color.withOpacity(0.5), ); diff --git a/lib/src/stream_chat_theme.dart b/lib/src/stream_chat_theme.dart index 246459c6..3639d229 100644 --- a/lib/src/stream_chat_theme.dart +++ b/lib/src/stream_chat_theme.dart @@ -227,22 +227,22 @@ class StreamChatThemeData { ), ), channelPreviewTheme: ChannelPreviewTheme( - unreadCounterColor: colorTheme.accentRed, - avatarTheme: AvatarTheme( - borderRadius: BorderRadius.circular(20), - constraints: BoxConstraints.tightFor( - height: 40, - width: 40, + unreadCounterColor: colorTheme.accentRed, + avatarTheme: AvatarTheme( + borderRadius: BorderRadius.circular(20), + constraints: BoxConstraints.tightFor( + height: 40, + width: 40, + ), ), - ), - title: textTheme.bodyBold, - subtitle: textTheme.footnote.copyWith( - color: Color(0xff7A7A7A), - ), - lastMessageAt: textTheme.footnote.copyWith( - color: colorTheme.black.withOpacity(.5), - ), - ), + title: textTheme.bodyBold, + subtitle: textTheme.footnote.copyWith( + color: Color(0xff7A7A7A), + ), + lastMessageAt: textTheme.footnote.copyWith( + color: colorTheme.black.withOpacity(.5), + ), + indicatorIconSize: 16.0), channelTheme: ChannelTheme( messageInputButtonIconTheme: theme.iconTheme.copyWith( color: accentColor, @@ -698,6 +698,7 @@ class ChannelPreviewTheme { final TextStyle lastMessageAt; final AvatarTheme avatarTheme; final Color unreadCounterColor; + final double indicatorIconSize; const ChannelPreviewTheme({ this.title, @@ -705,6 +706,7 @@ class ChannelPreviewTheme { this.lastMessageAt, this.avatarTheme, this.unreadCounterColor, + this.indicatorIconSize, }); ChannelPreviewTheme copyWith({ @@ -713,6 +715,7 @@ class ChannelPreviewTheme { TextStyle lastMessageAt, AvatarTheme avatarTheme, Color unreadCounterColor, + double indicatorIconSize, }) => ChannelPreviewTheme( title: title ?? this.title, @@ -720,6 +723,7 @@ class ChannelPreviewTheme { lastMessageAt: lastMessageAt ?? this.lastMessageAt, avatarTheme: avatarTheme ?? this.avatarTheme, unreadCounterColor: unreadCounterColor ?? this.unreadCounterColor, + indicatorIconSize: indicatorIconSize ?? this.indicatorIconSize, ); } diff --git a/lib/src/stream_svg_icon.dart b/lib/src/stream_svg_icon.dart index e7ef46c3..9c91d9bd 100644 --- a/lib/src/stream_svg_icon.dart +++ b/lib/src/stream_svg_icon.dart @@ -194,6 +194,18 @@ class StreamSvgIcon extends StatelessWidget { ); } + factory StreamSvgIcon.checkAll({ + double size, + Color color, + }) { + return StreamSvgIcon( + assetName: 'Icon_check_all.svg', + color: color, + width: size, + height: size, + ); + } + factory StreamSvgIcon.penWrite({ double size, Color color, From 6f8de144e3047dcb55c2e0fea310a7162ff40a2f Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 6 Jan 2021 18:46:36 +0530 Subject: [PATCH 09/11] fix: Fixed online indicator size --- lib/src/channel_bottom_sheet.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/src/channel_bottom_sheet.dart b/lib/src/channel_bottom_sheet.dart index 21f85430..d03f233c 100644 --- a/lib/src/channel_bottom_sheet.dart +++ b/lib/src/channel_bottom_sheet.dart @@ -73,6 +73,8 @@ class _ChannelBottomSheetState extends State { maxWidth: 64.0, ), borderRadius: BorderRadius.circular(32.0), + onlineIndicatorConstraints: + BoxConstraints.tight(Size(16.0, 16.0)), ), SizedBox( height: 6.0, From 1522f3e50c9b7b5c8af7966fd2bec7d730d9fe6f Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 6 Jan 2021 20:50:07 +0530 Subject: [PATCH 10/11] fix: Fixed separator and added effects to theme --- lib/src/channel_list_view.dart | 15 ++++++-- lib/src/stream_chat_theme.dart | 63 ++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 3 deletions(-) diff --git a/lib/src/channel_list_view.dart b/lib/src/channel_list_view.dart index 4ffe4511..d8e1006b 100644 --- a/lib/src/channel_list_view.dart +++ b/lib/src/channel_list_view.dart @@ -9,6 +9,7 @@ import 'package:stream_chat/stream_chat.dart'; import 'package:stream_chat_flutter/src/channels_bloc.dart'; import 'package:stream_chat_flutter/src/stream_svg_icon.dart'; import 'package:stream_chat_flutter/src/utils.dart'; +import 'dart:ui' as ui; import '../stream_chat_flutter.dart'; import 'channel_bottom_sheet.dart'; @@ -728,9 +729,17 @@ class _ChannelListViewState extends State } Widget _separatorBuilder(context, i) { - return Container( - height: 1, - color: StreamChatTheme.of(context).colorTheme.black.withOpacity(0.08), + var effect = StreamChatTheme.of(context).colorTheme.borderTop; + + return BackdropFilter( + filter: ui.ImageFilter.blur( + sigmaX: effect.sigmaX, + sigmaY: effect.sigmaY, + ), + child: Container( + height: 1, + color: effect.color.withOpacity(0.08), + ), ); } diff --git a/lib/src/stream_chat_theme.dart b/lib/src/stream_chat_theme.dart index 3639d229..760a1061 100644 --- a/lib/src/stream_chat_theme.dart +++ b/lib/src/stream_chat_theme.dart @@ -502,6 +502,10 @@ class ColorTheme { final Color accentBlue; final Color accentRed; final Color accentGreen; + final Effect borderTop; + final Effect borderBottom; + final Effect shadowIconButton; + final Effect modalShadow; ColorTheme.light({ this.black = const Color(0xff000000), @@ -515,6 +519,14 @@ class ColorTheme { this.accentBlue = const Color(0xff005FFF), this.accentRed = const Color(0xffFF3742), this.accentGreen = const Color(0xff20E070), + this.borderTop = const Effect( + sigmaX: 0, sigmaY: -1, color: Color(0xff141924), blur: 0.0), + this.borderBottom = const Effect( + sigmaX: 0, sigmaY: 1, color: Color(0xff141924), blur: 0.0), + this.shadowIconButton = const Effect( + sigmaX: 0, sigmaY: 2, color: Color(0xff000000), alpha: 0.5, blur: 4.0), + this.modalShadow = const Effect( + sigmaX: 0, sigmaY: 0, color: Color(0xff000000), alpha: 1, blur: 8.0), }); ColorTheme.dark({ @@ -529,6 +541,14 @@ class ColorTheme { this.accentBlue = const Color(0xff005FFF), this.accentRed = const Color(0xffFF3742), this.accentGreen = const Color(0xff20E070), + this.borderTop = const Effect( + sigmaX: 0, sigmaY: -1, color: Color(0xff141924), blur: 0.0), + this.borderBottom = const Effect( + sigmaX: 0, sigmaY: 1, color: Color(0xff141924), blur: 0.0), + this.shadowIconButton = const Effect( + sigmaX: 0, sigmaY: 2, color: Color(0xff000000), alpha: 0.5, blur: 4.0), + this.modalShadow = const Effect( + sigmaX: 0, sigmaY: 0, color: Color(0xff000000), alpha: 1, blur: 8.0), }); ColorTheme copyWith({ @@ -544,6 +564,10 @@ class ColorTheme { Color accentBlue, Color accentRed, Color accentGreen, + Effect borderTop, + Effect borderBottom, + Effect shadowIconButton, + Effect modalShadow, }) { return type == ColorThemeType.light ? ColorTheme.light( @@ -558,6 +582,10 @@ class ColorTheme { accentBlue: accentBlue ?? this.accentBlue, accentRed: accentRed ?? this.accentRed, accentGreen: accentGreen ?? this.accentGreen, + borderTop: borderTop ?? this.borderTop, + borderBottom: borderBottom ?? this.borderBottom, + shadowIconButton: shadowIconButton ?? this.shadowIconButton, + modalShadow: modalShadow ?? this.modalShadow, ) : ColorTheme.dark( black: black ?? this.black, @@ -571,6 +599,10 @@ class ColorTheme { accentBlue: accentBlue ?? this.accentBlue, accentRed: accentRed ?? this.accentRed, accentGreen: accentGreen ?? this.accentGreen, + borderTop: borderTop ?? this.borderTop, + borderBottom: borderBottom ?? this.borderBottom, + shadowIconButton: shadowIconButton ?? this.shadowIconButton, + modalShadow: modalShadow ?? this.modalShadow, ); } } @@ -753,3 +785,34 @@ class ChannelHeaderTheme { color: color ?? this.color, ); } + +class Effect { + final double sigmaX; + final double sigmaY; + final Color color; + final double alpha; + final double blur; + + const Effect({ + this.sigmaX, + this.sigmaY, + this.color, + this.alpha, + this.blur, + }); + + Effect copyWith({ + double sigmaX, + double sigmaY, + Color color, + double alpha, + double blur, + }) => + Effect( + sigmaX: sigmaX ?? this.sigmaX, + sigmaY: sigmaY ?? this.sigmaY, + color: color ?? this.color, + alpha: color ?? this.alpha, + blur: blur ?? this.blur, + ); +} From b4b2f26200df1b6459be82380f241b91682368fb Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 6 Jan 2021 20:59:17 +0530 Subject: [PATCH 11/11] Fixed conflicts and added properties to merge() --- lib/src/stream_chat_theme.dart | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/src/stream_chat_theme.dart b/lib/src/stream_chat_theme.dart index b6fdf074..439bd5ef 100644 --- a/lib/src/stream_chat_theme.dart +++ b/lib/src/stream_chat_theme.dart @@ -510,8 +510,8 @@ class ColorTheme { ), this.borderTop = const Effect( sigmaX: 0, sigmaY: -1, color: Color(0xff141924), blur: 0.0), - this.borderBottom = const Effect( - sigmaX: 0, sigmaY: 1, color: Color(0xff141924), blur: 0.0), + this.borderBottom = + const Effect(sigmaX: 0, sigmaY: 1, color: Color(0xff141924), blur: 0.0), this.shadowIconButton = const Effect( sigmaX: 0, sigmaY: 2, color: Color(0xff000000), alpha: 0.5, blur: 4.0), this.modalShadow = const Effect( @@ -532,8 +532,8 @@ class ColorTheme { this.accentGreen = const Color(0xff20E070), this.borderTop = const Effect( sigmaX: 0, sigmaY: -1, color: Color(0xff141924), blur: 0.0), - this.borderBottom = const Effect( - sigmaX: 0, sigmaY: 1, color: Color(0xff141924), blur: 0.0), + this.borderBottom = + const Effect(sigmaX: 0, sigmaY: 1, color: Color(0xff141924), blur: 0.0), this.shadowIconButton = const Effect( sigmaX: 0, sigmaY: 2, color: Color(0xff000000), alpha: 0.5, blur: 4.0), this.modalShadow = const Effect( @@ -634,6 +634,10 @@ class ColorTheme { overlay: other.overlay, overlayDark: other.overlayDark, bgGradient: other.bgGradient, + borderTop: other.borderTop, + borderBottom: other.borderBottom, + shadowIconButton: other.shadowIconButton, + modalShadow: other.modalShadow, ); } }