add channel muted ui

This commit is contained in:
Salvatore Giordano
2020-07-09 11:15:06 +02:00
parent 67dbac2857
commit a2a5b48928
2 changed files with 83 additions and 59 deletions
+33 -9
View File
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:jiffy/jiffy.dart';
import 'package:line_awesome_icons/line_awesome_icons.dart';
import 'package:stream_chat/stream_chat.dart';
import 'package:stream_chat_flutter/src/unread_indicator.dart';
@@ -42,7 +43,9 @@ class ChannelPreview extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ListTile(
return Opacity(
opacity: channel.isMuted ? 0.5 : 1,
child: ListTile(
onTap: () {
if (onTap != null) {
onTap(channel);
@@ -61,7 +64,8 @@ class ChannelPreview extends StatelessWidget {
children: <Widget>[
Flexible(
child: ChannelName(
textStyle: StreamChatTheme.of(context).channelPreviewTheme.title,
textStyle:
StreamChatTheme.of(context).channelPreviewTheme.title,
),
),
if (channel.state.unreadCount > 0)
@@ -96,6 +100,7 @@ class ChannelPreview extends StatelessWidget {
_buildDate(context),
],
),
),
);
}
@@ -129,15 +134,35 @@ class ChannelPreview extends StatelessWidget {
}
Widget _buildSubtitle(BuildContext context) {
if (channel.isMuted) {
return Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Icon(
LineAwesomeIcons.volume_off,
size: 15,
),
Text(
'Channel is muted',
style: StreamChatTheme.of(context)
.channelPreviewTheme
.subtitle
.copyWith(
color: StreamChatTheme.of(context)
.channelPreviewTheme
.subtitle
.color,
),
),
],
);
}
return TypingIndicator(
channel: channel,
alternativeWidget: _buildLastMessage(context),
style: StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith(
color: StreamChatTheme.of(context)
.channelPreviewTheme
.subtitle
.color
.withOpacity(0.5),
color:
StreamChatTheme.of(context).channelPreviewTheme.subtitle.color,
),
);
}
@@ -186,8 +211,7 @@ class ChannelPreview extends StatelessWidget {
color: StreamChatTheme.of(context)
.channelPreviewTheme
.subtitle
.color
.withOpacity(0.5),
.color,
fontStyle: (lastMessage.isSystem || lastMessage.isDeleted)
? FontStyle.italic
: FontStyle.normal,
+1 -1
View File
@@ -231,7 +231,7 @@ class StreamChatThemeData {
),
subtitle: TextStyle(
fontSize: 12.5,
color: isDark ? Colors.white : Colors.black,
color: (isDark ? Colors.white : Colors.black).withOpacity(0.5),
),
lastMessageAt: TextStyle(
fontSize: 11,