diff --git a/lib/common.dart b/lib/common.dart index 655c3a2ed..b7024bbe1 100644 --- a/lib/common.dart +++ b/lib/common.dart @@ -32,45 +32,13 @@ final ButtonStyle flatButtonStyle = TextButton.styleFrom( ), ); -void Function()? loadingCancelCallback; void showLoading(String text, BuildContext? context) { if (_hasDialog && context != null) { Navigator.pop(context); _hasDialog = false; } dismissLoading(); - if (isAndroid) { - EasyLoading.show(status: text, maskType: EasyLoadingMaskType.black); - return; - } - // EasyLoading.showWidget( - // Container( - // constraints: BoxConstraints(maxWidth: 300), - // child: Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // Center(child: CircularProgressIndicator()), - // SizedBox(height: 20), - // Center( - // child: Text(Translator.call(text), - // style: TextStyle(fontSize: 15))), - // SizedBox(height: 20), - // Center( - // child: TextButton( - // style: flatButtonStyle, - // onPressed: () { - // // with out loadingCancelCallback, we can see unexpected input password - // // dialog shown in home, no clue why, so use this as workaround - // // why no such issue on android? - // if (loadingCancelCallback != null) - // loadingCancelCallback(); - // Navigator.pop(context); - // }, - // child: Text(Translator.call('Cancel'), - // style: TextStyle(color: MyTheme.accent)))) - // ], - // )), - // maskType: EasyLoadingMaskType.black); + EasyLoading.show(status: text, maskType: EasyLoadingMaskType.black); } void dismissLoading() { @@ -112,7 +80,7 @@ Future showAlertDialog(BuildContext context, BuildAlertDailog build, return res; } -void msgbox(String type, String title, String text, BuildContext context, +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), @@ -167,22 +135,6 @@ void msgbox(String type, String title, String text, BuildContext context, ], )) ); - // EasyLoading.showWidget( - // Container( - // constraints: BoxConstraints(maxWidth: 300), - // child: Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // Text(Translator.call(title), style: TextStyle(fontSize: 21)), - // SizedBox(height: 20), - // Text(Translator.call(text), style: TextStyle(fontSize: 15)), - // SizedBox(height: 20), - // Row( - // children: buttons, - // ) - // ], - // )), - // maskType: EasyLoadingMaskType.black); } class PasswordWidget extends StatefulWidget { diff --git a/lib/main.dart b/lib/main.dart index 00b297b13..0e2471908 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:provider/provider.dart'; import 'package:firebase_analytics/firebase_analytics.dart'; import 'package:firebase_analytics/observer.dart'; @@ -10,11 +11,13 @@ import 'server_page.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); + // EasyLoading.instance.loadingStyle = EasyLoadingStyle.light; toAndroidChannelInit(); runApp(App()); } class App extends StatelessWidget { + @override Widget build(BuildContext context) { final analytics = FirebaseAnalytics(); @@ -39,6 +42,7 @@ class App extends StatelessWidget { navigatorObservers: [ FirebaseAnalyticsObserver(analytics: analytics), ], + builder: EasyLoading.init(), ), ); } diff --git a/lib/remote_page.dart b/lib/remote_page.dart index 30979be49..64814b03f 100644 --- a/lib/remote_page.dart +++ b/lib/remote_page.dart @@ -3,7 +3,6 @@ import 'package:flutter_hbb/widgets/gesture_help.dart'; import 'package:provider/provider.dart'; import 'package:flutter/services.dart'; import 'dart:ui' as ui; -import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'dart:async'; import 'package:tuple/tuple.dart'; import 'package:wakelock/wakelock.dart'; @@ -48,7 +47,6 @@ class _RemotePageState extends State { Timer.periodic(Duration(milliseconds: 30), (timer) => interval()); }); Wakelock.enable(); - loadingCancelCallback = () => _interval?.cancel(); _touchMode = FFI.getByName('peer_option', "touch-mode") != ''; } @@ -56,7 +54,6 @@ class _RemotePageState extends State { void dispose() { _focusNode.dispose(); FFI.close(); - loadingCancelCallback = null; _interval?.cancel(); _timer?.cancel(); dismissLoading(); @@ -110,7 +107,7 @@ class _RemotePageState extends State { } void showMsgBox(String type, String title, String text, bool hasRetry) { - msgbox(type, title, text, context); + msgBox(type, title, text, context); if (hasRetry) { _timer?.cancel(); _timer = Timer(Duration(seconds: _reconnects), () { @@ -223,7 +220,6 @@ class _RemotePageState extends State { final pi = Provider.of(context).pi; final hideKeyboard = isKeyboardShown() && _showEdit; final showActionButton = !_showBar || hideKeyboard; - EasyLoading.instance.loadingStyle = EasyLoadingStyle.light; return WillPopScope( onWillPop: () async { close(); @@ -249,13 +245,12 @@ class _RemotePageState extends State { }), bottomNavigationBar: _showBar && pi.displays != null ? getBottomAppBar() : null, - body: FlutterEasyLoading( - child: Container( + body: Container( color: Colors.black, child: isDesktop ? getBodyForDesktopWithListener() : SafeArea(child: getBodyForMobileWithGesture())), - )), + ), ); } @@ -575,7 +570,7 @@ class _RemotePageState extends State { } void close() { - msgbox('', 'Close', 'Are you sure to close the connection?', context); + msgBox('', 'Close', 'Are you sure to close the connection?', context); } Widget getHelpTools() {