2022-08-29 20:38:28 -06:00
|
|
|
part of '../collection_screen.dart';
|
|
|
|
|
2022-11-08 11:15:39 -07:00
|
|
|
class _CollectibleImage extends StatelessWidget {
|
|
|
|
const _CollectibleImage({
|
2024-02-20 13:56:39 -08:00
|
|
|
super.key,
|
2022-08-29 20:38:28 -06:00
|
|
|
required this.collectible,
|
|
|
|
required this.state,
|
|
|
|
required this.onPressed,
|
|
|
|
this.heroTag,
|
2024-02-20 13:56:39 -08:00
|
|
|
});
|
2022-08-29 20:38:28 -06:00
|
|
|
|
|
|
|
final CollectibleData collectible;
|
|
|
|
final ValueSetter<CollectibleData> onPressed;
|
|
|
|
final int state;
|
|
|
|
final String? heroTag;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return RepaintBoundary(
|
|
|
|
child: state == CollectibleState.lost
|
|
|
|
? _buildHidden(context, collectible)
|
|
|
|
: _buildFound(context, collectible, state),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildHidden(BuildContext context, CollectibleData collectible) {
|
|
|
|
return Container(
|
|
|
|
color: $styles.colors.black,
|
|
|
|
child: Center(
|
|
|
|
child: FractionallySizedBox(
|
2022-09-16 14:56:11 -06:00
|
|
|
widthFactor: 0.66,
|
|
|
|
heightFactor: 0.66,
|
|
|
|
child: Image(
|
|
|
|
image: collectible.icon,
|
2022-10-03 19:34:40 -06:00
|
|
|
color: $styles.colors.black,
|
|
|
|
colorBlendMode: BlendMode.color,
|
|
|
|
opacity: AlwaysStoppedAnimation(0.2),
|
2022-09-16 14:56:11 -06:00
|
|
|
),
|
2022-08-29 20:38:28 -06:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildFound(BuildContext context, CollectibleData collectible, int state) {
|
|
|
|
final bool isNew = state == CollectibleState.discovered;
|
|
|
|
Widget content = Container(
|
|
|
|
width: double.infinity,
|
|
|
|
height: double.infinity,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: $styles.colors.black,
|
|
|
|
border: isNew ? Border.all(color: $styles.colors.accent1, width: 3) : null,
|
|
|
|
boxShadow:
|
|
|
|
!isNew ? null : [BoxShadow(color: $styles.colors.accent1.withOpacity(0.6), blurRadius: $styles.insets.sm)],
|
|
|
|
),
|
|
|
|
child: AppImage(
|
|
|
|
image: NetworkImage(collectible.imageUrlSmall),
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
scale: 0.5,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
return AppBtn.basic(
|
|
|
|
semanticLabel: collectible.title,
|
|
|
|
onPressed: () => onPressed(collectible),
|
|
|
|
child: content,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|