refactor alertDialog

This commit is contained in:
open-trade
2020-11-19 21:59:49 +08:00
parent 86add59e92
commit 0b0fb4f145
5 changed files with 137 additions and 130 deletions

View File

@@ -41,7 +41,11 @@ class FfiModel with ChangeNotifier {
_decoding = false;
}
void update(String id, BuildContext context) {
void update(
String id,
BuildContext context,
void Function(Map<String, dynamic> evt, String id, BuildContext context)
handleMsgbox) {
for (;;) {
var evt = FFI.popEvent();
if (evt == null) break;
@@ -82,19 +86,6 @@ class FfiModel with ChangeNotifier {
}
}
void handleMsgbox(Map<String, dynamic> evt, String id, BuildContext context) {
var type = evt['type'];
var title = evt['title'];
var text = evt['text'];
if (type == 're-input-password') {
wrongPasswordDialog(id, context);
} else if (type == 'input-password') {
enterPasswordDialog(id, context);
} else {
msgbox(type, title, text, context);
}
}
void handleSwitchDisplay(Map<String, dynamic> evt) {
_pi.currentDisplay = int.parse(evt['display']);
_display.x = double.parse(evt['x']);