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>
59 lines
2.1 KiB
Dart
59 lines
2.1 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';
|
|
|
|
/// Thin banner under the app bar that tells the driver when the numbers on
|
|
/// screen are NOT live, instead of silently showing stale or default values.
|
|
class DataStatusBanner extends ConsumerWidget {
|
|
const DataStatusBanner({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final status = ref.watch(btProvider.select((s) => s.status));
|
|
final data = ref.watch(btProvider.select((s) => s.dataStatus));
|
|
final error = ref.watch(btProvider.select((s) => s.error));
|
|
final playing = ref.watch(playbackProvider.select((p) => p.isActive));
|
|
|
|
final String? msg;
|
|
Color color = const Color(0xFF8A5A00);
|
|
if (playing) {
|
|
msg = 'Playing back a recorded session — not live data';
|
|
color = const Color(0xFF0D47A1);
|
|
} else if (status == BtStatus.reconnecting) {
|
|
msg = 'Connection interrupted — reconnecting…';
|
|
} else if (status == BtStatus.error) {
|
|
msg = error ?? 'Connection lost';
|
|
color = const Color(0xFF7A0000);
|
|
} else if (status == BtStatus.disconnected) {
|
|
msg = 'Not connected';
|
|
color = const Color(0xFF444444);
|
|
} else if (status != BtStatus.connected) {
|
|
msg = null;
|
|
} else {
|
|
msg = switch (data) {
|
|
EcuDataStatus.live => null,
|
|
EcuDataStatus.none => 'Connected — waiting for data…',
|
|
EcuDataStatus.adapterDefaults =>
|
|
'Adapter connected, but no data from the ECU (ignition on?)',
|
|
EcuDataStatus.noResponse => 'Adapter is not responding',
|
|
};
|
|
}
|
|
|
|
if (msg == null) return const SizedBox.shrink();
|
|
return Material(
|
|
color: color,
|
|
child: SizedBox(
|
|
width: double.infinity,
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
|
child: Text(
|
|
msg,
|
|
style: const TextStyle(color: Colors.white, fontSize: 12),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|