diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index 2f44280..c224a39 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -57,7 +57,7 @@ }, { "name": "connectivity", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/connectivity-0.4.9+3", + "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/connectivity-0.4.9+5", "packageUri": "lib/", "languageVersion": "2.1" }, @@ -93,7 +93,7 @@ }, { "name": "device_info", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/device_info-0.4.2+8", + "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/device_info-0.4.2+9", "packageUri": "lib/", "languageVersion": "2.1" }, @@ -237,7 +237,7 @@ }, { "name": "image_picker", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/image_picker-0.6.7+11", + "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/image_picker-0.6.7+12", "packageUri": "lib/", "languageVersion": "2.1" }, @@ -297,7 +297,7 @@ }, { "name": "path_provider", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.6.18", + "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.6.21", "packageUri": "lib/", "languageVersion": "2.1" }, @@ -405,7 +405,7 @@ }, { "name": "shared_preferences", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences-0.5.12", + "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences-0.5.12+2", "packageUri": "lib/", "languageVersion": "2.1" }, @@ -537,7 +537,7 @@ }, { "name": "url_launcher", - "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/url_launcher-5.7.2", + "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/url_launcher-5.7.4", "packageUri": "lib/", "languageVersion": "2.1" }, @@ -620,7 +620,7 @@ "languageVersion": "2.1" } ], - "generated": "2020-10-15T08:11:29.784634Z", + "generated": "2020-10-15T08:14:11.281280Z", "generator": "pub", "generatorVersion": "2.8.2" } diff --git a/lib/dialog/loading/loading.dart b/lib/dialog/loading/loading.dart new file mode 100644 index 0000000..cfcc17d --- /dev/null +++ b/lib/dialog/loading/loading.dart @@ -0,0 +1,32 @@ +import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/dialog/loading/loading_dialog.dart'; + +// loading弹窗 +class Loading { + static LoadingDialog _dialog; + static BuildContext _context; + + static Future show( + BuildContext context, { + String msg, + }) async { + dismiss(); + + _context = context; + _dialog = LoadingDialog( + message: msg, + ); + var result = await showDialog(context: context, child: _dialog); + _context = null; + _dialog = null; + return result; + } + + static dismiss() { + if (_dialog != null && _context != null) { + Navigator.pop(_context); + } + _context = null; + _dialog = null; + } +} diff --git a/lib/dialog/loading/loading_dialog.dart b/lib/dialog/loading/loading_dialog.dart new file mode 100644 index 0000000..151cf48 --- /dev/null +++ b/lib/dialog/loading/loading_dialog.dart @@ -0,0 +1,52 @@ +import 'package:flutter/material.dart'; +import 'package:loading_indicator/loading_indicator.dart'; + +class LoadingDialog extends StatelessWidget { + final String message; + + const LoadingDialog({Key key, this.message}) : super(key: key); + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () { + Navigator.pop(context); + }, + child: Scaffold( + backgroundColor: Colors.transparent, + body: Center( + child: UnconstrainedBox( + child: Container( + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.circular(8)), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 80, + height: 80, + child: LoadingIndicator( + indicatorType: Indicator.ballSpinFadeLoader, + color: Colors.redAccent, + ), + ), + message == null || message == '' + ? Container() + : Container( + margin: EdgeInsets.only(top: 8), + child: Text( + message, + style: TextStyle(fontSize: 14), + ), + ), + ], + ), + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/goods_share_page/goods_share_image/goods_share_image.dart b/lib/pages/goods_share_page/goods_share_image/goods_share_image.dart index 5b7bd9c..22b3715 100644 --- a/lib/pages/goods_share_page/goods_share_image/goods_share_image.dart +++ b/lib/pages/goods_share_page/goods_share_image/goods_share_image.dart @@ -10,6 +10,7 @@ import 'package:flutter/services.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:save_image/save_image.dart'; +import 'package:zhiying_base_widget/dialog/loading/loading.dart'; import 'package:zhiying_base_widget/pages/goods_share_page/goods_share_editor/goods_share_editor.dart'; import 'package:zhiying_base_widget/pages/goods_share_page/goods_share_image/goods_share_image_model.dart'; import 'package:zhiying_base_widget/pages/goods_share_page/models/goods_share_poster_model.dart'; @@ -250,6 +251,8 @@ class _GoodsShareImageState extends State } void _saveImages() async { + Loading.show(context, msg: '正在保存'); + await _updateModel(); List images = List(); @@ -267,6 +270,7 @@ class _GoodsShareImageState extends State if ((_shareModel.image == null || _shareModel.image.length == 0) && _shareModel.poster == null) { Fluttertoast.showToast(msg: '请选择要保存的图片'); + Loading.dismiss(); return; } @@ -277,6 +281,7 @@ class _GoodsShareImageState extends State } if (status == PermissionStatus.denied) { Fluttertoast.showToast(msg: '暂无权限,保存失败'); + Loading.dismiss(); return null; } @@ -287,6 +292,7 @@ class _GoodsShareImageState extends State } if (status == PermissionStatus.denied) { Fluttertoast.showToast(msg: '暂无权限,分享失败'); + Loading.dismiss(); return null; } @@ -304,6 +310,8 @@ class _GoodsShareImageState extends State Fluttertoast.showToast(msg: '保存成功'); else Fluttertoast.showToast(msg: '保存失败'); + + Loading.dismiss(); } Future _updateModel() async { diff --git a/lib/pages/mine_detail_page/mine_detail_page.dart b/lib/pages/mine_detail_page/mine_detail_page.dart index 73ea51c..a748c16 100644 --- a/lib/pages/mine_detail_page/mine_detail_page.dart +++ b/lib/pages/mine_detail_page/mine_detail_page.dart @@ -7,6 +7,7 @@ import 'package:fluttertoast/fluttertoast.dart'; import 'package:image_cropper/image_cropper.dart'; import 'package:image_picker/image_picker.dart'; import 'package:intl/intl.dart'; +import 'package:zhiying_base_widget/dialog/loading/loading.dart'; import 'package:zhiying_base_widget/pages/mine_detail_page/mine_detail_bloc.dart'; import 'package:zhiying_base_widget/pages/mine_detail_page/models/mine_detail_model.dart'; import 'package:zhiying_base_widget/widgets/others/action_date_alert/action_date_alert.dart'; @@ -94,6 +95,7 @@ class _MineDetailContainerState extends State<_MineDetailContainer> { stream: _bloc.outData, builder: (BuildContext context, AsyncSnapshot snapshot) { MineDetailModel user = snapshot.data; + Loading.dismiss(); if (user == null) { return Container(); } @@ -308,7 +310,11 @@ class _MineDetailContainerState extends State<_MineDetailContainer> { lockAspectRatio: true), iosUiSettings: IOSUiSettings( minimumAspectRatio: 1.0, aspectRatioLockEnabled: true)); + if (cropperFile == null) { + return; + } File resultFile = await EncodeUtil.compressImage(cropperFile, 800); + Loading.show(context); _bloc.uploadAvatar(resultFile); } } diff --git a/lib/widgets/home/home_goods/home_goods.dart b/lib/widgets/home/home_goods/home_goods.dart index 6169552..8dbe683 100644 --- a/lib/widgets/home/home_goods/home_goods.dart +++ b/lib/widgets/home/home_goods/home_goods.dart @@ -4,6 +4,7 @@ import 'package:event_bus/event_bus.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:zhiying_base_widget/dialog/loading/loading.dart'; import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart'; import 'package:zhiying_base_widget/widgets/home/home_goods/bloc/home_goods_bloc.dart'; import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods_creater.dart'; @@ -64,6 +65,7 @@ class _HomeGoodsContainerState extends State<_HomeGoodsContainer> { widget.eventBus.on().listen((data) { _provider = data.provider; _bloc.loadMore(_provider); + Loading.show(context); }); super.initState(); @@ -90,7 +92,7 @@ class _HomeGoodsContainerState extends State<_HomeGoodsContainer> { // child: HomeGoodsSkeleton(), // ); // } - + Loading.dismiss(); List goods = snapshot.data; int column = int.tryParse(_style.listColumn); column = column <= 0 ? 1 : column; diff --git a/lib/widgets/share/share_alert.dart b/lib/widgets/share/share_alert.dart index ced0ba0..67b13df 100644 --- a/lib/widgets/share/share_alert.dart +++ b/lib/widgets/share/share_alert.dart @@ -9,6 +9,7 @@ import 'package:path_provider/path_provider.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:share_extend/share_extend.dart'; import 'package:sharesdk_plugin/sharesdk_plugin.dart'; +import 'package:zhiying_base_widget/dialog/loading/loading.dart'; import 'package:zhiying_base_widget/utils/image_download_util/image_download_util.dart'; import 'package:zhiying_base_widget/widgets/share/models/share_data_model.dart'; import 'package:zhiying_base_widget/widgets/share/models/share_icon_model.dart'; @@ -66,10 +67,10 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { void initState() { NetUtil.request('/api/v1/mod/${widget.skipIdentifier}', method: NetMethod.GET, onCache: (data) { - _parseData(data); - }, onSuccess: (data) { - _parseData(data); - }, onError: (err) {}); + _parseData(data); + }, onSuccess: (data) { + _parseData(data); + }, onError: (err) {}); super.initState(); } @@ -121,7 +122,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { ), Container( margin: - EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10), + EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10), child: _createIcons(), ), GestureDetector( @@ -228,6 +229,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { return; } + Loading.show(context); SSDKMap params; if (widget.model.poster != null) { String path = await _savePoster(); @@ -273,6 +275,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { Fluttertoast.showToast(msg: '取消分享'); } Logger.debug('${state}, ${error.rawData}'); + Loading.dismiss(); }); } @@ -337,9 +340,11 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { paths.add(path); } + Loading.show(context); List downPaths = - await ImageDownloadUtil.download(widget.model.image); + await ImageDownloadUtil.download(widget.model.image); paths.addAll(downPaths); ShareExtend.shareMultiple(paths, "image", subject: ""); + Loading.dismiss(); } } diff --git a/lib/zhiying_base_widget.dart b/lib/zhiying_base_widget.dart new file mode 100644 index 0000000..a86f45f --- /dev/null +++ b/lib/zhiying_base_widget.dart @@ -0,0 +1,3 @@ +library zhiying_base_widget; + +export 'dialog/loading/loading.dart';