mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-05-11 10:26:19 +02:00
update idController when create new connection
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
4d3f5373d4
commit
21cf2a01c7
4 changed files with 17 additions and 1 deletions
|
@ -11,6 +11,7 @@ import 'package:flutter/foundation.dart';
|
|||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_hbb/common/formatter/id_formatter.dart';
|
||||
import 'package:flutter_hbb/desktop/widgets/refresh_wrapper.dart';
|
||||
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
|
||||
import 'package:flutter_hbb/main.dart';
|
||||
|
@ -1833,6 +1834,14 @@ connect(
|
|||
bool isRDP = false,
|
||||
}) async {
|
||||
if (id == '') return;
|
||||
if (!isDesktop || desktopType == DesktopType.main) {
|
||||
try {
|
||||
if (Get.isRegistered<IDTextEditingController>()) {
|
||||
final idController = Get.find<IDTextEditingController>();
|
||||
idController.text = formatID(id);
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
id = id.replaceAll(' ', '');
|
||||
final oldId = id;
|
||||
id = await bind.mainHandleRelayId(id: id);
|
||||
|
|
|
@ -35,6 +35,11 @@ class IDTextInputFormatter extends TextInputFormatter {
|
|||
|
||||
String formatID(String id) {
|
||||
String id2 = id.replaceAll(' ', '');
|
||||
String suffix = '';
|
||||
if (id2.endsWith(r'\r') || id2.endsWith(r'/r')) {
|
||||
suffix = id2.substring(id2.length - 2, id2.length);
|
||||
id2 = id2.substring(0, id2.length - 2);
|
||||
}
|
||||
if (int.tryParse(id2) == null) return id;
|
||||
String newID = '';
|
||||
if (id2.length <= 3) {
|
||||
|
@ -47,7 +52,7 @@ String formatID(String id) {
|
|||
newID += " ${id2.substring(i, i + 3)}";
|
||||
}
|
||||
}
|
||||
return newID;
|
||||
return newID + suffix;
|
||||
}
|
||||
|
||||
String trimID(String id) {
|
||||
|
|
|
@ -68,6 +68,7 @@ class _ConnectionPageState extends State<ConnectionPage>
|
|||
_idController.selection = TextSelection(
|
||||
baseOffset: 0, extentOffset: _idController.value.text.length);
|
||||
});
|
||||
Get.put<IDTextEditingController>(_idController);
|
||||
windowManager.addListener(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
|||
_idController.addListener(() {
|
||||
_idEmpty.value = _idController.text.isEmpty;
|
||||
});
|
||||
Get.put<IDTextEditingController>(_idController);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue