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>
148 lines
4.3 KiB
Dart
148 lines
4.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../../../../core/models/sensor_defs.dart';
|
|
import '../../../../core/models/units.dart';
|
|
import '../../../theme/app_colors.dart';
|
|
|
|
/// One choosable entry in [showPickerSheet].
|
|
class PickerItem {
|
|
final String id;
|
|
final String title;
|
|
final String? subtitle;
|
|
const PickerItem(this.id, this.title, [this.subtitle]);
|
|
}
|
|
|
|
/// Bottom sheet listing [items]; resolves to the chosen id, or null.
|
|
Future<String?> showPickerSheet(
|
|
BuildContext context, {
|
|
required String title,
|
|
required List<PickerItem> items,
|
|
required String currentId,
|
|
}) {
|
|
return showModalBottomSheet<String>(
|
|
context: context,
|
|
isScrollControlled: true,
|
|
backgroundColor: Colors.transparent,
|
|
builder: (_) => _PickerSheet(
|
|
title: title,
|
|
items: items,
|
|
currentId: currentId,
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Picker over every analog sensor, showing the unit currently in use.
|
|
Future<String?> pickSensor(
|
|
BuildContext context, {
|
|
required String title,
|
|
required String currentId,
|
|
required UnitPrefs units,
|
|
}) {
|
|
return showPickerSheet(
|
|
context,
|
|
title: title,
|
|
currentId: currentId,
|
|
items: [
|
|
for (final d in sensorDefs)
|
|
PickerItem(d.id, d.displayName, sensorView(d.id, units).unit),
|
|
],
|
|
);
|
|
}
|
|
|
|
/// Picker over every flag.
|
|
Future<String?> pickFlag(BuildContext context, {required String currentId}) {
|
|
return showPickerSheet(
|
|
context,
|
|
title: 'SELECT FLAG',
|
|
currentId: currentId,
|
|
items: [for (final f in flagDefs) PickerItem(f.id, f.displayName)],
|
|
);
|
|
}
|
|
|
|
class _PickerSheet extends StatelessWidget {
|
|
final String title;
|
|
final List<PickerItem> items;
|
|
final String currentId;
|
|
|
|
const _PickerSheet({
|
|
required this.title,
|
|
required this.items,
|
|
required this.currentId,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final c = AppColors.of(context);
|
|
return DraggableScrollableSheet(
|
|
expand: false,
|
|
initialChildSize: 0.6,
|
|
minChildSize: 0.4,
|
|
maxChildSize: 0.9,
|
|
builder: (context, scrollController) {
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: c.surface,
|
|
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
const SizedBox(height: 8),
|
|
Container(
|
|
width: 40,
|
|
height: 4,
|
|
decoration: BoxDecoration(
|
|
color: c.onSurfaceMuted.withAlpha(90),
|
|
borderRadius: BorderRadius.circular(2),
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Text(
|
|
title,
|
|
style: TextStyle(
|
|
color: c.onSurfaceMuted,
|
|
fontSize: 12,
|
|
letterSpacing: 2,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
Divider(height: 1, color: c.divider),
|
|
Expanded(
|
|
child: ListView.builder(
|
|
controller: scrollController,
|
|
itemCount: items.length,
|
|
itemBuilder: (context, i) {
|
|
final item = items[i];
|
|
final isSelected = item.id == currentId;
|
|
return ListTile(
|
|
title: Text(
|
|
item.title,
|
|
style: TextStyle(
|
|
color: c.onSurface,
|
|
fontWeight:
|
|
isSelected ? FontWeight.bold : FontWeight.normal,
|
|
),
|
|
),
|
|
subtitle: item.subtitle == null
|
|
? null
|
|
: Text(
|
|
item.subtitle!,
|
|
style: TextStyle(
|
|
color: c.onSurfaceMuted, fontSize: 12),
|
|
),
|
|
trailing: isSelected
|
|
? Icon(Icons.check, color: c.accent, size: 18)
|
|
: null,
|
|
onTap: () => Navigator.pop(context, item.id),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|