58 lines
1.7 KiB
Dart
58 lines
1.7 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:path_provider/path_provider.dart';
|
|
import 'package:timezone/data/latest.dart' as tzdata;
|
|
|
|
import 'app/app_controller.dart';
|
|
import 'app/hepan_app.dart';
|
|
import 'app/tp_startup.dart';
|
|
import 'data/file_snapshot_store.dart';
|
|
import 'services/local_notification_service.dart';
|
|
import 'services/android_calendar_service.dart';
|
|
import 'features/school/school_session.dart';
|
|
import 'features/school/school_auth_page.dart';
|
|
|
|
Widget buildApplication(
|
|
AppController controller, {
|
|
ValueNotifier<String?>? notificationSelection,
|
|
SchoolSession? school,
|
|
}) => HepanApp(
|
|
controller: controller,
|
|
notificationSelection: notificationSelection,
|
|
school: school,
|
|
schoolBuilder: school == null
|
|
? null
|
|
: () => SchoolAuthPage(session: school, controller: controller),
|
|
);
|
|
Future<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
AppController? controller;
|
|
await launchApplication(
|
|
bootstrap: () async {
|
|
tzdata.initializeTimeZones();
|
|
final selection = ValueNotifier<String?>(null);
|
|
final gateway = PluginReminderGateway(
|
|
onTap: (key) => selection.value = key,
|
|
);
|
|
final value = AppController(
|
|
FileSnapshotStore(await getApplicationSupportDirectory()),
|
|
LocalNotificationService(gateway),
|
|
AndroidCalendarService(MethodCalendarGateway()),
|
|
DateTime.now,
|
|
);
|
|
await value.initialize(reconcileServices: false);
|
|
controller = value;
|
|
return buildApplication(
|
|
value,
|
|
notificationSelection: selection,
|
|
school: SchoolSession(),
|
|
);
|
|
},
|
|
onHomeReady: () {
|
|
final value = controller;
|
|
if (value != null) unawaited(value.refreshServices());
|
|
},
|
|
);
|
|
}
|