ca2f7eee32
AppDesign builds each design's light and dark ThemeData with an AppDesignTokens extension (corner radius, flat surfaces, frame colour, ANSI accents, prompt glyph). Settings gains a Design picker stored per device; the theme hosts rebuild live. Terminal is monospace (bundled RobotoMono), near-black or paper, flat 1px frames with 3px corners, and draws the chat transcript as prompt lines, tool dot/result lines and bracketed follow-up lines. Default keeps its exact themes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
94 lines
3.1 KiB
Dart
94 lines
3.1 KiB
Dart
import '../ui/adaptive/window_margins.dart';
|
|
import '../ui/theme/app_design.dart';
|
|
import '../ui/theme/app_design_controller.dart';
|
|
import '../ui/theme/app_font_controller.dart';
|
|
import '../ui/scale/ui_scale.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'clipboard_failures.dart';
|
|
|
|
import '../shell/adaptive_shell.dart';
|
|
import '../shell/destination.dart';
|
|
|
|
/// The injectable application shell. Composition supplies the live feature
|
|
/// bodies and, when it owns a route, the selected destination; widget tests
|
|
/// can continue to pass a small map or no bodies at all.
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({
|
|
super.key,
|
|
this.destinationBodies = const {},
|
|
this.destination,
|
|
this.onDestinationSelected,
|
|
this.fonts,
|
|
this.designs,
|
|
}) : routerConfig = null;
|
|
|
|
/// A host for a [Router]-owned location, so browser Back/Forward and deep
|
|
/// links use Flutter's multi-entry web history instead of a second, competing
|
|
/// history implementation.
|
|
const MyApp.router({
|
|
super.key,
|
|
required RouterConfig<Object> this.routerConfig,
|
|
this.fonts,
|
|
this.designs,
|
|
}) : destinationBodies = const {},
|
|
destination = null,
|
|
onDestinationSelected = null;
|
|
|
|
final Map<AppDestination, WidgetBuilder> destinationBodies;
|
|
|
|
final AppDestination? destination;
|
|
final ValueChanged<AppDestination>? onDestinationSelected;
|
|
final RouterConfig<Object>? routerConfig;
|
|
|
|
/// The device's interface font; defaults to the app's shared controller.
|
|
/// A change rebuilds the themes in place, without a restart.
|
|
final AppFontController? fonts;
|
|
|
|
/// The device's design; defaults to the app's shared controller. A change
|
|
/// rebuilds the themes in place, like a font change.
|
|
final AppDesignController? designs;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final fonts = this.fonts ?? AppFontController.instance;
|
|
final designs = this.designs ?? AppDesignController.instance;
|
|
return ListenableBuilder(
|
|
listenable: Listenable.merge([fonts, designs]),
|
|
builder: (context, _) => _host(designs.design, fonts.family),
|
|
);
|
|
}
|
|
|
|
Widget _host(AppDesign design, String? fontFamily) {
|
|
final router = routerConfig;
|
|
if (router != null) {
|
|
return MaterialApp.router(
|
|
title: 'Pipelines',
|
|
scaffoldMessengerKey: appScaffoldMessengerKey,
|
|
builder: _scaled,
|
|
theme: design.light(fontFamily: fontFamily),
|
|
darkTheme: design.dark(fontFamily: fontFamily),
|
|
themeMode: ThemeMode.system,
|
|
routerConfig: router,
|
|
);
|
|
}
|
|
return MaterialApp(
|
|
title: 'Pipelines',
|
|
scaffoldMessengerKey: appScaffoldMessengerKey,
|
|
builder: _scaled,
|
|
theme: design.light(fontFamily: fontFamily),
|
|
darkTheme: design.dark(fontFamily: fontFamily),
|
|
themeMode: ThemeMode.system,
|
|
home: AdaptiveShell(
|
|
destinationBodies: destinationBodies,
|
|
destination: destination,
|
|
onDestinationSelected: onDestinationSelected,
|
|
),
|
|
);
|
|
}
|
|
|
|
static Widget _scaled(BuildContext context, Widget? child) => UiScaleHost(
|
|
child: WindowMargins(child: child ?? const SizedBox.shrink()),
|
|
);
|
|
}
|