mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-23 22:12:34 +01:00
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:
commit
1200940f3a
@ -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