ocarina2/lib/widgets/hero_banner.dart

76 lines
2.2 KiB
Dart
Raw Normal View History

import 'package:auto_size_text/auto_size_text.dart';
2024-05-27 21:46:18 +02:00
import 'package:cached_network_image/cached_network_image.dart';
2024-05-23 19:14:08 +02:00
import 'package:flutter/material.dart';
import 'package:responsive_sizer/responsive_sizer.dart';
import 'package:shimmer/shimmer.dart';
import 'package:text_scroll/text_scroll.dart';
2024-05-23 19:14:08 +02:00
class HeroBanner extends StatelessWidget {
const HeroBanner({
required this.imageUrl,
required this.title,
required this.description,
this.heroTag = "NotAHero",
super.key,
});
final String imageUrl;
final String title;
final String description;
final String heroTag;
@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,
2024-05-27 21:46:18 +02:00
child: CachedNetworkImage(
imageUrl: imageUrl,
placeholder: (c, d) => Shimmer.fromColors(
2024-05-23 19:14:08 +02:00
baseColor: Colors.grey.shade300,
highlightColor: Colors.grey.shade100,
child: Container(
color: Colors.grey,
),
),
2024-05-27 21:46:18 +02:00
errorWidget: (c, _, __) {
2024-05-23 19:14:08 +02:00
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),
),
2024-05-23 19:14:08 +02:00
],
2024-05-27 21:46:18 +02:00
),
2024-05-23 19:14:08 +02:00
],
),
);
}
}