Merge branch 'braid/matrix-to-links' into 'main'

fix: handle matrix.to prefix when starting chat

See merge request famedly/fluffychat!877
This commit is contained in:
Krille Fear 2022-05-22 05:44:55 +00:00
commit 1200940f3a
2 changed files with 10 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
@ -27,11 +28,18 @@ class NewPrivateChatController extends State<NewPrivateChat> {
bool _hideFab = false;
// remove leading matrix.to from text field in order to simplify pasting
final List<TextInputFormatter> removeMatrixToFormatters = [
FilteringTextInputFormatter.deny(NewPrivateChatController.prefix),
FilteringTextInputFormatter.deny(NewPrivateChatController.prefixNoProtocol),
];
bool get hideFab => _hideFab;
static const Set<String> supportedSigils = {'@', '!', '#'};
static const String prefix = 'https://matrix.to/#/';
static const String prefixNoProtocol = 'matrix.to/#/';
void setHideFab() {
if (textFieldFocus.hasFocus != _hideFab) {

View File

@ -83,10 +83,11 @@ class NewPrivateChatView extends StatelessWidget {
focusNode: controller.textFieldFocus,
onFieldSubmitted: controller.submitAction,
validator: controller.validateForm,
inputFormatters: controller.removeMatrixToFormatters,
decoration: InputDecoration(
labelText: L10n.of(context)!.typeInInviteLinkManually,
hintText: '@username',
prefixText: 'matrix.to/#/',
prefixText: NewPrivateChatController.prefixNoProtocol,
suffixIcon: IconButton(
icon: const Icon(Icons.send_outlined),
onPressed: controller.submitAction,