Repository navigation
Expand file tree
/
Copy pathmain.dart
More file actions
72 lines (64 loc) · 2.68 KB
/
Copy pathmain.dart
File metadata and controls
72 lines (64 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import 'dart:async';
import 'package:flood/flood.dart';
import 'package:flutter/material.dart';
import 'package:todo/firebase_options.dart';
import 'package:todo/presentation/style.dart';
import 'package:todo/presentation/todo_pages_pond_component.dart';
import 'package:todo/presentation/utils/user_theme_extensions.dart';
import 'package:todo/testing.dart';
import 'package:todo_core/features/user/user_entity.dart';
import 'package:todo_core/pond.dart';
// When setting up the test suite [testingLoggedIn] will determine whether to have the user logged in.
const testingLoggedIn = true;
Future<void> main(List<String> args) async {
await PondApp.run(
appPondContextGetter: buildAppPondContext,
loadingPage: StyledLoadingPage(),
notFoundPage: StyledPage(
body: Center(
child: StyledText.twoXl('Not Found!'),
),
),
);
}
Future<AppPondContext> buildAppPondContext() async {
final corePondContext = await getCorePondContext(
environmentConfig: EnvironmentConfig.static.flutterAssets(),
initialCoreComponents: (corePondContext) => [
if (corePondContext.environment.isOnline) ...[FirebaseCoreComponent(app: DefaultFirebaseOptions.currentPlatform)]
],
repositoryImplementations: (corePondContext) => [
FirebaseCloudRepositoryImplementation(),
],
authServiceImplementations: (corePondContext) => [FirebaseAuthServiceImplementation()],
messagingService: (corePondContext) => corePondContext
.environmental((type) => type.isOnline ? MessagingService.static.firebase : MessagingService.static.local()),
taskRunner: (corePondContext) => TaskRunner.static.local,
loggerService: (corePondContext) => corePondContext.environment.isOnline
? LoggerService.static.console.withFileLogHistory(corePondContext.fileSystem.tempDirectory / 'logs')
: LoggerService.static.console,
);
final appPondContext = AppPondContext(corePondContext: corePondContext);
await appPondContext.register(FloodAppComponent(
style: darkStyle,
styleLoader: (context) async {
final loggedInUserId = context.authCoreComponent.loggedInUserId;
if (loggedInUserId == null) {
return null;
}
final loggedInUserEntity = await Query.getByIdOrNull<UserEntity>(loggedInUserId).get(context.dropCoreComponent);
if (loggedInUserEntity == null) {
return null;
}
final theme = loggedInUserEntity.value.themeProperty.value;
return theme.style;
},
));
await appPondContext.register(TestingSetupAppComponent(onSetup: () async {
if (testingLoggedIn) {
await setupTesting(corePondContext);
}
}));
await appPondContext.register(TodoPagesAppPondComponent());
return appPondContext;
}