add: change id on flutter

This commit is contained in:
Kingtous 2022-07-15 17:00:37 +08:00
parent 19c3c6034e
commit f4e0b6e50a
3 changed files with 73 additions and 3 deletions

View File

@ -266,6 +266,8 @@ class _DesktopHomePageState extends State<DesktopHomePage> with TrayListener {
} else if (value == "stop-service") { } else if (value == "stop-service") {
final option = gFFI.getOption(value); final option = gFFI.getOption(value);
gFFI.setOption(value, option == "Y" ? "" : "Y"); gFFI.setOption(value, option == "Y" ? "" : "Y");
} else if (value == "change-id") {
changeId();
} }
} }
@ -341,4 +343,64 @@ class _DesktopHomePageState extends State<DesktopHomePage> with TrayListener {
}, },
), value: 'audio-input',); ), value: 'audio-input',);
} }
/// change local ID
void changeId() {
var newId = "";
var msg = "";
var isInProgress = false;
DialogManager.show( (setState, close) {
return CustomAlertDialog(
title: Text(translate("Change ID")),
content: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(translate("id_change_tip")),
Offstage(
offstage: msg.isEmpty,
child: Text(msg, style: TextStyle(color: Colors.grey),)).marginOnly(bottom: 4.0),
TextField(
onChanged: (s) {
newId = s;
},
decoration: InputDecoration(
border: OutlineInputBorder()
),
inputFormatters: [
LengthLimitingTextInputFormatter(16),
// FilteringTextInputFormatter(RegExp(r"[a-zA-z][a-zA-z0-9\_]*"), allow: true)
],
maxLength: 16,
),
SizedBox(height: 4.0,),
Offstage(
offstage: !isInProgress,
child: LinearProgressIndicator())
],
), actions: [
TextButton(onPressed: (){
close();
}, child: Text("取消")),
TextButton(onPressed: () async {
setState(() {
msg = "";
isInProgress = true;
gFFI.bind.mainChangeId(newId: newId);
});
var status = await gFFI.bind.mainGetAsyncStatus();
while (status == " "){
await Future.delayed(Duration(milliseconds: 100));
status = await gFFI.bind.mainGetAsyncStatus();
}
setState(() {
isInProgress = false;
msg = translate(status);
});
}, child: Text("确定")),
],
);
});
}
} }

View File

@ -187,8 +187,8 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." path: "."
ref: c7d97cb6615f2def34f8bad4def01af9e0077beb ref: "7b72918710921f5fe79eae2dbaa411a66f5dfb45"
resolved-ref: c7d97cb6615f2def34f8bad4def01af9e0077beb resolved-ref: "7b72918710921f5fe79eae2dbaa411a66f5dfb45"
url: "https://github.com/Kingtous/rustdesk_desktop_multi_window" url: "https://github.com/Kingtous/rustdesk_desktop_multi_window"
source: git source: git
version: "0.0.1" version: "0.0.1"

View File

@ -19,7 +19,7 @@ use crate::flutter::connection_manager::{self, get_clients_length, get_clients_s
use crate::flutter::{self, Session, SESSIONS}; use crate::flutter::{self, Session, SESSIONS};
use crate::start_server; use crate::start_server;
use crate::ui_interface; use crate::ui_interface;
use crate::ui_interface::get_sound_inputs; use crate::ui_interface::{change_id, get_async_job_status, get_sound_inputs, is_ok_change_id};
fn initialize(app_dir: &str) { fn initialize(app_dir: &str) {
*config::APP_DIR.write().unwrap() = app_dir.to_owned(); *config::APP_DIR.write().unwrap() = app_dir.to_owned();
@ -383,6 +383,14 @@ pub fn main_get_sound_inputs() -> Vec<String> {
get_sound_inputs() get_sound_inputs()
} }
pub fn main_change_id(new_id: String) {
change_id(new_id)
}
pub fn main_get_async_status() -> String {
get_async_job_status()
}
/// FFI for **get** commands which are idempotent. /// FFI for **get** commands which are idempotent.
/// Return result in c string. /// Return result in c string.
/// ///