4cf7a786d6
The shell (shell.dart): a drawer from the left edge or each page's menu button. Dash, Signals, Captures; Tools (Camera, Link test, Orin power options), the rarely used ones, after pirate-station-aide; Settings (gateway address, dark/bright, build-time theme and landing). Landing view at build time: YUKART_HOME=dash|signals, signals for now. Dash, Signals and Captures stay alive while hidden; Captures has its own navigator, so a run survives switching views. Back goes inside Captures, then to the landing view, then out. The mock banner sits over every page. main.dart is startup only; the old home screen is pages/signals.dart; dialogs and sheets moved to actions/; the protocol client, USB binding and Reading to link/. lib/README.md catalogues it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DDwfd6Ki8UfG4hK6W5YpJz
91 lines
2.8 KiB
Dart
91 lines
2.8 KiB
Dart
// Yukart display: the tablet app. Starts the link to the Orin and hands the screen to
|
|
// the shell (lib/shell.dart). Code layout: lib/README.md.
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'link/boundary.dart';
|
|
import 'link/net.dart';
|
|
import 'pages/link_test.dart';
|
|
import 'shell.dart';
|
|
import 'shell_scope.dart';
|
|
import 'theme/palette.dart';
|
|
|
|
/// Override for development, e.g. `--dart-define=YUKART_GW=ws://halogen.local:7700/`.
|
|
const defaultUrl = String.fromEnvironment(
|
|
'YUKART_GW',
|
|
defaultValue: 'ws://192.168.55.1:7700/',
|
|
);
|
|
|
|
Future<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
final themes = await Themes.load();
|
|
final usb = UsbLink();
|
|
await usb.bindFor(Uri.parse(defaultUrl));
|
|
final boundary = Boundary(defaultUrl)..start();
|
|
final linkTest = LinkTest(usb);
|
|
// 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.
|
|
Future<void> runLinkTest(String request) async {
|
|
final mode = request.startsWith('dl:') || request.startsWith('bi:')
|
|
? request.substring(0, 2)
|
|
: '';
|
|
if (mode.isNotEmpty) request = request.substring(3);
|
|
final at = request.indexOf('@');
|
|
final label = at < 0 ? request : request.substring(0, at);
|
|
final host = at < 0
|
|
? Uri.parse(boundary.url).host
|
|
: request.substring(at + 1);
|
|
shellView.value = ShellView.linkTest;
|
|
await switch (mode) {
|
|
'dl' => linkTest.runDownload(host, label),
|
|
'bi' => linkTest.runBurstIdle(host, label),
|
|
_ => linkTest.run(host, label),
|
|
};
|
|
await usb.bindFor(Uri.parse(boundary.url));
|
|
}
|
|
|
|
usb.onLinkTest = runLinkTest;
|
|
runApp(
|
|
YukartApp(boundary: boundary, usb: usb, linkTest: linkTest, themes: themes),
|
|
);
|
|
final pending = await usb.takeLinkTest();
|
|
if (pending != null) {
|
|
WidgetsBinding.instance.addPostFrameCallback((_) => runLinkTest(pending));
|
|
}
|
|
}
|
|
|
|
class YukartApp extends StatelessWidget {
|
|
const YukartApp({
|
|
super.key,
|
|
required this.boundary,
|
|
required this.usb,
|
|
required this.linkTest,
|
|
required this.themes,
|
|
});
|
|
final Boundary boundary;
|
|
final UsbLink usb;
|
|
final LinkTest linkTest;
|
|
final Themes themes;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// Every page takes its colours from the palette; switching dark/bright rebuilds them all.
|
|
return ListenableBuilder(
|
|
listenable: themes,
|
|
builder: (context, _) => MaterialApp(
|
|
title: 'Yukart',
|
|
debugShowCheckedModeBanner: false,
|
|
theme: themes.material(),
|
|
builder: (context, child) =>
|
|
AppTheme(palette: themes.current, child: child!),
|
|
home: AppShell(
|
|
boundary: boundary,
|
|
usb: usb,
|
|
linkTest: linkTest,
|
|
themes: themes,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|