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

View File

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

View File

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