ocarina2/lib/widgets/hero_banner.dart
2024-05-28 18:54:05 +02:00

79 lines
2.2 KiB
Dart

import 'package:auto_size_text/auto_size_text.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:responsive_sizer/responsive_sizer.dart';
import 'package:shimmer/shimmer.dart';
import 'package:text_scroll/text_scroll.dart';
class HeroBanner extends StatelessWidget {
const HeroBanner({
required this.imageUrl,
required this.title,
required this.description,
this.heroTag = "NotAHero",
this.cacheKey,
super.key,
});
final String imageUrl;
final String title;
final String description;
final String heroTag;
final String? cacheKey;
@override
Widget build(BuildContext context) {
return SizedBox(
height: 30.h,
width: 95.w,
child: Row(
children: [
SizedBox(
height: 180,
width: 180,
child: Hero(
tag: heroTag,
child: CachedNetworkImage(
imageUrl: imageUrl,
cacheKey: cacheKey,
placeholder: (c, d) => Shimmer.fromColors(
baseColor: Colors.grey.shade300,
highlightColor: Colors.grey.shade100,
child: Container(
color: Colors.grey,
),
),
errorWidget: (c, _, __) {
return ColoredBox(
color: Theme.of(context).colorScheme.primaryContainer,
child: Center(
child: Icon(
Icons.music_note,
color: Theme.of(context).colorScheme.onPrimaryContainer,
),
),
);
},
),
),
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
title,
style: const TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(
height: 5,
),
AutoSizeText(
description,
overflowReplacement: TextScroll(description),
),
],
),
],
),
);
}
}