ocarina2/lib/widgets/image_cover.dart

73 lines
2 KiB
Dart
Raw Normal View History

2024-05-23 19:14:08 +02:00
import 'package:auto_size_text/auto_size_text.dart';
import 'package:fast_cached_network_image/fast_cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:shimmer/shimmer.dart';
import 'package:text_scroll/text_scroll.dart';
class ImageCover extends StatelessWidget {
const ImageCover({
required this.imageUrl,
required this.title,
this.heroTag = "VeryUnconspicous",
super.key,
});
final String imageUrl;
final String title;
final double _width = 180;
final String heroTag;
@override
Widget build(BuildContext context) {
return Column(
children: [
SizedBox(
width: _width,
height: _width,
child: Hero(
tag: heroTag,
child: FastCachedImage(
url: imageUrl,
loadingBuilder: (c, d) => Shimmer.fromColors(
baseColor: Colors.grey.shade300,
highlightColor: Colors.grey.shade100,
child: Container(
color: Colors.grey,
),
),
errorBuilder: (c, _, __) {
return ColoredBox(
color: Theme.of(context).colorScheme.primaryContainer,
child: Center(
child: Icon(
Icons.music_note,
color: Theme.of(context).colorScheme.onPrimaryContainer,
),
),
);
},
),
),
),
const SizedBox(
height: 5,
),
SizedBox(
width: _width * 0.7,
child: AutoSizeText(
title,
textAlign: TextAlign.center,
style: const TextStyle(fontWeight: FontWeight.bold),
overflowReplacement: TextScroll(
title,
style: const TextStyle(fontWeight: FontWeight.bold),
),
),
),
const SizedBox(
height: 10,
),
],
);
}
}