fix: clean up messages composer bar

ref:
This commit is contained in:
Janez T
2026-03-06 14:11:36 +01:00
parent a9d062dc34
commit f6779e8776

View File

@@ -287,61 +287,6 @@ class _MessagesTabState extends State<MessagesTab> {
return 'Select recipient'; return 'Select recipient';
} }
String _getCurrentScopeLabel() {
if (_destinationType ==
MessageDestinationPreferences.destinationTypeChannel) {
final channelName =
_selectedRecipient?.getLocalizedDisplayName(context) ??
AppLocalizations.of(context)!.publicChannel;
return 'Channel > $channelName';
}
if (_destinationType == MessageDestinationPreferences.destinationTypeRoom) {
final roomName =
_selectedRecipient?.displayName ??
AppLocalizations.of(context)!.messages;
return 'Room > $roomName';
}
final contactName =
_selectedRecipient?.displayName ??
AppLocalizations.of(context)!.messages;
return 'Direct > $contactName';
}
Widget _buildScopeIndicator() {
final theme = Theme.of(context);
return SizedBox(
width: double.infinity,
child: Align(
alignment: Alignment.centerLeft,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.visibility_outlined,
size: 14,
color: theme.colorScheme.onSurfaceVariant,
),
const SizedBox(width: 6),
Flexible(
child: Text(
'View: ${_getCurrentScopeLabel()}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.left,
style: theme.textTheme.labelSmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
),
],
),
),
);
}
Future<void> _sendMessage() async { Future<void> _sendMessage() async {
final text = _textController.text.trim(); final text = _textController.text.trim();
if (text.isEmpty) return; if (text.isEmpty) return;
@@ -1622,7 +1567,7 @@ class _MessagesTabState extends State<MessagesTab> {
vertical: 8, vertical: 8,
), ),
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
// Quick actions (+) button // Quick actions (+) button
IconButton( IconButton(
@@ -1672,27 +1617,13 @@ class _MessagesTabState extends State<MessagesTab> {
), ),
), ),
const SizedBox(width: 4), const SizedBox(width: 4),
// Scope label + text field share the same alignment
Expanded( Expanded(
child: Column( child: TextField(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(
left: 4,
right: 4,
bottom: 6,
),
child: _buildScopeIndicator(),
),
TextField(
controller: _textController, controller: _textController,
focusNode: _focusNode, focusNode: _focusNode,
maxLength: _maxCharacters, maxLength: _maxCharacters,
maxLines: null, maxLines: null,
maxLengthEnforcement: maxLengthEnforcement: MaxLengthEnforcement.enforced,
MaxLengthEnforcement.enforced,
style: const TextStyle(fontSize: 14), style: const TextStyle(fontSize: 14),
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of( hintText: AppLocalizations.of(
@@ -1712,16 +1643,51 @@ class _MessagesTabState extends State<MessagesTab> {
: '', : '',
counterStyle: TextStyle( counterStyle: TextStyle(
fontSize: 10, fontSize: 10,
color: color: _characterCount > _maxCharacters * 0.9
_characterCount > _maxCharacters * 0.9
? Colors.orange ? Colors.orange
: Theme.of( : Theme.of(
context, context,
).textTheme.bodySmall?.color, ).textTheme.bodySmall?.color,
), ),
suffixIcon: GestureDetector( suffixIcon: Builder(
onLongPressStart: builder: (context) {
final canSendText =
!_isRecording &&
!_isSendingVoice &&
_textController.text.trim().isNotEmpty;
final semanticsLabel = _isRecording
? 'Recording... release to send voice'
: (_isSendingVoice
? 'Sending voice...'
: _voiceSupported
? 'Send (long press to record voice)'
: 'Send');
return Semantics(
button: true,
enabled:
canSendText ||
(_voiceSupported && !_isSendingVoice),
label: semanticsLabel,
onTap: canSendText ? _sendMessage : null,
onLongPress:
(_voiceSupported && !_isSendingVoice) (_voiceSupported && !_isSendingVoice)
? () {
if (_isRecording) {
_stopAndSendVoice();
return;
}
_startVoiceRecording();
}
: null,
child: Tooltip(
message: semanticsLabel,
excludeFromSemantics: true,
child: GestureDetector(
excludeFromSemantics: true,
onLongPressStart:
(_voiceSupported &&
!_isSendingVoice)
? (_) => _startVoiceRecording() ? (_) => _startVoiceRecording()
: null, : null,
onLongPressEnd: onLongPressEnd:
@@ -1737,7 +1703,8 @@ class _MessagesTabState extends State<MessagesTab> {
? const SizedBox( ? const SizedBox(
width: 18, width: 18,
height: 18, height: 18,
child: CircularProgressIndicator( child:
CircularProgressIndicator(
strokeWidth: 2, strokeWidth: 2,
), ),
) )
@@ -1758,29 +1725,19 @@ class _MessagesTabState extends State<MessagesTab> {
.colorScheme .colorScheme
.primary), .primary),
), ),
onPressed: onPressed: canSendText
_isRecording || ? _sendMessage
_isSendingVoice || : null,
_textController.text
.trim()
.isEmpty
? null
: _sendMessage,
tooltip: _isRecording
? 'Recording... release to send voice'
: (_isSendingVoice
? 'Sending voice...'
: _voiceSupported
? 'Send (long press to record voice)'
: 'Send'),
), ),
), ),
), ),
);
},
),
),
textInputAction: TextInputAction.send, textInputAction: TextInputAction.send,
onSubmitted: (_) => _sendMessage(), onSubmitted: (_) => _sendMessage(),
), ),
],
),
), ),
], ],
), ),