This commit is contained in:
1 parent
5f9382ef61
commit
5e31a9e6bc
4 files changed
+47
-90
No files matched your search
Binary file not shown.
Binary file not shown.
@@ -1,7 +1,6 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import '../services/image_manager.dart';
|
|
||||||
|
|
||||||
class ImageCanvas extends StatefulWidget {
|
class ImageCanvas extends StatefulWidget {
|
||||||
final String filePath;
|
final String filePath;
|
||||||
@@ -35,7 +34,7 @@ class _ImageCanvasState extends State<ImageCanvas> {
|
|||||||
void _resetView() {
|
void _resetView() {
|
||||||
_controller.value = Matrix4.identity();
|
_controller.value = Matrix4.identity();
|
||||||
_currentScale = 1.0;
|
_currentScale = 1.0;
|
||||||
_isFilled = true; // yeni resimde fill moduna dön
|
_isFilled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onTransformChanged() {
|
void _onTransformChanged() {
|
||||||
@@ -88,16 +87,6 @@ class _ImageCanvasState extends State<ImageCanvas> {
|
|||||||
_controller.value = newMatrix;
|
_controller.value = newMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
String _zoomPercent() {
|
|
||||||
return '${(_currentScale * 100).round()}%';
|
|
||||||
}
|
|
||||||
|
|
||||||
String _imageInfo() {
|
|
||||||
final mgr = ImageManager.instance;
|
|
||||||
if (mgr.images.isEmpty) return '';
|
|
||||||
return '${mgr.currentIndex + 1} / ${mgr.imageCount}';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_controller.removeListener(_onTransformChanged);
|
_controller.removeListener(_onTransformChanged);
|
||||||
@@ -117,86 +106,54 @@ class _ImageCanvasState extends State<ImageCanvas> {
|
|||||||
},
|
},
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onDoubleTap: _handleDoubleTap,
|
onDoubleTap: _handleDoubleTap,
|
||||||
child: Stack(
|
child: InteractiveViewer(
|
||||||
children: [
|
transformationController: _controller,
|
||||||
InteractiveViewer(
|
boundaryMargin: const EdgeInsets.all(double.infinity),
|
||||||
transformationController: _controller,
|
minScale: 0.1,
|
||||||
boundaryMargin: const EdgeInsets.all(double.infinity),
|
maxScale: 10.0,
|
||||||
minScale: 0.1,
|
panEnabled: true,
|
||||||
maxScale: 10.0,
|
scaleEnabled: false,
|
||||||
panEnabled: true,
|
child: _isFilled
|
||||||
scaleEnabled: false,
|
? SizedBox.expand(
|
||||||
child: _isFilled
|
child: Image.file(
|
||||||
? SizedBox.expand(
|
File(widget.filePath),
|
||||||
child: Image.file(
|
fit: BoxFit.cover,
|
||||||
File(widget.filePath),
|
filterQuality: FilterQuality.high,
|
||||||
fit: BoxFit.cover,
|
errorBuilder: (context, error, stackTrace) {
|
||||||
filterQuality: FilterQuality.high,
|
return const Center(
|
||||||
errorBuilder: (context, error, stackTrace) {
|
child: Column(
|
||||||
return const Center(
|
mainAxisSize: MainAxisSize.min,
|
||||||
child: Column(
|
children: [
|
||||||
mainAxisSize: MainAxisSize.min,
|
Icon(Icons.broken_image, size: 48, color: Colors.white38),
|
||||||
children: [
|
SizedBox(height: 8),
|
||||||
Icon(Icons.broken_image, size: 48, color: Colors.white38),
|
Text('Resim yüklenemedi',
|
||||||
SizedBox(height: 8),
|
style: TextStyle(color: Colors.white38)),
|
||||||
Text('Resim yüklenemedi',
|
],
|
||||||
style: TextStyle(color: Colors.white38)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Center(
|
|
||||||
child: Image.file(
|
|
||||||
File(widget.filePath),
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
filterQuality: FilterQuality.high,
|
|
||||||
errorBuilder: (context, error, stackTrace) {
|
|
||||||
return const Center(
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Icon(Icons.broken_image, size: 48, color: Colors.white38),
|
|
||||||
SizedBox(height: 8),
|
|
||||||
Text('Resim yüklenemedi',
|
|
||||||
style: TextStyle(color: Colors.white38)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// Alt bilgi çubuğu
|
|
||||||
Positioned(
|
|
||||||
bottom: 4,
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
child: Center(
|
|
||||||
child: ListenableBuilder(
|
|
||||||
listenable: _controller,
|
|
||||||
builder: (context, _) {
|
|
||||||
return Container(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 3),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.black54,
|
|
||||||
borderRadius: BorderRadius.circular(6),
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
'${_imageInfo()} | ${_zoomPercent()}',
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.white70,
|
|
||||||
fontSize: 12,
|
|
||||||
fontFamily: 'monospace',
|
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
),
|
||||||
|
)
|
||||||
|
: Center(
|
||||||
|
child: Image.file(
|
||||||
|
File(widget.filePath),
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
filterQuality: FilterQuality.high,
|
||||||
|
errorBuilder: (context, error, stackTrace) {
|
||||||
|
return const Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.broken_image, size: 48, color: Colors.white38),
|
||||||
|
SizedBox(height: 8),
|
||||||
|
Text('Resim yüklenemedi',
|
||||||
|
style: TextStyle(color: Colors.white38)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Binary file not shown.
Reference in new issue
Block a user