new dialog impl based on Overlay
This commit is contained in:
parent
2e9a6ed4f6
commit
e6329dc7eb
@ -4,10 +4,10 @@ import 'dart:io';
|
||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/instance_manager.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
import 'package:back_button_interceptor/back_button_interceptor.dart';
|
||||
|
||||
import 'models/model.dart';
|
||||
import 'models/platform_model.dart';
|
||||
@ -26,10 +26,6 @@ int androidVersion = 0;
|
||||
typedef F = String Function(String);
|
||||
typedef FMethod = String Function(String, dynamic);
|
||||
|
||||
class Translator {
|
||||
static late F call;
|
||||
}
|
||||
|
||||
class MyTheme {
|
||||
MyTheme._();
|
||||
|
||||
@ -71,44 +67,12 @@ final ButtonStyle flatButtonStyle = TextButton.styleFrom(
|
||||
),
|
||||
);
|
||||
|
||||
void showToast(String text, {Duration? duration}) {
|
||||
SmartDialog.showToast(text, displayTime: duration);
|
||||
}
|
||||
|
||||
void showLoading(String text, {bool clickMaskDismiss = false}) {
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showLoading(
|
||||
clickMaskDismiss: false,
|
||||
builder: (context) {
|
||||
return Container(
|
||||
color: MyTheme.white,
|
||||
constraints: BoxConstraints(maxWidth: 240),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(height: 30),
|
||||
Center(child: CircularProgressIndicator()),
|
||||
SizedBox(height: 20),
|
||||
Center(
|
||||
child: Text(Translator.call(text),
|
||||
style: TextStyle(fontSize: 15))),
|
||||
SizedBox(height: 20),
|
||||
Center(
|
||||
child: TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: () {
|
||||
SmartDialog.dismiss();
|
||||
backToHome();
|
||||
},
|
||||
child: Text(Translator.call('Cancel'),
|
||||
style: TextStyle(color: MyTheme.accent))))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
backToHome() {
|
||||
Navigator.popUntil(globalKey.currentContext!, ModalRoute.withName("/"));
|
||||
backToHomePage() {
|
||||
if (isAndroid || isIOS) {
|
||||
Navigator.popUntil(globalKey.currentContext!, ModalRoute.withName("/"));
|
||||
} else {
|
||||
// TODO desktop
|
||||
}
|
||||
}
|
||||
|
||||
void window_on_top(int? id) {
|
||||
@ -127,51 +91,140 @@ void window_on_top(int? id) {
|
||||
typedef DialogBuilder = CustomAlertDialog Function(
|
||||
StateSetter setState, void Function([dynamic]) close);
|
||||
|
||||
class DialogManager {
|
||||
static int _tag = 0;
|
||||
class Dialog<T> {
|
||||
OverlayEntry? entry;
|
||||
Completer<T?> completer = Completer<T>();
|
||||
|
||||
static dismissByTag(String tag, [result]) {
|
||||
SmartDialog.dismiss(tag: tag, result: result);
|
||||
Dialog();
|
||||
|
||||
void complete(T? res) {
|
||||
try {
|
||||
if (!completer.isCompleted) {
|
||||
completer.complete(res);
|
||||
}
|
||||
entry?.remove();
|
||||
} catch (e) {
|
||||
debugPrint("Dialog complete catch error: $e");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class OverlayDialogManager {
|
||||
OverlayState? _overlayState;
|
||||
Map<String, Dialog> _dialogs = Map();
|
||||
int _tagCount = 0;
|
||||
|
||||
/// By default OverlayDialogManager use global overlay
|
||||
OverlayDialogManager() {
|
||||
_overlayState = globalKey.currentState?.overlay;
|
||||
}
|
||||
|
||||
static Future<T?> show<T>(DialogBuilder builder,
|
||||
void setOverlayState(OverlayState? overlayState) {
|
||||
_overlayState = overlayState;
|
||||
}
|
||||
|
||||
void dismissAll() {
|
||||
_dialogs.forEach((key, value) {
|
||||
value.complete(null);
|
||||
BackButtonInterceptor.removeByName(key);
|
||||
});
|
||||
_dialogs.clear();
|
||||
}
|
||||
|
||||
void dismissByTag(String tag) {
|
||||
_dialogs[tag]?.complete(null);
|
||||
_dialogs.remove(tag);
|
||||
BackButtonInterceptor.removeByName(tag);
|
||||
}
|
||||
|
||||
// TODO clickMaskDismiss
|
||||
Future<T?> show<T>(DialogBuilder builder,
|
||||
{bool clickMaskDismiss = false,
|
||||
bool backDismiss = false,
|
||||
String? tag,
|
||||
bool useAnimation = true}) async {
|
||||
final t;
|
||||
if (tag != null) {
|
||||
t = tag;
|
||||
} else {
|
||||
_tag += 1;
|
||||
t = _tag.toString();
|
||||
bool useAnimation = true,
|
||||
bool forceGlobal = false}) {
|
||||
final overlayState =
|
||||
forceGlobal ? globalKey.currentState?.overlay : _overlayState;
|
||||
|
||||
if (overlayState == null) {
|
||||
return Future.error(
|
||||
"[OverlayDialogManager] Failed to show dialog, _overlayState is null, call [setOverlayState] first");
|
||||
}
|
||||
SmartDialog.dismiss(status: SmartStatus.allToast);
|
||||
SmartDialog.dismiss(status: SmartStatus.loading);
|
||||
|
||||
final _tag;
|
||||
if (tag != null) {
|
||||
_tag = tag;
|
||||
} else {
|
||||
_tag = _tagCount.toString();
|
||||
_tagCount++;
|
||||
}
|
||||
|
||||
final dialog = Dialog<T>();
|
||||
_dialogs[_tag] = dialog;
|
||||
|
||||
final close = ([res]) {
|
||||
SmartDialog.dismiss(tag: t, result: res);
|
||||
_dialogs.remove(_tag);
|
||||
dialog.complete(res);
|
||||
BackButtonInterceptor.removeByName(_tag);
|
||||
};
|
||||
final res = await SmartDialog.show<T>(
|
||||
tag: t,
|
||||
clickMaskDismiss: clickMaskDismiss,
|
||||
backDismiss: backDismiss,
|
||||
useAnimation: useAnimation,
|
||||
builder: (_) => StatefulBuilder(
|
||||
builder: (_, setState) => builder(setState, close)));
|
||||
return res;
|
||||
dialog.entry = OverlayEntry(builder: (_) {
|
||||
return Container(
|
||||
color: Colors.transparent,
|
||||
child: StatefulBuilder(
|
||||
builder: (_, setState) => builder(setState, close)));
|
||||
});
|
||||
overlayState.insert(dialog.entry!);
|
||||
BackButtonInterceptor.add((stopDefaultButtonEvent, routeInfo) {
|
||||
if (backDismiss) {
|
||||
close();
|
||||
}
|
||||
return true;
|
||||
}, name: _tag);
|
||||
return dialog.completer.future;
|
||||
}
|
||||
|
||||
void showLoading(String text,
|
||||
{bool clickMaskDismiss = false, bool cancelToClose = false}) {
|
||||
show((setState, close) => CustomAlertDialog(
|
||||
content: Container(
|
||||
color: MyTheme.white,
|
||||
constraints: BoxConstraints(maxWidth: 240),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(height: 30),
|
||||
Center(child: CircularProgressIndicator()),
|
||||
SizedBox(height: 20),
|
||||
Center(
|
||||
child: Text(translate(text),
|
||||
style: TextStyle(fontSize: 15))),
|
||||
SizedBox(height: 20),
|
||||
Center(
|
||||
child: TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: () {
|
||||
dismissAll();
|
||||
if (cancelToClose) backToHomePage();
|
||||
},
|
||||
child: Text(translate('Cancel'),
|
||||
style: TextStyle(color: MyTheme.accent))))
|
||||
]))));
|
||||
}
|
||||
|
||||
void showToast(String text) {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
class CustomAlertDialog extends StatelessWidget {
|
||||
CustomAlertDialog(
|
||||
{required this.title,
|
||||
required this.content,
|
||||
required this.actions,
|
||||
this.contentPadding});
|
||||
{this.title, required this.content, this.actions, this.contentPadding});
|
||||
|
||||
final Widget title;
|
||||
final Widget? title;
|
||||
final Widget content;
|
||||
final List<Widget> actions;
|
||||
final List<Widget>? actions;
|
||||
final double? contentPadding;
|
||||
|
||||
@override
|
||||
@ -187,7 +240,9 @@ class CustomAlertDialog extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
void msgBox(String type, String title, String text, {bool? hasCancel}) {
|
||||
void msgBox(
|
||||
String type, String title, String text, OverlayDialogManager dialogManager,
|
||||
{bool? hasCancel}) {
|
||||
var wrap = (String text, void Function() onPressed) => ButtonTheme(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
@ -198,17 +253,17 @@ void msgBox(String type, String title, String text, {bool? hasCancel}) {
|
||||
child: TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: onPressed,
|
||||
child: Text(Translator.call(text),
|
||||
style: TextStyle(color: MyTheme.accent))));
|
||||
child:
|
||||
Text(translate(text), style: TextStyle(color: MyTheme.accent))));
|
||||
|
||||
SmartDialog.dismiss();
|
||||
dialogManager.dismissAll();
|
||||
List<Widget> buttons = [];
|
||||
if (type != "connecting" && type != "success" && type.indexOf("nook") < 0) {
|
||||
buttons.insert(
|
||||
0,
|
||||
wrap(Translator.call('OK'), () {
|
||||
SmartDialog.dismiss();
|
||||
backToHome();
|
||||
wrap(translate('OK'), () {
|
||||
dialogManager.dismissAll();
|
||||
backToHomePage();
|
||||
}));
|
||||
}
|
||||
if (hasCancel == null) {
|
||||
@ -220,21 +275,21 @@ void msgBox(String type, String title, String text, {bool? hasCancel}) {
|
||||
if (hasCancel) {
|
||||
buttons.insert(
|
||||
0,
|
||||
wrap(Translator.call('Cancel'), () {
|
||||
SmartDialog.dismiss();
|
||||
wrap(translate('Cancel'), () {
|
||||
dialogManager.dismissAll();
|
||||
}));
|
||||
}
|
||||
// TODO: test this button
|
||||
if (type.indexOf("hasclose") >= 0) {
|
||||
buttons.insert(
|
||||
0,
|
||||
wrap(Translator.call('Close'), () {
|
||||
SmartDialog.dismiss();
|
||||
wrap(translate('Close'), () {
|
||||
dialogManager.dismissAll();
|
||||
}));
|
||||
}
|
||||
DialogManager.show((setState, close) => CustomAlertDialog(
|
||||
dialogManager.show((setState, close) => CustomAlertDialog(
|
||||
title: Text(translate(title), style: TextStyle(fontSize: 21)),
|
||||
content: Text(Translator.call(text), style: TextStyle(fontSize: 15)),
|
||||
content: Text(translate(text), style: TextStyle(fontSize: 15)),
|
||||
actions: buttons));
|
||||
}
|
||||
|
||||
|
@ -625,7 +625,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
||||
var field = "";
|
||||
var msg = "";
|
||||
var isInProgress = false;
|
||||
DialogManager.show((setState, close) {
|
||||
gFFI.dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate("Add ID")),
|
||||
content: Column(
|
||||
@ -698,7 +698,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
||||
var field = "";
|
||||
var msg = "";
|
||||
var isInProgress = false;
|
||||
DialogManager.show((setState, close) {
|
||||
gFFI.dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate("Add Tag")),
|
||||
content: Column(
|
||||
@ -769,7 +769,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
||||
final tags = List.of(gFFI.abModel.tags);
|
||||
var selectedTag = gFFI.abModel.getPeerTags(id).obs;
|
||||
|
||||
DialogManager.show((setState, close) {
|
||||
gFFI.dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate("Edit Tag")),
|
||||
content: Column(
|
||||
@ -884,16 +884,16 @@ class _WebMenuState extends State<WebMenu> {
|
||||
},
|
||||
onSelected: (value) {
|
||||
if (value == 'server') {
|
||||
showServerSettings();
|
||||
showServerSettings(gFFI.dialogManager);
|
||||
}
|
||||
if (value == 'about') {
|
||||
showAbout();
|
||||
showAbout(gFFI.dialogManager);
|
||||
}
|
||||
if (value == 'login') {
|
||||
if (username == null) {
|
||||
showLogin();
|
||||
showLogin(gFFI.dialogManager);
|
||||
} else {
|
||||
logout();
|
||||
logout(gFFI.dialogManager);
|
||||
}
|
||||
}
|
||||
if (value == 'scan') {
|
||||
|
@ -116,7 +116,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
onDoubleTap: () {
|
||||
Clipboard.setData(
|
||||
ClipboardData(text: model.serverId.text));
|
||||
showToast(translate("Copied"));
|
||||
gFFI.dialogManager.showToast(translate("Copied"));
|
||||
},
|
||||
child: TextFormField(
|
||||
controller: model.serverId,
|
||||
@ -253,7 +253,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
kUsePermanentPassword) {
|
||||
Clipboard.setData(
|
||||
ClipboardData(text: model.serverPasswd.text));
|
||||
showToast(translate("Copied"));
|
||||
gFFI.dialogManager.showToast(translate("Copied"));
|
||||
}
|
||||
},
|
||||
child: TextFormField(
|
||||
@ -604,7 +604,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
var newId = "";
|
||||
var msg = "";
|
||||
var isInProgress = false;
|
||||
DialogManager.show((setState, close) {
|
||||
gFFI.dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate("Change ID")),
|
||||
content: Column(
|
||||
@ -690,7 +690,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
var key = oldOptions['key'] ?? "";
|
||||
|
||||
var isInProgress = false;
|
||||
DialogManager.show((setState, close) {
|
||||
gFFI.dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate("ID/Relay Server")),
|
||||
content: ConstrainedBox(
|
||||
@ -891,7 +891,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
var newWhiteListField = newWhiteList.join('\n');
|
||||
var msg = "";
|
||||
var isInProgress = false;
|
||||
DialogManager.show((setState, close) {
|
||||
gFFI.dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate("IP Whitelisting")),
|
||||
content: Column(
|
||||
@ -980,7 +980,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
}
|
||||
|
||||
var isInProgress = false;
|
||||
DialogManager.show((setState, close) {
|
||||
gFFI.dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate("Socks5 Proxy")),
|
||||
content: ConstrainedBox(
|
||||
@ -1117,7 +1117,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
final license = await bind.mainGetLicense();
|
||||
final version = await bind.mainGetVersion();
|
||||
final linkStyle = TextStyle(decoration: TextDecoration.underline);
|
||||
DialogManager.show((setState, close) {
|
||||
gFFI.dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text("About $appName"),
|
||||
content: ConstrainedBox(
|
||||
@ -1208,7 +1208,7 @@ Future<bool> loginDialog() async {
|
||||
|
||||
var isInProgress = false;
|
||||
var completer = Completer<bool>();
|
||||
DialogManager.show((setState, close) {
|
||||
gFFI.dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate("Login")),
|
||||
content: ConstrainedBox(
|
||||
@ -1339,7 +1339,7 @@ void setPasswordDialog() async {
|
||||
var errMsg0 = "";
|
||||
var errMsg1 = "";
|
||||
|
||||
DialogManager.show((setState, close) {
|
||||
gFFI.dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate("Set Password")),
|
||||
content: ConstrainedBox(
|
||||
|
@ -4,7 +4,6 @@ import 'dart:math';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/mobile/pages/file_manager_page.dart';
|
||||
import 'package:flutter_hbb/models/file_model.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wakelock/wakelock.dart';
|
||||
@ -26,8 +25,7 @@ class _FileManagerPageState extends State<FileManagerPage>
|
||||
final _localSelectedItems = SelectedItems();
|
||||
final _remoteSelectedItems = SelectedItems();
|
||||
|
||||
/// FFI with name file_transfer_id
|
||||
FFI get _ffi => ffi('ft_${widget.id}');
|
||||
late FFI _ffi;
|
||||
|
||||
FileModel get model => _ffi.fileModel;
|
||||
|
||||
@ -38,8 +36,9 @@ class _FileManagerPageState extends State<FileManagerPage>
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
Get.put(FFI()..connect(widget.id, isFileTransfer: true),
|
||||
tag: 'ft_${widget.id}');
|
||||
_ffi = FFI();
|
||||
_ffi.connect(widget.id, isFileTransfer: true);
|
||||
Get.put(_ffi, tag: 'ft_${widget.id}');
|
||||
// _ffi.ffiModel.updateEventListener(widget.id);
|
||||
if (!Platform.isLinux) {
|
||||
Wakelock.enable();
|
||||
@ -51,7 +50,7 @@ class _FileManagerPageState extends State<FileManagerPage>
|
||||
void dispose() {
|
||||
model.onClose();
|
||||
_ffi.close();
|
||||
SmartDialog.dismiss();
|
||||
_ffi.dialogManager.dismissAll();
|
||||
if (!Platform.isLinux) {
|
||||
Wakelock.disable();
|
||||
}
|
||||
@ -552,7 +551,7 @@ class _FileManagerPageState extends State<FileManagerPage>
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
final name = TextEditingController();
|
||||
DialogManager.show((setState, close) =>
|
||||
_ffi.dialogManager.show((setState, close) =>
|
||||
CustomAlertDialog(
|
||||
title: Text(translate("Create Folder")),
|
||||
content: Column(
|
||||
|
@ -7,9 +7,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_hbb/mobile/widgets/gesture_help.dart';
|
||||
import 'package:flutter_hbb/models/chat_model.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/route_manager.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wakelock/wakelock.dart';
|
||||
|
||||
@ -51,18 +49,19 @@ class _RemotePageState extends State<RemotePage>
|
||||
var _showEdit = false; // use soft keyboard
|
||||
var _isPhysicalMouse = false;
|
||||
|
||||
FFI get _ffi => ffi(widget.id);
|
||||
late FFI _ffi;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
var ffitmp = FFI();
|
||||
ffitmp.canvasModel.tabBarHeight = super.widget.tabBarHeight;
|
||||
final ffi = Get.put(ffitmp, tag: widget.id);
|
||||
ffi.connect(widget.id, tabBarHeight: super.widget.tabBarHeight);
|
||||
_ffi = FFI();
|
||||
_ffi.canvasModel.tabBarHeight = super.widget.tabBarHeight;
|
||||
Get.put(_ffi, tag: widget.id);
|
||||
_ffi.connect(widget.id, tabBarHeight: super.widget.tabBarHeight);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
||||
showLoading(translate('Connecting...'));
|
||||
_ffi.dialogManager
|
||||
.showLoading(translate('Connecting...'), cancelToClose: true);
|
||||
_interval =
|
||||
Timer.periodic(Duration(milliseconds: 30), (timer) => interval());
|
||||
});
|
||||
@ -70,8 +69,8 @@ class _RemotePageState extends State<RemotePage>
|
||||
Wakelock.enable();
|
||||
}
|
||||
_physicalFocusNode.requestFocus();
|
||||
ffi.ffiModel.updateEventListener(widget.id);
|
||||
ffi.listenToMouse(true);
|
||||
_ffi.ffiModel.updateEventListener(widget.id);
|
||||
_ffi.listenToMouse(true);
|
||||
// WindowManager.instance.addListener(this);
|
||||
}
|
||||
|
||||
@ -86,7 +85,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
_ffi.close();
|
||||
_interval?.cancel();
|
||||
_timer?.cancel();
|
||||
SmartDialog.dismiss();
|
||||
_ffi.dialogManager.dismissAll();
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
|
||||
overlays: SystemUiOverlay.values);
|
||||
if (!Platform.isLinux) {
|
||||
@ -262,8 +261,11 @@ class _RemotePageState extends State<RemotePage>
|
||||
initialEntries: [
|
||||
OverlayEntry(builder: (context) {
|
||||
_ffi.chatModel.setOverlayState(Overlay.of(context));
|
||||
_ffi.dialogManager.setOverlayState(Overlay.of(context));
|
||||
return Container(
|
||||
child: getRawPointerAndKeyBody(getBodyForDesktop(keyboard)));
|
||||
color: Colors.black,
|
||||
child: getRawPointerAndKeyBody(
|
||||
getBodyForDesktop(context, keyboard)));
|
||||
})
|
||||
],
|
||||
));
|
||||
@ -275,7 +277,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
_ffi.canvasModel.tabBarHeight = super.widget.tabBarHeight;
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
clientClose();
|
||||
clientClose(_ffi.dialogManager);
|
||||
return false;
|
||||
},
|
||||
child: MultiProvider(
|
||||
@ -410,7 +412,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
color: Colors.white,
|
||||
icon: Icon(Icons.clear),
|
||||
onPressed: () {
|
||||
clientClose();
|
||||
clientClose(_ffi.dialogManager);
|
||||
},
|
||||
)
|
||||
] +
|
||||
@ -420,7 +422,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
icon: Icon(Icons.tv),
|
||||
onPressed: () {
|
||||
setState(() => _showEdit = false);
|
||||
showOptions(widget.id);
|
||||
showOptions(widget.id, _ffi.dialogManager);
|
||||
},
|
||||
)
|
||||
] +
|
||||
@ -497,7 +499,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
/// DoubleFiner -> right click
|
||||
/// HoldDrag -> left drag
|
||||
|
||||
Widget getBodyForDesktop(bool keyboard) {
|
||||
Widget getBodyForDesktop(BuildContext context, bool keyboard) {
|
||||
var paints = <Widget>[
|
||||
MouseRegion(onEnter: (evt) {
|
||||
bind.hostStopSystemKeyPropagate(stopped: false);
|
||||
@ -567,7 +569,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
style: flatButtonStyle,
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
showSetOSPassword(widget.id, false);
|
||||
showSetOSPassword(widget.id, false, _ffi.dialogManager);
|
||||
},
|
||||
child: Icon(Icons.edit, color: MyTheme.accent),
|
||||
)
|
||||
@ -632,7 +634,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
if (password != null) {
|
||||
bind.sessionInputOsPassword(id: widget.id, value: password);
|
||||
} else {
|
||||
showSetOSPassword(widget.id, true);
|
||||
showSetOSPassword(widget.id, true, _ffi.dialogManager);
|
||||
}
|
||||
} else if (value == 'reset_canvas') {
|
||||
_ffi.cursorModel.reset();
|
||||
@ -889,7 +891,7 @@ class ImagePainter extends CustomPainter {
|
||||
}
|
||||
}
|
||||
|
||||
void showOptions(String id) async {
|
||||
void showOptions(String id, OverlayDialogManager dialogManager) async {
|
||||
String quality = await bind.getSessionImageQuality(id: id) ?? 'balanced';
|
||||
if (quality == '') quality = 'balanced';
|
||||
String viewStyle =
|
||||
@ -907,7 +909,7 @@ void showOptions(String id) async {
|
||||
onTap: () {
|
||||
if (i == cur) return;
|
||||
bind.sessionSwitchDisplay(id: id, value: i);
|
||||
SmartDialog.dismiss();
|
||||
dialogManager.dismissAll();
|
||||
},
|
||||
child: Ink(
|
||||
width: 40,
|
||||
@ -932,7 +934,7 @@ void showOptions(String id) async {
|
||||
}
|
||||
final perms = ffi(id).ffiModel.permissions;
|
||||
|
||||
DialogManager.show((setState, close) {
|
||||
dialogManager.show((setState, close) {
|
||||
final more = <Widget>[];
|
||||
if (perms['audio'] != false) {
|
||||
more.add(getToggle(id, setState, 'disable-audio', 'Mute'));
|
||||
@ -990,12 +992,13 @@ void showOptions(String id) async {
|
||||
}, clickMaskDismiss: true, backDismiss: true);
|
||||
}
|
||||
|
||||
void showSetOSPassword(String id, bool login) async {
|
||||
void showSetOSPassword(
|
||||
String id, bool login, OverlayDialogManager dialogManager) async {
|
||||
final controller = TextEditingController();
|
||||
var password = await bind.getSessionOption(id: id, arg: "os-password") ?? "";
|
||||
var autoLogin = await bind.getSessionOption(id: id, arg: "auto-login") != "";
|
||||
controller.text = password;
|
||||
DialogManager.show((setState, close) {
|
||||
dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate('OS Password')),
|
||||
content: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/file_manager_tab_page.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
/// multi-tab file transfer remote screen
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/connection_tab_page.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
/// multi-tab desktop remote screen
|
||||
|
@ -258,7 +258,7 @@ class _PeerCardState extends State<_PeerCard>
|
||||
final tags = List.of(gFFI.abModel.tags);
|
||||
var selectedTag = gFFI.abModel.getPeerTags(id).obs;
|
||||
|
||||
DialogManager.show((setState, close) {
|
||||
gFFI.dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate("Edit Tag")),
|
||||
content: Column(
|
||||
@ -314,7 +314,7 @@ class _PeerCardState extends State<_PeerCard>
|
||||
}
|
||||
}
|
||||
final k = GlobalKey<FormState>();
|
||||
DialogManager.show((setState, close) {
|
||||
gFFI.dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate("Rename")),
|
||||
content: Column(
|
||||
|
@ -5,7 +5,6 @@ import 'package:flutter_hbb/desktop/pages/desktop_tab_page.dart';
|
||||
import 'package:flutter_hbb/desktop/screen/desktop_file_transfer_screen.dart';
|
||||
import 'package:flutter_hbb/desktop/screen/desktop_remote_screen.dart';
|
||||
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/route_manager.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@ -95,14 +94,7 @@ void runRemoteScreen(Map<String, dynamic> argument) async {
|
||||
),
|
||||
navigatorObservers: [
|
||||
// FirebaseAnalyticsObserver(analytics: analytics),
|
||||
FlutterSmartDialog.observer
|
||||
],
|
||||
builder: FlutterSmartDialog.init(
|
||||
builder: isAndroid
|
||||
? (_, child) => AccessibilityListener(
|
||||
child: child,
|
||||
)
|
||||
: null),
|
||||
));
|
||||
}
|
||||
|
||||
@ -116,14 +108,7 @@ void runFileTransferScreen(Map<String, dynamic> argument) async {
|
||||
home: DesktopFileTransferScreen(params: argument),
|
||||
navigatorObservers: [
|
||||
// FirebaseAnalyticsObserver(analytics: analytics),
|
||||
FlutterSmartDialog.observer
|
||||
],
|
||||
builder: FlutterSmartDialog.init(
|
||||
builder: isAndroid
|
||||
? (_, child) => AccessibilityListener(
|
||||
child: child,
|
||||
)
|
||||
: null)));
|
||||
]));
|
||||
}
|
||||
|
||||
class App extends StatelessWidget {
|
||||
@ -153,14 +138,12 @@ class App extends StatelessWidget {
|
||||
: HomePage(),
|
||||
navigatorObservers: [
|
||||
// FirebaseAnalyticsObserver(analytics: analytics),
|
||||
FlutterSmartDialog.observer
|
||||
],
|
||||
builder: FlutterSmartDialog.init(
|
||||
builder: isAndroid
|
||||
? (_, child) => AccessibilityListener(
|
||||
child: child,
|
||||
)
|
||||
: null)),
|
||||
builder: isAndroid
|
||||
? (_, child) => AccessibilityListener(
|
||||
child: child,
|
||||
)
|
||||
: null),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -380,16 +380,16 @@ class _WebMenuState extends State<WebMenu> {
|
||||
},
|
||||
onSelected: (value) {
|
||||
if (value == 'server') {
|
||||
showServerSettings();
|
||||
showServerSettings(gFFI.dialogManager);
|
||||
}
|
||||
if (value == 'about') {
|
||||
showAbout();
|
||||
showAbout(gFFI.dialogManager);
|
||||
}
|
||||
if (value == 'login') {
|
||||
if (username == null) {
|
||||
showLogin();
|
||||
showLogin(gFFI.dialogManager);
|
||||
} else {
|
||||
logout();
|
||||
logout(gFFI.dialogManager);
|
||||
}
|
||||
}
|
||||
if (value == 'scan') {
|
||||
|
@ -3,13 +3,11 @@ import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_breadcrumb/flutter_breadcrumb.dart';
|
||||
import 'package:flutter_hbb/models/file_model.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toggle_switch/toggle_switch.dart';
|
||||
import 'package:wakelock/wakelock.dart';
|
||||
|
||||
import '../../common.dart';
|
||||
import '../../models/model.dart';
|
||||
import '../widgets/dialog.dart';
|
||||
|
||||
class FileManagerPage extends StatefulWidget {
|
||||
@ -29,7 +27,10 @@ class _FileManagerPageState extends State<FileManagerPage> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
gFFI.connect(widget.id, isFileTransfer: true);
|
||||
showLoading(translate('Connecting...'));
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
gFFI.dialogManager
|
||||
.showLoading(translate('Connecting...'), cancelToClose: true);
|
||||
});
|
||||
gFFI.ffiModel.updateEventListener(widget.id);
|
||||
Wakelock.enable();
|
||||
}
|
||||
@ -38,7 +39,7 @@ class _FileManagerPageState extends State<FileManagerPage> {
|
||||
void dispose() {
|
||||
model.onClose();
|
||||
gFFI.close();
|
||||
SmartDialog.dismiss();
|
||||
gFFI.dialogManager.dismissAll();
|
||||
Wakelock.disable();
|
||||
super.dispose();
|
||||
}
|
||||
@ -60,7 +61,9 @@ class _FileManagerPageState extends State<FileManagerPage> {
|
||||
backgroundColor: MyTheme.grayBg,
|
||||
appBar: AppBar(
|
||||
leading: Row(children: [
|
||||
IconButton(icon: Icon(Icons.close), onPressed: clientClose),
|
||||
IconButton(
|
||||
icon: Icon(Icons.close),
|
||||
onPressed: () => clientClose(gFFI.dialogManager)),
|
||||
]),
|
||||
centerTitle: true,
|
||||
title: ToggleSwitch(
|
||||
@ -141,8 +144,8 @@ class _FileManagerPageState extends State<FileManagerPage> {
|
||||
model.toggleSelectMode();
|
||||
} else if (v == "folder") {
|
||||
final name = TextEditingController();
|
||||
DialogManager.show(
|
||||
(setState, close) => CustomAlertDialog(
|
||||
gFFI.dialogManager
|
||||
.show((setState, close) => CustomAlertDialog(
|
||||
title: Text(translate("Create Folder")),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
@ -6,7 +6,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_hbb/mobile/widgets/gesture_help.dart';
|
||||
import 'package:flutter_hbb/models/chat_model.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wakelock/wakelock.dart';
|
||||
|
||||
@ -51,7 +50,8 @@ class _RemotePageState extends State<RemotePage> {
|
||||
gFFI.connect(widget.id);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
||||
showLoading(translate('Connecting...'));
|
||||
gFFI.dialogManager
|
||||
.showLoading(translate('Connecting...'), cancelToClose: true);
|
||||
_interval =
|
||||
Timer.periodic(Duration(milliseconds: 30), (timer) => interval());
|
||||
});
|
||||
@ -71,7 +71,7 @@ class _RemotePageState extends State<RemotePage> {
|
||||
gFFI.close();
|
||||
_interval?.cancel();
|
||||
_timer?.cancel();
|
||||
SmartDialog.dismiss();
|
||||
gFFI.dialogManager.dismissAll();
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
|
||||
overlays: SystemUiOverlay.values);
|
||||
Wakelock.disable();
|
||||
@ -226,7 +226,7 @@ class _RemotePageState extends State<RemotePage> {
|
||||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
clientClose();
|
||||
clientClose(gFFI.dialogManager);
|
||||
return false;
|
||||
},
|
||||
child: getRawPointerAndKeyBody(
|
||||
@ -401,7 +401,7 @@ class _RemotePageState extends State<RemotePage> {
|
||||
color: Colors.white,
|
||||
icon: Icon(Icons.clear),
|
||||
onPressed: () {
|
||||
clientClose();
|
||||
clientClose(gFFI.dialogManager);
|
||||
},
|
||||
)
|
||||
] +
|
||||
@ -411,7 +411,7 @@ class _RemotePageState extends State<RemotePage> {
|
||||
icon: Icon(Icons.tv),
|
||||
onPressed: () {
|
||||
setState(() => _showEdit = false);
|
||||
showOptions(widget.id);
|
||||
showOptions(widget.id, gFFI.dialogManager);
|
||||
},
|
||||
)
|
||||
] +
|
||||
@ -671,7 +671,7 @@ class _RemotePageState extends State<RemotePage> {
|
||||
style: flatButtonStyle,
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
showSetOSPassword(id, false);
|
||||
showSetOSPassword(id, false, gFFI.dialogManager);
|
||||
},
|
||||
child: Icon(Icons.edit, color: MyTheme.accent),
|
||||
)
|
||||
@ -739,12 +739,12 @@ class _RemotePageState extends State<RemotePage> {
|
||||
if (password != null) {
|
||||
bind.sessionInputOsPassword(id: widget.id, value: password);
|
||||
} else {
|
||||
showSetOSPassword(id, true);
|
||||
showSetOSPassword(id, true, gFFI.dialogManager);
|
||||
}
|
||||
} else if (value == 'reset_canvas') {
|
||||
gFFI.cursorModel.reset();
|
||||
} else if (value == 'restart') {
|
||||
showRestartRemoteDevice(pi, widget.id);
|
||||
showRestartRemoteDevice(pi, widget.id, gFFI.dialogManager);
|
||||
}
|
||||
}();
|
||||
}
|
||||
@ -1008,7 +1008,7 @@ class QualityMonitor extends StatelessWidget {
|
||||
: SizedBox.shrink())));
|
||||
}
|
||||
|
||||
void showOptions(String id) async {
|
||||
void showOptions(String id, OverlayDialogManager dialogManager) async {
|
||||
String quality = await bind.getSessionImageQuality(id: id) ?? 'balanced';
|
||||
if (quality == '') quality = 'balanced';
|
||||
String viewStyle =
|
||||
@ -1026,7 +1026,7 @@ void showOptions(String id) async {
|
||||
onTap: () {
|
||||
if (i == cur) return;
|
||||
bind.sessionSwitchDisplay(id: id, value: i);
|
||||
SmartDialog.dismiss();
|
||||
gFFI.dialogManager.dismissAll();
|
||||
},
|
||||
child: Ink(
|
||||
width: 40,
|
||||
@ -1051,7 +1051,7 @@ void showOptions(String id) async {
|
||||
}
|
||||
final perms = gFFI.ffiModel.permissions;
|
||||
|
||||
DialogManager.show((setState, close) {
|
||||
dialogManager.show((setState, close) {
|
||||
final more = <Widget>[];
|
||||
if (perms['audio'] != false) {
|
||||
more.add(getToggle(id, setState, 'disable-audio', 'Mute'));
|
||||
@ -1107,9 +1107,10 @@ void showOptions(String id) async {
|
||||
}, clickMaskDismiss: true, backDismiss: true);
|
||||
}
|
||||
|
||||
void showRestartRemoteDevice(PeerInfo pi, String id) async {
|
||||
void showRestartRemoteDevice(
|
||||
PeerInfo pi, String id, OverlayDialogManager dialogManager) async {
|
||||
final res =
|
||||
await DialogManager.show<bool>((setState, close) => CustomAlertDialog(
|
||||
await dialogManager.show<bool>((setState, close) => CustomAlertDialog(
|
||||
title: Row(children: [
|
||||
Icon(Icons.warning_amber_sharp,
|
||||
color: Colors.redAccent, size: 28),
|
||||
@ -1128,12 +1129,13 @@ void showRestartRemoteDevice(PeerInfo pi, String id) async {
|
||||
if (res == true) bind.sessionRestartRemoteDevice(id: id);
|
||||
}
|
||||
|
||||
void showSetOSPassword(String id, bool login) async {
|
||||
void showSetOSPassword(
|
||||
String id, bool login, OverlayDialogManager dialogManager) async {
|
||||
final controller = TextEditingController();
|
||||
var password = await bind.getSessionOption(id: id, arg: "os-password") ?? "";
|
||||
var autoLogin = await bind.getSessionOption(id: id, arg: "auto-login") != "";
|
||||
controller.text = password;
|
||||
DialogManager.show((setState, close) {
|
||||
dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate('OS Password')),
|
||||
content: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
|
@ -63,7 +63,7 @@ class _ScanPageState extends State<ScanPage> {
|
||||
var result = reader.decode(bitmap);
|
||||
showServerSettingFromQr(result.text);
|
||||
} catch (e) {
|
||||
showToast('No QR code found');
|
||||
gFFI.dialogManager.showToast('No QR code found');
|
||||
}
|
||||
}
|
||||
}),
|
||||
@ -121,7 +121,7 @@ class _ScanPageState extends State<ScanPage> {
|
||||
|
||||
void _onPermissionSet(BuildContext context, QRViewController ctrl, bool p) {
|
||||
if (!p) {
|
||||
showToast('No permisssion');
|
||||
gFFI.dialogManager.showToast('No permisssion');
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,10 +132,10 @@ class _ScanPageState extends State<ScanPage> {
|
||||
}
|
||||
|
||||
void showServerSettingFromQr(String data) async {
|
||||
backToHome();
|
||||
backToHomePage();
|
||||
await controller?.pauseCamera();
|
||||
if (!data.startsWith('config=')) {
|
||||
showToast('Invalid QR code');
|
||||
gFFI.dialogManager.showToast('Invalid QR code');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@ -144,16 +144,16 @@ class _ScanPageState extends State<ScanPage> {
|
||||
var key = values['key'] != null ? values['key'] as String : '';
|
||||
var api = values['api'] != null ? values['api'] as String : '';
|
||||
Timer(Duration(milliseconds: 60), () {
|
||||
showServerSettingsWithValue(host, '', key, api);
|
||||
showServerSettingsWithValue(host, '', key, api, gFFI.dialogManager);
|
||||
});
|
||||
} catch (e) {
|
||||
showToast('Invalid QR code');
|
||||
gFFI.dialogManager.showToast('Invalid QR code');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void showServerSettingsWithValue(
|
||||
String id, String relay, String key, String api) async {
|
||||
void showServerSettingsWithValue(String id, String relay, String key,
|
||||
String api, OverlayDialogManager dialogManager) async {
|
||||
Map<String, dynamic> oldOptions = jsonDecode(await bind.mainGetOptions());
|
||||
String id0 = oldOptions['custom-rendezvous-server'] ?? "";
|
||||
String relay0 = oldOptions['relay-server'] ?? "";
|
||||
@ -168,7 +168,7 @@ void showServerSettingsWithValue(
|
||||
String? relayServerMsg;
|
||||
String? apiServerMsg;
|
||||
|
||||
DialogManager.show((setState, close) {
|
||||
dialogManager.show((setState, close) {
|
||||
Future<bool> validate() async {
|
||||
if (idController.text != id) {
|
||||
final res = await validateAsync(idController.text);
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/mobile/widgets/dialog.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../common.dart';
|
||||
@ -90,9 +89,9 @@ class ServerPage extends StatefulWidget implements PageShape {
|
||||
if (value == "changeID") {
|
||||
// TODO
|
||||
} else if (value == "setPermanentPassword") {
|
||||
setPermanentPasswordDialog();
|
||||
setPermanentPasswordDialog(gFFI.dialogManager);
|
||||
} else if (value == "setTemporaryPasswordLength") {
|
||||
setTemporaryPasswordLengthDialog();
|
||||
setTemporaryPasswordLengthDialog(gFFI.dialogManager);
|
||||
} else if (value == kUsePermanentPassword ||
|
||||
value == kUseTemporaryPassword ||
|
||||
value == kUseBothPasswords) {
|
||||
@ -522,7 +521,7 @@ void toAndroidChannelInit() {
|
||||
switch (method) {
|
||||
case "start_capture":
|
||||
{
|
||||
SmartDialog.dismiss();
|
||||
gFFI.dialogManager.dismissAll();
|
||||
gFFI.serverModel.updateClientState();
|
||||
break;
|
||||
}
|
||||
|
@ -119,8 +119,8 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
||||
if (v) {
|
||||
PermissionManager.request("ignore_battery_optimizations");
|
||||
} else {
|
||||
final res = await DialogManager.show<bool>(
|
||||
(setState, close) => CustomAlertDialog(
|
||||
final res = await gFFI.dialogManager
|
||||
.show<bool>((setState, close) => CustomAlertDialog(
|
||||
title: Text(translate("Open System Setting")),
|
||||
content: Text(translate(
|
||||
"android_open_battery_optimizations_tip")),
|
||||
@ -153,9 +153,9 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
||||
leading: Icon(Icons.person),
|
||||
onPressed: (context) {
|
||||
if (username == null) {
|
||||
showLogin();
|
||||
showLogin(gFFI.dialogManager);
|
||||
} else {
|
||||
logout();
|
||||
logout(gFFI.dialogManager);
|
||||
}
|
||||
},
|
||||
),
|
||||
@ -166,13 +166,13 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
||||
title: Text(translate('ID/Relay Server')),
|
||||
leading: Icon(Icons.cloud),
|
||||
onPressed: (context) {
|
||||
showServerSettings();
|
||||
showServerSettings(gFFI.dialogManager);
|
||||
}),
|
||||
SettingsTile.navigation(
|
||||
title: Text(translate('Language')),
|
||||
leading: Icon(Icons.translate),
|
||||
onPressed: (context) {
|
||||
showLanguageSettings();
|
||||
showLanguageSettings(gFFI.dialogManager);
|
||||
})
|
||||
]),
|
||||
SettingsSection(
|
||||
@ -204,20 +204,20 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
||||
}
|
||||
}
|
||||
|
||||
void showServerSettings() async {
|
||||
void showServerSettings(OverlayDialogManager dialogManager) async {
|
||||
Map<String, dynamic> options = jsonDecode(await bind.mainGetOptions());
|
||||
String id = options['custom-rendezvous-server'] ?? "";
|
||||
String relay = options['relay-server'] ?? "";
|
||||
String api = options['api-server'] ?? "";
|
||||
String key = options['key'] ?? "";
|
||||
showServerSettingsWithValue(id, relay, key, api);
|
||||
showServerSettingsWithValue(id, relay, key, api, dialogManager);
|
||||
}
|
||||
|
||||
void showLanguageSettings() async {
|
||||
void showLanguageSettings(OverlayDialogManager dialogManager) async {
|
||||
try {
|
||||
final langs = json.decode(await bind.mainGetLangs()) as List<dynamic>;
|
||||
var lang = await bind.mainGetLocalOption(key: "lang");
|
||||
DialogManager.show((setState, close) {
|
||||
dialogManager.show((setState, close) {
|
||||
final setLang = (v) {
|
||||
if (lang != v) {
|
||||
setState(() {
|
||||
@ -246,8 +246,8 @@ void showLanguageSettings() async {
|
||||
} catch (_e) {}
|
||||
}
|
||||
|
||||
void showAbout() {
|
||||
DialogManager.show((setState, close) {
|
||||
void showAbout(OverlayDialogManager dialogManager) {
|
||||
dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate('About') + ' RustDesk'),
|
||||
content: Wrap(direction: Axis.vertical, spacing: 12, children: [
|
||||
@ -350,7 +350,7 @@ void refreshCurrentUser() async {
|
||||
}
|
||||
}
|
||||
|
||||
void logout() async {
|
||||
void logout(OverlayDialogManager dialogManager) async {
|
||||
final token = await bind.mainGetOption(key: "access_token");
|
||||
if (token == '') return;
|
||||
final url = getUrl();
|
||||
@ -363,7 +363,7 @@ void logout() async {
|
||||
},
|
||||
body: json.encode(body));
|
||||
} catch (e) {
|
||||
showToast('Failed to access $url');
|
||||
dialogManager.showToast('Failed to access $url');
|
||||
}
|
||||
resetToken();
|
||||
}
|
||||
@ -396,12 +396,12 @@ Future<String> getUrl() async {
|
||||
return url;
|
||||
}
|
||||
|
||||
void showLogin() {
|
||||
void showLogin(OverlayDialogManager dialogManager) {
|
||||
final passwordController = TextEditingController();
|
||||
final nameController = TextEditingController();
|
||||
var loading = false;
|
||||
var error = '';
|
||||
DialogManager.show((setState, close) {
|
||||
dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate('Login')),
|
||||
content: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
|
@ -1,32 +1,31 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
|
||||
import '../../common.dart';
|
||||
import '../../models/platform_model.dart';
|
||||
|
||||
void clientClose() {
|
||||
msgBox('', 'Close', 'Are you sure to close the connection?');
|
||||
void clientClose(OverlayDialogManager dialogManager) {
|
||||
msgBox('', 'Close', 'Are you sure to close the connection?', dialogManager);
|
||||
}
|
||||
|
||||
const SEC1 = Duration(seconds: 1);
|
||||
void showSuccess({Duration duration = SEC1}) {
|
||||
SmartDialog.dismiss();
|
||||
showToast(translate("Successful"), duration: SEC1);
|
||||
// TODO
|
||||
// showToast(translate("Successful"), duration: SEC1);
|
||||
}
|
||||
|
||||
void showError({Duration duration = SEC1}) {
|
||||
SmartDialog.dismiss();
|
||||
showToast(translate("Error"), duration: SEC1);
|
||||
// TODO
|
||||
// showToast(translate("Error"), duration: SEC1);
|
||||
}
|
||||
|
||||
void setPermanentPasswordDialog() async {
|
||||
void setPermanentPasswordDialog(OverlayDialogManager dialogManager) async {
|
||||
final pw = await bind.mainGetPermanentPassword();
|
||||
final p0 = TextEditingController(text: pw);
|
||||
final p1 = TextEditingController(text: pw);
|
||||
var validateLength = false;
|
||||
var validateSame = false;
|
||||
DialogManager.show((setState, close) {
|
||||
dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate('Set your own password')),
|
||||
content: Form(
|
||||
@ -86,7 +85,7 @@ void setPermanentPasswordDialog() async {
|
||||
onPressed: (validateLength && validateSame)
|
||||
? () async {
|
||||
close();
|
||||
showLoading(translate("Waiting"));
|
||||
dialogManager.showLoading(translate("Waiting"));
|
||||
if (await gFFI.serverModel.setPermanentPassword(p0.text)) {
|
||||
showSuccess();
|
||||
} else {
|
||||
@ -101,13 +100,14 @@ void setPermanentPasswordDialog() async {
|
||||
});
|
||||
}
|
||||
|
||||
void setTemporaryPasswordLengthDialog() async {
|
||||
void setTemporaryPasswordLengthDialog(
|
||||
OverlayDialogManager dialogManager) async {
|
||||
List<String> lengths = ['6', '8', '10'];
|
||||
String length = await bind.mainGetOption(key: "temporary-password-length");
|
||||
var index = lengths.indexOf(length);
|
||||
if (index < 0) index = 0;
|
||||
length = lengths[index];
|
||||
DialogManager.show((setState, close) {
|
||||
dialogManager.show((setState, close) {
|
||||
final setLength = (newValue) {
|
||||
final oldValue = length;
|
||||
if (oldValue == newValue) return;
|
||||
@ -133,10 +133,11 @@ void setTemporaryPasswordLengthDialog() async {
|
||||
}, backDismiss: true, clickMaskDismiss: true);
|
||||
}
|
||||
|
||||
void enterPasswordDialog(String id) async {
|
||||
void enterPasswordDialog(String id, OverlayDialogManager dialogManager) async {
|
||||
final controller = TextEditingController();
|
||||
var remember = await bind.getSessionRemember(id: id) ?? false;
|
||||
DialogManager.show((setState, close) {
|
||||
dialogManager.dismissAll();
|
||||
dialogManager.show((setState, close) {
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate('Password Required')),
|
||||
content: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
@ -161,7 +162,7 @@ void enterPasswordDialog(String id) async {
|
||||
style: flatButtonStyle,
|
||||
onPressed: () {
|
||||
close();
|
||||
backToHome();
|
||||
backToHomePage();
|
||||
},
|
||||
child: Text(translate('Cancel')),
|
||||
),
|
||||
@ -172,7 +173,8 @@ void enterPasswordDialog(String id) async {
|
||||
if (text == '') return;
|
||||
gFFI.login(id, text, remember);
|
||||
close();
|
||||
showLoading(translate('Logging in...'));
|
||||
dialogManager.showLoading(translate('Logging in...'),
|
||||
cancelToClose: true);
|
||||
},
|
||||
child: Text(translate('OK')),
|
||||
),
|
||||
@ -181,8 +183,8 @@ void enterPasswordDialog(String id) async {
|
||||
});
|
||||
}
|
||||
|
||||
void wrongPasswordDialog(String id) {
|
||||
DialogManager.show((setState, close) => CustomAlertDialog(
|
||||
void wrongPasswordDialog(String id, OverlayDialogManager dialogManager) {
|
||||
dialogManager.show((setState, close) => CustomAlertDialog(
|
||||
title: Text(translate('Wrong Password')),
|
||||
content: Text(translate('Do you want to enter again?')),
|
||||
actions: [
|
||||
@ -190,14 +192,14 @@ void wrongPasswordDialog(String id) {
|
||||
style: flatButtonStyle,
|
||||
onPressed: () {
|
||||
close();
|
||||
backToHome();
|
||||
backToHomePage();
|
||||
},
|
||||
child: Text(translate('Cancel')),
|
||||
),
|
||||
TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: () {
|
||||
enterPasswordDialog(id);
|
||||
enterPasswordDialog(id, dialogManager);
|
||||
},
|
||||
child: Text(translate('Retry')),
|
||||
),
|
||||
@ -239,8 +241,8 @@ class _PasswordWidgetState extends State<PasswordWidget> {
|
||||
//This will obscure text dynamically
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
decoration: InputDecoration(
|
||||
labelText: Translator.call('Password'),
|
||||
hintText: Translator.call('Enter your password'),
|
||||
labelText: translate('Password'),
|
||||
hintText: translate('Enter your password'),
|
||||
// Here is key idea
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
|
@ -4,7 +4,6 @@ import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:flutter_hbb/mobile/pages/file_manager_page.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:path/path.dart' as Path;
|
||||
|
||||
@ -126,9 +125,9 @@ class FileModel extends ChangeNotifier {
|
||||
|
||||
final _jobResultListener = JobResultListener<Map<String, dynamic>>();
|
||||
|
||||
final WeakReference<FFI> _ffi;
|
||||
final WeakReference<FFI> parent;
|
||||
|
||||
FileModel(this._ffi);
|
||||
FileModel(this.parent);
|
||||
|
||||
toggleSelectMode() {
|
||||
if (jobState == JobState.inProgress) {
|
||||
@ -275,7 +274,7 @@ class FileModel extends ChangeNotifier {
|
||||
need_override = true;
|
||||
}
|
||||
bind.sessionSetConfirmOverrideFile(
|
||||
id: _ffi.target?.id ?? "",
|
||||
id: parent.target?.id ?? "",
|
||||
actId: id,
|
||||
fileNum: int.parse(evt['file_num']),
|
||||
needOverride: need_override,
|
||||
@ -292,22 +291,22 @@ class FileModel extends ChangeNotifier {
|
||||
onReady() async {
|
||||
_localOption.home = await bind.mainGetHomeDir();
|
||||
_localOption.showHidden = (await bind.sessionGetPeerOption(
|
||||
id: _ffi.target?.id ?? "", name: "local_show_hidden"))
|
||||
id: parent.target?.id ?? "", name: "local_show_hidden"))
|
||||
.isNotEmpty;
|
||||
|
||||
_remoteOption.showHidden = (await bind.sessionGetPeerOption(
|
||||
id: _ffi.target?.id ?? "", name: "remote_show_hidden"))
|
||||
id: parent.target?.id ?? "", name: "remote_show_hidden"))
|
||||
.isNotEmpty;
|
||||
_remoteOption.isWindows = _ffi.target?.ffiModel.pi.platform == "Windows";
|
||||
_remoteOption.isWindows = parent.target?.ffiModel.pi.platform == "Windows";
|
||||
|
||||
debugPrint("remote platform: ${_ffi.target?.ffiModel.pi.platform}");
|
||||
debugPrint("remote platform: ${parent.target?.ffiModel.pi.platform}");
|
||||
|
||||
await Future.delayed(Duration(milliseconds: 100));
|
||||
|
||||
final local = (await bind.sessionGetPeerOption(
|
||||
id: _ffi.target?.id ?? "", name: "local_dir"));
|
||||
id: parent.target?.id ?? "", name: "local_dir"));
|
||||
final remote = (await bind.sessionGetPeerOption(
|
||||
id: _ffi.target?.id ?? "", name: "remote_dir"));
|
||||
id: parent.target?.id ?? "", name: "remote_dir"));
|
||||
openDirectory(local.isEmpty ? _localOption.home : local, isLocal: true);
|
||||
openDirectory(remote.isEmpty ? _remoteOption.home : remote, isLocal: false);
|
||||
await Future.delayed(Duration(seconds: 1));
|
||||
@ -318,11 +317,11 @@ class FileModel extends ChangeNotifier {
|
||||
openDirectory(_remoteOption.home, isLocal: false);
|
||||
}
|
||||
// load last transfer jobs
|
||||
await bind.sessionLoadLastTransferJobs(id: '${_ffi.target?.id}');
|
||||
await bind.sessionLoadLastTransferJobs(id: '${parent.target?.id}');
|
||||
}
|
||||
|
||||
onClose() {
|
||||
SmartDialog.dismiss();
|
||||
parent.target?.dialogManager.dismissAll();
|
||||
jobReset();
|
||||
|
||||
// save config
|
||||
@ -332,7 +331,7 @@ class FileModel extends ChangeNotifier {
|
||||
msgMap["local_show_hidden"] = _localOption.showHidden ? "Y" : "";
|
||||
msgMap["remote_dir"] = _currentRemoteDir.path;
|
||||
msgMap["remote_show_hidden"] = _remoteOption.showHidden ? "Y" : "";
|
||||
final id = _ffi.target?.id ?? "";
|
||||
final id = parent.target?.id ?? "";
|
||||
for (final msg in msgMap.entries) {
|
||||
bind.sessionPeerOption(id: id, name: msg.key, value: msg.value);
|
||||
}
|
||||
@ -419,7 +418,7 @@ class FileModel extends ChangeNotifier {
|
||||
..id = jobId
|
||||
..isRemote = isRemote);
|
||||
bind.sessionSendFiles(
|
||||
id: '${_ffi.target?.id}',
|
||||
id: '${parent.target?.id}',
|
||||
actId: _jobId,
|
||||
path: from.path,
|
||||
to: PathUtil.join(toPath, from.name, isWindows),
|
||||
@ -477,14 +476,14 @@ class FileModel extends ChangeNotifier {
|
||||
entries = [item];
|
||||
} else if (item.isDirectory) {
|
||||
title = translate("Not an empty directory");
|
||||
showLoading(translate("Waiting"));
|
||||
parent.target?.dialogManager.showLoading(translate("Waiting"));
|
||||
final fd = await _fileFetcher.fetchDirectoryRecursive(
|
||||
_jobId, item.path, items.isLocal!, true);
|
||||
if (fd.path.isEmpty) {
|
||||
fd.path = item.path;
|
||||
}
|
||||
fd.format(isWindows);
|
||||
SmartDialog.dismiss();
|
||||
parent.target?.dialogManager.dismissAll();
|
||||
if (fd.entries.isEmpty) {
|
||||
final confirm = await showRemoveDialog(
|
||||
translate(
|
||||
@ -543,7 +542,7 @@ class FileModel extends ChangeNotifier {
|
||||
|
||||
Future<bool?> showRemoveDialog(
|
||||
String title, String content, bool showCheckbox) async {
|
||||
return await DialogManager.show<bool>(
|
||||
return await parent.target?.dialogManager.show<bool>(
|
||||
(setState, Function(bool v) close) => CustomAlertDialog(
|
||||
title: Row(
|
||||
children: [
|
||||
@ -594,7 +593,7 @@ class FileModel extends ChangeNotifier {
|
||||
Future<bool?> showFileConfirmDialog(
|
||||
String title, String content, bool showCheckbox) async {
|
||||
fileConfirmCheckboxRemember = false;
|
||||
return await DialogManager.show<bool?>(
|
||||
return await parent.target?.dialogManager.show<bool?>(
|
||||
(setState, Function(bool? v) close) => CustomAlertDialog(
|
||||
title: Row(
|
||||
children: [
|
||||
@ -648,7 +647,7 @@ class FileModel extends ChangeNotifier {
|
||||
|
||||
sendRemoveFile(String path, int fileNum, bool isLocal) {
|
||||
bind.sessionRemoveFile(
|
||||
id: '${_ffi.target?.id}',
|
||||
id: '${parent.target?.id}',
|
||||
actId: _jobId,
|
||||
path: path,
|
||||
isRemote: !isLocal,
|
||||
@ -657,7 +656,7 @@ class FileModel extends ChangeNotifier {
|
||||
|
||||
sendRemoveEmptyDir(String path, int fileNum, bool isLocal) {
|
||||
bind.sessionRemoveAllEmptyDirs(
|
||||
id: '${_ffi.target?.id}',
|
||||
id: '${parent.target?.id}',
|
||||
actId: _jobId,
|
||||
path: path,
|
||||
isRemote: !isLocal);
|
||||
@ -667,14 +666,14 @@ class FileModel extends ChangeNotifier {
|
||||
isLocal = isLocal ?? this.isLocal;
|
||||
_jobId++;
|
||||
bind.sessionCreateDir(
|
||||
id: '${_ffi.target?.id}',
|
||||
id: '${parent.target?.id}',
|
||||
actId: _jobId,
|
||||
path: path,
|
||||
isRemote: !isLocal);
|
||||
}
|
||||
|
||||
cancelJob(int id) async {
|
||||
bind.sessionCancelJob(id: '${_ffi.target?.id}', actId: id);
|
||||
bind.sessionCancelJob(id: '${parent.target?.id}', actId: id);
|
||||
jobReset();
|
||||
}
|
||||
|
||||
@ -701,7 +700,7 @@ class FileModel extends ChangeNotifier {
|
||||
}
|
||||
|
||||
initFileFetcher() {
|
||||
_fileFetcher.id = _ffi.target?.id;
|
||||
_fileFetcher.id = parent.target?.id;
|
||||
}
|
||||
|
||||
void updateFolderFiles(Map<String, dynamic> evt) {
|
||||
@ -742,7 +741,7 @@ class FileModel extends ChangeNotifier {
|
||||
..state = JobState.paused;
|
||||
jobTable.add(jobProgress);
|
||||
bind.sessionAddJob(
|
||||
id: '${_ffi.target?.id}',
|
||||
id: '${parent.target?.id}',
|
||||
isRemote: isRemote,
|
||||
includeHidden: showHidden,
|
||||
actId: currJobId,
|
||||
@ -757,7 +756,7 @@ class FileModel extends ChangeNotifier {
|
||||
if (jobIndex != -1) {
|
||||
final job = jobTable[jobIndex];
|
||||
bind.sessionResumeJob(
|
||||
id: '${_ffi.target?.id}', actId: job.id, isRemote: job.isRemote);
|
||||
id: '${parent.target?.id}', actId: job.id, isRemote: job.isRemote);
|
||||
job.state = JobState.inProgress;
|
||||
} else {
|
||||
debugPrint("jobId ${jobId} is not exists");
|
||||
|
@ -13,7 +13,6 @@ import 'package:flutter_hbb/models/chat_model.dart';
|
||||
import 'package:flutter_hbb/models/file_model.dart';
|
||||
import 'package:flutter_hbb/models/server_model.dart';
|
||||
import 'package:flutter_hbb/models/user_model.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
@ -60,7 +59,6 @@ class FfiModel with ChangeNotifier {
|
||||
}
|
||||
|
||||
FfiModel(this.parent) {
|
||||
Translator.call = translate;
|
||||
clear();
|
||||
}
|
||||
|
||||
@ -261,32 +259,35 @@ class FfiModel with ChangeNotifier {
|
||||
|
||||
/// Handle the message box event based on [evt] and [id].
|
||||
void handleMsgBox(Map<String, dynamic> evt, String id) {
|
||||
if (parent.target == null) return;
|
||||
final dialogManager = parent.target!.dialogManager;
|
||||
var type = evt['type'];
|
||||
var title = evt['title'];
|
||||
var text = evt['text'];
|
||||
if (type == 're-input-password') {
|
||||
wrongPasswordDialog(id);
|
||||
wrongPasswordDialog(id, dialogManager);
|
||||
} else if (type == 'input-password') {
|
||||
enterPasswordDialog(id);
|
||||
enterPasswordDialog(id, dialogManager);
|
||||
} else if (type == 'restarting') {
|
||||
showMsgBox(id, type, title, text, false, hasCancel: false);
|
||||
showMsgBox(id, type, title, text, false, dialogManager, hasCancel: false);
|
||||
} else {
|
||||
var hasRetry = evt['hasRetry'] == 'true';
|
||||
showMsgBox(id, type, title, text, hasRetry);
|
||||
showMsgBox(id, type, title, text, hasRetry, dialogManager);
|
||||
}
|
||||
}
|
||||
|
||||
/// Show a message box with [type], [title] and [text].
|
||||
void showMsgBox(
|
||||
String id, String type, String title, String text, bool hasRetry,
|
||||
void showMsgBox(String id, String type, String title, String text,
|
||||
bool hasRetry, OverlayDialogManager dialogManager,
|
||||
{bool? hasCancel}) {
|
||||
msgBox(type, title, text, hasCancel: hasCancel);
|
||||
msgBox(type, title, text, dialogManager, hasCancel: hasCancel);
|
||||
_timer?.cancel();
|
||||
if (hasRetry) {
|
||||
_timer = Timer(Duration(seconds: _reconnects), () {
|
||||
bind.sessionReconnect(id: id);
|
||||
clearPermissions();
|
||||
showLoading(translate('Connecting...'));
|
||||
dialogManager.showLoading(translate('Connecting...'),
|
||||
cancelToClose: true);
|
||||
});
|
||||
_reconnects *= 2;
|
||||
} else {
|
||||
@ -296,7 +297,7 @@ class FfiModel with ChangeNotifier {
|
||||
|
||||
/// Handle the peer info event based on [evt].
|
||||
void handlePeerInfo(Map<String, dynamic> evt, String peerId) async {
|
||||
SmartDialog.dismiss();
|
||||
parent.target?.dialogManager.dismissAll();
|
||||
_pi.version = evt['version'];
|
||||
_pi.username = evt['username'];
|
||||
_pi.hostname = evt['hostname'];
|
||||
@ -332,7 +333,9 @@ class FfiModel with ChangeNotifier {
|
||||
_display = _pi.displays[_pi.currentDisplay];
|
||||
}
|
||||
if (displays.length > 0) {
|
||||
showLoading(translate('Connected, waiting for image...'));
|
||||
parent.target?.dialogManager.showLoading(
|
||||
translate('Connected, waiting for image...'),
|
||||
cancelToClose: true);
|
||||
_waitForImage = true;
|
||||
_reconnects = 1;
|
||||
}
|
||||
@ -364,7 +367,7 @@ class ImageModel with ChangeNotifier {
|
||||
void onRgba(Uint8List rgba, double tabBarHeight) {
|
||||
if (_waitForImage) {
|
||||
_waitForImage = false;
|
||||
SmartDialog.dismiss();
|
||||
parent.target?.dialogManager.dismissAll();
|
||||
}
|
||||
final pid = parent.target?.id;
|
||||
ui.decodeImageFromPixels(
|
||||
@ -874,16 +877,20 @@ class FFI {
|
||||
var alt = false;
|
||||
var command = false;
|
||||
var version = "";
|
||||
late final ImageModel imageModel;
|
||||
late final FfiModel ffiModel;
|
||||
late final CursorModel cursorModel;
|
||||
late final CanvasModel canvasModel;
|
||||
late final ServerModel serverModel;
|
||||
late final ChatModel chatModel;
|
||||
late final FileModel fileModel;
|
||||
late final AbModel abModel;
|
||||
late final UserModel userModel;
|
||||
late final QualityMonitorModel qualityMonitorModel;
|
||||
|
||||
/// dialogManager use late to ensure init after main page binding [globalKey]
|
||||
late final dialogManager = OverlayDialogManager();
|
||||
|
||||
late final ImageModel imageModel; // session
|
||||
late final FfiModel ffiModel; // session
|
||||
late final CursorModel cursorModel; // session
|
||||
late final CanvasModel canvasModel; // session
|
||||
late final ServerModel serverModel; // global
|
||||
late final ChatModel chatModel; // session
|
||||
late final FileModel fileModel; // session
|
||||
late final AbModel abModel; // global
|
||||
late final UserModel userModel; // global
|
||||
late final QualityMonitorModel qualityMonitorModel; // session
|
||||
|
||||
FFI() {
|
||||
this.imageModel = ImageModel(WeakReference(this));
|
||||
|
@ -75,7 +75,7 @@ class PlatformFFI {
|
||||
}
|
||||
|
||||
String translate(String name, String locale) {
|
||||
if (_translate == null) return '';
|
||||
if (_translate == null) return name;
|
||||
var a = name.toNativeUtf8();
|
||||
var b = locale.toNativeUtf8();
|
||||
var p = _translate!(a, b);
|
||||
|
@ -10,7 +10,7 @@ import '../common.dart';
|
||||
import '../mobile/pages/server_page.dart';
|
||||
import 'model.dart';
|
||||
|
||||
const loginDialogTag = "LOGIN";
|
||||
const KLoginDialogTag = "LOGIN";
|
||||
|
||||
const kUseTemporaryPassword = "use-temporary-password";
|
||||
const kUsePermanentPassword = "use-permanent-password";
|
||||
@ -206,8 +206,8 @@ class ServerModel with ChangeNotifier {
|
||||
/// Toggle the screen sharing service.
|
||||
toggleService() async {
|
||||
if (_isStart) {
|
||||
final res =
|
||||
await DialogManager.show<bool>((setState, close) => CustomAlertDialog(
|
||||
final res = await parent.target?.dialogManager
|
||||
.show<bool>((setState, close) => CustomAlertDialog(
|
||||
title: Row(children: [
|
||||
Icon(Icons.warning_amber_sharp,
|
||||
color: Colors.redAccent, size: 28),
|
||||
@ -228,8 +228,8 @@ class ServerModel with ChangeNotifier {
|
||||
stopService();
|
||||
}
|
||||
} else {
|
||||
final res =
|
||||
await DialogManager.show<bool>((setState, close) => CustomAlertDialog(
|
||||
final res = await parent.target?.dialogManager
|
||||
.show<bool>((setState, close) => CustomAlertDialog(
|
||||
title: Row(children: [
|
||||
Icon(Icons.warning_amber_sharp,
|
||||
color: Colors.redAccent, size: 28),
|
||||
@ -272,7 +272,7 @@ class ServerModel with ChangeNotifier {
|
||||
Future<Null> stopService() async {
|
||||
_isStart = false;
|
||||
// TODO
|
||||
parent.target?.serverModel.closeAll();
|
||||
closeAll();
|
||||
await parent.target?.invokeMethod("stop_service");
|
||||
await bind.mainStopService();
|
||||
notifyListeners();
|
||||
@ -370,7 +370,7 @@ class ServerModel with ChangeNotifier {
|
||||
}
|
||||
|
||||
void showLoginDialog(Client client) {
|
||||
DialogManager.show(
|
||||
parent.target?.dialogManager.show(
|
||||
(setState, close) => CustomAlertDialog(
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
@ -442,7 +442,7 @@ class ServerModel with ChangeNotifier {
|
||||
void onClientAuthorized(Map<String, dynamic> evt) {
|
||||
try {
|
||||
final client = Client.fromJson(jsonDecode(evt['client']));
|
||||
DialogManager.dismissByTag(getLoginDialogTag(client.id));
|
||||
parent.target?.dialogManager.dismissByTag(getLoginDialogTag(client.id));
|
||||
_clients[client.id] = client;
|
||||
scrollToBottom();
|
||||
notifyListeners();
|
||||
@ -454,7 +454,7 @@ class ServerModel with ChangeNotifier {
|
||||
final id = int.parse(evt['id'] as String);
|
||||
if (_clients.containsKey(id)) {
|
||||
_clients.remove(id);
|
||||
DialogManager.dismissByTag(getLoginDialogTag(id));
|
||||
parent.target?.dialogManager.dismissByTag(getLoginDialogTag(id));
|
||||
parent.target?.invokeMethod("cancel_notification", id);
|
||||
}
|
||||
notifyListeners();
|
||||
@ -510,11 +510,11 @@ class Client {
|
||||
}
|
||||
|
||||
String getLoginDialogTag(int id) {
|
||||
return loginDialogTag + id.toString();
|
||||
return KLoginDialogTag + id.toString();
|
||||
}
|
||||
|
||||
showInputWarnAlert(FFI ffi) {
|
||||
DialogManager.show((setState, close) => CustomAlertDialog(
|
||||
ffi.dialogManager.show((setState, close) => CustomAlertDialog(
|
||||
title: Text(translate("How to get Android input permission?")),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -49,7 +49,7 @@ dependencies:
|
||||
zxing2: ^0.1.0
|
||||
image_picker: ^0.8.5
|
||||
image: ^3.1.3
|
||||
flutter_smart_dialog: ^4.3.1
|
||||
back_button_interceptor: ^6.0.1
|
||||
flutter_rust_bridge:
|
||||
git:
|
||||
url: https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge
|
||||
|
Loading…
x
Reference in New Issue
Block a user