import 'package:flutter/material.dart'; import '../services/ble_service.dart'; class StatisticsCard extends StatelessWidget { final BLEService ble; const StatisticsCard({super.key, required this.ble}); @override Widget build(BuildContext context) { final duration = ble.streamingDuration; final durationStr = duration != null ? '${duration.inMinutes}:${(duration.inSeconds % 60).toString().padLeft(2, '0')}' : '0:00'; return Card( margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), child: Padding( padding: const EdgeInsets.all(16), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ _StatItem( icon: Icons.data_usage, label: 'Packets', value: '${ble.packetCount}', ), _StatItem( icon: Icons.speed, label: 'Rate', value: '${ble.packetsPerSecond.toStringAsFixed(2)}/s', ), _StatItem( icon: Icons.timer, label: 'Duration', value: durationStr, ), ], ), ), ); } } class _StatItem extends StatelessWidget { final IconData icon; final String label; final String value; const _StatItem({ required this.icon, required this.label, required this.value, }); @override Widget build(BuildContext context) { return Column( mainAxisSize: MainAxisSize.min, children: [ Icon(icon, size: 24, color: Theme.of(context).primaryColor), const SizedBox(height: 4), Text( value, style: Theme.of(context).textTheme.titleMedium?.copyWith( fontWeight: FontWeight.bold, ), ), Text( label, style: Theme.of(context).textTheme.bodySmall, ), ], ); } }