flutter_desktop: handle privacy mode back notifications

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2022-08-08 22:00:01 +08:00
parent e553756ad8
commit b2ffe9dee4
8 changed files with 210 additions and 38 deletions

View File

@@ -194,14 +194,20 @@ void msgBox(String type, String title, String text, {bool? hasCancel}) {
style: TextStyle(color: MyTheme.accent))));
SmartDialog.dismiss();
final buttons = [
wrap(Translator.call('OK'), () {
SmartDialog.dismiss();
backToHome();
})
];
List<Widget> buttons = [];
if (type != "connecting" && type != "success" && type.indexOf("nook") < 0) {
buttons.insert(
0,
wrap(Translator.call('OK'), () {
SmartDialog.dismiss();
backToHome();
}));
}
if (hasCancel == null) {
hasCancel = type != 'error';
// hasCancel = type != 'error';
hasCancel = type.indexOf("error") < 0 &&
type.indexOf("nocancel") < 0 &&
type != "restarting";
}
if (hasCancel) {
buttons.insert(
@@ -210,6 +216,14 @@ void msgBox(String type, String title, String text, {bool? hasCancel}) {
SmartDialog.dismiss();
}));
}
// TODO: test this button
if (type.indexOf("hasclose") >= 0) {
buttons.insert(
0,
wrap(Translator.call('Close'), () {
SmartDialog.dismiss();
}));
}
DialogManager.show((setState, close) => CustomAlertDialog(
title: Text(translate(title), style: TextStyle(fontSize: 21)),
content: Text(Translator.call(text), style: TextStyle(fontSize: 15)),

View File

@@ -604,8 +604,12 @@ class _RemotePageState extends State<RemotePage>
await bind.getSessionToggleOption(id: id, arg: 'privacy-mode') !=
true) {
more.add(PopupMenuItem<String>(
child: Text(translate((_ffi.ffiModel.inputBlocked ? 'Unb' : 'B') +
'lock user input')),
child: Consumer<FfiModel>(
builder: (_context, ffiModel, _child) => () {
return Text(translate(
(ffiModel.inputBlocked ? 'Unb' : 'B') +
'lock user input'));
}()),
value: 'block-input'));
}
}
@@ -951,7 +955,11 @@ void showOptions(String id) async {
more.add(getToggle(
id, setState, 'lock-after-session-end', 'Lock after session end'));
if (pi.platform == 'Windows') {
more.add(getToggle(id, setState, 'privacy-mode', 'Privacy mode'));
more.add(Consumer<FfiModel>(
builder: (_context, _ffiModel, _child) => () {
return getToggle(
id, setState, 'privacy-mode', 'Privacy mode');
}()));
}
}
var setQuality = (String? value) {

View File

@@ -173,6 +173,10 @@ class FfiModel with ChangeNotifier {
parent.target?.serverModel.onClientRemove(evt);
} else if (name == 'update_quality_status') {
parent.target?.qualityMonitorModel.updateQualityStatus(evt);
} else if (name == 'update_block_input_state') {
updateBlockInputState(evt);
} else if (name == 'update_privacy_mode') {
updatePrivacyMode(evt);
}
};
}
@@ -228,6 +232,10 @@ class FfiModel with ChangeNotifier {
parent.target?.serverModel.onClientRemove(evt);
} else if (name == 'update_quality_status') {
parent.target?.qualityMonitorModel.updateQualityStatus(evt);
} else if (name == 'update_block_input_state') {
updateBlockInputState(evt);
} else if (name == 'update_privacy_mode') {
updatePrivacyMode(evt);
}
};
platformFFI.setEventCallback(cb);
@@ -331,6 +339,15 @@ class FfiModel with ChangeNotifier {
}
notifyListeners();
}
updateBlockInputState(Map<String, dynamic> evt) {
_inputBlocked = evt['input_state'] == 'on';
notifyListeners();
}
updatePrivacyMode(Map<String, dynamic> evt) {
notifyListeners();
}
}
class ImageModel with ChangeNotifier {

View File

@@ -1,4 +1,5 @@
import 'dart:convert';
import 'dart:ui';
import 'package:desktop_multi_window/desktop_multi_window.dart';
import 'package:flutter/services.dart';