Refine message composer layout

This commit is contained in:
Janez T
2026-03-07 08:31:09 +01:00
parent b0eded3780
commit bb1c1f455d
3 changed files with 38 additions and 21 deletions

View File

@@ -49,6 +49,7 @@ class MessagesTab extends StatefulWidget {
class _MessagesTabState extends State<MessagesTab> { class _MessagesTabState extends State<MessagesTab> {
static const int _maxContactMessageBytes = 156; static const int _maxContactMessageBytes = 156;
static const int _maxChannelMessageBytes = 127; static const int _maxChannelMessageBytes = 127;
static const double _composerOverlayHeight = 148;
final TextEditingController _textController = TextEditingController(); final TextEditingController _textController = TextEditingController();
final FocusNode _focusNode = FocusNode(); final FocusNode _focusNode = FocusNode();
@@ -1546,35 +1547,42 @@ class _MessagesTabState extends State<MessagesTab> {
return GestureDetector( return GestureDetector(
behavior: HitTestBehavior.translucent, behavior: HitTestBehavior.translucent,
onTap: () => FocusScope.of(context).unfocus(), onTap: () => FocusScope.of(context).unfocus(),
child: Column( child: Stack(
children: [ children: [
Expanded( Positioned.fill(
child: MessagesContent( child: MessagesContent(
messages: messages, messages: messages,
scrollController: _scrollController, scrollController: _scrollController,
highlightedMessageId: _highlightedMessageId, highlightedMessageId: _highlightedMessageId,
bottomContentPadding:
_composerOverlayHeight + composerBottomPadding,
onRefresh: _handleRefresh, onRefresh: _handleRefresh,
onNavigateToMap: widget.onNavigateToMap, onNavigateToMap: widget.onNavigateToMap,
onMessageTap: _handleMessageTap, onMessageTap: _handleMessageTap,
), ),
), ),
MessagesComposer( Positioned(
textController: _textController, left: 0,
focusNode: _focusNode, right: 0,
messageByteLimiter: _messageByteLimiter, bottom: 0,
messageByteCount: _messageByteCount, child: MessagesComposer(
maxMessageBytes: _maxMessageBytes, textController: _textController,
isRecording: _isRecording, focusNode: _focusNode,
isSendingVoice: _isSendingVoice, messageByteLimiter: _messageByteLimiter,
voiceSupported: _voiceSupported, messageByteCount: _messageByteCount,
bottomPadding: composerBottomPadding, maxMessageBytes: _maxMessageBytes,
destinationLabel: _getDestinationLabel(), isRecording: _isRecording,
destinationAvatar: _buildDestinationAvatar(context), isSendingVoice: _isSendingVoice,
onShowComposerActions: _showComposerActions, voiceSupported: _voiceSupported,
onShowRecipientSelector: _showRecipientSelector, bottomPadding: composerBottomPadding,
onStartVoiceRecording: _startVoiceRecording, destinationLabel: _getDestinationLabel(),
onStopAndSendVoice: _stopAndSendVoice, destinationAvatar: _buildDestinationAvatar(context),
onSendMessage: _sendMessage, onShowComposerActions: _showComposerActions,
onShowRecipientSelector: _showRecipientSelector,
onStartVoiceRecording: _startVoiceRecording,
onStopAndSendVoice: _stopAndSendVoice,
onSendMessage: _sendMessage,
),
), ),
], ],
), ),

View File

@@ -44,7 +44,7 @@ class MessagesComposer extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
decoration: BoxDecoration(color: Theme.of(context).colorScheme.surface), decoration: const BoxDecoration(color: Colors.transparent),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [

View File

@@ -5,9 +5,12 @@ import '../../models/message.dart';
import '../../widgets/messages/message_bubble.dart'; import '../../widgets/messages/message_bubble.dart';
class MessagesContent extends StatelessWidget { class MessagesContent extends StatelessWidget {
static const double defaultPadding = 8;
final List<Message> messages; final List<Message> messages;
final ScrollController scrollController; final ScrollController scrollController;
final String? highlightedMessageId; final String? highlightedMessageId;
final double bottomContentPadding;
final Future<void> Function() onRefresh; final Future<void> Function() onRefresh;
final VoidCallback? onNavigateToMap; final VoidCallback? onNavigateToMap;
final ValueChanged<Message>? onMessageTap; final ValueChanged<Message>? onMessageTap;
@@ -17,6 +20,7 @@ class MessagesContent extends StatelessWidget {
required this.messages, required this.messages,
required this.scrollController, required this.scrollController,
required this.highlightedMessageId, required this.highlightedMessageId,
this.bottomContentPadding = 0,
required this.onRefresh, required this.onRefresh,
this.onNavigateToMap, this.onNavigateToMap,
this.onMessageTap, this.onMessageTap,
@@ -64,7 +68,12 @@ class MessagesContent extends StatelessWidget {
controller: scrollController, controller: scrollController,
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag, keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
reverse: true, reverse: true,
padding: const EdgeInsets.all(8), padding: EdgeInsets.fromLTRB(
defaultPadding,
defaultPadding,
defaultPadding,
defaultPadding + bottomContentPadding,
),
itemCount: messages.length, itemCount: messages.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final message = messages[index]; final message = messages[index];