39 lines
1.5 KiB
Dart
39 lines
1.5 KiB
Dart
|
|
import 'dart:io';
|
||
|
|
|
||
|
|
import 'package:halkyon_app/halkyon_app.dart';
|
||
|
|
import 'package:halkyon_train_flutter/src/app/licences.dart';
|
||
|
|
import 'package:halkyon_train_flutter/src/app/train_app.dart';
|
||
|
|
import 'package:halkyon_train_flutter/src/app/train_dependencies.dart';
|
||
|
|
import 'package:halkyon_ui/halkyon_ui.dart';
|
||
|
|
import 'package:material_ui/material_ui.dart';
|
||
|
|
import 'package:path/path.dart' as p;
|
||
|
|
import 'package:serverpod_flutter/serverpod_flutter.dart';
|
||
|
|
|
||
|
|
Future<void> main() async {
|
||
|
|
WidgetsFlutterBinding.ensureInitialized();
|
||
|
|
// Noto Sans' notice (halkyon_ui), the flags' and Unicode CLDR's
|
||
|
|
// (halkyon_app), and Lucide's for the app's icon.
|
||
|
|
registerFontLicenses();
|
||
|
|
registerHalkyonAppLicenses();
|
||
|
|
registerLucideLicense();
|
||
|
|
// The instance the build names (`--dart-define=SERVER_URL=…`, or
|
||
|
|
// `assets/config.json`): the first offered at the first start.
|
||
|
|
final builtIn = Instance.parse(await getServerUrl())!;
|
||
|
|
final device = await TrainDevice.create(builtIn: builtIn);
|
||
|
|
final instances = InstanceChoice(
|
||
|
|
FileInstanceStore(File(p.join(device.support, 'instances.json'))),
|
||
|
|
builtIn: builtIn,
|
||
|
|
forget: device.storage.forget,
|
||
|
|
sharesStorage: device.storage.sharesWith,
|
||
|
|
);
|
||
|
|
await instances.load(usedBefore: device.storage.usedBefore());
|
||
|
|
runApp(
|
||
|
|
TrainApp(
|
||
|
|
choice: instances,
|
||
|
|
// Only an instance of Halkyon Train: one of another Halkyon app's
|
||
|
|
// answers too, but holds nothing of this app's.
|
||
|
|
checker: ServerpodInstanceChecker(app: 'train'),
|
||
|
|
open: (instance) => TrainDependencies.create(instance, device),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|