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

107 lines
2.6 KiB
Dart

import 'package:flutter/material.dart';
import '../../../../core/models/sensor_defs.dart';
import '../../../../core/protocol/sensor_state.dart';
import '../../../theme/app_colors.dart';
/// Colour of an active flag. Faults red, warnings amber, status green/blue.
Color flagColor(String id) {
switch (id) {
case 'mil':
case 'knock':
case 'o2error':
case 'iaterror':
case 'ecterror':
return Colors.red;
case 'revlimit':
case 'igncut':
case 'boostcut':
case 'launch':
case 'launchretard':
case 'shiftcut':
return Colors.orange;
case 'vtec':
case 'vtp':
return Colors.blue;
default:
return Colors.green;
}
}
class FlagPill extends StatelessWidget {
final String label;
final bool active;
final Color color;
const FlagPill({
super.key,
required this.label,
required this.active,
required this.color,
});
@override
Widget build(BuildContext context) {
final c = AppColors.of(context);
return AnimatedContainer(
duration: const Duration(milliseconds: 100),
height: 30,
alignment: Alignment.center,
padding: const EdgeInsets.symmetric(horizontal: 6),
decoration: BoxDecoration(
color: active ? color.withAlpha(200) : c.surface,
borderRadius: BorderRadius.circular(6),
border: Border.all(
color: active ? color : c.accent.withAlpha(90),
width: 1.2,
),
),
child: FittedBox(
fit: BoxFit.scaleDown,
child: Text(
label,
style: TextStyle(
color: active ? Colors.white : c.onSurfaceMuted,
fontSize: 12,
fontWeight: active ? FontWeight.bold : FontWeight.normal,
),
),
),
);
}
}
/// The 4 selectable flags of the dashboard. Long-press a pill to change it.
class FlagRow extends StatelessWidget {
final SensorState state;
final List<String> flagIds;
final void Function(int index) onLongPress;
const FlagRow({
super.key,
required this.state,
required this.flagIds,
required this.onLongPress,
});
@override
Widget build(BuildContext context) {
return Row(
children: [
for (var i = 0; i < flagIds.length; i++) ...[
if (i > 0) const SizedBox(width: 6),
Expanded(
child: GestureDetector(
onLongPress: () => onLongPress(i),
child: FlagPill(
label: flagDef(flagIds[i]).displayName,
active: flagDef(flagIds[i]).read(state),
color: flagColor(flagIds[i]),
),
),
),
],
],
);
}
}