refactoring

This commit is contained in:
Salvatore Giordano
2021-05-10 09:21:31 +02:00
parent fff82c8455
commit 43d5e9063e
6 changed files with 172 additions and 223 deletions
@@ -104,6 +104,7 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final channel = StreamChannel.of(context).channel; final channel = StreamChannel.of(context).channel;
final chatThemeData = StreamChatTheme.of(context);
final leadingWidget = leading ?? final leadingWidget = leading ??
(showBackButton (showBackButton
@@ -139,26 +140,18 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget {
brightness: Theme.of(context).brightness, brightness: Theme.of(context).brightness,
elevation: 1, elevation: 1,
leading: leadingWidget, leading: leadingWidget,
backgroundColor: StreamChatTheme.of(context) backgroundColor:
.channelTheme chatThemeData.channelTheme.channelHeaderTheme.color,
.channelHeaderTheme
.color,
actions: actions ?? actions: actions ??
<Widget>[ <Widget>[
Padding( Padding(
padding: const EdgeInsets.only(right: 10), padding: const EdgeInsets.only(right: 10),
child: Center( child: Center(
child: ChannelImage( child: ChannelImage(
borderRadius: StreamChatTheme.of(context) borderRadius: chatThemeData.channelTheme
.channelTheme .channelHeaderTheme.avatarTheme?.borderRadius,
.channelHeaderTheme constraints: chatThemeData.channelTheme
.avatarTheme .channelHeaderTheme.avatarTheme?.constraints,
?.borderRadius,
constraints: StreamChatTheme.of(context)
.channelTheme
.channelHeaderTheme
.avatarTheme
?.constraints,
onTap: onImageTap, onTap: onImageTap,
), ),
), ),
@@ -175,20 +168,16 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget {
children: <Widget>[ children: <Widget>[
title ?? title ??
ChannelName( ChannelName(
textStyle: StreamChatTheme.of(context) textStyle: chatThemeData
.channelTheme .channelTheme.channelHeaderTheme.title,
.channelHeaderTheme
.title,
), ),
const SizedBox(height: 2), const SizedBox(height: 2),
subtitle ?? subtitle ??
ChannelInfo( ChannelInfo(
showTypingIndicator: showTypingIndicator, showTypingIndicator: showTypingIndicator,
channel: channel, channel: channel,
textStyle: StreamChatTheme.of(context) textStyle: chatThemeData
.channelTheme .channelTheme.channelHeaderTheme.subtitle,
.channelHeaderTheme
.subtitle,
), ),
], ],
), ),
@@ -88,6 +88,7 @@ class ChannelImage extends StatelessWidget {
initialData: channel.extraData, initialData: channel.extraData,
builder: (context, snapshot) { builder: (context, snapshot) {
String? image; String? image;
final chatThemeData = StreamChatTheme.of(context);
if (snapshot.data!.containsKey('image') == true) { if (snapshot.data!.containsKey('image') == true) {
image = snapshot.data!['image']; image = snapshot.data!['image'];
} else if (channel.state?.members.length == 2) { } else if (channel.state?.members.length == 2) {
@@ -99,20 +100,16 @@ class ChannelImage extends StatelessWidget {
initialData: otherMember!.user, initialData: otherMember!.user,
builder: (context, snapshot) => UserAvatar( builder: (context, snapshot) => UserAvatar(
borderRadius: borderRadius ?? borderRadius: borderRadius ??
StreamChatTheme.of(context) chatThemeData
.channelPreviewTheme .channelPreviewTheme.avatarTheme?.borderRadius,
.avatarTheme
?.borderRadius,
user: snapshot.data ?? otherMember.user!, user: snapshot.data ?? otherMember.user!,
constraints: constraints ?? constraints: constraints ??
StreamChatTheme.of(context) chatThemeData
.channelPreviewTheme .channelPreviewTheme.avatarTheme?.constraints,
.avatarTheme
?.constraints,
onTap: onTap != null ? (_) => onTap!() : null, onTap: onTap != null ? (_) => onTap!() : null,
selected: selected, selected: selected,
selectionColor: selectionColor ?? selectionColor:
StreamChatTheme.of(context).colorTheme.accentBlue, selectionColor ?? chatThemeData.colorTheme.accentBlue,
selectionThickness: selectionThickness, selectionThickness: selectionThickness,
)); ));
} else { } else {
@@ -127,37 +124,25 @@ class ChannelImage extends StatelessWidget {
return GroupImage( return GroupImage(
images: images ?? [], images: images ?? [],
borderRadius: borderRadius ?? borderRadius: borderRadius ??
StreamChatTheme.of(context) chatThemeData.channelPreviewTheme.avatarTheme?.borderRadius,
.channelPreviewTheme
.avatarTheme
?.borderRadius,
constraints: constraints ?? constraints: constraints ??
StreamChatTheme.of(context) chatThemeData.channelPreviewTheme.avatarTheme?.constraints,
.channelPreviewTheme
.avatarTheme
?.constraints,
onTap: onTap, onTap: onTap,
selected: selected, selected: selected,
selectionColor: selectionColor ?? selectionColor:
StreamChatTheme.of(context).colorTheme.accentBlue, selectionColor ?? chatThemeData.colorTheme.accentBlue,
selectionThickness: selectionThickness, selectionThickness: selectionThickness,
); );
} }
Widget child = ClipRRect( Widget child = ClipRRect(
borderRadius: borderRadius ?? borderRadius: borderRadius ??
StreamChatTheme.of(context) chatThemeData.channelPreviewTheme.avatarTheme?.borderRadius,
.channelPreviewTheme
.avatarTheme
?.borderRadius,
child: Container( child: Container(
constraints: constraints ?? constraints: constraints ??
StreamChatTheme.of(context) chatThemeData.channelPreviewTheme.avatarTheme?.constraints,
.channelPreviewTheme
.avatarTheme
?.constraints,
decoration: BoxDecoration( decoration: BoxDecoration(
color: StreamChatTheme.of(context).colorTheme.accentBlue, color: chatThemeData.colorTheme.accentBlue,
), ),
child: Stack( child: Stack(
alignment: Alignment.center, alignment: Alignment.center,
@@ -172,7 +157,7 @@ class ChannelImage extends StatelessWidget {
? snapshot.data!['name'][0] ? snapshot.data!['name'][0]
: '', : '',
style: TextStyle( style: TextStyle(
color: StreamChatTheme.of(context).colorTheme.white, color: chatThemeData.colorTheme.white,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
@@ -180,7 +165,7 @@ class ChannelImage extends StatelessWidget {
fit: BoxFit.cover, fit: BoxFit.cover,
) )
else else
StreamChatTheme.of(context).defaultChannelImage( chatThemeData.defaultChannelImage(
context, context,
channel, channel,
), ),
@@ -198,20 +183,13 @@ class ChannelImage extends StatelessWidget {
child = ClipRRect( child = ClipRRect(
key: const Key('selectedImage'), key: const Key('selectedImage'),
borderRadius: (borderRadius ?? borderRadius: (borderRadius ??
StreamChatTheme.of(context) chatThemeData.ownMessageTheme.avatarTheme?.borderRadius ??
.ownMessageTheme
.avatarTheme
?.borderRadius ??
BorderRadius.zero) + BorderRadius.zero) +
BorderRadius.circular(selectionThickness), BorderRadius.circular(selectionThickness),
child: Container( child: Container(
constraints: constraints ?? constraints: constraints ??
StreamChatTheme.of(context) chatThemeData.ownMessageTheme.avatarTheme?.constraints,
.ownMessageTheme color: selectionColor ?? chatThemeData.colorTheme.accentBlue,
.avatarTheme
?.constraints,
color: selectionColor ??
StreamChatTheme.of(context).colorTheme.accentBlue,
child: Padding( child: Padding(
padding: EdgeInsets.all(selectionThickness), padding: EdgeInsets.all(selectionThickness),
child: child, child: child,
@@ -46,7 +46,9 @@ class ChannelInfo extends StatelessWidget {
} }
Widget _buildConnectedTitleState( Widget _buildConnectedTitleState(
BuildContext context, List<Member>? members) { BuildContext context,
List<Member>? members,
) {
Widget? alternativeWidget; Widget? alternativeWidget;
if (channel.memberCount != null && channel.memberCount! > 2) { if (channel.memberCount != null && channel.memberCount! > 2) {
@@ -61,8 +63,9 @@ class ChannelInfo extends StatelessWidget {
.subtitle, .subtitle,
); );
} else { } else {
final userId = StreamChat.of(context).user?.id;
final otherMember = members?.firstWhereOrNull( final otherMember = members?.firstWhereOrNull(
(element) => element.userId != StreamChat.of(context).user?.id, (element) => element.userId != userId,
); );
if (otherMember != null) { if (otherMember != null) {
@@ -114,6 +114,7 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget {
break; break;
} }
final chatThemeData = StreamChatTheme.of(context);
return InfoTile( return InfoTile(
// ignore: avoid_bool_literals_in_conditional_expressions // ignore: avoid_bool_literals_in_conditional_expressions
showMessage: showConnectionStateTile ? showStatus : false, showMessage: showConnectionStateTile ? showStatus : false,
@@ -121,8 +122,7 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget {
child: AppBar( child: AppBar(
brightness: Theme.of(context).brightness, brightness: Theme.of(context).brightness,
elevation: 1, elevation: 1,
backgroundColor: backgroundColor: chatThemeData.channelListHeaderTheme.color,
StreamChatTheme.of(context).channelListHeaderTheme.color,
centerTitle: true, centerTitle: true,
leading: leading ?? leading: leading ??
Center( Center(
@@ -137,14 +137,10 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget {
} }
Scaffold.of(context).openDrawer(); Scaffold.of(context).openDrawer();
}, },
borderRadius: StreamChatTheme.of(context) borderRadius: chatThemeData
.channelListHeaderTheme .channelListHeaderTheme.avatarTheme?.borderRadius,
.avatarTheme constraints: chatThemeData
?.borderRadius, .channelListHeaderTheme.avatarTheme?.constraints,
constraints: StreamChatTheme.of(context)
.channelListHeaderTheme
.avatarTheme
?.constraints,
) )
: const Offstage(), : const Offstage(),
), ),
@@ -157,9 +153,7 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget {
Color? color; Color? color;
switch (status) { switch (status) {
case ConnectionStatus.connected: case ConnectionStatus.connected:
color = StreamChatTheme.of(context) color = chatThemeData.colorTheme.accentBlue;
.colorTheme
.accentBlue;
break; break;
case ConnectionStatus.connecting: case ConnectionStatus.connecting:
color = Colors.grey; color = Colors.grey;
@@ -209,12 +203,15 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget {
); );
} }
Widget _buildConnectedTitleState(BuildContext context) => Text( Widget _buildConnectedTitleState(BuildContext context) {
'Stream Chat', final chatThemeData = StreamChatTheme.of(context);
style: StreamChatTheme.of(context).textTheme.headlineBold.copyWith( return Text(
color: StreamChatTheme.of(context).colorTheme.black, 'Stream Chat',
), style: chatThemeData.textTheme.headlineBold.copyWith(
); color: chatThemeData.colorTheme.black,
),
);
}
Widget _buildConnectingTitleState(BuildContext context) => Row( Widget _buildConnectingTitleState(BuildContext context) => Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@@ -243,39 +240,35 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget {
Widget _buildDisconnectedTitleState( Widget _buildDisconnectedTitleState(
BuildContext context, BuildContext context,
StreamChatClient client, StreamChatClient client,
) => ) {
Row( final chatThemeData = StreamChatTheme.of(context);
mainAxisAlignment: MainAxisAlignment.center, return Row(
children: [ mainAxisAlignment: MainAxisAlignment.center,
Text( children: [
'Offline...', Text(
style: StreamChatTheme.of(context) 'Offline...',
.channelListHeaderTheme style: chatThemeData.channelListHeaderTheme.title?.copyWith(
.title fontSize: 16,
?.copyWith( fontWeight: FontWeight.bold,
fontSize: 16,
fontWeight: FontWeight.bold,
),
), ),
TextButton( ),
onPressed: () async { TextButton(
await client.disconnect(); onPressed: () async {
await client.connect(); await client.disconnect();
}, await client.connect();
child: Text( },
'Try Again', child: Text(
style: StreamChatTheme.of(context) 'Try Again',
.channelListHeaderTheme style: chatThemeData.channelListHeaderTheme.title?.copyWith(
.title fontSize: 16,
?.copyWith( fontWeight: FontWeight.bold,
fontSize: 16, color: chatThemeData.colorTheme.accentBlue,
fontWeight: FontWeight.bold,
color: StreamChatTheme.of(context).colorTheme.accentBlue,
),
), ),
), ),
], ),
); ],
);
}
@override @override
Size get preferredSize => const Size.fromHeight(kToolbarHeight); Size get preferredSize => const Size.fromHeight(kToolbarHeight);
@@ -237,78 +237,70 @@ class _ChannelListViewState extends State<ChannelListView> {
} }
Widget _buildEmptyWidget(BuildContext context) => LayoutBuilder( Widget _buildEmptyWidget(BuildContext context) => LayoutBuilder(
builder: (context, viewportConstraints) => SingleChildScrollView( builder: (context, viewportConstraints) {
physics: const AlwaysScrollableScrollPhysics(), final chatThemeData = StreamChatTheme.of(context);
child: Stack( return SingleChildScrollView(
children: [ physics: const AlwaysScrollableScrollPhysics(),
ConstrainedBox( child: Stack(
constraints: BoxConstraints( children: [
minHeight: viewportConstraints.maxHeight, ConstrainedBox(
constraints: BoxConstraints(
minHeight: viewportConstraints.maxHeight,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(8),
child: StreamSvgIcon.message(
size: 136,
color: chatThemeData.colorTheme.greyGainsboro,
),
),
Padding(
padding: const EdgeInsets.all(8),
child: Text(
'Lets start chatting!',
style: chatThemeData.textTheme.headline,
),
),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 8,
horizontal: 52,
),
child: Text(
'How about sending your first message to a friend?',
textAlign: TextAlign.center,
style: chatThemeData.textTheme.body.copyWith(
color: chatThemeData.colorTheme.grey,
),
),
),
],
),
), ),
child: Column( if (widget.onStartChatPressed != null)
mainAxisAlignment: MainAxisAlignment.center, Positioned(
children: [ right: 0,
Padding( left: 0,
padding: const EdgeInsets.all(8), bottom: 32,
child: StreamSvgIcon.message( child: Center(
size: 136, child: TextButton(
color: StreamChatTheme.of(context) onPressed: widget.onStartChatPressed,
.colorTheme child: Text(
.greyGainsboro, 'Start a chat',
), style: chatThemeData.textTheme.bodyBold.copyWith(
), color: chatThemeData.colorTheme.accentBlue,
Padding( ),
padding: const EdgeInsets.all(8), ),
child: Text(
'Lets start chatting!',
style: StreamChatTheme.of(context).textTheme.headline,
),
),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 8,
horizontal: 52,
),
child: Text(
'How about sending your first message to a friend?',
textAlign: TextAlign.center,
style: StreamChatTheme.of(context)
.textTheme
.body
.copyWith(
color:
StreamChatTheme.of(context).colorTheme.grey,
),
),
),
],
),
),
if (widget.onStartChatPressed != null)
Positioned(
right: 0,
left: 0,
bottom: 32,
child: Center(
child: TextButton(
onPressed: widget.onStartChatPressed,
child: Text(
'Start a chat',
style: StreamChatTheme.of(context)
.textTheme
.bodyBold
.copyWith(
color: StreamChatTheme.of(context)
.colorTheme
.accentBlue,
),
), ),
), ),
), ),
), ],
], ),
), );
), },
); );
Widget _buildLoadingWidget(BuildContext context) => ListView( Widget _buildLoadingWidget(BuildContext context) => ListView(
@@ -331,10 +323,11 @@ class _ChannelListViewState extends State<ChannelListView> {
); );
Shimmer _buildLoadingItem(BuildContext context) { Shimmer _buildLoadingItem(BuildContext context) {
final chatThemeData = StreamChatTheme.of(context);
if (widget.crossAxisCount > 1) { if (widget.crossAxisCount > 1) {
return Shimmer.fromColors( return Shimmer.fromColors(
baseColor: StreamChatTheme.of(context).colorTheme.greyGainsboro, baseColor: chatThemeData.colorTheme.greyGainsboro,
highlightColor: StreamChatTheme.of(context).colorTheme.whiteSmoke, highlightColor: chatThemeData.colorTheme.whiteSmoke,
child: Column( child: Column(
children: [ children: [
const SizedBox(height: 4), const SizedBox(height: 4),
@@ -362,12 +355,12 @@ class _ChannelListViewState extends State<ChannelListView> {
); );
} else { } else {
return Shimmer.fromColors( return Shimmer.fromColors(
baseColor: StreamChatTheme.of(context).colorTheme.greyGainsboro, baseColor: chatThemeData.colorTheme.greyGainsboro,
highlightColor: StreamChatTheme.of(context).colorTheme.whiteSmoke, highlightColor: chatThemeData.colorTheme.whiteSmoke,
child: ListTile( child: ListTile(
leading: Container( leading: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: StreamChatTheme.of(context).colorTheme.white, color: chatThemeData.colorTheme.white,
shape: BoxShape.circle, shape: BoxShape.circle,
), ),
constraints: const BoxConstraints.tightFor( constraints: const BoxConstraints.tightFor(
@@ -383,7 +376,7 @@ class _ChannelListViewState extends State<ChannelListView> {
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: StreamChatTheme.of(context).colorTheme.white, color: chatThemeData.colorTheme.white,
borderRadius: BorderRadius.circular(11), borderRadius: BorderRadius.circular(11),
), ),
constraints: const BoxConstraints.tightFor( constraints: const BoxConstraints.tightFor(
@@ -400,7 +393,7 @@ class _ChannelListViewState extends State<ChannelListView> {
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: StreamChatTheme.of(context).colorTheme.white, color: chatThemeData.colorTheme.white,
borderRadius: BorderRadius.circular(11), borderRadius: BorderRadius.circular(11),
), ),
constraints: const BoxConstraints.expand( constraints: const BoxConstraints.expand(
@@ -412,7 +405,7 @@ class _ChannelListViewState extends State<ChannelListView> {
Container( Container(
margin: const EdgeInsets.only(left: 16), margin: const EdgeInsets.only(left: 16),
decoration: BoxDecoration( decoration: BoxDecoration(
color: StreamChatTheme.of(context).colorTheme.white, color: chatThemeData.colorTheme.white,
borderRadius: BorderRadius.circular(11), borderRadius: BorderRadius.circular(11),
), ),
constraints: const BoxConstraints.tightFor( constraints: const BoxConstraints.tightFor(
@@ -456,12 +449,13 @@ class _ChannelListViewState extends State<ChannelListView> {
); );
Widget _listItemBuilder(BuildContext context, int i, List<Channel> channels) { Widget _listItemBuilder(BuildContext context, int i, List<Channel> channels) {
final channelsProvider = ChannelsBloc.of(context); final channelsBloc = ChannelsBloc.of(context);
if (i < channels.length) { if (i < channels.length) {
final channel = channels[i]; final channel = channels[i];
final onTap = _getChannelTap(context); final onTap = _getChannelTap(context);
final backgroundColor = StreamChatTheme.of(context).colorTheme.whiteSmoke; final chatThemeData = StreamChatTheme.of(context);
final backgroundColor = chatThemeData.colorTheme.whiteSmoke;
return StreamChannel( return StreamChannel(
key: ValueKey<String>('CHANNEL-${channel.id}'), key: ValueKey<String>('CHANNEL-${channel.id}'),
channel: channel, channel: channel,
@@ -506,7 +500,7 @@ class _ChannelListViewState extends State<ChannelListView> {
IconSlideAction( IconSlideAction(
color: backgroundColor, color: backgroundColor,
iconWidget: StreamSvgIcon.delete( iconWidget: StreamSvgIcon.delete(
color: StreamChatTheme.of(context).colorTheme.accentRed, color: chatThemeData.colorTheme.accentRed,
), ),
onTap: () async { onTap: () async {
final res = await showConfirmationDialog( final res = await showConfirmationDialog(
@@ -517,7 +511,7 @@ class _ChannelListViewState extends State<ChannelListView> {
'Are you sure you want to delete this conversation?', 'Are you sure you want to delete this conversation?',
cancelText: 'CANCEL', cancelText: 'CANCEL',
icon: StreamSvgIcon.delete( icon: StreamSvgIcon.delete(
color: StreamChatTheme.of(context).colorTheme.accentRed, color: chatThemeData.colorTheme.accentRed,
), ),
); );
if (res == true) { if (res == true) {
@@ -527,7 +521,7 @@ class _ChannelListViewState extends State<ChannelListView> {
), ),
], ],
child: Container( child: Container(
color: StreamChatTheme.of(context).colorTheme.whiteSnow, color: chatThemeData.colorTheme.whiteSnow,
child: widget.channelPreviewBuilder?.call(context, channel) ?? child: widget.channelPreviewBuilder?.call(context, channel) ??
ChannelPreview( ChannelPreview(
onLongPress: widget.onChannelLongPress, onLongPress: widget.onChannelLongPress,
@@ -540,7 +534,7 @@ class _ChannelListViewState extends State<ChannelListView> {
), ),
); );
} else { } else {
return _buildQueryProgressIndicator(context, channelsProvider); return _buildQueryProgressIndicator(context, channelsBloc);
} }
} }
@@ -68,6 +68,8 @@ class ChannelPreview extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final channelPreviewTheme = StreamChatTheme.of(context).channelPreviewTheme; final channelPreviewTheme = StreamChatTheme.of(context).channelPreviewTheme;
final streamChatState = StreamChat.of(context);
return StreamBuilder<bool>( return StreamBuilder<bool>(
stream: channel.isMutedStream, stream: channel.isMutedStream,
initialData: channel.isMuted, initialData: channel.isMuted,
@@ -130,7 +132,7 @@ class ChannelPreview extends StatelessWidget {
(m) => !m.isDeleted && m.shadowed != true, (m) => !m.isDeleted && m.shadowed != true,
); );
if (lastMessage?.user?.id == if (lastMessage?.user?.id ==
StreamChat.of(context).user?.id) { streamChatState.user?.id) {
return Padding( return Padding(
padding: const EdgeInsets.only(right: 4), padding: const EdgeInsets.only(right: 4),
child: SendingIndicator( child: SendingIndicator(
@@ -194,6 +196,7 @@ class ChannelPreview extends StatelessWidget {
); );
Widget _buildSubtitle(BuildContext context) { Widget _buildSubtitle(BuildContext context) {
final chatThemeData = StreamChatTheme.of(context);
if (channel.isMuted) { if (channel.isMuted) {
return Row( return Row(
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
@@ -203,7 +206,7 @@ class ChannelPreview extends StatelessWidget {
), ),
Text( Text(
' Channel is muted', ' Channel is muted',
style: StreamChatTheme.of(context).channelPreviewTheme.subtitle, style: chatThemeData.channelPreviewTheme.subtitle,
), ),
], ],
); );
@@ -211,7 +214,7 @@ class ChannelPreview extends StatelessWidget {
return TypingIndicator( return TypingIndicator(
channel: channel, channel: channel,
alternativeWidget: _buildLastMessage(context), alternativeWidget: _buildLastMessage(context),
style: StreamChatTheme.of(context).channelPreviewTheme.subtitle, style: chatThemeData.channelPreviewTheme.subtitle,
); );
} }
@@ -245,35 +248,24 @@ class ChannelPreview extends StatelessWidget {
text = parts.join(' '); text = parts.join(' ');
final chatThemeData = StreamChatTheme.of(context);
return Text.rich( return Text.rich(
_getDisplayText( _getDisplayText(
text, text,
lastMessage.mentionedUsers, lastMessage.mentionedUsers,
lastMessage.attachments, lastMessage.attachments,
StreamChatTheme.of(context) chatThemeData.channelPreviewTheme.subtitle?.copyWith(
.channelPreviewTheme color: chatThemeData.channelPreviewTheme.subtitle?.color,
.subtitle fontStyle: (lastMessage.isSystem || lastMessage.isDeleted)
?.copyWith( ? FontStyle.italic
color: StreamChatTheme.of(context) : FontStyle.normal),
.channelPreviewTheme chatThemeData.channelPreviewTheme.subtitle?.copyWith(
.subtitle color: chatThemeData.channelPreviewTheme.subtitle?.color,
?.color, fontStyle: (lastMessage.isSystem || lastMessage.isDeleted)
fontStyle: (lastMessage.isSystem || lastMessage.isDeleted) ? FontStyle.italic
? FontStyle.italic : FontStyle.normal,
: FontStyle.normal), fontWeight: FontWeight.bold,
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,
),
), ),
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,