removed useless container and sendOnEnter

This commit is contained in:
NicKoehler 2023-06-08 12:51:13 +02:00
parent 4e00945a5d
commit 92fada0c8e
No known key found for this signature in database
GPG Key ID: 0EC502B679A11DD1

View File

@ -50,113 +50,102 @@ class ChatPage extends StatelessWidget implements PageShape {
child: Consumer<ChatModel>( child: Consumer<ChatModel>(
builder: (context, chatModel, child) { builder: (context, chatModel, child) {
final currentUser = chatModel.currentUser; final currentUser = chatModel.currentUser;
return Container( return Stack(
padding: EdgeInsets.symmetric(vertical: 5.0), children: [
decoration: BoxDecoration( LayoutBuilder(builder: (context, constraints) {
borderRadius: BorderRadius.circular(10.0), final chat = DashChat(
color: Theme.of(context).colorScheme.background, onSend: (chatMsg) {
), chatModel.send(chatMsg);
child: Stack( chatModel.inputNode.requestFocus();
children: [ },
LayoutBuilder(builder: (context, constraints) { currentUser: chatModel.me,
final chat = DashChat( messages:
onSend: (chatMsg) { chatModel.messages[chatModel.currentID]?.chatMessages ??
chatModel.send(chatMsg); [],
chatModel.inputNode.requestFocus(); inputOptions: InputOptions(
}, focusNode: chatModel.inputNode,
currentUser: chatModel.me, inputTextStyle: TextStyle(
messages: chatModel fontSize: 14,
.messages[chatModel.currentID]?.chatMessages ?? color: Theme.of(context).textTheme.titleLarge?.color),
[], inputDecoration: InputDecoration(
inputOptions: InputOptions( isDense: true,
sendOnEnter: true, hintText: translate('Write a message'),
focusNode: chatModel.inputNode, filled: true,
inputTextStyle: TextStyle( fillColor: Theme.of(context).colorScheme.background,
fontSize: 14, contentPadding: EdgeInsets.all(10),
color: border: OutlineInputBorder(
Theme.of(context).textTheme.titleLarge?.color), borderRadius: BorderRadius.circular(10.0),
inputDecoration: InputDecoration( borderSide: const BorderSide(
isDense: true, width: 1,
hintText: translate('Write a message'), style: BorderStyle.solid,
filled: true,
fillColor: Theme.of(context).colorScheme.background,
contentPadding: EdgeInsets.all(10),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
borderSide: const BorderSide(
width: 1,
style: BorderStyle.solid,
),
), ),
), ),
sendButtonBuilder: defaultSendButton(
padding:
EdgeInsets.symmetric(horizontal: 6, vertical: 0),
color: MyTheme.accent,
icon: Icons.send_rounded,
),
), ),
messageOptions: MessageOptions( sendButtonBuilder: defaultSendButton(
showOtherUsersAvatar: false, padding:
showOtherUsersName: false, EdgeInsets.symmetric(horizontal: 6, vertical: 0),
textColor: Colors.white, color: MyTheme.accent,
maxWidth: constraints.maxWidth * 0.7, icon: Icons.send_rounded,
messageTextBuilder: (message, _, __) {
final isOwnMessage = message.user.id.isBlank!;
return Column(
crossAxisAlignment: isOwnMessage
? CrossAxisAlignment.end
: CrossAxisAlignment.start,
children: <Widget>[
Text(message.text,
style: TextStyle(color: Colors.white)),
Text(
"${message.createdAt.hour}:${message.createdAt.minute.toString().padLeft(2, '0')}",
style: TextStyle(
color: Colors.white,
fontSize: 8,
),
).marginOnly(top: 3),
],
);
},
messageDecorationBuilder:
(message, previousMessage, nextMessage) {
final isOwnMessage = message.user.id.isBlank!;
print("message.user.id = ${message.user.id}\n");
return defaultMessageDecoration(
color:
isOwnMessage ? MyTheme.accent : Colors.blueGrey,
borderTopLeft: 8,
borderTopRight: 8,
borderBottomRight: isOwnMessage ? 2 : 8,
borderBottomLeft: isOwnMessage ? 8 : 2,
);
},
), ),
); ),
return SelectionArea(child: chat); messageOptions: MessageOptions(
}), showOtherUsersAvatar: false,
desktopType == DesktopType.cm || showOtherUsersName: false,
chatModel.currentID == ChatModel.clientModeID textColor: Colors.white,
? SizedBox.shrink() maxWidth: constraints.maxWidth * 0.7,
: Padding( messageTextBuilder: (message, _, __) {
padding: EdgeInsets.all(12), final isOwnMessage = message.user.id.isBlank!;
child: Row( return Column(
children: [ crossAxisAlignment: isOwnMessage
Icon(Icons.account_circle, ? CrossAxisAlignment.end
color: MyTheme.accent80), : CrossAxisAlignment.start,
SizedBox(width: 5), children: <Widget>[
Text( Text(message.text,
"${currentUser.firstName} ${currentUser.id}", style: TextStyle(color: Colors.white)),
style: TextStyle(color: MyTheme.accent), Text(
"${message.createdAt.hour}:${message.createdAt.minute.toString().padLeft(2, '0')}",
style: TextStyle(
color: Colors.white,
fontSize: 8,
), ),
], ).marginOnly(top: 3),
), ],
);
},
messageDecorationBuilder:
(message, previousMessage, nextMessage) {
final isOwnMessage = message.user.id.isBlank!;
return defaultMessageDecoration(
color:
isOwnMessage ? MyTheme.accent : Colors.blueGrey,
borderTopLeft: 8,
borderTopRight: 8,
borderBottomRight: isOwnMessage ? 2 : 8,
borderBottomLeft: isOwnMessage ? 8 : 2,
);
},
),
);
return SelectionArea(child: chat);
}),
desktopType == DesktopType.cm ||
chatModel.currentID == ChatModel.clientModeID
? SizedBox.shrink()
: Padding(
padding: EdgeInsets.all(12),
child: Row(
children: [
Icon(Icons.account_circle, color: MyTheme.accent80),
SizedBox(width: 5),
Text(
"${currentUser.firstName} ${currentUser.id}",
style: TextStyle(color: MyTheme.accent),
),
],
), ),
], ),
), ],
); ).paddingOnly(bottom: 8);
}, },
), ),
), ),