| .. | .. |
|---|
| 1 | 1 | import 'package:flutter/material.dart'; |
|---|
| 2 | +import 'package:flutter/services.dart'; |
|---|
| 2 | 3 | |
|---|
| 3 | 4 | import '../providers/providers.dart'; |
|---|
| 4 | 5 | import '../theme/app_theme.dart'; |
|---|
| .. | .. |
|---|
| 97 | 98 | const SizedBox(width: 8), |
|---|
| 98 | 99 | // Text field |
|---|
| 99 | 100 | Expanded( |
|---|
| 100 | | - child: TextField( |
|---|
| 101 | | - controller: textController, |
|---|
| 102 | | - decoration: InputDecoration( |
|---|
| 103 | | - hintText: 'Type a message...', |
|---|
| 104 | | - filled: true, |
|---|
| 105 | | - fillColor: isDark ? AppColors.darkInputBg : AppColors.lightInputBg, |
|---|
| 106 | | - border: OutlineInputBorder( |
|---|
| 107 | | - borderRadius: BorderRadius.circular(24), |
|---|
| 108 | | - borderSide: BorderSide.none, |
|---|
| 101 | + child: CallbackShortcuts( |
|---|
| 102 | + // Cmd+Enter (or Ctrl+Enter on other keyboards) sends the message. |
|---|
| 103 | + // Plain Enter still inserts a newline (textInputAction: newline). |
|---|
| 104 | + bindings: <ShortcutActivator, VoidCallback>{ |
|---|
| 105 | + const SingleActivator(LogicalKeyboardKey.enter, meta: true): |
|---|
| 106 | + onSendText, |
|---|
| 107 | + const SingleActivator(LogicalKeyboardKey.enter, control: true): |
|---|
| 108 | + onSendText, |
|---|
| 109 | + }, |
|---|
| 110 | + child: TextField( |
|---|
| 111 | + controller: textController, |
|---|
| 112 | + decoration: InputDecoration( |
|---|
| 113 | + hintText: 'Type a message...', |
|---|
| 114 | + filled: true, |
|---|
| 115 | + fillColor: isDark |
|---|
| 116 | + ? AppColors.darkInputBg |
|---|
| 117 | + : AppColors.lightInputBg, |
|---|
| 118 | + border: OutlineInputBorder( |
|---|
| 119 | + borderRadius: BorderRadius.circular(24), |
|---|
| 120 | + borderSide: BorderSide.none, |
|---|
| 121 | + ), |
|---|
| 122 | + contentPadding: const EdgeInsets.symmetric( |
|---|
| 123 | + horizontal: 16, |
|---|
| 124 | + vertical: 10, |
|---|
| 125 | + ), |
|---|
| 126 | + isDense: true, |
|---|
| 109 | 127 | ), |
|---|
| 110 | | - contentPadding: |
|---|
| 111 | | - const EdgeInsets.symmetric(horizontal: 16, vertical: 10), |
|---|
| 112 | | - isDense: true, |
|---|
| 128 | + textInputAction: TextInputAction.newline, |
|---|
| 129 | + maxLines: 4, |
|---|
| 130 | + minLines: 1, |
|---|
| 113 | 131 | ), |
|---|
| 114 | | - textInputAction: TextInputAction.newline, |
|---|
| 115 | | - maxLines: 4, |
|---|
| 116 | | - minLines: 1, |
|---|
| 117 | 132 | ), |
|---|
| 118 | 133 | ), |
|---|
| 119 | 134 | const SizedBox(width: 8), |
|---|