From a110db32e98b1c5ddbe6fc7a7c073346987aa9d6 Mon Sep 17 00:00:00 2001 From: open-trade Date: Wed, 18 Nov 2020 01:55:26 +0800 Subject: [PATCH] msgbox start to work --- flutter_hbb/lib/common.dart | 26 ++++++++++++++++++++++++-- flutter_hbb/lib/remote_page.dart | 7 ++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/flutter_hbb/lib/common.dart b/flutter_hbb/lib/common.dart index ea69756ff..50e82fe45 100644 --- a/flutter_hbb/lib/common.dart +++ b/flutter_hbb/lib/common.dart @@ -93,11 +93,11 @@ class FFI { return Uint8List.sublistView(ref.data.asTypedList(ref.len)); } - static Map popEvent() { + static Map popEvent() { var s = getByName('event'); if (s == '') return null; try { - Map event = json.decode(s); + Map event = json.decode(s); return event; } catch (e) { print(e); @@ -178,6 +178,7 @@ void showSuccess(String text) { // https://material.io/develop/flutter/components/dialogs void enterPasswordDialog(String id, BuildContext context) { + dismissLoading(); var remember = FFI.getByName('remember', arg: id) == 'true'; var dialog = AlertDialog( title: Text('Please enter your password'), @@ -219,6 +220,7 @@ void enterPasswordDialog(String id, BuildContext context) { } void wrongPasswordDialog(String id, BuildContext context) { + dismissLoading(); var dialog = AlertDialog( title: Text('Please enter your password'), contentPadding: EdgeInsets.zero, @@ -241,3 +243,23 @@ void wrongPasswordDialog(String id, BuildContext context) { ); showDialog(context: context, builder: (context) => dialog); } + +void msgbox(String type, String title, String text, BuildContext context) { + dismissLoading(); + var dialog = AlertDialog( + title: Text(title), + contentPadding: EdgeInsets.zero, + content: Text(text), + actions: [ + FlatButton( + textColor: MyTheme.accent, + onPressed: () { + Navigator.pop(context); + Navigator.pop(context); + }, + child: Text('OK'), + ), + ], + ); + showDialog(context: context, builder: (context) => dialog); +} diff --git a/flutter_hbb/lib/remote_page.dart b/flutter_hbb/lib/remote_page.dart index 853bc0f2a..78a1c0839 100644 --- a/flutter_hbb/lib/remote_page.dart +++ b/flutter_hbb/lib/remote_page.dart @@ -60,15 +60,16 @@ class _RemotePageState extends State { } } - void handleMsgbox(evt) { + void handleMsgbox(Map evt) { var type = evt['type']; var title = evt['title']; var text = evt['text']; - if (type == 'error') { - } else if (type == 're-input-password') { + if (type == 're-input-password') { wrongPasswordDialog(widget.id, context); } else if (type == 'input-password') { enterPasswordDialog(widget.id, context); + } else { + msgbox(type, title, text, context); } }