diff --git a/flutter_hbb/lib/common.dart b/flutter_hbb/lib/common.dart index c84260b1e..c1e531125 100644 --- a/flutter_hbb/lib/common.dart +++ b/flutter_hbb/lib/common.dart @@ -64,33 +64,52 @@ Future showAlertDialog(BuildContext context, BuildAlertDailog build, return res; } -Future msgbox( - String type, String title, String text, BuildContext context, - [bool hasCancel]) async { +void msgbox(String type, String title, String text, BuildContext context, + [bool hasCancel]) { + var wrap = (String text, void Function() onPressed) => ButtonTheme( + padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10), + materialTapTargetSize: MaterialTapTargetSize + .shrinkWrap, //limits the touch area to the button area + minWidth: 0, //wraps child's width + height: 0, + child: FlatButton( + focusColor: MyTheme.accent, + onPressed: onPressed, + child: Text(text, style: TextStyle(color: MyTheme.accent)))); + + dismissLoading(); + if (_hasDialog) { + Navigator.pop(context); + } + final buttons = [ + Expanded(child: Container()), + wrap('OK', () { + dismissLoading(); + Navigator.pop(context); + }) + ]; if (hasCancel == null) { hasCancel = type != 'error'; } - return await showAlertDialog( - context, - (_) => Tuple3(Text(title), Text(text), [ - hasCancel - ? FlatButton( - textColor: MyTheme.accent, - onPressed: () { - Navigator.pop(context); - }, - child: Text('Cancel'), - ) - : Spacer(), - FlatButton( - textColor: MyTheme.accent, - onPressed: () { - Navigator.pop(context); - Navigator.pop(context); - }, - child: Text('OK'), - ), - ])); + if (hasCancel) { + buttons.insert( + 1, + wrap('Cancel', () { + dismissLoading(); + })); + } + EasyLoading.showWidget(Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(title, style: TextStyle(fontSize: 21)), + SizedBox(height: 20), + Text(text, style: TextStyle(fontSize: 15)), + SizedBox(height: 20), + Row( + children: buttons, + ) + ], + )); } class PasswordWidget extends StatefulWidget { diff --git a/flutter_hbb/lib/remote_page.dart b/flutter_hbb/lib/remote_page.dart index 163db41ba..f814339a4 100644 --- a/flutter_hbb/lib/remote_page.dart +++ b/flutter_hbb/lib/remote_page.dart @@ -99,8 +99,8 @@ class _RemotePageState extends State { } } - Future showMsgBox(String type, String title, String text) async { - await msgbox(type, title, text, context); + void showMsgBox(String type, String title, String text) { + msgbox(type, title, text, context); final hasRetry = type == "error" && title == "Connection Error" && text.toLowerCase().indexOf("offline") < 0 && @@ -179,7 +179,7 @@ class _RemotePageState extends State { onPressed: () { setState(() => _showBar = !_showBar); }), - bottomNavigationBar: _showBar + bottomNavigationBar: _showBar && FFI.ffiModel.pi.displays != null ? BottomAppBar( elevation: 10, color: MyTheme.accent, diff --git a/flutter_hbb/pubspec.lock b/flutter_hbb/pubspec.lock index f65d572b2..cc63ee266 100644 --- a/flutter_hbb/pubspec.lock +++ b/flutter_hbb/pubspec.lock @@ -43,20 +43,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.15.0-nullsafety.3" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" - crypto: - dependency: transitive - description: - name: crypto - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.5" csslib: dependency: transitive description: @@ -114,31 +100,12 @@ packages: flutter_easyloading: dependency: "direct main" description: - name: flutter_easyloading - url: "https://pub.dartlang.org" - source: hosted + path: "." + ref: HEAD + resolved-ref: "2d085c411dc262043b6173c3b962d3e66ce657b1" + url: "git://github.com/open-trade/flutter_easyloading" + source: git version: "2.2.0" - flutter_sound: - dependency: "direct main" - description: - name: flutter_sound - url: "https://pub.dartlang.org" - source: hosted - version: "6.4.2+1" - flutter_sound_platform_interface: - dependency: transitive - description: - name: flutter_sound_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "6.4.2+1" - flutter_sound_web: - dependency: transitive - description: - name: flutter_sound_web - url: "https://pub.dartlang.org" - source: hosted - version: "6.4.2+1" flutter_spinkit: dependency: transitive description: @@ -184,13 +151,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.6.2" - logger: - dependency: transitive - description: - name: logger - url: "https://pub.dartlang.org" - source: hosted - version: "0.7.0+2" matcher: dependency: transitive description: @@ -289,13 +249,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.5" - recase: - dependency: transitive - description: - name: recase - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.1" sky_engine: dependency: transitive description: flutter @@ -329,13 +282,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0-nullsafety.1" - synchronized: - dependency: transitive - description: - name: synchronized - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.0+2" term_glyph: dependency: transitive description: @@ -364,13 +310,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0-nullsafety.3" - uuid: - dependency: transitive - description: - name: uuid - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.2" vector_math: dependency: transitive description: diff --git a/flutter_hbb/pubspec.yaml b/flutter_hbb/pubspec.yaml index 49b28d44f..e24940cff 100644 --- a/flutter_hbb/pubspec.yaml +++ b/flutter_hbb/pubspec.yaml @@ -31,7 +31,10 @@ dependencies: ffi: ^0.1.3 path_provider: ^1.6.24 provider: ^4.3.2+2 - flutter_easyloading: ^2.1.3 + flutter_easyloading: + git: + url: git://github.com/open-trade/flutter_easyloading + #path: flutter_easyloading tuple: ^1.0.1 wakelock: ^0.2.1+1 device_info: ^1.0.0