first commit
This commit is contained in:
1
moehu/moehu_fontend/lib/views/ImageView/.pydio
Normal file
1
moehu/moehu_fontend/lib/views/ImageView/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
a4277967-b661-464a-af2f-b5364f5d720a
|
||||
123
moehu/moehu_fontend/lib/views/ImageView/ImageView.dart
Normal file
123
moehu/moehu_fontend/lib/views/ImageView/ImageView.dart
Normal file
@@ -0,0 +1,123 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:peach/entity/_.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
import 'package:photo_view/photo_view_gallery.dart';
|
||||
|
||||
/*
|
||||
* 查看大图
|
||||
*/
|
||||
class PhotoViewGalleryScreen extends StatefulWidget {
|
||||
List<ImagePickerEntity> images = [];
|
||||
int index = 0;
|
||||
String heroTag;
|
||||
PageController controller;
|
||||
|
||||
PhotoViewGalleryScreen(
|
||||
{Key key,
|
||||
@required this.images,
|
||||
this.index,
|
||||
this.controller,
|
||||
this.heroTag})
|
||||
: super(key: key) {
|
||||
controller = PageController(initialPage: index);
|
||||
}
|
||||
|
||||
@override
|
||||
_PhotoViewGalleryScreenState createState() => _PhotoViewGalleryScreenState();
|
||||
}
|
||||
|
||||
class _PhotoViewGalleryScreenState extends State<PhotoViewGalleryScreen> {
|
||||
int currentIndex = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
currentIndex = widget.index;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
children: <Widget>[
|
||||
Positioned(
|
||||
top: 0,
|
||||
left: 0,
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
child: Container(
|
||||
child: PhotoViewGallery.builder(
|
||||
scrollPhysics: const BouncingScrollPhysics(),
|
||||
builder: (BuildContext context, int index) {
|
||||
return PhotoViewGalleryPageOptions(
|
||||
imageProvider: widget.images[index].getNetWorkPath != null
|
||||
? NetworkImage(widget.images[index]?.getNetWorkPath)
|
||||
: FileImage(widget.images[index]?.getPath),
|
||||
);
|
||||
},
|
||||
itemCount: widget.images.length,
|
||||
backgroundDecoration: null,
|
||||
pageController: widget.controller,
|
||||
enableRotation: true,
|
||||
onPageChanged: (index) {
|
||||
setState(
|
||||
() {
|
||||
currentIndex = index;
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
//图片index显示
|
||||
top: MediaQuery.of(context).padding.top + 15,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: Center(
|
||||
child: Text("${currentIndex + 1}/${widget.images.length}",
|
||||
style: TextStyle(color: Colors.white, fontSize: 16)),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
//右上角关闭按钮
|
||||
right: 10,
|
||||
top: MediaQuery.of(context).padding.top,
|
||||
child: IconButton(
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
size: 30,
|
||||
color: Colors.white,
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FadeRoute extends PageRouteBuilder {
|
||||
final Widget page;
|
||||
FadeRoute({this.page})
|
||||
: super(
|
||||
pageBuilder: (
|
||||
BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
) =>
|
||||
page,
|
||||
transitionsBuilder: (
|
||||
BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child,
|
||||
) =>
|
||||
FadeTransition(
|
||||
opacity: animation,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user