move showMsgBox,fix fileModel value init

This commit is contained in:
csf
2022-03-28 17:24:52 +08:00
parent 0ae338524c
commit 7957efee5e
5 changed files with 42 additions and 73 deletions

View File

@@ -21,8 +21,6 @@ class _FileManagerPageState extends State<FileManagerPage> {
final model = FFI.fileModel;
final _selectedItems = SelectedItems();
Timer? _interval;
Timer? _timer;
var _reconnects = 1;
final _breadCrumbScroller = ScrollController();
@override
@@ -30,9 +28,8 @@ class _FileManagerPageState extends State<FileManagerPage> {
super.initState();
showLoading(translate('Connecting...'));
FFI.connect(widget.id, isFileTransfer: true);
_interval = Timer.periodic(Duration(milliseconds: 30),
(timer) => FFI.ffiModel.update(widget.id, handleMsgBox));
_interval = Timer.periodic(
Duration(milliseconds: 30), (timer) => FFI.ffiModel.update(widget.id));
}
@override
@@ -193,35 +190,6 @@ class _FileManagerPageState extends State<FileManagerPage> {
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() {
Future.delayed(Duration(milliseconds: 200), () {
_breadCrumbScroller.animateTo(

View File

@@ -35,7 +35,6 @@ class _RemotePageState extends State<RemotePage> {
var _fn = false;
final FocusNode _focusNode = FocusNode();
var _showEdit = false;
var _reconnects = 1;
var _touchMode = false;
@override
@@ -86,7 +85,7 @@ class _RemotePageState extends State<RemotePage> {
}
});
}
FFI.ffiModel.update(widget.id, handleMsgBox);
FFI.ffiModel.update(widget.id);
}
void interval() {
@@ -95,35 +94,6 @@ class _RemotePageState extends State<RemotePage> {
} 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) {
var oldValue = _value;
_value = newValue;