2022-05-15 16:45:35 +02:00
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
2022-05-13 06:02:53 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2022-05-16 02:51:47 +02:00
|
|
|
import 'package:nekoya_flutter/utils/utils.dart';
|
2022-05-13 06:02:53 +02:00
|
|
|
|
|
|
|
class ProductCard extends StatelessWidget {
|
|
|
|
const ProductCard({
|
|
|
|
Key? key,
|
2022-05-15 16:45:35 +02:00
|
|
|
required this.imageUrl,
|
2022-05-13 06:02:53 +02:00
|
|
|
required this.title,
|
|
|
|
required this.press,
|
|
|
|
required this.bgColor,
|
|
|
|
}) : super(key: key);
|
2022-05-15 16:45:35 +02:00
|
|
|
final String imageUrl, title;
|
2022-05-13 06:02:53 +02:00
|
|
|
final VoidCallback press;
|
|
|
|
final Color bgColor;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: press,
|
|
|
|
child: Container(
|
|
|
|
width: 154,
|
|
|
|
padding: const EdgeInsets.all(defaultPadding / 2),
|
|
|
|
decoration: const BoxDecoration(
|
2022-05-16 02:42:29 +02:00
|
|
|
color: Color(0xff212226),
|
2022-05-13 06:02:53 +02:00
|
|
|
borderRadius: BorderRadius.all(Radius.circular(defaultBorderRadius)),
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
width: double.infinity,
|
2022-05-16 02:42:29 +02:00
|
|
|
decoration: const BoxDecoration(
|
|
|
|
color: Color(0xff212226),
|
|
|
|
borderRadius: BorderRadius.all(
|
2022-05-13 06:02:53 +02:00
|
|
|
Radius.circular(defaultBorderRadius)),
|
|
|
|
),
|
2022-05-15 16:45:35 +02:00
|
|
|
child: CachedNetworkImage(
|
|
|
|
imageUrl: imageUrl,
|
|
|
|
placeholder: (context, url) =>
|
2022-05-15 17:05:14 +02:00
|
|
|
const Center(
|
|
|
|
child: CircularProgressIndicator(
|
2022-05-15 16:45:35 +02:00
|
|
|
color: Color(0xff8B0000),
|
|
|
|
),
|
2022-05-15 17:05:14 +02:00
|
|
|
),
|
2022-05-15 16:45:35 +02:00
|
|
|
errorWidget: (context, url, error) =>
|
2022-05-16 03:01:04 +02:00
|
|
|
Image.asset('assets/images/image_error.webp'),
|
2022-05-15 16:45:35 +02:00
|
|
|
fadeOutDuration: const Duration(milliseconds: 5),
|
|
|
|
imageBuilder: (context, imageProvider) => Container(
|
|
|
|
height: 132,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
image: DecorationImage(
|
|
|
|
image: imageProvider, fit: BoxFit.cover)),
|
|
|
|
),
|
2022-05-13 06:02:53 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: defaultPadding / 2),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Text(
|
|
|
|
title,
|
2022-05-15 10:19:33 +02:00
|
|
|
style: const TextStyle(color: Colors.white),
|
2022-05-13 06:02:53 +02:00
|
|
|
),
|
2022-05-16 07:23:21 +02:00
|
|
|
)
|
2022-05-13 06:02:53 +02:00
|
|
|
],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|