move showMsgBox,fix fileModel value init
This commit is contained in:
parent
0ae338524c
commit
7957efee5e
@ -12,6 +12,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import '../common.dart';
|
import '../common.dart';
|
||||||
|
import '../widgets/dialog.dart';
|
||||||
import 'native_model.dart' if (dart.library.html) 'web_model.dart';
|
import 'native_model.dart' if (dart.library.html) 'web_model.dart';
|
||||||
|
|
||||||
typedef HandleMsgBox = void Function(Map<String, dynamic> evt, String id);
|
typedef HandleMsgBox = void Function(Map<String, dynamic> evt, String id);
|
||||||
@ -26,6 +27,8 @@ class FfiModel with ChangeNotifier {
|
|||||||
final _permissions = Map<String, bool>();
|
final _permissions = Map<String, bool>();
|
||||||
bool? _secure;
|
bool? _secure;
|
||||||
bool? _direct;
|
bool? _direct;
|
||||||
|
Timer? _timer;
|
||||||
|
var _reconnects = 1;
|
||||||
|
|
||||||
get permissions => _permissions;
|
get permissions => _permissions;
|
||||||
|
|
||||||
@ -78,6 +81,8 @@ class FfiModel with ChangeNotifier {
|
|||||||
_secure = null;
|
_secure = null;
|
||||||
_direct = null;
|
_direct = null;
|
||||||
_inputBlocked = false;
|
_inputBlocked = false;
|
||||||
|
_timer?.cancel();
|
||||||
|
_timer = null;
|
||||||
clearPermissions();
|
clearPermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +112,7 @@ class FfiModel with ChangeNotifier {
|
|||||||
_permissions.clear();
|
_permissions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(String peerId, HandleMsgBox handleMsgBox) {
|
void update(String peerId) {
|
||||||
var pos;
|
var pos;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
var evt = FFI.popEvent();
|
var evt = FFI.popEvent();
|
||||||
@ -193,6 +198,35 @@ class FfiModel with ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleMsgBox(Map<String, dynamic> evt, String id) {
|
||||||
|
var type = evt['type'];
|
||||||
|
var title = evt['title'];
|
||||||
|
var text = evt['text'];
|
||||||
|
if (type == 're-input-password') {
|
||||||
|
wrongPasswordDialog(id);
|
||||||
|
} else if (type == 'input-password') {
|
||||||
|
enterPasswordDialog(id);
|
||||||
|
} else {
|
||||||
|
var hasRetry = evt['hasRetry'] == 'true';
|
||||||
|
print(evt);
|
||||||
|
showMsgBox(type, title, text, hasRetry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void showMsgBox(String type, String title, String text, bool hasRetry) {
|
||||||
|
msgBox(type, title, text);
|
||||||
|
if (hasRetry) {
|
||||||
|
_timer?.cancel();
|
||||||
|
_timer = Timer(Duration(seconds: _reconnects), () {
|
||||||
|
FFI.reconnect();
|
||||||
|
showLoading(translate('Connecting...'));
|
||||||
|
});
|
||||||
|
_reconnects *= 2;
|
||||||
|
} else {
|
||||||
|
_reconnects = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void handlePeerInfo(Map<String, dynamic> evt) {
|
void handlePeerInfo(Map<String, dynamic> evt) {
|
||||||
EasyLoading.dismiss();
|
EasyLoading.dismiss();
|
||||||
DialogManager.reset();
|
DialogManager.reset();
|
||||||
|
@ -13,8 +13,8 @@ class ServerModel with ChangeNotifier {
|
|||||||
bool _isStart = false;
|
bool _isStart = false;
|
||||||
bool _mediaOk = false;
|
bool _mediaOk = false;
|
||||||
bool _inputOk = false;
|
bool _inputOk = false;
|
||||||
late bool _audioOk;
|
bool _audioOk = false;
|
||||||
late bool _fileOk;
|
bool _fileOk = false;
|
||||||
final _serverId = TextEditingController(text: _emptyIdShow);
|
final _serverId = TextEditingController(text: _emptyIdShow);
|
||||||
final _serverPasswd = TextEditingController(text: "");
|
final _serverPasswd = TextEditingController(text: "");
|
||||||
|
|
||||||
@ -48,6 +48,7 @@ class ServerModel with ChangeNotifier {
|
|||||||
..["name"] = "enable-keyboard"
|
..["name"] = "enable-keyboard"
|
||||||
..["value"] = 'N';
|
..["value"] = 'N';
|
||||||
FFI.setByName('option', jsonEncode(res)); // input false by default
|
FFI.setByName('option', jsonEncode(res)); // input false by default
|
||||||
|
notifyListeners();
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +111,7 @@ class ServerModel with ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
FFI.setByName("ensure_init_event_queue");
|
FFI.setByName("ensure_init_event_queue");
|
||||||
_interval = Timer.periodic(Duration(milliseconds: 30), (timer) {
|
_interval = Timer.periodic(Duration(milliseconds: 30), (timer) {
|
||||||
FFI.ffiModel.update("", (_, __) {});
|
FFI.ffiModel.update("");
|
||||||
});
|
});
|
||||||
await FFI.invokeMethod("init_service");
|
await FFI.invokeMethod("init_service");
|
||||||
FFI.setByName("start_service");
|
FFI.setByName("start_service");
|
||||||
|
@ -21,8 +21,6 @@ class _FileManagerPageState extends State<FileManagerPage> {
|
|||||||
final model = FFI.fileModel;
|
final model = FFI.fileModel;
|
||||||
final _selectedItems = SelectedItems();
|
final _selectedItems = SelectedItems();
|
||||||
Timer? _interval;
|
Timer? _interval;
|
||||||
Timer? _timer;
|
|
||||||
var _reconnects = 1;
|
|
||||||
final _breadCrumbScroller = ScrollController();
|
final _breadCrumbScroller = ScrollController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -30,9 +28,8 @@ class _FileManagerPageState extends State<FileManagerPage> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
showLoading(translate('Connecting...'));
|
showLoading(translate('Connecting...'));
|
||||||
FFI.connect(widget.id, isFileTransfer: true);
|
FFI.connect(widget.id, isFileTransfer: true);
|
||||||
|
_interval = Timer.periodic(
|
||||||
_interval = Timer.periodic(Duration(milliseconds: 30),
|
Duration(milliseconds: 30), (timer) => FFI.ffiModel.update(widget.id));
|
||||||
(timer) => FFI.ffiModel.update(widget.id, handleMsgBox));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -193,35 +190,6 @@ class _FileManagerPageState extends State<FileManagerPage> {
|
|||||||
model.goToParentDirectory();
|
model.goToParentDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleMsgBox(Map<String, dynamic> evt, String id) {
|
|
||||||
var type = evt['type'];
|
|
||||||
var title = evt['title'];
|
|
||||||
var text = evt['text'];
|
|
||||||
if (type == 're-input-password') {
|
|
||||||
wrongPasswordDialog(id);
|
|
||||||
} else if (type == 'input-password') {
|
|
||||||
enterPasswordDialog(id);
|
|
||||||
} else {
|
|
||||||
var hasRetry = evt['hasRetry'] == 'true';
|
|
||||||
print(evt);
|
|
||||||
showMsgBox(type, title, text, hasRetry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void showMsgBox(String type, String title, String text, bool hasRetry) {
|
|
||||||
msgBox(type, title, text);
|
|
||||||
if (hasRetry) {
|
|
||||||
_timer?.cancel();
|
|
||||||
_timer = Timer(Duration(seconds: _reconnects), () {
|
|
||||||
FFI.reconnect();
|
|
||||||
showLoading(translate('Connecting...'));
|
|
||||||
});
|
|
||||||
_reconnects *= 2;
|
|
||||||
} else {
|
|
||||||
_reconnects = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
breadCrumbScrollToEnd() {
|
breadCrumbScrollToEnd() {
|
||||||
Future.delayed(Duration(milliseconds: 200), () {
|
Future.delayed(Duration(milliseconds: 200), () {
|
||||||
_breadCrumbScroller.animateTo(
|
_breadCrumbScroller.animateTo(
|
||||||
|
@ -35,7 +35,6 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
var _fn = false;
|
var _fn = false;
|
||||||
final FocusNode _focusNode = FocusNode();
|
final FocusNode _focusNode = FocusNode();
|
||||||
var _showEdit = false;
|
var _showEdit = false;
|
||||||
var _reconnects = 1;
|
|
||||||
var _touchMode = false;
|
var _touchMode = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -86,7 +85,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
FFI.ffiModel.update(widget.id, handleMsgBox);
|
FFI.ffiModel.update(widget.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void interval() {
|
void interval() {
|
||||||
@ -95,35 +94,6 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleMsgBox(Map<String, dynamic> evt, String id) {
|
|
||||||
var type = evt['type'];
|
|
||||||
var title = evt['title'];
|
|
||||||
var text = evt['text'];
|
|
||||||
if (type == 're-input-password') {
|
|
||||||
wrongPasswordDialog(id);
|
|
||||||
} else if (type == 'input-password') {
|
|
||||||
enterPasswordDialog(id);
|
|
||||||
} else {
|
|
||||||
var hasRetry = evt['hasRetry'] == 'true';
|
|
||||||
print(evt);
|
|
||||||
showMsgBox(type, title, text, hasRetry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void showMsgBox(String type, String title, String text, bool hasRetry) {
|
|
||||||
msgBox(type, title, text);
|
|
||||||
if (hasRetry) {
|
|
||||||
_timer?.cancel();
|
|
||||||
_timer = Timer(Duration(seconds: _reconnects), () {
|
|
||||||
FFI.reconnect();
|
|
||||||
showLoading(translate('Connecting...'));
|
|
||||||
});
|
|
||||||
_reconnects *= 2;
|
|
||||||
} else {
|
|
||||||
_reconnects = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleInput(String newValue) {
|
void handleInput(String newValue) {
|
||||||
var oldValue = _value;
|
var oldValue = _value;
|
||||||
_value = newValue;
|
_value = newValue;
|
||||||
|
@ -33,10 +33,6 @@ dependencies:
|
|||||||
external_path: ^1.0.1
|
external_path: ^1.0.1
|
||||||
provider: ^5.0.0
|
provider: ^5.0.0
|
||||||
flutter_easyloading: ^3.0.3
|
flutter_easyloading: ^3.0.3
|
||||||
# flutter_easyloading: # not Null safety 2.2.0
|
|
||||||
# git:
|
|
||||||
# url: git://github.com/open-trade/flutter_easyloading
|
|
||||||
# #path: flutter_easyloading
|
|
||||||
tuple: ^2.0.0
|
tuple: ^2.0.0
|
||||||
wakelock: ^0.5.2
|
wakelock: ^0.5.2
|
||||||
device_info: ^2.0.2
|
device_info: ^2.0.2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user