/
main.dart
132 lines (115 loc) · 2.83 KB
/
main.dart
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:masamune/masamune.dart';
part 'main.theme.dart';
part 'main.localize.dart';
/// App Title.
const title = "";
/// Initial page query.
const initialQuery = null;
/// App Model.
///
/// By replacing this with another adapter, the data storage location can be changed.
const modelAdapter = RuntimeModelAdapter();
/// App Auth.
///
/// Changing to another adapter allows you to change to another authentication mechanism.
const authAdapter = RuntimeAuthAdapter();
/// App Storage.
///
/// Changing to another adapter allows you to change to another storage mechanism.
const storageAdapter = LocalStorageAdapter();
/// App Functions.
///
/// Changing to another adapter allows you to change to another functions mechanism.
const functionsAdapter = RuntimeFunctionsAdapter();
/// App Theme.
///
/// ```dart
/// theme.color.primary // Primary color.
/// theme.text.bodyMedium // Medium body text style.
/// theme.asset.xxx // xxx image.
/// theme.font.xxx // xxx font.
/// ```
@appTheme
final theme = AppThemeData(
primary: Colors.blue,
secondary: Colors.cyan,
onPrimary: Colors.white,
onSecondary: Colors.white,
);
/// App Router.
///
/// ```dart
/// router.push(Page.query()); // Push page to Page.
/// router.pop(); // Pop page.
/// ```
final router = AppRouter(
boot: null,
initialQuery: initialQuery,
redirect: [],
pages: [],
);
/// App Localization.
///
/// ```dart
/// l().xxx // Localization for xxx.
/// ```
final l = AppLocalize();
@GoogleSpreadSheetLocalize(
[
"https://docs.google.com/spreadsheets/d/1bw7IXEr7BGkZ4U6on0OuF7HQkTMgDSm6u5ThpBkDPeo/edit#gid=551986808"
],
version: 1,
)
class AppLocalize extends _$AppLocalize {}
/// App Ref.
///
/// ```dart
/// appRef.controller(Controller.query()); // Get a controller.
/// appRef.model(Model.query()); // Get a model.
/// ```
final appRef = AppRef();
/// App authentication.
///
/// ```dart
/// appAuth.signIn(
/// EmailAndPasswordSignInAuthProvider(
/// email: email,
/// password: password,
/// ),
/// );
/// ```
final appAuth = Authentication();
/// App server functions.
///
/// It is used in conjunction with the server side.
///
/// ```dart
/// appFunction.notification(
/// title: "Notification",
/// text: "Notification text",
/// target: "Topic",
/// );
/// ```
final appFunction = Functions();
/// App Flavor.
const flavor = String.fromEnvironment("FLAVOR");
/// App.
void main() {
runMasamuneApp(
(adapters) => MasamuneApp(
title: title,
appRef: appRef,
theme: theme,
routerConfig: router,
localize: l,
authAdapter: authAdapter,
modelAdapter: modelAdapter,
storageAdapter: storageAdapter,
functionsAdapter: functionsAdapter,
masamuneAdapters: adapters,
),
);
}