first
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
/// Colored glyph used as the [Hero] flight target for an [Item].
|
||||
library;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../models/item.dart';
|
||||
|
||||
/// Rounded square that carries the category icon. Size is animated by [Hero].
|
||||
class ItemHeroBadge extends StatelessWidget {
|
||||
const ItemHeroBadge({
|
||||
super.key,
|
||||
required this.item,
|
||||
required this.heroTag,
|
||||
this.size = 48,
|
||||
});
|
||||
|
||||
final Item item;
|
||||
final double size;
|
||||
|
||||
/// Unique among on-screen Heroes. Home and Search both list the same items,
|
||||
/// so callers pass a scoped tag (for example `home-item-hero-1`).
|
||||
final String heroTag;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final radius = size * 0.28;
|
||||
return Hero(
|
||||
tag: heroTag,
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: Container(
|
||||
width: size,
|
||||
height: size,
|
||||
decoration: BoxDecoration(
|
||||
color: item.category.accent,
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: item.category.accent.withValues(alpha: 0.35),
|
||||
blurRadius: size * 0.18,
|
||||
offset: Offset(0, size * 0.08),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Icon(
|
||||
item.category.icon,
|
||||
color: Colors.white,
|
||||
size: size * 0.5,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user