smartfarming-mobile/agrilink_vocpro/lib/features/home/widgets/data_display_widget.dart

91 lines
2.6 KiB
Dart
Raw Normal View History

2024-09-17 04:17:03 +00:00
import 'package:agrilink_vocpro/core/constant/app_theme.dart';
import 'package:flutter/material.dart';
2024-10-01 03:49:55 +00:00
import 'package:flutter_screenutil/flutter_screenutil.dart';
2024-09-17 04:17:03 +00:00
class DataDisplayerWidget extends StatelessWidget {
const DataDisplayerWidget({
super.key,
required this.title,
required this.subtitle,
required this.value,
required this.icon,
required this.color,
this.iconColor = Colors.teal,
this.textColor = Colors.black,
required this.unit,
2024-10-01 03:49:55 +00:00
this.censorIdentifier,
2024-09-17 04:17:03 +00:00
this.onTap,
});
final String title;
final String subtitle;
final String value;
final IconData icon;
final Color color;
final Color iconColor;
final Color textColor;
final String unit;
2024-10-01 03:49:55 +00:00
final String? censorIdentifier;
2024-09-17 04:17:03 +00:00
final VoidCallback? onTap;
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () {
onTap != null ? onTap!() : null;
},
style: ElevatedButton.styleFrom(
backgroundColor: color,
2024-10-01 03:49:55 +00:00
padding: EdgeInsets.all(12.r), // Padding di dalam button
2024-09-17 04:17:03 +00:00
shape: RoundedRectangleBorder(
2024-10-01 03:49:55 +00:00
borderRadius: BorderRadius.circular(16.r), // Bentuk sudut yang bundar
2024-09-17 04:17:03 +00:00
),
elevation: 20, // Efek bayangan
2024-12-12 02:39:48 +00:00
shadowColor: Colors.grey.withValues(alpha: 0.2),
2024-09-17 04:17:03 +00:00
),
2024-10-01 03:49:55 +00:00
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
// Tidak perlu menggunakan mainAxisSize: MainAxisSize.min di sini
children: [
Align(
alignment: Alignment.centerRight,
child: Text(
censorIdentifier ?? '',
style: AppTheme.labelSmall
2024-12-12 02:39:48 +00:00
.copyWith(color: textColor.withValues(alpha: 0.5)),
2024-09-17 04:17:03 +00:00
),
2024-10-01 03:49:55 +00:00
),
Icon(icon, color: iconColor, size: 32.r),
SizedBox(height: 8.h),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: AppTheme.labelMedium.copyWith(color: textColor),
),
Text(
subtitle,
style: AppTheme.labelSmall
2024-12-12 02:39:48 +00:00
.copyWith(color: textColor.withValues(alpha: 0.5)),
2024-10-01 03:49:55 +00:00
),
],
),
const Spacer(),
Row(
children: [
Text(
value,
style: AppTheme.headline1.copyWith(color: textColor),
),
SizedBox(width: 4.w),
Text(unit,
style: AppTheme.titleMedium.copyWith(color: textColor)),
],
),
],
2024-09-17 04:17:03 +00:00
),
);
}
}