hondavert-dev/lib/ui/widgets/record_fab.dart
metatroncubeswdev e4bcfb57a6 Meet Requrements.pdf: selectable dashboard, units, list/graph, light mode, playback
Dashboard
- Selectable main sensor (gauge) + sub sensor, 10 selectable values
  (landscape 5 left + 5 right, portrait 2x5 on one screen) and 4
  selectable flags; long-press to change; persisted.
- Flags: the requirement examples (MIL, FAN Out, VTEC Out, Knock, WBO /
  IAT / CLT Error - errors derived from the stored DTC bits) plus the
  other S300 status bits (cuts, launch, closed loop, VTP, AC, brake).
- Record button moved to the app bar; debug screen moved to Settings.

Sensor list: 1 column on phone portrait, 2 on tablet/landscape; name,
unit, min/max, segmented bar and value.
Graph: auto-scaled Y, window max/min, current value, seconds axis and a
touch cursor; RPM/MAP/TPS/ECT by default.
Units: km/h|mph, degC|degF, kPa|bar|psi (display only), persisted.
Light/dark: palette is a ThemeExtension used by every screen; theme
persisted. SafeArea keeps content off the side navigation bar.
Datalog playback now drives the dashboard, list, graph and DTC screen,
with the playback bar on the main screen and seek updating the displays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 23:24:28 -04:00

50 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';
/// App-bar record/stop button for datalogging (shown while connected).
class RecordButton extends ConsumerWidget {
const RecordButton({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 IconButton(
color: isRecording ? Colors.red : null,
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',
icon: AnimatedSwitcher(
duration: const Duration(milliseconds: 200),
child: isRecording
? const Icon(Icons.stop_circle, key: ValueKey('stop'))
: const Icon(Icons.fiber_manual_record_outlined,
key: ValueKey('rec')),
),
);
}
}