FreekakeApp/lib/components/collection_container.dart
2025-04-09 16:28:42 +07:00

125 lines
4.2 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
class CollectionContainer extends StatelessWidget {
final String? label;
final String? imagesrc;
final String? imageSvg;
final double? width;
final double? height;
final VoidCallback onTapAc;
final Color? textColor;
final double? iconw;
final double? iconh;
final double? lblSize;
final bool? circle;
final Color? colorContiner;
const CollectionContainer({
Key? key,
this.label,
this.imagesrc,
this.imageSvg,
this.width,
this.height,
required this.onTapAc,
this.textColor,
this.iconh,
this.iconw,
this.lblSize,
this.circle,
this.colorContiner,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTapAc,
child: Container(
// padding: EdgeInsets.only(top: 20),
width: width ?? 130,
height: height ?? 170,
decoration: BoxDecoration(
color: const Color.fromARGB(0, 83, 246, 8),
borderRadius: BorderRadius.circular(10),
),
child: Card(
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(10.0),
// ),
elevation: 5,
color: colorContiner ?? Color.fromRGBO(76, 77, 164, 1.0),
child: Stack(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Padding(
padding: const EdgeInsets.only(bottom: 30.0),
child:
imageSvg != null && imageSvg!.isNotEmpty
? Container(
decoration:
(circle ?? false)
? BoxDecoration(
color: const Color.fromARGB(
224,
0,
0,
0,
),
borderRadius: BorderRadius.circular(50),
)
: null,
child: Padding(
padding: const EdgeInsets.all(
8.0,
), // Tambahkan padding di sini
child: SvgPicture.asset(
imageSvg!,
width: iconw ?? 40,
height: iconh ?? 40,
colorFilter: const ColorFilter.mode(
Color.fromARGB(255, 242, 242, 242),
BlendMode.srcIn,
),
),
),
)
: imagesrc != null && imagesrc!.isNotEmpty
? Image.asset(imagesrc!, fit: BoxFit.cover)
: const SizedBox(
// width: 60,
// height: 60,
child: Center(
child: Icon(
Icons.image_not_supported,
color: Colors.white,
),
),
),
),
),
),
Positioned(
bottom: 10,
left: 0,
right: 0,
child: Text(
label ?? '',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: lblSize ?? 14,
fontWeight: FontWeight.bold,
color: textColor ?? Colors.black,
),
),
),
],
),
),
),
);
}
}