Compare commits

..

No commits in common. "hoverEffects" and "master" have entirely different histories.

3 changed files with 41 additions and 89 deletions

View File

@ -113,10 +113,8 @@ 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();
() async { await tmpPic.create(recursive: true);
await tmpPic.create(recursive: true); await tmpPic.writeAsBytes(bytes);
await tmpPic.writeAsBytes(bytes);
}();
} }
if (bytes.lengthInBytes == 0) { if (bytes.lengthInBytes == 0) {

View File

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