[Message Widget] Modify read indicator as per new design v2

Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
Sahil Kumar
2020-12-31 14:18:12 +05:30
parent 168630fcad
commit ef0bad1192
3 changed files with 43 additions and 24 deletions
+5 -1
View File
@@ -122,7 +122,11 @@ class ChannelPreview extends StatelessWidget {
padding: const EdgeInsets.only(right: 4.0), padding: const EdgeInsets.only(right: 4.0),
child: SendingIndicator( child: SendingIndicator(
message: channel.state.lastMessage, message: channel.state.lastMessage,
allRead: channel.state.read size: StreamChatTheme.of(context)
.channelPreviewTheme
.lastMessageAt
.fontSize,
isMessageRead: channel.state.read
.where((element) => element.lastRead .where((element) => element.lastRead
.isAfter(channel .isAfter(channel
.state.lastMessage.createdAt)) .state.lastMessage.createdAt))
+29 -16
View File
@@ -228,7 +228,7 @@ class _MessageWidgetState extends State<MessageWidget> {
bool get showTimeStamp => bool get showTimeStamp =>
widget.message.createdAt != null && widget.showTimestamp; widget.message.createdAt != null && widget.showTimestamp;
bool get showReadList => widget.readList?.isNotEmpty == true; bool get isMessageRead => widget.readList?.isNotEmpty == true;
bool get showInChannel => bool get showInChannel =>
widget.showInChannelIndicator && widget.message?.showInChannel == true; widget.showInChannelIndicator && widget.message?.showInChannel == true;
@@ -488,14 +488,14 @@ class _MessageWidgetState extends State<MessageWidget> {
children.addAll([ children.addAll([
if (showSendingIndicator) _buildSendingIndicator(), if (showSendingIndicator) _buildSendingIndicator(),
if (showReadList) // if (showReadList)
SizedBox.fromSize( // SizedBox.fromSize(
size: Size((widget.readList.length * 10.0) + 10, 17), // size: Size((widget.readList.length * 10.0) + 10, 17),
child: Padding( // child: Padding(
padding: const EdgeInsets.only(left: 4.0), // padding: const EdgeInsets.only(left: 4.0),
child: _buildReadIndicator(), // child: _buildReadIndicator(),
), // ),
), // ),
if (showThreadReplyIndicator) if (showThreadReplyIndicator)
InkWell( InkWell(
onTap: widget.onThreadTap != null ? onThreadTap : null, onTap: widget.onThreadTap != null ? onThreadTap : null,
@@ -798,14 +798,27 @@ class _MessageWidgetState extends State<MessageWidget> {
} }
Widget _buildSendingIndicator() { Widget _buildSendingIndicator() {
return Container( final style = widget.messageTheme.createdAt;
height: widget.messageTheme.createdAt.fontSize + 2, Widget child = SendingIndicator(
width: widget.messageTheme.createdAt.fontSize + 2, message: widget.message,
child: SendingIndicator( isMessageRead: isMessageRead,
message: widget.message, size: style.fontSize,
allRead: widget.allRead,
),
); );
if (isMessageRead) {
child = Row(
children: [
Text(
widget.readList.length.toString(),
style: style.copyWith(
color: StreamChatTheme.of(context).accentColor,
),
),
SizedBox(width: 2),
child,
],
);
}
return child;
} }
Widget _buildUserAvatar() => Transform( Widget _buildUserAvatar() => Transform(
+9 -7
View File
@@ -4,27 +4,29 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
/// Used to show the sending status of the message /// Used to show the sending status of the message
class SendingIndicator extends StatelessWidget { class SendingIndicator extends StatelessWidget {
final Message message; final Message message;
final bool allRead; final bool isMessageRead;
final double size;
const SendingIndicator({ const SendingIndicator({
Key key, Key key,
this.message, this.message,
this.allRead = false, this.isMessageRead = false,
this.size = 12,
}) : super(key: key); }) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (allRead) { if (isMessageRead) {
return Icon( return Icon(
Icons.done_all, Icons.done_all_rounded,
size: 8, size: size,
color: StreamChatTheme.of(context).accentColor, color: StreamChatTheme.of(context).accentColor,
); );
} }
if (message.status == MessageSendingStatus.SENT || message.status == null) { if (message.status == MessageSendingStatus.SENT || message.status == null) {
return Icon( return Icon(
Icons.done, Icons.done,
size: 8, size: size,
color: IconTheme.of(context).color.withOpacity(0.5), color: IconTheme.of(context).color.withOpacity(0.5),
); );
} }
@@ -32,7 +34,7 @@ class SendingIndicator extends StatelessWidget {
message.status == MessageSendingStatus.UPDATING) { message.status == MessageSendingStatus.UPDATING) {
return Icon( return Icon(
Icons.access_time, Icons.access_time,
size: 8, size: size,
); );
} }
return SizedBox(); return SizedBox();