Skip to content

Commit ce924cc

Browse files
authored
combine upload files/folder button (rustdesk#9643)
* combine upload files/folder button Signed-off-by: 21pages <sunboeasy@gmail.com> * web compress cache Signed-off-by: 21pages <sunboeasy@gmail.com> --------- Signed-off-by: 21pages <sunboeasy@gmail.com>
1 parent 498b8ba commit ce924cc

46 files changed

Lines changed: 201 additions & 42 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,4 @@ examples/**/target/
5454
vcpkg_installed
5555
flutter/lib/generated_plugin_registrant.dart
5656
libsciter.dylib
57+
flutter/web/

flutter/lib/desktop/pages/file_manager_page.dart

Lines changed: 59 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,9 @@ class _FileManagerViewState extends State<FileManagerView> {
490490
}
491491

492492
Widget headTools() {
493+
var uploadButtonTapPosition = RelativeRect.fill;
494+
RxBool isUploadFolder =
495+
(bind.mainGetLocalOption(key: 'upload-folder-button') == 'Y').obs;
493496
return Container(
494497
child: Column(
495498
children: [
@@ -814,48 +817,64 @@ class _FileManagerViewState extends State<FileManagerView> {
814817
),
815818
if (isWeb)
816819
Obx(() => ElevatedButton.icon(
817-
style: ButtonStyle(
818-
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(
819-
isLocal
820-
? EdgeInsets.only(left: 10)
821-
: EdgeInsets.only(right: 10)),
822-
backgroundColor: MaterialStateProperty.all(
823-
selectedItems.items.isEmpty
824-
? MyTheme.accent80
825-
: MyTheme.accent,
826-
),
827-
),
828-
onPressed: () => {webselectFiles(is_folder: true)},
829-
icon: Offstage(),
830-
label: Text(
831-
translate('Upload folder'),
832-
textAlign: TextAlign.right,
833-
style: TextStyle(
834-
color: Colors.white,
835-
),
836-
))).marginOnly(left: 16),
837-
if (isWeb)
838-
Obx(() => ElevatedButton.icon(
839-
style: ButtonStyle(
840-
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(
841-
isLocal
842-
? EdgeInsets.only(left: 10)
843-
: EdgeInsets.only(right: 10)),
844-
backgroundColor: MaterialStateProperty.all(
845-
selectedItems.items.isEmpty
846-
? MyTheme.accent80
847-
: MyTheme.accent,
820+
style: ButtonStyle(
821+
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(
822+
isLocal
823+
? EdgeInsets.only(left: 10)
824+
: EdgeInsets.only(right: 10)),
825+
backgroundColor: MaterialStateProperty.all(
826+
selectedItems.items.isEmpty
827+
? MyTheme.accent80
828+
: MyTheme.accent,
829+
),
848830
),
849-
),
850-
onPressed: () => {webselectFiles(is_folder: false)},
851-
icon: Offstage(),
852-
label: Text(
853-
translate('Upload files'),
854-
textAlign: TextAlign.right,
855-
style: TextStyle(
856-
color: Colors.white,
831+
onPressed: () =>
832+
{webselectFiles(is_folder: isUploadFolder.value)},
833+
label: InkWell(
834+
hoverColor: Colors.transparent,
835+
splashColor: Colors.transparent,
836+
highlightColor: Colors.transparent,
837+
focusColor: Colors.transparent,
838+
onTapDown: (e) {
839+
final x = e.globalPosition.dx;
840+
final y = e.globalPosition.dy;
841+
uploadButtonTapPosition =
842+
RelativeRect.fromLTRB(x, y, x, y);
843+
},
844+
onTap: () async {
845+
final value = await showMenu<bool>(
846+
context: context,
847+
position: uploadButtonTapPosition,
848+
items: [
849+
PopupMenuItem<bool>(
850+
value: false,
851+
child: Text(translate('Upload files')),
852+
),
853+
PopupMenuItem<bool>(
854+
value: true,
855+
child: Text(translate('Upload folder')),
856+
),
857+
]);
858+
if (value != null) {
859+
isUploadFolder.value = value;
860+
bind.mainSetLocalOption(
861+
key: 'upload-folder-button',
862+
value: value ? 'Y' : '');
863+
webselectFiles(is_folder: value);
864+
}
865+
},
866+
child: Icon(Icons.arrow_drop_down),
857867
),
858-
))).marginOnly(left: 16),
868+
icon: Text(
869+
translate(isUploadFolder.isTrue
870+
? 'Upload folder'
871+
: 'Upload files'),
872+
textAlign: TextAlign.right,
873+
style: TextStyle(
874+
color: Colors.white,
875+
),
876+
).marginOnly(left: 8),
877+
)).marginOnly(left: 16),
859878
Obx(() => ElevatedButton.icon(
860879
style: ButtonStyle(
861880
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(

flutter/lib/web/bridge.dart

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,12 @@ class RustdeskImpl {
12091209
}
12101210

12111211
Future<String> mainLoadAb({dynamic hint}) {
1212-
return Future(() => js.context.callMethod('getByName', ['load_ab']));
1212+
Completer<String> completer = Completer();
1213+
js.context["onLoadAbFinished"] = (String s) {
1214+
completer.complete(s);
1215+
};
1216+
js.context.callMethod('setByName', ['load_ab']);
1217+
return completer.future;
12131218
}
12141219

12151220
Future<void> mainSaveGroup({required String json, dynamic hint}) {
@@ -1222,7 +1227,12 @@ class RustdeskImpl {
12221227
}
12231228

12241229
Future<String> mainLoadGroup({dynamic hint}) {
1225-
return Future(() => js.context.callMethod('getByName', ['load_group']));
1230+
Completer<String> completer = Completer();
1231+
js.context["onLoadGroupFinished"] = (String s) {
1232+
completer.complete(s);
1233+
};
1234+
js.context.callMethod('setByName', ['load_group']);
1235+
return completer.future;
12261236
}
12271237

12281238
Future<void> sessionSendPointer(

src/lang/ar.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,5 +648,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
648648
("Authentication Required", ""),
649649
("Authenticate", ""),
650650
("web_id_input_tip", ""),
651+
("Download", ""),
652+
("Upload folder", ""),
653+
("Upload files", ""),
651654
].iter().cloned().collect();
652655
}

src/lang/be.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,5 +648,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
648648
("Authentication Required", ""),
649649
("Authenticate", ""),
650650
("web_id_input_tip", ""),
651+
("Download", ""),
652+
("Upload folder", ""),
653+
("Upload files", ""),
651654
].iter().cloned().collect();
652655
}

src/lang/bg.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,5 +648,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
648648
("Authentication Required", ""),
649649
("Authenticate", ""),
650650
("web_id_input_tip", ""),
651+
("Download", ""),
652+
("Upload folder", ""),
653+
("Upload files", ""),
651654
].iter().cloned().collect();
652655
}

src/lang/ca.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,5 +648,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
648648
("Authentication Required", "Autenticació requerida"),
649649
("Authenticate", "Autentica"),
650650
("web_id_input_tip", "Podeu inserir el número ID al propi servidor; l'accés directe per IP no és compatible amb el client web.\nSi voleu accedir a un dispositiu d'un altre servidor, afegiu l'adreça del servidor, com ara <id>@<adreça_del_servidor>?key=<valor_de_la_clau> (p. ex.\n9123456234@192.168.16.1:21117?key=5Qbwsde3unUcJBtrx9ZkvUmwFNoExHzpryHuPUdqlWM=.\nSi voleu accedir a un dispositiu en un servidor públic, no cal que inseriu la clau pública «<id>@» per al servidor públic."),
651+
("Download", ""),
652+
("Upload folder", ""),
653+
("Upload files", ""),
651654
].iter().cloned().collect();
652655
}

src/lang/cn.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,5 +648,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
648648
("Authentication Required", "需要身份验证"),
649649
("Authenticate", "认证"),
650650
("web_id_input_tip", "可以输入同一个服务器内的 ID,web 客户端不支持直接 IP 访问。\n要访问另一台服务器上的设备,请附加服务器地址(<ID>@<服务器地址>?key=<密钥>)。比如,\n9123456234@192.168.16.1:21117?key=5Qbwsde3unUcJBtrx9ZkvUmwFNoExHzpryHuPUdqlWM=。\n要访问公共服务器上的设备,请输入 \"<ID>@public\",无需密钥。"),
651+
("Download", "下载"),
652+
("Upload folder", "上传文件夹"),
653+
("Upload files", "上传文件"),
651654
].iter().cloned().collect();
652655
}

src/lang/cs.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,5 +648,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
648648
("Authentication Required", ""),
649649
("Authenticate", ""),
650650
("web_id_input_tip", ""),
651+
("Download", ""),
652+
("Upload folder", ""),
653+
("Upload files", ""),
651654
].iter().cloned().collect();
652655
}

src/lang/da.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,5 +648,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
648648
("Authentication Required", ""),
649649
("Authenticate", ""),
650650
("web_id_input_tip", ""),
651+
("Download", ""),
652+
("Upload folder", ""),
653+
("Upload files", ""),
651654
].iter().cloned().collect();
652655
}

0 commit comments

Comments
 (0)