tweak examples
This commit is contained in:
@@ -72,17 +72,30 @@ class ChannelPage extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _messageBuilder(context, message, _) {
|
Widget _messageBuilder(context, message, index) {
|
||||||
final isCurrentUser = StreamChat.of(context).user.id == message.user.id;
|
final isCurrentUser = StreamChat.of(context).user.id == message.user.id;
|
||||||
final textAlign = isCurrentUser ? TextAlign.right : TextAlign.left;
|
final textAlign = isCurrentUser ? TextAlign.right : TextAlign.left;
|
||||||
return ListTile(
|
final color = isCurrentUser ? Colors.blueGrey : Colors.blue;
|
||||||
title: Text(
|
|
||||||
message.text,
|
return Padding(
|
||||||
textAlign: textAlign,
|
padding: EdgeInsets.all(5.0),
|
||||||
),
|
child: Container(
|
||||||
subtitle: Text(
|
decoration: BoxDecoration(
|
||||||
message.user.extraData['name'],
|
border: Border.all(color: color, width: 1),
|
||||||
textAlign: textAlign,
|
borderRadius: BorderRadius.all(
|
||||||
|
Radius.circular(5.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: ListTile(
|
||||||
|
title: Text(
|
||||||
|
message.text,
|
||||||
|
textAlign: textAlign,
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
message.user.extraData['name'],
|
||||||
|
textAlign: textAlign,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,13 +51,24 @@ class ChannelListPage extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _channelPreviewBuilder(BuildContext context, Channel channel) {
|
Widget _channelPreviewBuilder(BuildContext context, Channel channel) {
|
||||||
|
final lastMessage = channel.state.messages.reversed
|
||||||
|
.firstWhere((message) => message.type != "deleted");
|
||||||
|
|
||||||
|
final subtitle = (lastMessage == null ? "nothing yet" : lastMessage.text);
|
||||||
|
final opacity = channel.state.unreadCount > .0 ? 1.0 : 0.5;
|
||||||
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: ChannelImage(
|
leading: ChannelImage(
|
||||||
channel: channel,
|
channel: channel,
|
||||||
),
|
),
|
||||||
title: ChannelName(
|
title: ChannelName(
|
||||||
channel: channel,
|
channel: channel,
|
||||||
|
textStyle:
|
||||||
|
StreamChatTheme.of(context).channelPreviewTheme.title.copyWith(
|
||||||
|
color: Colors.black.withOpacity(opacity),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
subtitle: Text(subtitle),
|
||||||
trailing: channel.state.unreadCount > 0
|
trailing: channel.state.unreadCount > 0
|
||||||
? CircleAvatar(
|
? CircleAvatar(
|
||||||
radius: 10,
|
radius: 10,
|
||||||
|
|||||||
Reference in New Issue
Block a user