89 lines
2.7 KiB
Dart
89 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../../../core/theme/app_colors.dart';
|
|
import '../../../core/theme/app_typography.dart';
|
|
|
|
/// Standardized high-contrast metric card/tile for rider dashboard.
|
|
class MetricTile extends StatelessWidget {
|
|
final String label;
|
|
final String value;
|
|
final String? unit;
|
|
final IconData? icon;
|
|
final bool compact;
|
|
|
|
const MetricTile({
|
|
super.key,
|
|
required this.label,
|
|
required this.value,
|
|
this.unit,
|
|
this.icon,
|
|
this.compact = false,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
|
final labelColor = isDark ? Colors.white54 : AppColors.lightOnSurfaceVariant;
|
|
final valueColor = isDark ? Colors.white : AppColors.lightOnSurface;
|
|
final unitColor = isDark ? AppColors.cyberCyan : AppColors.lightPrimary;
|
|
|
|
return FittedBox(
|
|
fit: BoxFit.scaleDown,
|
|
alignment: Alignment.centerLeft,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
if (icon != null) ...[
|
|
Icon(icon, size: compact ? 11 : 13, color: labelColor),
|
|
const SizedBox(width: 4),
|
|
],
|
|
Text(
|
|
label.toUpperCase(),
|
|
style: TextStyle(
|
|
fontFamily: AppTypography.fontBody,
|
|
fontSize: compact ? 9 : 11,
|
|
fontWeight: FontWeight.w800,
|
|
letterSpacing: 1.0,
|
|
color: labelColor,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 2),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.baseline,
|
|
textBaseline: TextBaseline.alphabetic,
|
|
children: [
|
|
Text(
|
|
value,
|
|
style: TextStyle(
|
|
fontFamily: AppTypography.fontTelemetry,
|
|
fontSize: compact ? 16 : 20,
|
|
fontWeight: FontWeight.w800,
|
|
color: valueColor,
|
|
),
|
|
),
|
|
if (unit != null) ...[
|
|
const SizedBox(width: 3),
|
|
Text(
|
|
unit!,
|
|
style: TextStyle(
|
|
fontFamily: AppTypography.fontTelemetry,
|
|
fontSize: compact ? 10 : 12,
|
|
fontWeight: FontWeight.w700,
|
|
color: unitColor,
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|