Skip to content

Commit

Permalink
## 0.7.9
Browse files Browse the repository at this point in the history
fixed image preview * 3
  • Loading branch information
chendoxiu committed Dec 13, 2024
1 parent 663beeb commit 3824ba0
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 60 deletions.
5 changes: 3 additions & 2 deletions lib/pages/image_preview/image_preview.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:blurhash_shader/blurhash_shader.dart';
import 'package:dio/src/dio.dart';
import 'package:dio/dio.dart';
import 'package:extended_image/extended_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down Expand Up @@ -163,10 +163,11 @@ class ImagePreviewPage extends HookConsumerWidget {
var item = galleryItems[index];
Widget image = FutureBuilder(
future: precacheImage(
ExtendedNetworkImageProvider(item.url, cache: true),
getExtendedResizeImage(item.url),
context,
),
builder: (BuildContext context, AsyncSnapshot snapshot) {
print(snapshot);
var isLoaded =
snapshot.connectionState == ConnectionState.done ||
snapshot.hasError;
Expand Down
108 changes: 55 additions & 53 deletions lib/widgets/mk_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,60 +63,62 @@ class _MkImageState extends State<MkImage> with SingleTickerProviderStateMixin {
width: widget.width, height: widget.height, fit: widget.fit),
);
}
Widget image = ExtendedImage(
image: getExtendedResizeImage(widget.url),
shape: widget.shape,
loadStateChanged: (state) {
switch (state.extendedImageLoadState) {
case LoadState.completed:
_controller.forward();
var image = FadeTransition(
opacity: _controller,
child: ExtendedRawImage(
image: state.extendedImageInfo?.image,
height: widget.height,
width: widget.width,
fit: widget.fit,
filterQuality: FilterQuality.medium,
),
);
if (widget.blurHash == null || widget.blurHash!.isEmpty) {
return image;
}
return BlurHash(
widget.blurHash!,
child: image,
);
case LoadState.loading:
case LoadState.failed:
return LayoutBuilder(
builder: (context, constraints) {
var constraintsHeight = constraints.maxHeight;
var constraintsWidth = constraints.maxWidth;
if (constraints.maxHeight == double.infinity) {
constraintsHeight = constraints.minHeight;
}
if (constraints.maxWidth == double.infinity) {
constraintsWidth = constraints.minWidth;
}
return Container(
width: widget.width ?? widget.height ?? constraintsWidth,
height: widget.height ?? constraintsHeight,
color: const Color.fromARGB(10, 0, 0, 0),
child:
(widget.blurHash != null && widget.blurHash!.isNotEmpty)
? BlurHash(widget.blurHash!)
: null,
);
},
);
}
},
);

if (widget.heroKey != null) {
image = Hero(tag: widget.heroKey ?? UniqueKey(), child: image);
}
return RepaintBoundary(
child: Hero(
tag: widget.heroKey ?? UniqueKey(),
child: ExtendedImage(
image: getExtendedResizeImage(widget.url),
shape: widget.shape,
loadStateChanged: (state) {
switch (state.extendedImageLoadState) {
case LoadState.completed:
_controller.forward();
var image = FadeTransition(
opacity: _controller,
child: ExtendedRawImage(
image: state.extendedImageInfo?.image,
height: widget.height,
width: widget.width,
fit: widget.fit,
filterQuality: FilterQuality.medium,
),
);
if (widget.blurHash == null || widget.blurHash!.isEmpty) {
return image;
}
return BlurHash(
widget.blurHash!,
child: image,
);
case LoadState.loading:
case LoadState.failed:
return LayoutBuilder(
builder: (context, constraints) {
var constraintsHeight = constraints.maxHeight;
var constraintsWidth = constraints.maxWidth;
if (constraints.maxHeight == double.infinity) {
constraintsHeight = constraints.minHeight;
}
if (constraints.maxWidth == double.infinity) {
constraintsWidth = constraints.minWidth;
}
return Container(
width:
widget.width ?? widget.height ?? constraintsWidth,
height: widget.height ?? constraintsHeight,
color: const Color.fromARGB(10, 0, 0, 0),
child: (widget.blurHash != null &&
widget.blurHash!.isNotEmpty)
? BlurHash(widget.blurHash!)
: null,
);
},
);
}
},
)),
child: image,
);
}
}
11 changes: 8 additions & 3 deletions lib/widgets/notes/note_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,10 @@ class _TimeLineImageState extends State<TimeLineImage> {
open(index) {
context.push('/image-preview', extra: {
'initialIndex': index,
'galleryItems': widget.files,
'galleryItems': [
for (var value in widget.files)
if (value.type.startsWith("image")) value
],
'heroKeys': heroKeys
});
}
Expand All @@ -955,8 +958,10 @@ class _TimeLineImageState extends State<TimeLineImage> {
@override
void initState() {
super.initState();
for (var i = 0; i < widget.files.length; i++) {
heroKeys.add(UniqueKey());
for (var value in widget.files) {
if (value.type.startsWith("image")) {
heroKeys.add(UniqueKey());
}
}
}

Expand Down
1 change: 0 additions & 1 deletion lib/widgets/notes/note_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'package:moekey/status/themes.dart';

import '../../apis/models/drive.dart';
import '../../generated/l10n.dart';
import '../../utils/custom_rect_tween.dart';
import '../mk_image.dart';
import '../video_player.dart';

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

environment:
sdk: '>=3.5.0 <4.0.0'
Expand Down

0 comments on commit 3824ba0

Please sign in to comment.