Compare commits

...

2 Commits

3 changed files with 89 additions and 41 deletions

View File

@ -113,8 +113,10 @@ class _SSHImageProvider extends ImageProvider<_SSHImageProvider> {
} else { } else {
final file = await sftpClient.open(uri.toFilePath()); final file = await sftpClient.open(uri.toFilePath());
bytes = await file.readBytes(); bytes = await file.readBytes();
await tmpPic.create(recursive: true); () async {
await tmpPic.writeAsBytes(bytes); await tmpPic.create(recursive: true);
await tmpPic.writeAsBytes(bytes);
}();
} }
if (bytes.lengthInBytes == 0) { if (bytes.lengthInBytes == 0) {

25
lib/hover_detector.dart Normal file
View File

@ -0,0 +1,25 @@
import 'package:flutter/material.dart';
class HoverDetector extends StatefulWidget {
const HoverDetector(
{Key? key, required this.defaultChild, required this.hoverChild})
: super(key: key);
final Widget defaultChild;
final Widget hoverChild;
@override
State<HoverDetector> createState() => _HoverDetectorState();
}
class _HoverDetectorState extends State<HoverDetector> {
bool amIHovering = false;
@override
Widget build(BuildContext context) {
return MouseRegion(
child: amIHovering ? widget.hoverChild : widget.defaultChild,
onEnter: (PointerEvent details) => setState(() => amIHovering = true),
onExit: (PointerEvent details) => setState(() => amIHovering = false),
);
}
}

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gallery/data_provider/data_provider.dart'; import 'package:gallery/data_provider/data_provider.dart';
import 'package:gallery/hover_detector.dart';
import 'package:gallery/utils/tile_size.dart'; import 'package:gallery/utils/tile_size.dart';
class ImageTile extends StatelessWidget { class ImageTile extends StatelessWidget {
@ -20,45 +21,65 @@ class ImageTile extends StatelessWidget {
child: Container( child: Container(
padding: const EdgeInsets.all(3), padding: const EdgeInsets.all(3),
child: imageUri == null child: imageUri == null
? Container( ? HoverDetector(
decoration: BoxDecoration( defaultChild: _renderIcon(false),
color: Colors.white, hoverChild: _renderIcon(true))
borderRadius: BorderRadius.all( : HoverDetector(
Radius.circular(calcTileMaxWidth() / 30)), defaultChild: _renderImage(false),
boxShadow: [ hoverChild: _renderImage(true)),
BoxShadow( ));
color: Colors.black12, }
spreadRadius: calcTileMaxWidth() / 150,
blurRadius: calcTileMaxWidth() / 60), Widget _renderIcon(bool border) {
]), return Container(
child: child) decoration: BoxDecoration(
: Container( color: Colors.white,
decoration: BoxDecoration( border: border
borderRadius: BorderRadius.all( ? Border.all(color: const Color(0x7f444444), width: 3)
Radius.circular(calcTileMaxWidth() / 30)), : null,
boxShadow: [ borderRadius:
BoxShadow( BorderRadius.all(Radius.circular(calcTileMaxWidth() / 30)),
color: Colors.black12, boxShadow: [
spreadRadius: calcTileMaxWidth() / 150, BoxShadow(
blurRadius: calcTileMaxWidth() / 60), color: Colors.black12,
]), spreadRadius: calcTileMaxWidth() / 150,
child: ClipRRect( blurRadius: calcTileMaxWidth() / 60),
borderRadius: BorderRadius.all( ]),
Radius.circular(calcTileMaxWidth() / 30), child: child);
), }
child: Image(
fit: BoxFit.cover, Widget _renderImage(bool border) {
frameBuilder: final image = Image(
(context, child, frame, wasSynchronouslyLoaded) { fit: BoxFit.cover,
return frame == null filterQuality: FilterQuality.high,
? const Center( frameBuilder: (context, child, frame, wasSynchronouslyLoaded) {
child: CircularProgressIndicator(), return frame == null
) ? const Center(
: child; child: CircularProgressIndicator(),
}, )
image: dtaProvider!.getImageProvider(imageUri!), : child;
)), },
), image: dtaProvider!.getImageProvider(imageUri!),
);
return Container(
decoration: BoxDecoration(
border: border
? Border.all(color: const Color(0x7f444444), width: 3)
: null,
borderRadius: BorderRadius.all(
Radius.circular(calcTileMaxWidth() / (border ? 25 : 30))),
boxShadow: [
BoxShadow(
color: Colors.black12,
spreadRadius: calcTileMaxWidth() / 150,
blurRadius: calcTileMaxWidth() / 60),
]),
child: ClipRRect(
borderRadius: BorderRadius.all(
Radius.circular(calcTileMaxWidth() / 30),
),
child: image,
)); ));
} }
} }