fix messages order/color

This commit is contained in:
NicKoehler 2023-05-25 12:04:52 +02:00
parent 349b54b4b4
commit 04cfd4ab3f
No known key found for this signature in database
GPG Key ID: 0EC502B679A11DD1

@ -105,43 +105,43 @@ class ChatPage extends StatelessWidget implements PageShape {
), ),
), ),
messageOptions: MessageOptions( messageOptions: MessageOptions(
showOtherUsersAvatar: false, showOtherUsersAvatar: false,
showOtherUsersName: false, showOtherUsersName: false,
textColor: Colors.white, textColor: Colors.white,
maxWidth: constraints.maxWidth * 0.7, maxWidth: constraints.maxWidth * 0.7,
messageTextBuilder: (message, _, __) { messageTextBuilder: (message, _, __) {
final isOwnMessage = final isOwnMessage = message.user.id.isBlank!;
message.user.id == currentUser.id; return Column(
return Column( crossAxisAlignment: isOwnMessage
crossAxisAlignment: isOwnMessage ? CrossAxisAlignment.end
? CrossAxisAlignment.start : CrossAxisAlignment.start,
: CrossAxisAlignment.end, children: <Widget>[
children: <Widget>[ Text(message.text,
Text(message.text, style: TextStyle(color: Colors.white)),
style: TextStyle(color: Colors.white)), Text(
Text( "${message.createdAt.hour}:${message.createdAt.minute.toString().padLeft(2, '0')}",
"${message.createdAt.hour}:${message.createdAt.minute.toString().padLeft(2, '0')}", style: TextStyle(
style: TextStyle( color: Colors.white,
color: Colors.white, fontSize: 8,
fontSize: 8, ),
), ).marginOnly(top: 3),
).marginOnly(top: 3), ],
], );
); },
}, messageDecorationBuilder:
messageDecorationBuilder: (message, __, ___) { (message, previousMessage, nextMessage) {
final isOwnMessage = final isOwnMessage = message.user.id.isBlank!;
message.user.id == currentUser.id; print("message.user.id = ${message.user.id}\n");
return defaultMessageDecoration( return defaultMessageDecoration(
color: isOwnMessage color:
? Colors.blueGrey isOwnMessage ? MyTheme.accent : Colors.blueGrey,
: MyTheme.accent, borderTopLeft: 8,
borderTopLeft: 8, borderTopRight: 8,
borderTopRight: 8, borderBottomRight: isOwnMessage ? 2 : 8,
borderBottomRight: isOwnMessage ? 8 : 2, borderBottomLeft: isOwnMessage ? 8 : 2,
borderBottomLeft: isOwnMessage ? 2 : 8, );
); },
}), ),
); );
return SelectionArea(child: chat); return SelectionArea(child: chat);
}), }),