forked from cwtch.im/cwtch-ui
Merge branch 'trunk' into windowsPerf
This commit is contained in:
commit
f43fdc57bb
|
@ -7,6 +7,7 @@ import 'package:flutter/cupertino.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:cwtch/views/peersettingsview.dart';
|
||||
import 'package:cwtch/widgets/DropdownContacts.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
|
@ -102,12 +103,14 @@ class _MessageViewState extends State<MessageView> {
|
|||
}
|
||||
|
||||
void _sendMessage([String? ignoredParam]) {
|
||||
if (ctrlrCompose.value.text.isNotEmpty) {
|
||||
ChatMessage cm = new ChatMessage(o: 1, d: ctrlrCompose.value.text);
|
||||
Provider.of<FlwtchState>(context, listen: false)
|
||||
.cwtch
|
||||
.SendMessage(Provider.of<ContactInfoState>(context, listen: false).profileOnion, Provider.of<ContactInfoState>(context, listen: false).onion, jsonEncode(cm));
|
||||
_sendMessageHelper();
|
||||
}
|
||||
}
|
||||
|
||||
void _sendInvitation([String? ignoredParam]) {
|
||||
Provider.of<FlwtchState>(context, listen: false)
|
||||
|
@ -137,12 +140,18 @@ class _MessageViewState extends State<MessageView> {
|
|||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(border: Border(top: BorderSide(color: Provider.of<Settings>(context).theme.defaultButtonActiveColor()))),
|
||||
child: RawKeyboardListener(
|
||||
focusNode: FocusNode(),
|
||||
onKey: handleKeyPress,
|
||||
child: TextFormField(
|
||||
key: Key('txtCompose'),
|
||||
controller: ctrlrCompose,
|
||||
autofocus: !Platform.isAndroid,
|
||||
focusNode: focusNode,
|
||||
textInputAction: TextInputAction.send,
|
||||
autofocus: !Platform.isAndroid,
|
||||
textInputAction: TextInputAction.newline,
|
||||
keyboardType: TextInputType.multiline,
|
||||
minLines: 1,
|
||||
maxLines: null,
|
||||
onFieldSubmitted: _sendMessage,
|
||||
decoration: InputDecoration(
|
||||
enabledBorder: InputBorder.none,
|
||||
|
@ -160,13 +169,26 @@ class _MessageViewState extends State<MessageView> {
|
|||
tooltip: AppLocalizations.of(context)!.sendMessage,
|
||||
onPressed: _sendMessage,
|
||||
),
|
||||
))),
|
||||
)))),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Send the message if enter is pressed without the shift key...
|
||||
void handleKeyPress(event) {
|
||||
var data = event.data as RawKeyEventData;
|
||||
if (data.logicalKey == LogicalKeyboardKey.enter && !event.isShiftPressed) {
|
||||
final messageWithoutNewLine = ctrlrCompose.value.text.trimRight();
|
||||
ctrlrCompose.value = TextEditingValue(
|
||||
text: messageWithoutNewLine
|
||||
);
|
||||
_sendMessage();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void placeHolder() => {};
|
||||
|
||||
// explicitly passing BuildContext ctx here is important, change at risk to own health
|
||||
|
|
Loading…
Reference in New Issue