Files
pipelines/app/lib/application/bootstrap.dart
T
alan 2853b18b9e 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.
2026-11-04 02:01:49 +00:00

75 lines
2.3 KiB
Dart

import '../core/session/server_session.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
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');
/// Resolves the launch endpoint: on a phone the server saved at onboarding,
/// else the build's default (which only pre-fills onboarding until saved).
Future<ServerEndpoint> resolveLaunchServer({
Uri? base,
String configured = configuredServerUrl,
bool web = kIsWeb,
SettingsStore? settingsStore,
}) async {
WidgetsFlutterBinding.ensureInitialized();
var endpoint = configured;
if (!web) {
try {
final saved =
(await (settingsStore ?? const SharedPreferencesSettingsStore())
.load())
.serverUrl;
if (saved.trim().isNotEmpty) endpoint = saved;
} catch (_) {
// Keep the build's default.
}
}
return ServerEndpoint.resolve(
base: base ?? Uri.base,
web: web,
configured: endpoint,
);
}
/// 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,
String configured = configuredServerUrl,
SettingsStore? settingsStore,
}) 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,
settingsStore: settingsStore,
);
runApp(
PipelinesRoot(
server: server,
buildDefault: configured,
signedIn: kIsWeb || ServerSession.cookie != null,
),
);
}