Skip to content

Commit 3824ba0

Browse files
author
chendoxiu
committed
## 0.7.9
fixed image preview * 3
1 parent 663beeb commit 3824ba0

File tree

5 files changed

+67
-60
lines changed

5 files changed

+67
-60
lines changed

lib/pages/image_preview/image_preview.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'package:blurhash_shader/blurhash_shader.dart';
2-
import 'package:dio/src/dio.dart';
2+
import 'package:dio/dio.dart';
33
import 'package:extended_image/extended_image.dart';
44
import 'package:flutter/material.dart';
55
import 'package:flutter/services.dart';
@@ -163,10 +163,11 @@ class ImagePreviewPage extends HookConsumerWidget {
163163
var item = galleryItems[index];
164164
Widget image = FutureBuilder(
165165
future: precacheImage(
166-
ExtendedNetworkImageProvider(item.url, cache: true),
166+
getExtendedResizeImage(item.url),
167167
context,
168168
),
169169
builder: (BuildContext context, AsyncSnapshot snapshot) {
170+
print(snapshot);
170171
var isLoaded =
171172
snapshot.connectionState == ConnectionState.done ||
172173
snapshot.hasError;

lib/widgets/mk_image.dart

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -63,60 +63,62 @@ class _MkImageState extends State<MkImage> with SingleTickerProviderStateMixin {
6363
width: widget.width, height: widget.height, fit: widget.fit),
6464
);
6565
}
66+
Widget image = ExtendedImage(
67+
image: getExtendedResizeImage(widget.url),
68+
shape: widget.shape,
69+
loadStateChanged: (state) {
70+
switch (state.extendedImageLoadState) {
71+
case LoadState.completed:
72+
_controller.forward();
73+
var image = FadeTransition(
74+
opacity: _controller,
75+
child: ExtendedRawImage(
76+
image: state.extendedImageInfo?.image,
77+
height: widget.height,
78+
width: widget.width,
79+
fit: widget.fit,
80+
filterQuality: FilterQuality.medium,
81+
),
82+
);
83+
if (widget.blurHash == null || widget.blurHash!.isEmpty) {
84+
return image;
85+
}
86+
return BlurHash(
87+
widget.blurHash!,
88+
child: image,
89+
);
90+
case LoadState.loading:
91+
case LoadState.failed:
92+
return LayoutBuilder(
93+
builder: (context, constraints) {
94+
var constraintsHeight = constraints.maxHeight;
95+
var constraintsWidth = constraints.maxWidth;
96+
if (constraints.maxHeight == double.infinity) {
97+
constraintsHeight = constraints.minHeight;
98+
}
99+
if (constraints.maxWidth == double.infinity) {
100+
constraintsWidth = constraints.minWidth;
101+
}
102+
return Container(
103+
width: widget.width ?? widget.height ?? constraintsWidth,
104+
height: widget.height ?? constraintsHeight,
105+
color: const Color.fromARGB(10, 0, 0, 0),
106+
child:
107+
(widget.blurHash != null && widget.blurHash!.isNotEmpty)
108+
? BlurHash(widget.blurHash!)
109+
: null,
110+
);
111+
},
112+
);
113+
}
114+
},
115+
);
116+
117+
if (widget.heroKey != null) {
118+
image = Hero(tag: widget.heroKey ?? UniqueKey(), child: image);
119+
}
66120
return RepaintBoundary(
67-
child: Hero(
68-
tag: widget.heroKey ?? UniqueKey(),
69-
child: ExtendedImage(
70-
image: getExtendedResizeImage(widget.url),
71-
shape: widget.shape,
72-
loadStateChanged: (state) {
73-
switch (state.extendedImageLoadState) {
74-
case LoadState.completed:
75-
_controller.forward();
76-
var image = FadeTransition(
77-
opacity: _controller,
78-
child: ExtendedRawImage(
79-
image: state.extendedImageInfo?.image,
80-
height: widget.height,
81-
width: widget.width,
82-
fit: widget.fit,
83-
filterQuality: FilterQuality.medium,
84-
),
85-
);
86-
if (widget.blurHash == null || widget.blurHash!.isEmpty) {
87-
return image;
88-
}
89-
return BlurHash(
90-
widget.blurHash!,
91-
child: image,
92-
);
93-
case LoadState.loading:
94-
case LoadState.failed:
95-
return LayoutBuilder(
96-
builder: (context, constraints) {
97-
var constraintsHeight = constraints.maxHeight;
98-
var constraintsWidth = constraints.maxWidth;
99-
if (constraints.maxHeight == double.infinity) {
100-
constraintsHeight = constraints.minHeight;
101-
}
102-
if (constraints.maxWidth == double.infinity) {
103-
constraintsWidth = constraints.minWidth;
104-
}
105-
return Container(
106-
width:
107-
widget.width ?? widget.height ?? constraintsWidth,
108-
height: widget.height ?? constraintsHeight,
109-
color: const Color.fromARGB(10, 0, 0, 0),
110-
child: (widget.blurHash != null &&
111-
widget.blurHash!.isNotEmpty)
112-
? BlurHash(widget.blurHash!)
113-
: null,
114-
);
115-
},
116-
);
117-
}
118-
},
119-
)),
121+
child: image,
120122
);
121123
}
122124
}

lib/widgets/notes/note_card.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,10 @@ class _TimeLineImageState extends State<TimeLineImage> {
944944
open(index) {
945945
context.push('/image-preview', extra: {
946946
'initialIndex': index,
947-
'galleryItems': widget.files,
947+
'galleryItems': [
948+
for (var value in widget.files)
949+
if (value.type.startsWith("image")) value
950+
],
948951
'heroKeys': heroKeys
949952
});
950953
}
@@ -955,8 +958,10 @@ class _TimeLineImageState extends State<TimeLineImage> {
955958
@override
956959
void initState() {
957960
super.initState();
958-
for (var i = 0; i < widget.files.length; i++) {
959-
heroKeys.add(UniqueKey());
961+
for (var value in widget.files) {
962+
if (value.type.startsWith("image")) {
963+
heroKeys.add(UniqueKey());
964+
}
960965
}
961966
}
962967

lib/widgets/notes/note_image.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import 'package:moekey/status/themes.dart';
99

1010
import '../../apis/models/drive.dart';
1111
import '../../generated/l10n.dart';
12-
import '../../utils/custom_rect_tween.dart';
1312
import '../mk_image.dart';
1413
import '../video_player.dart';
1514

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
1616
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
1717
# In Windows, build-name is used as the major, minor, and patch parts
1818
# of the product and file versions while build-number is used as the build suffix.
19-
version: 0.7.5+48
19+
version: 0.7.9+49
2020

2121
environment:
2222
sdk: '>=3.5.0 <4.0.0'

0 commit comments

Comments
 (0)