hondavert-dev/lib/ui/widgets/record_fab.dart
HVBT Dev 763821171c feat: Add ECU Frame Debug Screen and DTC Screen
- Implemented RawFrameDebugScreen for displaying ECU frame data and diagnostics.
- Created DtcScreen to show active Diagnostic Trouble Codes (DTCs) with detailed descriptions.
- Added DtcRow widget for individual DTC representation.
- Introduced GraphScreen for visualizing sensor data over time with customizable time windows.
- Developed SensorListScreen to display available sensors and their current values.
- Enhanced SettingsScreen with options for Bluetooth connection, ECU protocol selection, polling interval, and theme settings.
- Added AppColors and AppTheme for consistent theming across the application.
- Implemented BtStatusChip to show Bluetooth connection status in the app bar.
- Created RecordFab for starting and stopping data recording sessions.
2026-07-26 23:14:58 +05:30

49 lines
1.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../core/providers/bt_provider.dart';
import '../../core/providers/datalog_provider.dart';
class RecordFab extends ConsumerWidget {
const RecordFab({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final recording = ref.watch(recordingProvider);
final bt = ref.watch(btProvider);
// Only show when BT is connected
if (!bt.isConnected) return const SizedBox.shrink();
final isRecording = recording.isRecording;
return FloatingActionButton(
heroTag: 'record_fab',
backgroundColor: isRecording ? Colors.red : Theme.of(context).colorScheme.primary,
onPressed: () async {
if (isRecording) {
await ref.read(recordingProvider.notifier).stopRecording();
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'Session saved — ${recording.frameCount} frames',
),
duration: const Duration(seconds: 2),
),
);
}
} else {
await ref.read(recordingProvider.notifier).startRecording();
}
},
tooltip: isRecording ? 'Stop recording' : 'Start recording',
child: AnimatedSwitcher(
duration: const Duration(milliseconds: 200),
child: isRecording
? const Icon(Icons.stop, key: ValueKey('stop'))
: const Icon(Icons.fiber_manual_record, key: ValueKey('rec')),
),
);
}
}