flutter_desktop: custom image quality

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2022-08-31 23:02:02 -07:00
parent 7cb079afc8
commit ce1a504e9f
4 changed files with 34 additions and 28 deletions

2
flutter/.gitignore vendored
View File

@ -48,7 +48,7 @@ lib/generated_bridge.dart
lib/generated_bridge.freezed.dart
# Flutter Generated Files
**/flutter/GeneratedPluginRegistrant.swift
**/GeneratedPluginRegistrant.swift
**/flutter/generated_plugin_registrant.cc
**/flutter/generated_plugin_registrant.h
**/flutter/generated_plugins.cmake

View File

@ -432,7 +432,7 @@ void msgBox(
if (type != "connecting" && type != "success" && !type.contains("nook")) {
buttons.insert(
0,
getMsgBoxButton(translate('OK'), () {
msgBoxButton(translate('OK'), () {
dialogManager.dismissAll();
// https://github.com/fufesou/rustdesk/blob/5e9a31340b899822090a3731769ae79c6bf5f3e5/src/ui/common.tis#L263
if (!type.contains("custom")) {
@ -446,7 +446,7 @@ void msgBox(
if (hasCancel) {
buttons.insert(
0,
getMsgBoxButton(translate('Cancel'), () {
msgBoxButton(translate('Cancel'), () {
dialogManager.dismissAll();
}));
}
@ -454,17 +454,17 @@ void msgBox(
if (type.contains("hasclose")) {
buttons.insert(
0,
getMsgBoxButton(translate('Close'), () {
msgBoxButton(translate('Close'), () {
dialogManager.dismissAll();
}));
}
dialogManager.show((setState, close) => CustomAlertDialog(
title: Text(translate(title), style: TextStyle(fontSize: 21)),
title: _msgBoxTitle(title),
content: Text(translate(text), style: TextStyle(fontSize: 15)),
actions: buttons));
}
Widget getMsgBoxButton(String text, void Function() onPressed) {
Widget msgBoxButton(String text, void Function() onPressed) {
return ButtonTheme(
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
@ -479,11 +479,13 @@ Widget getMsgBoxButton(String text, void Function() onPressed) {
Text(translate(text), style: TextStyle(color: MyTheme.accent))));
}
Widget _msgBoxTitle(String title) => Text(translate(title), style: TextStyle(fontSize: 21));
void msgBoxCommon(OverlayDialogManager dialogManager, String title,
Widget content, List<Widget> buttons) {
dialogManager.dismissAll();
dialogManager.show((setState, close) => CustomAlertDialog(
title: Text(translate(title), style: TextStyle(fontSize: 21)),
title: _msgBoxTitle(title),
content: content,
actions: buttons));
}

View File

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hbb/models/chat_model.dart';
import 'package:get/get.dart';
import 'package:tuple/tuple.dart';
import 'package:rxdart/rxdart.dart' as rxdart;
import '../../common.dart';
import '../../mobile/widgets/dialog.dart';
@ -467,7 +467,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
}
if (newValue == 'custom') {
final btnCancel = getMsgBoxButton(translate('Cancel'), () {
final btnCancel = msgBoxButton(translate('Close'), () {
widget.ffi.dialogManager.dismissAll();
});
final quality =
@ -475,26 +475,29 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
final double initValue = quality != null && quality.isNotEmpty
? quality[0].toDouble()
: 50.0;
// final slider = _ImageCustomQualitySlider(
// id: widget.id, v: RxDouble(initValue));
final RxDouble sliderValue = RxDouble(initValue);
final slider = Obx(() => Slider(
value: sliderValue.value,
max: 100,
label: sliderValue.value.round().toString(),
onChanged: (double value) {
() async {
await bind.sessionSetCustomImageQuality(
id: widget.id, value: value.toInt());
final quality = await bind.sessionGetCustomImageQuality(
id: widget.id);
sliderValue.value =
quality != null && quality.isNotEmpty
? quality[0].toDouble()
: 50.0;
}();
},
));
final rxReplay = rxdart.ReplaySubject<double>();
rxReplay
.throttleTime(const Duration(milliseconds: 1000),
trailing: true, leading: false)
.listen((double v) {
() async {
await bind.sessionSetCustomImageQuality(
id: widget.id, value: v.toInt());
}();
});
final slider = Obx(() {
return Slider(
value: sliderValue.value,
max: 100,
divisions: 100,
label: sliderValue.value.round().toString(),
onChanged: (double value) {
sliderValue.value = value;
rxReplay.add(value);
},
);
});
msgBoxCommon(widget.ffi.dialogManager, 'Custom Image Quality',
slider, [btnCancel]);
}

View File

@ -73,6 +73,7 @@ dependencies:
contextmenu: ^3.0.0
desktop_drop: ^0.3.3
scroll_pos: ^0.3.0
rxdart: ^0.27.5
dev_dependencies:
flutter_launcher_icons: ^0.9.1