63 lines
2.1 KiB
Dart
63 lines
2.1 KiB
Dart
// Device-only fixture entry point. Never used by the distributable APK.
|
|
import 'package:flutter/material.dart';
|
|
import 'package:timezone/data/latest.dart' as tzdata;
|
|
import 'package:timezone/timezone.dart' as tz;
|
|
import 'package:hepan_everyday/main.dart' show buildApplication;
|
|
import 'package:hepan_everyday/app/app_controller.dart';
|
|
import 'package:hepan_everyday/domain/app_snapshot.dart';
|
|
import 'package:hepan_everyday/domain/app_settings.dart';
|
|
import 'package:hepan_everyday/domain/schedule_engine.dart';
|
|
import 'package:hepan_everyday/services/local_notification_service.dart';
|
|
|
|
import '../test/support/fakes.dart';
|
|
|
|
Future<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
tzdata.initializeTimeZones();
|
|
final now = tz.TZDateTime.now(tz.getLocation('Asia/Shanghai'));
|
|
final date = DateTime.utc(now.year, now.month, now.day);
|
|
final course = Course(
|
|
id: 'native-probe',
|
|
name: '系统提醒验证(测试)',
|
|
teacher: '测试教师',
|
|
room: '测试教室',
|
|
weekday: now.weekday,
|
|
startPeriod: 1,
|
|
endPeriod: 2,
|
|
weeks: {1},
|
|
source: CourseSource.file,
|
|
);
|
|
final settings = AppSettings(
|
|
semester: Semester(startDate: date, totalWeeks: 1),
|
|
);
|
|
final selection = ValueNotifier<String?>(null);
|
|
final gateway = PluginReminderGateway(onTap: (key) => selection.value = key);
|
|
final service = LocalNotificationService(gateway);
|
|
const fireDelay = int.fromEnvironment(
|
|
'PROBE_DELAY_SECONDS',
|
|
defaultValue: 30,
|
|
);
|
|
final start = now.add(Duration(minutes: 15, seconds: fireDelay));
|
|
await service.reconcile(
|
|
[
|
|
CourseOccurrence(
|
|
key: 'native-probe/${date.toIso8601String().substring(0, 10)}',
|
|
course: course,
|
|
week: 1,
|
|
start: start,
|
|
end: start.add(const Duration(minutes: 95)),
|
|
),
|
|
],
|
|
settings,
|
|
now,
|
|
);
|
|
final controller = AppController(
|
|
MemoryStore(AppSnapshot(courses: [course], settings: settings)),
|
|
FakeNotifications(),
|
|
FakeCalendar(),
|
|
DateTime.now,
|
|
);
|
|
await controller.initialize();
|
|
runApp(buildApplication(controller, notificationSelection: selection));
|
|
}
|