Merge pull request #216 from cogwheel0/improve-chat-input-semantics

feat(chat): Improve chat input semantics and keyboard interactions
This commit is contained in:
cogwheel
2025-12-03 15:06:15 +05:30
committed by GitHub

View File

@@ -1293,15 +1293,17 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
} catch (_) {} } catch (_) {}
_ensureFocusedIfEnabled(); _ensureFocusedIfEnabled();
}, },
child: MergeSemantics(
child: Semantics( child: Semantics(
textField: true,
label: AppLocalizations.of(context)!.messageInputLabel, label: AppLocalizations.of(context)!.messageInputLabel,
hint: AppLocalizations.of(context)!.messageInputHint, hint: AppLocalizations.of(context)!.messageInputHint,
child: Shortcuts( child: Shortcuts(
shortcuts: () { shortcuts: () {
final map = <LogicalKeySet, Intent>{ final map = <LogicalKeySet, Intent>{
LogicalKeySet(LogicalKeyboardKey.meta, LogicalKeyboardKey.enter): LogicalKeySet(
const _SendMessageIntent(), LogicalKeyboardKey.meta,
LogicalKeyboardKey.enter,
): const _SendMessageIntent(),
LogicalKeySet( LogicalKeySet(
LogicalKeyboardKey.control, LogicalKeyboardKey.control,
LogicalKeyboardKey.enter, LogicalKeyboardKey.enter,
@@ -1344,7 +1346,8 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
return null; return null;
}, },
), ),
_SelectNextPromptIntent: CallbackAction<_SelectNextPromptIntent>( _SelectNextPromptIntent:
CallbackAction<_SelectNextPromptIntent>(
onInvoke: (intent) { onInvoke: (intent) {
_movePromptSelection(1); _movePromptSelection(1);
return null; return null;
@@ -1381,7 +1384,8 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
final FontWeight recordingWeight = _isRecording final FontWeight recordingWeight = _isRecording
? FontWeight.w500 ? FontWeight.w500
: FontWeight.w400; : FontWeight.w400;
final TextStyle baseChatStyle = AppTypography.chatMessageStyle; final TextStyle baseChatStyle =
AppTypography.chatMessageStyle;
return TextField( return TextField(
controller: _controller, controller: _controller,
@@ -1427,7 +1431,8 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
alignLabelWithHint: true, alignLabelWithHint: true,
), ),
// Enable pasting images and files from clipboard // Enable pasting images and files from clipboard
contentInsertionConfiguration: ContentInsertionConfiguration( contentInsertionConfiguration:
ContentInsertionConfiguration(
allowedMimeTypes: ClipboardAttachmentService allowedMimeTypes: ClipboardAttachmentService
.supportedImageMimeTypes .supportedImageMimeTypes
.toList(), .toList(),
@@ -1448,6 +1453,7 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
), ),
), ),
), ),
),
); );
} }