| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import 'package:flutter/material.dart';
- import 'package:flutter_riverpod/flutter_riverpod.dart';
- import '../services/bluetooth_service.dart';
- class StatisticsScreen extends ConsumerWidget {
- const StatisticsScreen({super.key});
- @override
- Widget build(BuildContext context, WidgetRef ref) {
- final machineState = ref.watch(bluetoothServiceProvider);
- return Scaffold(
- appBar: AppBar(title: const Text('Statistics')),
- body: ListView(
- padding: const EdgeInsets.all(16),
- children: [
- _StatTile(
- label: 'Total Shots',
- value: '${machineState.shotCounter}',
- icon: Icons.coffee,
- ),
- _StatTile(
- label: 'Grinder Cycles',
- value: '${machineState.grinderCounter}',
- icon: Icons.settings_input_component,
- ),
- const Divider(),
- const Padding(
- padding: EdgeInsets.all(16.0),
- child: Text(
- 'Shot counter is tracked on this device. Grinder counter is reported directly by the meCoffee hardware.',
- style: TextStyle(color: Colors.grey, fontSize: 12),
- textAlign: TextAlign.center,
- ),
- ),
- ],
- ),
- );
- }
- }
- class _StatTile extends StatelessWidget {
- final String label;
- final String value;
- final IconData icon;
- const _StatTile({
- required this.label,
- required this.value,
- required this.icon,
- });
- @override
- Widget build(BuildContext context) {
- return ListTile(
- leading: Icon(icon, color: Colors.orangeAccent),
- title: Text(label),
- trailing: Text(
- value,
- style: const TextStyle(
- fontSize: 20,
- fontWeight: FontWeight.bold,
- ),
- ),
- );
- }
- }
|