86 lines
2.9 KiB
Dart
86 lines
2.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import '../../../core/theme/app_colors.dart';
|
|
import '../../../core/theme/app_typography.dart';
|
|
import '../../performance/performance_timer_service.dart';
|
|
|
|
/// Performance run summary chip / card (0-60 and 0-100 timing).
|
|
class PerformanceSummary extends ConsumerWidget {
|
|
final bool compact;
|
|
|
|
const PerformanceSummary({
|
|
super.key,
|
|
this.compact = false,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final perfData = ref.watch(performanceTimerProvider);
|
|
final lastResult = perfData.lastResult;
|
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
|
|
|
if (perfData.state == PerformanceState.timing) {
|
|
final elapsed = perfData.currentElapsedSeconds ?? 0.0;
|
|
final targetStr = perfData.target == PerformanceTarget.sixty ? '0-60' : '0-100';
|
|
|
|
return Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.telemetryGreen.withValues(alpha: 0.15),
|
|
borderRadius: BorderRadius.circular(6),
|
|
border: Border.all(color: AppColors.telemetryGreen, width: 1.0),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const Icon(Icons.timer, color: AppColors.telemetryGreen, size: 14),
|
|
const SizedBox(width: 5),
|
|
Text(
|
|
'$targetStr: ${elapsed.toStringAsFixed(2)}s',
|
|
style: const TextStyle(
|
|
fontFamily: AppTypography.fontTelemetry,
|
|
fontSize: 11,
|
|
fontWeight: FontWeight.w800,
|
|
color: AppColors.telemetryGreen,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
if (lastResult == null) {
|
|
return const SizedBox.shrink();
|
|
}
|
|
|
|
final targetStr = lastResult.target == PerformanceTarget.sixty ? '0-60' : '0-100';
|
|
return Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
|
decoration: BoxDecoration(
|
|
color: isDark ? AppColors.darkSurfaceContainer : AppColors.lightSurfaceContainer,
|
|
borderRadius: BorderRadius.circular(6),
|
|
border: Border.all(
|
|
color: isDark ? AppColors.darkOutline : AppColors.lightOutline,
|
|
width: 0.8,
|
|
),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const Icon(Icons.emoji_events_outlined, size: 13, color: AppColors.warningAmber),
|
|
const SizedBox(width: 4),
|
|
Text(
|
|
'$targetStr: ${lastResult.timeSeconds.toStringAsFixed(2)}s',
|
|
style: TextStyle(
|
|
fontFamily: AppTypography.fontTelemetry,
|
|
fontSize: 10,
|
|
fontWeight: FontWeight.w700,
|
|
color: isDark ? Colors.white70 : AppColors.lightOnSurface,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|