Browse Source

更新loading

tags/0.0.1
Weller 4 years ago
parent
commit
2a9d75e675
3 changed files with 26 additions and 24 deletions
  1. +5
    -5
      .dart_tool/package_config.json
  2. +18
    -18
      lib/dialog/loading/loading.dart
  3. +3
    -1
      lib/dialog/loading/loading_dialog.dart

+ 5
- 5
.dart_tool/package_config.json View File

@@ -165,7 +165,7 @@
},
{
"name": "flutter_native_image",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/flutter_native_image-0.0.5+2",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/flutter_native_image-0.0.5+3",
"packageUri": "lib/",
"languageVersion": "1.19"
},
@@ -465,7 +465,7 @@
},
{
"name": "sqflite",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/sqflite-1.3.1+1",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/sqflite-1.3.1+2",
"packageUri": "lib/",
"languageVersion": "2.7"
},
@@ -537,13 +537,13 @@
},
{
"name": "url_launcher",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/url_launcher-5.7.5",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/url_launcher-5.7.6",
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "url_launcher_linux",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_linux-0.0.1+1",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_linux-0.0.1+3",
"packageUri": "lib/",
"languageVersion": "2.1"
},
@@ -620,7 +620,7 @@
"languageVersion": "2.8"
}
],
"generated": "2020-10-17T09:07:26.676256Z",
"generated": "2020-10-22T02:18:13.447793Z",
"generator": "pub",
"generatorVersion": "2.8.2"
}

+ 18
- 18
lib/dialog/loading/loading.dart View File

@@ -3,31 +3,31 @@ import 'package:zhiying_base_widget/dialog/loading/loading_dialog.dart';

// loading弹窗
class Loading {
static LoadingDialog _dialog;
static BuildContext _context;
static OverlayEntry _overlayEntry;

static Future show(BuildContext context, {
static Future show(
BuildContext context, {
String msg,
}) async {
dismiss();
_overlayEntry = new OverlayEntry(builder: (context) {
return GestureDetector(
onTap: dismiss,
child: Container(
color: Colors.black.withOpacity(0.5),
child: LoadingDialog(
message: msg,
),
),
);
});

_context = context;
_dialog = LoadingDialog(
message: msg,
);
var result = await showDialog(context: context, child: _dialog);
_context = null;
_dialog = null;
return result;
//插入到 Overlay中显示 OverlayEntry
Overlay.of(context).insert(_overlayEntry);
}

static dismiss() {
if (_dialog != null && _context != null) {
if (Navigator.canPop(_context)) {
Navigator.pop(_context);
}
}
_context = null;
_dialog = null;
_overlayEntry?.remove();
_overlayEntry = null;
}
}

+ 3
- 1
lib/dialog/loading/loading_dialog.dart View File

@@ -10,7 +10,9 @@ class LoadingDialog extends StatelessWidget {
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
Navigator.pop(context);
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
},
child: Scaffold(
backgroundColor: Colors.transparent,


Loading…
Cancel
Save