mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-01-11 10:12:49 +01:00
fix: handle matrix.to prefix when starting chat
- remove leading matrix.to beginning from content of the start chat matrix.to text field in order to allow simply pasting matrix.to links Signed-off-by: TheOneWithTheBraid <the-one@with-the-braid.cf>
This commit is contained in:
parent
014c1574ee
commit
247e437c07
@ -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) {
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user