Settings: per-device interface font choice

System default plus Inter, IBM Plex Sans, Source Sans 3 and Atkinson
Hyperlegible Next (OFL 1.1, bundled as on-demand assets and loaded with
FontLoader, so the web fetches only the previewed/chosen files). Stored in
shared_preferences, applied live to Material and Cupertino text themes;
RobotoMono styles unchanged. Licences registered with LicenseRegistry.
This commit is contained in:
2026-11-04 02:01:49 +00:00
parent fa6c0864db
commit 2853b18b9e
38 changed files with 1486 additions and 26 deletions
+22 -6
View File
@@ -1,4 +1,5 @@
import '../ui/adaptive/platform.dart';
import '../ui/theme/app_font_controller.dart';
import '../ui/theme/app_theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@@ -16,6 +17,7 @@ class MyApp extends StatelessWidget {
this.cupertino,
this.destination,
this.onDestinationSelected,
this.fonts,
}) : routerConfig = null;
/// A host for a [Router]-owned location, so browser Back/Forward and deep
@@ -25,6 +27,7 @@ class MyApp extends StatelessWidget {
super.key,
required RouterConfig<Object> this.routerConfig,
this.cupertino,
this.fonts,
}) : destinationBodies = const {},
destination = null,
onDestinationSelected = null;
@@ -35,20 +38,33 @@ class MyApp extends StatelessWidget {
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;
@override
Widget build(BuildContext context) {
final fonts = this.fonts ?? AppFontController.instance;
return ListenableBuilder(
listenable: fonts,
builder: (context, _) => _host(fonts.family),
);
}
Widget _host(String? fontFamily) {
final router = routerConfig;
if (cupertino ?? _platformIsCupertino) {
final theme = appCupertinoThemeWith(fontFamily: fontFamily);
if (router != null) {
return CupertinoApp.router(
title: 'Pipelines',
theme: appCupertinoTheme,
theme: theme,
routerConfig: router,
);
}
return CupertinoApp(
title: 'Pipelines',
theme: appCupertinoTheme,
theme: theme,
home: AdaptiveShell(
destinationBodies: destinationBodies,
cupertino: true,
@@ -60,16 +76,16 @@ class MyApp extends StatelessWidget {
if (router != null) {
return MaterialApp.router(
title: 'Pipelines',
theme: appLightTheme(),
darkTheme: appDarkTheme(),
theme: appLightTheme(fontFamily: fontFamily),
darkTheme: appDarkTheme(fontFamily: fontFamily),
themeMode: ThemeMode.system,
routerConfig: router,
);
}
return MaterialApp(
title: 'Pipelines',
theme: appLightTheme(),
darkTheme: appDarkTheme(),
theme: appLightTheme(fontFamily: fontFamily),
darkTheme: appDarkTheme(fontFamily: fontFamily),
themeMode: ThemeMode.system,
home: AdaptiveShell(
destinationBodies: destinationBodies,
+11
View File
@@ -6,6 +6,8 @@ import 'app_url_strategy.dart';
import 'pipelines_root.dart';
import 'server_endpoint.dart';
import '../features/settings/settings_store.dart';
import '../ui/theme/app_font_controller.dart';
import '../ui/theme/app_font_licenses.dart';
/// Native builds must supply their server explicitly; there is no baked host.
const configuredServerUrl = String.fromEnvironment('PIPELINES_SERVER_URL');
@@ -38,6 +40,10 @@ Future<ServerEndpoint> resolveLaunchServer({
);
}
/// How long the first frame waits for a stored font before drawing in the
/// system font.
const appFontStartupWait = Duration(milliseconds: 1500);
/// Resolves the endpoint for this launch and starts the normal composition.
Future<void> runPipelinesApp({
Uri? base,
@@ -46,8 +52,13 @@ Future<void> runPipelinesApp({
}) async {
useAppUrlStrategy();
WidgetsFlutterBinding.ensureInitialized();
registerAppFontLicenses();
// The device's chosen font loads beside the session; a slow download does
// not hold the first frame, and applies when it lands.
final font = AppFontController.instance.restore(wait: appFontStartupWait);
// A phone behind the web login reconnects with its kept session.
await ServerSession.load();
await font;
final server = await resolveLaunchServer(
base: base,
configured: configured,
+19 -14
View File
@@ -14,6 +14,7 @@ import '../features/onboarding/onboarding_flow.dart';
import '../features/settings/server_connections.dart';
import '../features/settings/saved_servers_section.dart';
import '../features/settings/settings_store.dart';
import '../ui/theme/app_font_controller.dart';
import '../ui/theme/app_theme.dart';
import 'pipelines_app.dart';
import 'server_endpoint.dart';
@@ -294,19 +295,23 @@ class _PipelinesRootState extends State<PipelinesRoot> {
_servers.catalog.active?.endpoints.map(Uri.parse).toList() ??
const [],
);
return _cupertino
? CupertinoApp(
title: 'Pipelines',
theme: appCupertinoTheme,
debugShowCheckedModeBanner: false,
home: flow,
)
: MaterialApp(
title: 'Pipelines',
theme: appLightTheme(),
darkTheme: appDarkTheme(),
debugShowCheckedModeBanner: false,
home: flow,
);
final fonts = AppFontController.instance;
return ListenableBuilder(
listenable: fonts,
builder: (context, _) => _cupertino
? CupertinoApp(
title: 'Pipelines',
theme: appCupertinoThemeWith(fontFamily: fonts.family),
debugShowCheckedModeBanner: false,
home: flow,
)
: MaterialApp(
title: 'Pipelines',
theme: appLightTheme(fontFamily: fonts.family),
darkTheme: appDarkTheme(fontFamily: fonts.family),
debugShowCheckedModeBanner: false,
home: flow,
),
);
}
}