flutter_desktop: custom image quality
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
7cb079afc8
commit
ce1a504e9f
2
flutter/.gitignore
vendored
2
flutter/.gitignore
vendored
@ -48,7 +48,7 @@ lib/generated_bridge.dart
|
|||||||
lib/generated_bridge.freezed.dart
|
lib/generated_bridge.freezed.dart
|
||||||
|
|
||||||
# Flutter Generated Files
|
# Flutter Generated Files
|
||||||
**/flutter/GeneratedPluginRegistrant.swift
|
**/GeneratedPluginRegistrant.swift
|
||||||
**/flutter/generated_plugin_registrant.cc
|
**/flutter/generated_plugin_registrant.cc
|
||||||
**/flutter/generated_plugin_registrant.h
|
**/flutter/generated_plugin_registrant.h
|
||||||
**/flutter/generated_plugins.cmake
|
**/flutter/generated_plugins.cmake
|
||||||
|
@ -432,7 +432,7 @@ void msgBox(
|
|||||||
if (type != "connecting" && type != "success" && !type.contains("nook")) {
|
if (type != "connecting" && type != "success" && !type.contains("nook")) {
|
||||||
buttons.insert(
|
buttons.insert(
|
||||||
0,
|
0,
|
||||||
getMsgBoxButton(translate('OK'), () {
|
msgBoxButton(translate('OK'), () {
|
||||||
dialogManager.dismissAll();
|
dialogManager.dismissAll();
|
||||||
// https://github.com/fufesou/rustdesk/blob/5e9a31340b899822090a3731769ae79c6bf5f3e5/src/ui/common.tis#L263
|
// https://github.com/fufesou/rustdesk/blob/5e9a31340b899822090a3731769ae79c6bf5f3e5/src/ui/common.tis#L263
|
||||||
if (!type.contains("custom")) {
|
if (!type.contains("custom")) {
|
||||||
@ -446,7 +446,7 @@ void msgBox(
|
|||||||
if (hasCancel) {
|
if (hasCancel) {
|
||||||
buttons.insert(
|
buttons.insert(
|
||||||
0,
|
0,
|
||||||
getMsgBoxButton(translate('Cancel'), () {
|
msgBoxButton(translate('Cancel'), () {
|
||||||
dialogManager.dismissAll();
|
dialogManager.dismissAll();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -454,17 +454,17 @@ void msgBox(
|
|||||||
if (type.contains("hasclose")) {
|
if (type.contains("hasclose")) {
|
||||||
buttons.insert(
|
buttons.insert(
|
||||||
0,
|
0,
|
||||||
getMsgBoxButton(translate('Close'), () {
|
msgBoxButton(translate('Close'), () {
|
||||||
dialogManager.dismissAll();
|
dialogManager.dismissAll();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
dialogManager.show((setState, close) => CustomAlertDialog(
|
dialogManager.show((setState, close) => CustomAlertDialog(
|
||||||
title: Text(translate(title), style: TextStyle(fontSize: 21)),
|
title: _msgBoxTitle(title),
|
||||||
content: Text(translate(text), style: TextStyle(fontSize: 15)),
|
content: Text(translate(text), style: TextStyle(fontSize: 15)),
|
||||||
actions: buttons));
|
actions: buttons));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getMsgBoxButton(String text, void Function() onPressed) {
|
Widget msgBoxButton(String text, void Function() onPressed) {
|
||||||
return ButtonTheme(
|
return ButtonTheme(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
@ -479,11 +479,13 @@ Widget getMsgBoxButton(String text, void Function() onPressed) {
|
|||||||
Text(translate(text), style: TextStyle(color: MyTheme.accent))));
|
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,
|
void msgBoxCommon(OverlayDialogManager dialogManager, String title,
|
||||||
Widget content, List<Widget> buttons) {
|
Widget content, List<Widget> buttons) {
|
||||||
dialogManager.dismissAll();
|
dialogManager.dismissAll();
|
||||||
dialogManager.show((setState, close) => CustomAlertDialog(
|
dialogManager.show((setState, close) => CustomAlertDialog(
|
||||||
title: Text(translate(title), style: TextStyle(fontSize: 21)),
|
title: _msgBoxTitle(title),
|
||||||
content: content,
|
content: content,
|
||||||
actions: buttons));
|
actions: buttons));
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_hbb/models/chat_model.dart';
|
import 'package:flutter_hbb/models/chat_model.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:rxdart/rxdart.dart' as rxdart;
|
||||||
|
|
||||||
import '../../common.dart';
|
import '../../common.dart';
|
||||||
import '../../mobile/widgets/dialog.dart';
|
import '../../mobile/widgets/dialog.dart';
|
||||||
@ -467,7 +467,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (newValue == 'custom') {
|
if (newValue == 'custom') {
|
||||||
final btnCancel = getMsgBoxButton(translate('Cancel'), () {
|
final btnCancel = msgBoxButton(translate('Close'), () {
|
||||||
widget.ffi.dialogManager.dismissAll();
|
widget.ffi.dialogManager.dismissAll();
|
||||||
});
|
});
|
||||||
final quality =
|
final quality =
|
||||||
@ -475,26 +475,29 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
|
|||||||
final double initValue = quality != null && quality.isNotEmpty
|
final double initValue = quality != null && quality.isNotEmpty
|
||||||
? quality[0].toDouble()
|
? quality[0].toDouble()
|
||||||
: 50.0;
|
: 50.0;
|
||||||
// final slider = _ImageCustomQualitySlider(
|
|
||||||
// id: widget.id, v: RxDouble(initValue));
|
|
||||||
final RxDouble sliderValue = RxDouble(initValue);
|
final RxDouble sliderValue = RxDouble(initValue);
|
||||||
final slider = Obx(() => Slider(
|
final rxReplay = rxdart.ReplaySubject<double>();
|
||||||
value: sliderValue.value,
|
rxReplay
|
||||||
max: 100,
|
.throttleTime(const Duration(milliseconds: 1000),
|
||||||
label: sliderValue.value.round().toString(),
|
trailing: true, leading: false)
|
||||||
onChanged: (double value) {
|
.listen((double v) {
|
||||||
() async {
|
() async {
|
||||||
await bind.sessionSetCustomImageQuality(
|
await bind.sessionSetCustomImageQuality(
|
||||||
id: widget.id, value: value.toInt());
|
id: widget.id, value: v.toInt());
|
||||||
final quality = await bind.sessionGetCustomImageQuality(
|
|
||||||
id: widget.id);
|
|
||||||
sliderValue.value =
|
|
||||||
quality != null && quality.isNotEmpty
|
|
||||||
? quality[0].toDouble()
|
|
||||||
: 50.0;
|
|
||||||
}();
|
}();
|
||||||
|
});
|
||||||
|
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',
|
msgBoxCommon(widget.ffi.dialogManager, 'Custom Image Quality',
|
||||||
slider, [btnCancel]);
|
slider, [btnCancel]);
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,7 @@ dependencies:
|
|||||||
contextmenu: ^3.0.0
|
contextmenu: ^3.0.0
|
||||||
desktop_drop: ^0.3.3
|
desktop_drop: ^0.3.3
|
||||||
scroll_pos: ^0.3.0
|
scroll_pos: ^0.3.0
|
||||||
|
rxdart: ^0.27.5
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_launcher_icons: ^0.9.1
|
flutter_launcher_icons: ^0.9.1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user