Files
GymLink_Flutter/lib/components/item_card.dart
2024-06-14 01:37:54 +03:00

62 lines
1.5 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/material.dart';
class ProductCard extends StatelessWidget {
final Widget imagePath;
final String name;
final String price;
final VoidCallback onTap;
const ProductCard({
super.key,
required this.imagePath,
required this.name,
required this.price,
required this.onTap,
});
double getCardHeight({required BuildContext context}) {
if (MediaQuery.of(context).size.width > 400) {
return 300;
}
return 160;
}
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: 160,
maxHeight: getCardHeight(context: context),
),
child: Card(
elevation: 3,
color: Theme.of(context).scaffoldBackgroundColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
imagePath,
const SizedBox(height: 16),
Text(
name,
style: Theme.of(context).textTheme.titleMedium,
maxLines: 2,
),
const SizedBox(height: 8),
Text(
'$price руб.',
style: Theme.of(context).textTheme.titleSmall,
),
],
),
),
),
);
}
}