2026-10-09 20:23:00 +09:00
|
|
|
|
// Yukart display — starter. A text readout of whatever svc-gw sends, proving the
|
|
|
|
|
|
// boundary contract before anything is drawn (initial plan, step 1).
|
|
|
|
|
|
|
2026-10-11 04:01:05 +09:00
|
|
|
|
import 'dart:math';
|
|
|
|
|
|
|
2026-09-05 13:50:51 +09:00
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
2026-10-09 20:23:00 +09:00
|
|
|
|
import 'boundary.dart';
|
2026-10-11 17:41:14 +09:00
|
|
|
|
import 'camview.dart';
|
2026-10-13 11:12:44 +09:00
|
|
|
|
import 'checklist.dart';
|
2026-10-11 15:55:52 +09:00
|
|
|
|
import 'linktest.dart';
|
2026-10-09 20:23:00 +09:00
|
|
|
|
import 'net.dart';
|
|
|
|
|
|
|
|
|
|
|
|
/// Override for development, e.g. `--dart-define=YUKART_GW=ws://halogen.local:7700/`.
|
2026-10-11 17:43:27 +09:00
|
|
|
|
const defaultUrl = String.fromEnvironment(
|
|
|
|
|
|
'YUKART_GW',
|
|
|
|
|
|
defaultValue: 'ws://192.168.55.1:7700/',
|
|
|
|
|
|
);
|
2026-10-09 20:23:00 +09:00
|
|
|
|
|
|
|
|
|
|
Future<void> main() async {
|
|
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
|
final usb = UsbLink();
|
|
|
|
|
|
await usb.bindFor(Uri.parse(defaultUrl));
|
|
|
|
|
|
final boundary = Boundary(defaultUrl)..start();
|
2026-10-11 15:55:52 +09:00
|
|
|
|
final linkTest = LinkTest(usb);
|
2026-10-11 16:33:55 +09:00
|
|
|
|
// Development hook: `am start ... --es linktest [dl:|bi:]<label>[@<host>]` runs the test
|
|
|
|
|
|
// (`dl:` the download series, `bi:` burst latency against idle gaps), on the gateway's host unless one is given.
|
2026-10-11 15:58:43 +09:00
|
|
|
|
Future<void> runLinkTest(String request) async {
|
2026-10-11 17:43:27 +09:00
|
|
|
|
final mode = request.startsWith('dl:') || request.startsWith('bi:')
|
|
|
|
|
|
? request.substring(0, 2)
|
|
|
|
|
|
: '';
|
2026-10-11 16:33:55 +09:00
|
|
|
|
if (mode.isNotEmpty) request = request.substring(3);
|
2026-10-11 15:58:43 +09:00
|
|
|
|
final at = request.indexOf('@');
|
|
|
|
|
|
final label = at < 0 ? request : request.substring(0, at);
|
2026-10-11 17:43:27 +09:00
|
|
|
|
final host = at < 0
|
|
|
|
|
|
? Uri.parse(boundary.url).host
|
|
|
|
|
|
: request.substring(at + 1);
|
|
|
|
|
|
navigatorKey.currentState?.push(
|
|
|
|
|
|
MaterialPageRoute<void>(
|
|
|
|
|
|
builder: (_) => linkTestPage(boundary, linkTest, usb),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
2026-10-11 16:33:55 +09:00
|
|
|
|
await switch (mode) {
|
|
|
|
|
|
'dl' => linkTest.runDownload(host, label),
|
|
|
|
|
|
'bi' => linkTest.runBurstIdle(host, label),
|
|
|
|
|
|
_ => linkTest.run(host, label),
|
|
|
|
|
|
};
|
2026-10-11 15:55:52 +09:00
|
|
|
|
await usb.bindFor(Uri.parse(boundary.url));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
usb.onLinkTest = runLinkTest;
|
|
|
|
|
|
runApp(YukartApp(boundary: boundary, usb: usb, linkTest: linkTest));
|
|
|
|
|
|
final pending = await usb.takeLinkTest();
|
|
|
|
|
|
if (pending != null) {
|
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) => runLinkTest(pending));
|
|
|
|
|
|
}
|
2026-09-05 13:50:51 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-11 15:55:52 +09:00
|
|
|
|
final navigatorKey = GlobalKey<NavigatorState>();
|
|
|
|
|
|
|
|
|
|
|
|
Widget linkTestPage(Boundary b, LinkTest t, UsbLink usb) => LinkTestPage(
|
2026-10-11 17:43:27 +09:00
|
|
|
|
test: t,
|
|
|
|
|
|
host: Uri.parse(b.url).host,
|
|
|
|
|
|
restoreBinding: () => usb.bindFor(Uri.parse(b.url)),
|
|
|
|
|
|
);
|
2026-10-11 15:55:52 +09:00
|
|
|
|
|
2026-10-09 20:23:00 +09:00
|
|
|
|
class YukartApp extends StatelessWidget {
|
2026-10-11 17:43:27 +09:00
|
|
|
|
const YukartApp({
|
|
|
|
|
|
super.key,
|
|
|
|
|
|
required this.boundary,
|
|
|
|
|
|
required this.usb,
|
|
|
|
|
|
required this.linkTest,
|
|
|
|
|
|
});
|
2026-10-09 20:23:00 +09:00
|
|
|
|
final Boundary boundary;
|
|
|
|
|
|
final UsbLink usb;
|
2026-10-11 15:55:52 +09:00
|
|
|
|
final LinkTest linkTest;
|
2026-09-05 13:50:51 +09:00
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
return MaterialApp(
|
2026-10-09 20:23:00 +09:00
|
|
|
|
title: 'Yukart',
|
2026-10-11 15:55:52 +09:00
|
|
|
|
navigatorKey: navigatorKey,
|
2026-10-09 20:23:00 +09:00
|
|
|
|
debugShowCheckedModeBanner: false,
|
2026-10-11 17:43:27 +09:00
|
|
|
|
theme: ThemeData(
|
|
|
|
|
|
colorSchemeSeed: Colors.teal,
|
|
|
|
|
|
brightness: Brightness.dark,
|
|
|
|
|
|
useMaterial3: true,
|
|
|
|
|
|
),
|
2026-10-09 20:23:00 +09:00
|
|
|
|
home: ListenableBuilder(
|
|
|
|
|
|
listenable: Listenable.merge([boundary, usb]),
|
2026-10-11 17:43:27 +09:00
|
|
|
|
builder: (context, _) =>
|
|
|
|
|
|
Readout(boundary: boundary, usb: usb, linkTest: linkTest),
|
2026-09-05 13:50:51 +09:00
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-09 20:23:00 +09:00
|
|
|
|
class Readout extends StatelessWidget {
|
2026-10-11 17:43:27 +09:00
|
|
|
|
const Readout({
|
|
|
|
|
|
super.key,
|
|
|
|
|
|
required this.boundary,
|
|
|
|
|
|
required this.usb,
|
|
|
|
|
|
required this.linkTest,
|
|
|
|
|
|
});
|
2026-10-09 20:23:00 +09:00
|
|
|
|
final Boundary boundary;
|
|
|
|
|
|
final UsbLink usb;
|
2026-10-11 15:55:52 +09:00
|
|
|
|
final LinkTest linkTest;
|
2026-09-05 13:50:51 +09:00
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
2026-10-09 20:23:00 +09:00
|
|
|
|
final b = boundary;
|
2026-09-05 13:50:51 +09:00
|
|
|
|
return Scaffold(
|
2026-10-09 20:23:00 +09:00
|
|
|
|
body: SafeArea(
|
2026-09-05 13:50:51 +09:00
|
|
|
|
child: Column(
|
2026-10-09 20:23:00 +09:00
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
2026-09-05 13:50:51 +09:00
|
|
|
|
children: [
|
2026-10-09 20:23:00 +09:00
|
|
|
|
// Mock data must look like mock data: on the surface, not in a menu.
|
|
|
|
|
|
if (b.mock) const MockBanner(),
|
2026-10-11 15:55:52 +09:00
|
|
|
|
LinkBar(boundary: b, usb: usb, linkTest: linkTest),
|
2026-10-09 20:23:00 +09:00
|
|
|
|
Expanded(
|
|
|
|
|
|
child: LayoutBuilder(
|
|
|
|
|
|
builder: (context, c) {
|
|
|
|
|
|
final wide = c.maxWidth > 800;
|
|
|
|
|
|
final signals = SignalList(boundary: b);
|
|
|
|
|
|
final raw = RawLog(boundary: b);
|
|
|
|
|
|
return wide
|
2026-10-11 17:43:27 +09:00
|
|
|
|
? Row(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Expanded(flex: 3, child: signals),
|
|
|
|
|
|
const VerticalDivider(width: 1),
|
|
|
|
|
|
Expanded(flex: 2, child: raw),
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
|
|
|
|
|
: Column(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Expanded(child: signals),
|
|
|
|
|
|
const Divider(height: 1),
|
|
|
|
|
|
Expanded(child: raw),
|
|
|
|
|
|
],
|
|
|
|
|
|
);
|
2026-10-09 20:23:00 +09:00
|
|
|
|
},
|
|
|
|
|
|
),
|
2026-09-05 13:50:51 +09:00
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
2026-10-09 20:23:00 +09:00
|
|
|
|
floatingActionButton: FloatingActionButton.extended(
|
|
|
|
|
|
onPressed: () => showMarkSheet(context, b),
|
|
|
|
|
|
icon: const Icon(Icons.flag),
|
2026-10-11 17:43:27 +09:00
|
|
|
|
label: Text(
|
|
|
|
|
|
b.pending.isEmpty ? 'Mark' : 'Mark (${b.pending.length} pending)',
|
|
|
|
|
|
),
|
2026-10-09 20:23:00 +09:00
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class MockBanner extends StatelessWidget {
|
|
|
|
|
|
const MockBanner({super.key});
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
return Container(
|
|
|
|
|
|
color: Colors.amber.shade700,
|
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 6),
|
|
|
|
|
|
child: const Text(
|
|
|
|
|
|
'MOCK DATA — NOT FROM THE CAR',
|
|
|
|
|
|
textAlign: TextAlign.center,
|
2026-10-11 17:43:27 +09:00
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
|
fontWeight: FontWeight.w900,
|
|
|
|
|
|
fontSize: 20,
|
|
|
|
|
|
letterSpacing: 2,
|
|
|
|
|
|
),
|
2026-10-09 20:23:00 +09:00
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class LinkBar extends StatelessWidget {
|
2026-10-11 17:43:27 +09:00
|
|
|
|
const LinkBar({
|
|
|
|
|
|
super.key,
|
|
|
|
|
|
required this.boundary,
|
|
|
|
|
|
required this.usb,
|
|
|
|
|
|
required this.linkTest,
|
|
|
|
|
|
});
|
2026-10-09 20:23:00 +09:00
|
|
|
|
final Boundary boundary;
|
|
|
|
|
|
final UsbLink usb;
|
2026-10-11 15:55:52 +09:00
|
|
|
|
final LinkTest linkTest;
|
2026-10-09 20:23:00 +09:00
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
final b = boundary;
|
|
|
|
|
|
final (color, label) = switch (b.state) {
|
|
|
|
|
|
LinkState.up => (Colors.green, 'CONNECTED'),
|
|
|
|
|
|
LinkState.connecting => (Colors.orange, 'CONNECTING'),
|
|
|
|
|
|
LinkState.down => (Colors.red, 'DOWN'),
|
|
|
|
|
|
};
|
2026-10-11 17:43:27 +09:00
|
|
|
|
// Fixed-width numbers, padded with figure spaces (U+2007, digit-wide): the bar must
|
|
|
|
|
|
// not reflow every time a value gains a digit.
|
|
|
|
|
|
String pad(String v, int n) => v.padLeft(n, '\u2007');
|
|
|
|
|
|
final age = b.lastMessage == null
|
|
|
|
|
|
? pad('—', 4)
|
|
|
|
|
|
: pad(
|
2026-10-11 17:43:52 +09:00
|
|
|
|
'${DateTime.now().difference(b.lastMessage!).inMilliseconds.clamp(0, 9999)}',
|
|
|
|
|
|
4,
|
2026-10-11 17:43:27 +09:00
|
|
|
|
);
|
|
|
|
|
|
final offset = b.clockOffset == null
|
|
|
|
|
|
? pad('—', 6)
|
|
|
|
|
|
: pad((b.clockOffset!.inMilliseconds / 1000).toStringAsFixed(1), 6);
|
|
|
|
|
|
const fixed = TextStyle(fontFeatures: [FontFeature.tabularFigures()]);
|
2026-10-09 20:23:00 +09:00
|
|
|
|
return Material(
|
|
|
|
|
|
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
|
|
|
|
|
child: InkWell(
|
|
|
|
|
|
onTap: () => editUrl(context, b, usb),
|
|
|
|
|
|
child: Padding(
|
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
2026-10-11 17:43:27 +09:00
|
|
|
|
child: Wrap(
|
|
|
|
|
|
spacing: 16,
|
|
|
|
|
|
runSpacing: 4,
|
|
|
|
|
|
crossAxisAlignment: WrapCrossAlignment.center,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Chip(
|
|
|
|
|
|
label: Text(label),
|
|
|
|
|
|
backgroundColor: color.withValues(alpha: 0.3),
|
2026-10-11 15:55:52 +09:00
|
|
|
|
),
|
2026-10-11 17:43:27 +09:00
|
|
|
|
Text(b.url, style: const TextStyle(fontFamily: 'monospace')),
|
|
|
|
|
|
Text(b.detail),
|
|
|
|
|
|
Text('last msg $age ms', style: fixed),
|
|
|
|
|
|
Text('Orin−tablet clock $offset s', style: fixed),
|
|
|
|
|
|
if (usb.supported)
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'USB link ${usb.up ? 'up' : 'absent'}${usb.bound ? ', bound' : ''}',
|
|
|
|
|
|
),
|
|
|
|
|
|
TextButton.icon(
|
|
|
|
|
|
onPressed: () => Navigator.of(context).push(
|
|
|
|
|
|
MaterialPageRoute<void>(
|
|
|
|
|
|
builder: (_) => linkTestPage(b, linkTest, usb),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
icon: const Icon(Icons.speed),
|
|
|
|
|
|
label: const Text('Link test'),
|
2026-10-11 17:41:14 +09:00
|
|
|
|
),
|
2026-10-11 17:43:27 +09:00
|
|
|
|
TextButton.icon(
|
|
|
|
|
|
onPressed: () => Navigator.of(context).push(
|
|
|
|
|
|
MaterialPageRoute<void>(
|
|
|
|
|
|
builder: (_) => CamViewPage(host: Uri.parse(b.url).host),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
icon: const Icon(Icons.videocam),
|
|
|
|
|
|
label: const Text('Camera'),
|
|
|
|
|
|
),
|
2026-10-13 11:12:44 +09:00
|
|
|
|
TextButton.icon(
|
|
|
|
|
|
onPressed: () => Navigator.of(context).push(
|
|
|
|
|
|
MaterialPageRoute<void>(
|
|
|
|
|
|
builder: (_) => ChecklistsPage(boundary: b),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
icon: const Icon(Icons.checklist),
|
|
|
|
|
|
label: const Text('Captures'),
|
|
|
|
|
|
),
|
2026-10-11 17:43:27 +09:00
|
|
|
|
],
|
|
|
|
|
|
),
|
2026-10-09 20:23:00 +09:00
|
|
|
|
),
|
2026-09-05 13:50:51 +09:00
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-10-09 20:23:00 +09:00
|
|
|
|
|
|
|
|
|
|
class SignalList extends StatelessWidget {
|
|
|
|
|
|
const SignalList({super.key, required this.boundary});
|
|
|
|
|
|
final Boundary boundary;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
final b = boundary;
|
|
|
|
|
|
if (b.state != LinkState.up) {
|
|
|
|
|
|
return const Center(child: Text('No link to the Orin'));
|
|
|
|
|
|
}
|
2026-10-11 04:01:05 +09:00
|
|
|
|
if (b.seen.isEmpty) {
|
2026-10-09 20:23:00 +09:00
|
|
|
|
return Center(
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
'Connected — the Orin is sending no vehicle state\n(source: ${b.hello?['source'] ?? '?'})',
|
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2026-10-11 04:01:05 +09:00
|
|
|
|
// Rows stay put: a signal that drops out is shown as missing, not removed.
|
|
|
|
|
|
final names = b.seen.keys.toList()..sort();
|
2026-10-09 20:23:00 +09:00
|
|
|
|
return ListView(
|
|
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
|
|
children: [
|
2026-10-11 04:01:05 +09:00
|
|
|
|
for (final n in names)
|
|
|
|
|
|
b.signals[n] is Map
|
2026-10-11 17:43:27 +09:00
|
|
|
|
? SignalTile(
|
|
|
|
|
|
name: n,
|
|
|
|
|
|
envelope: Map<String, dynamic>.from(b.signals[n] as Map),
|
|
|
|
|
|
)
|
2026-10-11 04:01:05 +09:00
|
|
|
|
: SignalTile(name: n, envelope: b.seen[n]!, missing: true),
|
2026-10-09 20:23:00 +09:00
|
|
|
|
],
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-11 04:01:05 +09:00
|
|
|
|
/// Missing, known-without-value, stale and fresh each look different: all four are normal in a car.
|
2026-10-09 20:23:00 +09:00
|
|
|
|
class SignalTile extends StatelessWidget {
|
2026-10-11 17:43:27 +09:00
|
|
|
|
const SignalTile({
|
|
|
|
|
|
super.key,
|
|
|
|
|
|
required this.name,
|
|
|
|
|
|
required this.envelope,
|
|
|
|
|
|
this.missing = false,
|
|
|
|
|
|
});
|
2026-10-09 20:23:00 +09:00
|
|
|
|
final String name;
|
2026-10-11 04:01:05 +09:00
|
|
|
|
|
|
|
|
|
|
/// The current envelope, or the last one seen when [missing] (only its unit is used then).
|
2026-10-09 20:23:00 +09:00
|
|
|
|
final Map<String, dynamic> envelope;
|
2026-10-11 04:01:05 +09:00
|
|
|
|
final bool missing;
|
2026-10-09 20:23:00 +09:00
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
2026-10-11 04:01:05 +09:00
|
|
|
|
if (missing) {
|
|
|
|
|
|
return ListTile(
|
2026-10-11 17:43:27 +09:00
|
|
|
|
title: Text(
|
|
|
|
|
|
name,
|
|
|
|
|
|
style: const TextStyle(fontFamily: 'monospace', color: Colors.grey),
|
|
|
|
|
|
),
|
|
|
|
|
|
subtitle: const Text(
|
|
|
|
|
|
'MISSING · not in the latest state',
|
|
|
|
|
|
style: TextStyle(color: Colors.redAccent),
|
|
|
|
|
|
),
|
|
|
|
|
|
trailing: Text.rich(
|
|
|
|
|
|
TextSpan(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
const TextSpan(
|
|
|
|
|
|
text: '?',
|
|
|
|
|
|
style: TextStyle(fontSize: 34, color: Colors.grey),
|
|
|
|
|
|
),
|
|
|
|
|
|
TextSpan(
|
|
|
|
|
|
text: ' ${envelope['unit'] ?? ''}',
|
|
|
|
|
|
style: const TextStyle(fontSize: 16, color: Colors.grey),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
2026-10-11 04:01:05 +09:00
|
|
|
|
);
|
|
|
|
|
|
}
|
2026-10-09 20:23:00 +09:00
|
|
|
|
final v = envelope['value'];
|
|
|
|
|
|
final quality = envelope['quality'] as String? ?? 'ok';
|
|
|
|
|
|
final stale = quality != 'ok';
|
2026-10-11 17:43:27 +09:00
|
|
|
|
final text = v == null
|
|
|
|
|
|
? '—'
|
|
|
|
|
|
: (v is double && v == v.roundToDouble() ? v.toInt().toString() : '$v');
|
2026-10-09 20:23:00 +09:00
|
|
|
|
final style = TextStyle(
|
|
|
|
|
|
fontSize: 34,
|
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
|
fontFeatures: const [FontFeature.tabularFigures()],
|
|
|
|
|
|
color: stale || v == null ? Colors.grey : null,
|
|
|
|
|
|
fontStyle: stale ? FontStyle.italic : null,
|
|
|
|
|
|
);
|
|
|
|
|
|
return ListTile(
|
|
|
|
|
|
title: Text(name, style: const TextStyle(fontFamily: 'monospace')),
|
2026-10-11 17:43:27 +09:00
|
|
|
|
subtitle: Text(
|
|
|
|
|
|
[
|
|
|
|
|
|
if (stale) quality.toUpperCase(),
|
|
|
|
|
|
if (v == null) 'no value',
|
|
|
|
|
|
if (envelope['mock'] == true) 'mock',
|
|
|
|
|
|
].join(' · '),
|
|
|
|
|
|
),
|
|
|
|
|
|
trailing: Text.rich(
|
|
|
|
|
|
TextSpan(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
TextSpan(text: text, style: style),
|
|
|
|
|
|
TextSpan(
|
|
|
|
|
|
text: ' ${envelope['unit'] ?? ''}',
|
|
|
|
|
|
style: const TextStyle(fontSize: 16),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
2026-10-09 20:23:00 +09:00
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class RawLog extends StatelessWidget {
|
|
|
|
|
|
const RawLog({super.key, required this.boundary});
|
|
|
|
|
|
final Boundary boundary;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
final b = boundary;
|
|
|
|
|
|
return ListView(
|
|
|
|
|
|
padding: const EdgeInsets.all(8),
|
|
|
|
|
|
children: [
|
|
|
|
|
|
if (b.pending.isNotEmpty || b.acks.isNotEmpty) ...[
|
|
|
|
|
|
Text('Commands', style: Theme.of(context).textTheme.titleSmall),
|
2026-10-11 17:43:27 +09:00
|
|
|
|
for (final p in b.pending)
|
|
|
|
|
|
Text('… ${p.cmd} ${p.args['text'] ?? ''} (unacked)'),
|
|
|
|
|
|
for (final a in b.acks)
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'${a.ok ? '✓' : '✗'} ${a.detail}',
|
|
|
|
|
|
style: TextStyle(color: a.ok ? null : Colors.redAccent),
|
|
|
|
|
|
),
|
2026-10-09 20:23:00 +09:00
|
|
|
|
const Divider(),
|
|
|
|
|
|
],
|
2026-10-11 17:43:27 +09:00
|
|
|
|
Text(
|
|
|
|
|
|
'Raw messages, newest first',
|
|
|
|
|
|
style: Theme.of(context).textTheme.titleSmall,
|
|
|
|
|
|
),
|
2026-10-09 20:23:00 +09:00
|
|
|
|
for (final r in b.recent)
|
|
|
|
|
|
Padding(
|
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 2),
|
2026-10-11 17:43:27 +09:00
|
|
|
|
child: Text(
|
|
|
|
|
|
r,
|
|
|
|
|
|
style: const TextStyle(fontFamily: 'monospace', fontSize: 11),
|
|
|
|
|
|
),
|
2026-10-09 20:23:00 +09:00
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-11 17:43:27 +09:00
|
|
|
|
const quickMarks = [
|
|
|
|
|
|
'cold start',
|
|
|
|
|
|
'engine start',
|
|
|
|
|
|
'indicator left',
|
|
|
|
|
|
'indicator right',
|
|
|
|
|
|
'brake',
|
|
|
|
|
|
'headlights',
|
|
|
|
|
|
'something odd',
|
|
|
|
|
|
];
|
2026-10-09 20:23:00 +09:00
|
|
|
|
|
|
|
|
|
|
Future<void> showMarkSheet(BuildContext context, Boundary b) {
|
|
|
|
|
|
final custom = TextEditingController();
|
|
|
|
|
|
return showModalBottomSheet(
|
|
|
|
|
|
context: context,
|
2026-10-11 04:01:05 +09:00
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
|
useSafeArea: true,
|
2026-10-09 20:23:00 +09:00
|
|
|
|
builder: (ctx) {
|
|
|
|
|
|
void send(String text) {
|
|
|
|
|
|
if (text.trim().isEmpty) return;
|
|
|
|
|
|
b.command('mark', {'text': text.trim()});
|
|
|
|
|
|
Navigator.pop(ctx);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Padding(
|
2026-10-11 04:01:05 +09:00
|
|
|
|
// Clear the keyboard when it is up, the navigation bar when it is not.
|
2026-10-11 17:43:27 +09:00
|
|
|
|
padding: EdgeInsets.fromLTRB(
|
|
|
|
|
|
16,
|
|
|
|
|
|
16,
|
|
|
|
|
|
16,
|
|
|
|
|
|
16 +
|
|
|
|
|
|
max(
|
|
|
|
|
|
MediaQuery.of(ctx).viewInsets.bottom,
|
|
|
|
|
|
MediaQuery.of(ctx).viewPadding.bottom,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'Stamp into the recording',
|
|
|
|
|
|
style: Theme.of(ctx).textTheme.titleMedium,
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
|
Wrap(
|
|
|
|
|
|
spacing: 8,
|
|
|
|
|
|
runSpacing: 8,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
for (final q in quickMarks)
|
|
|
|
|
|
ActionChip(label: Text(q), onPressed: () => send(q)),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
TextField(
|
|
|
|
|
|
controller: custom,
|
|
|
|
|
|
decoration: const InputDecoration(labelText: 'Other'),
|
|
|
|
|
|
onSubmitted: send,
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
2026-10-09 20:23:00 +09:00
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> editUrl(BuildContext context, Boundary b, UsbLink usb) async {
|
|
|
|
|
|
final c = TextEditingController(text: b.url);
|
|
|
|
|
|
final url = await showDialog<String>(
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
builder: (ctx) => AlertDialog(
|
|
|
|
|
|
title: const Text('Gateway address'),
|
|
|
|
|
|
content: TextField(controller: c, autofocus: true),
|
|
|
|
|
|
actions: [
|
2026-10-11 17:43:27 +09:00
|
|
|
|
TextButton(
|
|
|
|
|
|
onPressed: () => Navigator.pop(ctx),
|
|
|
|
|
|
child: const Text('Cancel'),
|
|
|
|
|
|
),
|
|
|
|
|
|
TextButton(
|
|
|
|
|
|
onPressed: () => Navigator.pop(ctx, c.text.trim()),
|
|
|
|
|
|
child: const Text('Connect'),
|
|
|
|
|
|
),
|
2026-10-09 20:23:00 +09:00
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
if (url == null || url.isEmpty) return;
|
|
|
|
|
|
await usb.bindFor(Uri.parse(url));
|
|
|
|
|
|
b.retarget(url);
|
|
|
|
|
|
}
|