move easyloading to main
This commit is contained in:
parent
673991d7d5
commit
725b916392
@ -32,45 +32,13 @@ final ButtonStyle flatButtonStyle = TextButton.styleFrom(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
void Function()? loadingCancelCallback;
|
|
||||||
void showLoading(String text, BuildContext? context) {
|
void showLoading(String text, BuildContext? context) {
|
||||||
if (_hasDialog && context != null) {
|
if (_hasDialog && context != null) {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
_hasDialog = false;
|
_hasDialog = false;
|
||||||
}
|
}
|
||||||
dismissLoading();
|
dismissLoading();
|
||||||
if (isAndroid) {
|
EasyLoading.show(status: text, maskType: EasyLoadingMaskType.black);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dismissLoading() {
|
void dismissLoading() {
|
||||||
@ -112,7 +80,7 @@ Future<T?> showAlertDialog<T>(BuildContext context, BuildAlertDailog build,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void msgbox(String type, String title, String text, BuildContext context,
|
void msgBox(String type, String title, String text, BuildContext context,
|
||||||
{bool? hasCancel}) {
|
{bool? hasCancel}) {
|
||||||
var wrap = (String text, void Function() onPressed) => ButtonTheme(
|
var wrap = (String text, void Function() onPressed) => ButtonTheme(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
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 {
|
class PasswordWidget extends StatefulWidget {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:firebase_analytics/firebase_analytics.dart';
|
import 'package:firebase_analytics/firebase_analytics.dart';
|
||||||
import 'package:firebase_analytics/observer.dart';
|
import 'package:firebase_analytics/observer.dart';
|
||||||
@ -10,11 +11,13 @@ import 'server_page.dart';
|
|||||||
Future<Null> main() async {
|
Future<Null> main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await Firebase.initializeApp();
|
await Firebase.initializeApp();
|
||||||
|
// EasyLoading.instance.loadingStyle = EasyLoadingStyle.light;
|
||||||
toAndroidChannelInit();
|
toAndroidChannelInit();
|
||||||
runApp(App());
|
runApp(App());
|
||||||
}
|
}
|
||||||
|
|
||||||
class App extends StatelessWidget {
|
class App extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final analytics = FirebaseAnalytics();
|
final analytics = FirebaseAnalytics();
|
||||||
@ -39,6 +42,7 @@ class App extends StatelessWidget {
|
|||||||
navigatorObservers: [
|
navigatorObservers: [
|
||||||
FirebaseAnalyticsObserver(analytics: analytics),
|
FirebaseAnalyticsObserver(analytics: analytics),
|
||||||
],
|
],
|
||||||
|
builder: EasyLoading.init(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ import 'package:flutter_hbb/widgets/gesture_help.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
import 'package:wakelock/wakelock.dart';
|
import 'package:wakelock/wakelock.dart';
|
||||||
@ -48,7 +47,6 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
Timer.periodic(Duration(milliseconds: 30), (timer) => interval());
|
Timer.periodic(Duration(milliseconds: 30), (timer) => interval());
|
||||||
});
|
});
|
||||||
Wakelock.enable();
|
Wakelock.enable();
|
||||||
loadingCancelCallback = () => _interval?.cancel();
|
|
||||||
_touchMode = FFI.getByName('peer_option', "touch-mode") != '';
|
_touchMode = FFI.getByName('peer_option', "touch-mode") != '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +54,6 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
_focusNode.dispose();
|
_focusNode.dispose();
|
||||||
FFI.close();
|
FFI.close();
|
||||||
loadingCancelCallback = null;
|
|
||||||
_interval?.cancel();
|
_interval?.cancel();
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
dismissLoading();
|
dismissLoading();
|
||||||
@ -110,7 +107,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void showMsgBox(String type, String title, String text, bool hasRetry) {
|
void showMsgBox(String type, String title, String text, bool hasRetry) {
|
||||||
msgbox(type, title, text, context);
|
msgBox(type, title, text, context);
|
||||||
if (hasRetry) {
|
if (hasRetry) {
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
_timer = Timer(Duration(seconds: _reconnects), () {
|
_timer = Timer(Duration(seconds: _reconnects), () {
|
||||||
@ -223,7 +220,6 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
final pi = Provider.of<FfiModel>(context).pi;
|
final pi = Provider.of<FfiModel>(context).pi;
|
||||||
final hideKeyboard = isKeyboardShown() && _showEdit;
|
final hideKeyboard = isKeyboardShown() && _showEdit;
|
||||||
final showActionButton = !_showBar || hideKeyboard;
|
final showActionButton = !_showBar || hideKeyboard;
|
||||||
EasyLoading.instance.loadingStyle = EasyLoadingStyle.light;
|
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
onWillPop: () async {
|
onWillPop: () async {
|
||||||
close();
|
close();
|
||||||
@ -249,13 +245,12 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
}),
|
}),
|
||||||
bottomNavigationBar:
|
bottomNavigationBar:
|
||||||
_showBar && pi.displays != null ? getBottomAppBar() : null,
|
_showBar && pi.displays != null ? getBottomAppBar() : null,
|
||||||
body: FlutterEasyLoading(
|
body: Container(
|
||||||
child: Container(
|
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
child: isDesktop
|
child: isDesktop
|
||||||
? getBodyForDesktopWithListener()
|
? getBodyForDesktopWithListener()
|
||||||
: SafeArea(child: getBodyForMobileWithGesture())),
|
: SafeArea(child: getBodyForMobileWithGesture())),
|
||||||
)),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,7 +570,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void close() {
|
void close() {
|
||||||
msgbox('', 'Close', 'Are you sure to close the connection?', context);
|
msgBox('', 'Close', 'Are you sure to close the connection?', context);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getHelpTools() {
|
Widget getHelpTools() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user