Skip to content

Commit

Permalink
Merge pull request #101 from KosukeSaigusa/78_fix_cant_scaling_image
Browse files Browse the repository at this point in the history
#78 画像詳細ビューをphotoViewパッケージに変更
  • Loading branch information
RikitoNoto committed Aug 2, 2023
2 parents 188c625 + 2bd5c69 commit 3dff26f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 42 deletions.
55 changes: 15 additions & 40 deletions packages/dart_flutter_common/lib/src/widgets/generic_image.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';

/// [GenericImage] で表示する画像の形状。
enum ImageShape {
Expand Down Expand Up @@ -112,15 +113,7 @@ class GenericImage extends StatelessWidget {
MaterialPageRoute<void>(
builder: (context) => _ImageDetailView(
tag: tag,
child: _GenericCachedNetworkImage(
imageUrl: imageUrl,
imageShape: imageShape,
size: size,
width: width,
height: height,
borderRadius: borderRadius,
loadingWidget: loadingWidget,
),
imageUrl: imageUrl,
),
),
);
Expand Down Expand Up @@ -302,43 +295,25 @@ class _Image extends StatelessWidget {
class _ImageDetailView extends StatelessWidget {
const _ImageDetailView({
required this.tag,
required this.child,
required this.imageUrl,
});

final String tag;
final Widget child;
final String imageUrl;

@override
Widget build(BuildContext context) {
return Stack(
children: [
GestureDetector(
onTap: () => Navigator.pop(context),
child: Scaffold(
floatingActionButtonLocation: FloatingActionButtonLocation.startTop,
floatingActionButton: IconButton(
icon: const Icon(Icons.close),
onPressed: () => Navigator.pop(context),
),
body: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
decoration: const BoxDecoration(
color: Colors.black,
),
),
),
),
Center(
child: InteractiveViewer(
clipBehavior: Clip.none,
child: Hero(
tag: tag,
child: child,
),
),
),
],
return Scaffold(
floatingActionButtonLocation: FloatingActionButtonLocation.startTop,
floatingActionButton: IconButton(
icon: const Icon(Icons.close),
onPressed: () => Navigator.pop(context),
),
body: PhotoView(
imageProvider: NetworkImage(imageUrl),
minScale: PhotoViewComputedScale.contained,
heroAttributes: PhotoViewHeroAttributes(tag: tag),
),
);
}
}
8 changes: 8 additions & 0 deletions packages/dart_flutter_common/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.7"
photo_view:
dependency: "direct main"
description:
name: photo_view
sha256: "8036802a00bae2a78fc197af8a158e3e2f7b500561ed23b4c458107685e645bb"
url: "https://pub.dev"
source: hosted
version: "0.14.0"
platform:
dependency: transitive
description:
Expand Down
5 changes: 3 additions & 2 deletions packages/dart_flutter_common/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
name: dart_flutter_common
description: MOTTAI app Dart and Flutter common.
publish_to: 'none'
publish_to: "none"
version: 0.0.1

environment:
sdk: '>=3.0.0 <4.0.0'
sdk: ">=3.0.0 <4.0.0"

dependencies:
cached_network_image: ^3.2.3
flutter:
sdk: flutter
image_picker: ^1.0.1
intl: 0.18.1
photo_view: ^0.14.0

dev_dependencies:
flutter_test:
Expand Down
8 changes: 8 additions & 0 deletions packages/mottai_flutter_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.4.0"
photo_view:
dependency: transitive
description:
name: photo_view
sha256: "8036802a00bae2a78fc197af8a158e3e2f7b500561ed23b4c458107685e645bb"
url: "https://pub.dev"
source: hosted
version: "0.14.0"
platform:
dependency: transitive
description:
Expand Down

0 comments on commit 3dff26f

Please sign in to comment.