Repository navigation
Expand file tree
/
Copy pathPhotoViewPage.dart
More file actions
61 lines (56 loc) · 2.11 KB
/
Copy pathPhotoViewPage.dart
File metadata and controls
61 lines (56 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
import 'package:gsy_github_app_flutter/common/utils/CommonUtils.dart';
import 'package:gsy_github_app_flutter/widget/GSYCommonOptionWidget.dart';
import 'package:gsy_github_app_flutter/widget/GSYTitleBar.dart';
import 'package:photo_view/photo_view.dart';
/**
* 图片预览
* Created by guoshuyu
* Date: 2018-08-09
*/
class PhotoViewPage extends StatelessWidget {
final String url;
PhotoViewPage(this.url);
@override
Widget build(BuildContext context) {
OptionControl optionControl = new OptionControl();
optionControl.url = url;
return new Scaffold(
floatingActionButton: new FloatingActionButton(
child: new Icon(Icons.file_download),
onPressed: () {
CommonUtils.saveImage(url).then((res) {
if (res != null) {
Fluttertoast.showToast(msg: res);
if (Platform.isAndroid) {
const updateAlbum = const MethodChannel('com.shuyu.gsygithub.gsygithubflutter/UpdateAlbumPlugin');
updateAlbum.invokeMethod('updateAlbum', { 'path': res, 'name': CommonUtils.splitFileNameByPath(res)});
}
}
});
},
),
appBar: new AppBar(
title: GSYTitleBar("", rightWidget: new GSYCommonOptionWidget(optionControl)),
),
body: new Container(
color: Colors.black,
child: new PhotoView(
imageProvider: new NetworkImage(url ?? GSYICons.DEFAULT_REMOTE_PIC),
loadingChild: Container(
child: new Stack(
children: <Widget>[
new Center(child: new Image.asset(GSYICons.DEFAULT_IMAGE, height: 180.0, width: 180.0)),
new Center(child: new SpinKitFoldingCube(color: Colors.white30, size: 60.0)),
],
),
),
),
));
}
}