Преглед на файлове

添加loading提示

tags/0.0.1
Weller преди 4 години
родител
ревизия
1cea950aab
променени са 8 файла, в които са добавени 122 реда и са изтрити 14 реда
  1. +7
    -7
      .dart_tool/package_config.json
  2. +32
    -0
      lib/dialog/loading/loading.dart
  3. +52
    -0
      lib/dialog/loading/loading_dialog.dart
  4. +8
    -0
      lib/pages/goods_share_page/goods_share_image/goods_share_image.dart
  5. +6
    -0
      lib/pages/mine_detail_page/mine_detail_page.dart
  6. +3
    -1
      lib/widgets/home/home_goods/home_goods.dart
  7. +11
    -6
      lib/widgets/share/share_alert.dart
  8. +3
    -0
      lib/zhiying_base_widget.dart

+ 7
- 7
.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"
}

+ 32
- 0
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;
}
}

+ 52
- 0
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: <Widget>[
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),
),
),
],
),
),
),
),
),
);
}
}

+ 8
- 0
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<GoodsShareImage>
}

void _saveImages() async {
Loading.show(context, msg: '正在保存');

await _updateModel();

List<String> images = List();
@@ -267,6 +270,7 @@ class _GoodsShareImageState extends State<GoodsShareImage>
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<GoodsShareImage>
}
if (status == PermissionStatus.denied) {
Fluttertoast.showToast(msg: '暂无权限,保存失败');
Loading.dismiss();
return null;
}

@@ -287,6 +292,7 @@ class _GoodsShareImageState extends State<GoodsShareImage>
}
if (status == PermissionStatus.denied) {
Fluttertoast.showToast(msg: '暂无权限,分享失败');
Loading.dismiss();
return null;
}

@@ -304,6 +310,8 @@ class _GoodsShareImageState extends State<GoodsShareImage>
Fluttertoast.showToast(msg: '保存成功');
else
Fluttertoast.showToast(msg: '保存失败');

Loading.dismiss();
}

Future<ShareDataModel> _updateModel() async {


+ 6
- 0
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);
}
}


+ 3
- 1
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<HomeGoodsHeaderEvent>().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<HomeGoodsModel> goods = snapshot.data;
int column = int.tryParse(_style.listColumn);
column = column <= 0 ? 1 : column;


+ 11
- 6
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<String> downPaths =
await ImageDownloadUtil.download(widget.model.image);
await ImageDownloadUtil.download(widget.model.image);
paths.addAll(downPaths);
ShareExtend.shareMultiple(paths, "image", subject: "");
Loading.dismiss();
}
}

+ 3
- 0
lib/zhiying_base_widget.dart Целия файл

@@ -0,0 +1,3 @@
library zhiying_base_widget;

export 'dialog/loading/loading.dart';

Зареждане…
Отказ
Запис