update beeImagePreview

update horizontal image view
hmxc
小赖 4 years ago
parent 777cdbe51b
commit cfa7b2c54d

@ -1,8 +1,7 @@
/// Generate by [resource_generator](https://github.com/CaiJingLong/flutter_resource_generator) library.
/// PLEASE DO NOT EDIT MANUALLY.
class R {
/// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/.DS_Store)
static const String ASSETS__DS_STORE = 'assets/.DS_Store';
const R._();
/// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/example/QR_code.png)
static const String ASSETS_EXAMPLE_QR_CODE_PNG = 'assets/example/QR_code.png';

@ -1,9 +1,11 @@
import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/widget/picker/bee_image_preview.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:akuCommunity/const/resource.dart';
import 'package:get/get.dart';
class HorizontalImageView extends StatefulWidget {
final List<String> urls;
@ -21,17 +23,30 @@ class _HorizontalImageViewState extends State<HorizontalImageView> {
Widget build(BuildContext context) {
if (widget.urls.isEmpty) return 15.hb;
return Container(
height: 184.w + 24.w,
child: ListView.builder(
height: 184.w + 32.w,
child: ListView.separated(
padding: EdgeInsets.all(16.w),
separatorBuilder: (_, __) => 16.wb,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return Padding(
padding: EdgeInsets.all(16.w),
child: ClipRRect(
borderRadius: BorderRadius.circular(8.w),
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_ICONS_PROPOSAL_PNG,
image: API.image(widget.urls[index]),
return ClipRRect(
borderRadius: BorderRadius.circular(8.w),
child: GestureDetector(
onTap: () {
Get.to(
BeeImagePreview.path(path: widget.urls[index]),
opaque: false,
);
},
child: Hero(
tag: widget.urls[index],
child: FadeInImage.assetNetwork(
height: 184.w,
width: 184.w,
placeholder: R.ASSETS_IMAGES_LOGO_PNG,
image: API.image(widget.urls[index]),
fit: BoxFit.cover,
),
),
),
);

@ -1,17 +1,42 @@
import 'dart:io';
import 'package:akuCommunity/const/resource.dart';
import 'package:akuCommunity/constants/api.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class BeeImagePreview extends StatefulWidget {
final File file;
BeeImagePreview({Key key, @required this.file}) : super(key: key);
final String path;
BeeImagePreview.file({Key key, @required this.file})
: path = null,
super(key: key);
BeeImagePreview.path({Key key, @required this.path})
: file = null,
super(key: key);
@override
_BeeImagePreviewState createState() => _BeeImagePreviewState();
}
class _BeeImagePreviewState extends State<BeeImagePreview> {
Widget get image {
if (widget.file == null)
return Hero(
tag: widget.path,
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_LOGO_PNG,
image: API.image(widget.path),
),
);
else
return Hero(
tag: widget.file.hashCode,
child: Image.file(widget.file),
);
}
@override
Widget build(BuildContext context) {
return GestureDetector(
@ -21,10 +46,7 @@ class _BeeImagePreviewState extends State<BeeImagePreview> {
body: Center(
child: InteractiveViewer(
minScale: 0.2,
child: Hero(
tag: widget.file.hashCode,
child: Image.file(widget.file),
),
child: image,
),
),
),

@ -77,7 +77,7 @@ class _GridImagePickerState extends State<GridImagePicker> {
),
child: MaterialButton(
onPressed: () {
Get.to(BeeImagePreview(file: file),opaque: false);
Get.to(BeeImagePreview.file(file: file), opaque: false);
},
onLongPress: () async {
bool result = await Get.dialog(CupertinoAlertDialog(

Loading…
Cancel
Save