fix: send on enter

This commit is contained in:
Christian Pauly 2021-08-28 10:35:11 +02:00
parent bfb55b4525
commit abe200f90a
2 changed files with 11 additions and 4 deletions

View File

@ -698,9 +698,10 @@ class ChatView extends StatelessWidget {
minLines: 1, minLines: 1,
maxLines: 8, maxLines: 8,
autofocus: !PlatformInfos.isMobile, autofocus: !PlatformInfos.isMobile,
keyboardType: AppConfig.sendOnEnter keyboardType: TextInputType.multiline,
? null textInputAction: AppConfig.sendOnEnter
: TextInputType.multiline, ? TextInputAction.send
: null,
onSubmitted: onSubmitted:
controller.onInputBarSubmitted, controller.onInputBarSubmitted,
focusNode: controller.inputFocus, focusNode: controller.inputFocus,

View File

@ -1,3 +1,4 @@
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/utils/platform_infos.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
@ -15,6 +16,7 @@ class InputBar extends StatelessWidget {
final int minLines; final int minLines;
final int maxLines; final int maxLines;
final TextInputType keyboardType; final TextInputType keyboardType;
final TextInputAction textInputAction;
final ValueChanged<String> onSubmitted; final ValueChanged<String> onSubmitted;
final FocusNode focusNode; final FocusNode focusNode;
final TextEditingController controller; final TextEditingController controller;
@ -33,6 +35,7 @@ class InputBar extends StatelessWidget {
this.decoration, this.decoration,
this.onChanged, this.onChanged,
this.autofocus, this.autofocus,
this.textInputAction,
}); });
List<Map<String, String>> getSuggestions(String text) { List<Map<String, String>> getSuggestions(String text) {
@ -352,7 +355,9 @@ class InputBar extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final useShortCuts = (PlatformInfos.isWeb || PlatformInfos.isDesktop); final useShortCuts = (PlatformInfos.isWeb ||
PlatformInfos.isDesktop ||
AppConfig.sendOnEnter);
return Shortcuts( return Shortcuts(
shortcuts: !useShortCuts shortcuts: !useShortCuts
? {} ? {}
@ -397,6 +402,7 @@ class InputBar extends StatelessWidget {
minLines: minLines, minLines: minLines,
maxLines: maxLines, maxLines: maxLines,
keyboardType: keyboardType, keyboardType: keyboardType,
textInputAction: textInputAction,
autofocus: autofocus, autofocus: autofocus,
onSubmitted: (text) { onSubmitted: (text) {
// fix for library for now // fix for library for now