mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-06-07 01:42:49 +08:00
update idController when create new connection
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
4d3f5373d4
commit
21cf2a01c7
@ -11,6 +11,7 @@ import 'package:flutter/foundation.dart';
|
|||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.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/refresh_wrapper.dart';
|
||||||
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
|
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
|
||||||
import 'package:flutter_hbb/main.dart';
|
import 'package:flutter_hbb/main.dart';
|
||||||
@ -1833,6 +1834,14 @@ connect(
|
|||||||
bool isRDP = false,
|
bool isRDP = false,
|
||||||
}) async {
|
}) async {
|
||||||
if (id == '') return;
|
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(' ', '');
|
id = id.replaceAll(' ', '');
|
||||||
final oldId = id;
|
final oldId = id;
|
||||||
id = await bind.mainHandleRelayId(id: id);
|
id = await bind.mainHandleRelayId(id: id);
|
||||||
|
@ -35,6 +35,11 @@ class IDTextInputFormatter extends TextInputFormatter {
|
|||||||
|
|
||||||
String formatID(String id) {
|
String formatID(String id) {
|
||||||
String id2 = id.replaceAll(' ', '');
|
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;
|
if (int.tryParse(id2) == null) return id;
|
||||||
String newID = '';
|
String newID = '';
|
||||||
if (id2.length <= 3) {
|
if (id2.length <= 3) {
|
||||||
@ -47,7 +52,7 @@ String formatID(String id) {
|
|||||||
newID += " ${id2.substring(i, i + 3)}";
|
newID += " ${id2.substring(i, i + 3)}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newID;
|
return newID + suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
String trimID(String id) {
|
String trimID(String id) {
|
||||||
|
@ -68,6 +68,7 @@ class _ConnectionPageState extends State<ConnectionPage>
|
|||||||
_idController.selection = TextSelection(
|
_idController.selection = TextSelection(
|
||||||
baseOffset: 0, extentOffset: _idController.value.text.length);
|
baseOffset: 0, extentOffset: _idController.value.text.length);
|
||||||
});
|
});
|
||||||
|
Get.put<IDTextEditingController>(_idController);
|
||||||
windowManager.addListener(this);
|
windowManager.addListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
|||||||
_idController.addListener(() {
|
_idController.addListener(() {
|
||||||
_idEmpty.value = _idController.text.isEmpty;
|
_idEmpty.value = _idController.text.isEmpty;
|
||||||
});
|
});
|
||||||
|
Get.put<IDTextEditingController>(_idController);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
Loading…
Reference in New Issue
Block a user