Gallery/lib/image_tile.dart
lukas-heiligenbrunner 9373df296c load indicator on image grid
center load indicator on directory load
support for trackpads
2022-10-07 12:38:53 +02:00

65 lines
2.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:gallery/data_provider/data_provider.dart';
import 'package:gallery/utils/tile_size.dart';
class ImageTile extends StatelessWidget {
const ImageTile(
{Key? key, this.onClick, this.child, this.imageUri, this.dtaProvider})
: super(key: key);
final Function? onClick;
final Widget? child;
final Uri? imageUri;
final DataProvider? dtaProvider;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
onClick?.call();
},
child: Container(
padding: const EdgeInsets.all(3),
child: imageUri == null
? Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(
Radius.circular(calcTileMaxWidth() / 30)),
boxShadow: [
BoxShadow(
color: Colors.black12,
spreadRadius: calcTileMaxWidth() / 150,
blurRadius: calcTileMaxWidth() / 60),
]),
child: child)
: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(calcTileMaxWidth() / 30)),
boxShadow: [
BoxShadow(
color: Colors.black12,
spreadRadius: calcTileMaxWidth() / 150,
blurRadius: calcTileMaxWidth() / 60),
]),
child: ClipRRect(
borderRadius: BorderRadius.all(
Radius.circular(calcTileMaxWidth() / 30),
),
child: Image(
fit: BoxFit.cover,
frameBuilder:
(context, child, frame, wasSynchronouslyLoaded) {
return frame == null
? const Center(
child: CircularProgressIndicator(),
)
: child;
},
image: dtaProvider!.getImageProvider(imageUri!),
)),
),
));
}
}