new msgbox to avoid crash

This commit is contained in:
open-trade 2020-11-29 01:36:10 +08:00
parent d89ad33b98
commit 0797334e35
4 changed files with 55 additions and 94 deletions

View File

@ -64,33 +64,52 @@ Future<T> showAlertDialog<T>(BuildContext context, BuildAlertDailog build,
return res;
}
Future<T> msgbox<T>(
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<T>(
context,
(_) => Tuple3(Text(title), Text(text), [
hasCancel
? FlatButton(
textColor: MyTheme.accent,
onPressed: () {
Navigator.pop(context);
},
child: Text('Cancel'),
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,
)
: Spacer(),
FlatButton(
textColor: MyTheme.accent,
onPressed: () {
Navigator.pop(context);
Navigator.pop(context);
},
child: Text('OK'),
),
]));
],
));
}
class PasswordWidget extends StatefulWidget {

View File

@ -99,8 +99,8 @@ class _RemotePageState extends State<RemotePage> {
}
}
Future<Null> 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<RemotePage> {
onPressed: () {
setState(() => _showBar = !_showBar);
}),
bottomNavigationBar: _showBar
bottomNavigationBar: _showBar && FFI.ffiModel.pi.displays != null
? BottomAppBar(
elevation: 10,
color: MyTheme.accent,

View File

@ -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:

View File

@ -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