-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
main.dart
245 lines (236 loc) · 10.3 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
import 'dart:io';
import 'package:dargon2_flutter/dargon2_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter_autofill_service/flutter_autofill_service.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:kdbx/kdbx.dart';
import 'package:passy/passy_flutter/passy_flutter.dart';
import 'package:passy/screens/add_file_screen.dart';
import 'package:passy/screens/autofill_splash_screen.dart';
import 'package:passy/screens/automatic_backup_screen.dart';
import 'package:passy/screens/confirm_import_screen.dart';
import 'package:passy/screens/confirm_kdbx_export_screen.dart';
import 'package:passy/screens/export_and_import_screen.dart';
import 'package:passy/screens/export_screen.dart';
import 'package:passy/screens/passy_file_screen.dart';
import 'package:passy/screens/files_screen.dart';
import 'package:passy/screens/global_settings_screen.dart';
import 'package:passy/screens/import_screen.dart';
import 'package:passy/screens/key_derivation_screen.dart';
import 'package:passy/screens/manage_servers_screen.dart';
import 'package:passy/screens/no_accounts_screen.dart';
import 'package:passy/screens/server_connect_screen.dart';
import 'package:passy/screens/servers_screen.dart';
import 'common/common.dart';
import 'screens/change_password_screen.dart';
import 'screens/change_username_screen.dart';
import 'screens/common.dart';
import 'screens/confirm_restore_screen.dart';
import 'screens/credentials_screen.dart';
import 'screens/csv_import_screen.dart';
import 'screens/csv_import_entries_screen.dart';
import 'screens/remove_account_screen.dart';
import 'screens/server_setup_screen.dart';
import 'screens/setup_screen.dart';
import 'screens/security_screen.dart';
import 'screens/edit_note_screen.dart';
import 'screens/identities_screen.dart';
import 'screens/notes_screen.dart';
import 'screens/id_cards_screen.dart';
import 'screens/backup_and_restore_screen.dart';
import 'screens/biometric_auth_screen.dart';
import 'screens/add_account_screen.dart';
import 'screens/connect_screen.dart';
import 'screens/edit_custom_field_screen.dart';
import 'screens/edit_id_card_screen.dart';
import 'screens/edit_identity_screen.dart';
import 'screens/edit_password_screen.dart';
import 'screens/edit_payment_card_screen.dart';
import 'screens/id_card_screen.dart';
import 'screens/identity_screen.dart';
import 'screens/log_screen.dart';
import 'screens/login_screen.dart';
import 'screens/main_screen.dart';
import 'screens/note_screen.dart';
import 'screens/password_screen.dart';
import 'screens/passwords_screen.dart';
import 'screens/search_screen.dart';
import 'screens/payment_card_screen.dart';
import 'screens/payment_cards_screen.dart';
import 'screens/settings_screen.dart';
import 'screens/splash_screen.dart';
import 'screens/synchronization_logs_screen.dart';
import 'screens/unlock_screen.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
final ThemeData theme = ThemeData(
fontFamily: 'Roboto',
colorScheme: PassyTheme.theme.colorScheme,
snackBarTheme: PassyTheme.theme.snackBarTheme,
scaffoldBackgroundColor: PassyTheme.theme.scaffoldBackgroundColor,
inputDecorationTheme: PassyTheme.theme.inputDecorationTheme,
elevatedButtonTheme: PassyTheme.theme.elevatedButtonTheme,
textSelectionTheme: PassyTheme.theme.textSelectionTheme,
);
void main() {
KdbxDargon2().initialize(KdbxDargon2Platform.flutter);
DArgon2Flutter.init();
runApp(const Passy());
}
@pragma('vm:entry-point')
void autofillEntryPoint() {
isAutofill = true;
runApp(MaterialApp(
title: 'Passy',
theme: theme,
navigatorKey: navigatorKey,
navigatorObservers: [
routeObserver,
],
routes: {
AutofillSplashScreen.routeName: (context) => const AutofillSplashScreen(),
EditPasswordScreen.routeName: (context) => const EditPasswordScreen(),
LogScreen.routeName: (context) => const LogScreen(),
LoginScreen.routeName: (context) => const LoginScreen(),
NoAccountsScreen.routeName: (context) => const NoAccountsScreen(),
SearchScreen.routeName: (context) => const SearchScreen(),
UnlockScreen.routeName: (context) => const UnlockScreen(),
},
localizationsDelegates: const [
AppLocalizations.delegate, // Add this line
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
// LOCALIZATION TEST
//locale: const Locale('it'),
supportedLocales: supportedLocales,
));
}
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
class Passy extends StatelessWidget {
const Passy({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
if (Platform.isAndroid || Platform.isIOS) {
AutofillService().setPreferences(AutofillPreferences(
enableDebug: false,
enableSaving: false,
));
}
return MaterialApp(
title: 'Passy',
theme: theme,
navigatorKey: navigatorKey,
navigatorObservers: [
routeObserver,
],
routes: {
AddAccountScreen.routeName: (context) => const AddAccountScreen(),
AddFileScreen.routeName: (context) => const AddFileScreen(),
AutomaticBackupScreen.routeName: (context) =>
const AutomaticBackupScreen(),
BackupAndRestoreScreen.routeName: (context) =>
const BackupAndRestoreScreen(),
BiometricAuthScreen.routeName: (context) => const BiometricAuthScreen(),
ChangePasswordScreen.routeName: (context) =>
const ChangePasswordScreen(),
ChangeUsernameScreen.routeName: (context) =>
const ChangeUsernameScreen(),
ConfirmImportScreen.routeName: (context) => const ConfirmImportScreen(),
ConfirmKdbxExportScreen.routeName: (context) =>
const ConfirmKdbxExportScreen(),
ConfirmRestoreScreen.routeName: (context) =>
const ConfirmRestoreScreen(),
ConnectScreen.routeName: (context) => const ConnectScreen(),
CredentialsScreen.routeName: (context) => const CredentialsScreen(),
CSVImportScreen.routeName: (context) => const CSVImportScreen(),
CSVImportEntriesScreen.routeName: (context) =>
const CSVImportEntriesScreen(),
EditCustomFieldScreen.routeName: (context) =>
const EditCustomFieldScreen(),
EditIDCardScreen.routeName: (context) => const EditIDCardScreen(),
EditIdentityScreen.routeName: (context) => const EditIdentityScreen(),
EditNoteScreen.routeName: (context) => const EditNoteScreen(),
EditPasswordScreen.routeName: (context) => const EditPasswordScreen(),
EditPaymentCardScreen.routeName: (context) =>
const EditPaymentCardScreen(),
ExportAndImportScreen.routeName: (context) =>
const ExportAndImportScreen(),
ExportScreen.routeName: (context) => const ExportScreen(),
FilesScreen.routeName: (context) => const FilesScreen(),
PassyFileScreen.routeName: (context) => const PassyFileScreen(),
GlobalSettingsScreen.routeName: (context) =>
const GlobalSettingsScreen(),
IDCardScreen.routeName: (context) => const IDCardScreen(),
IDCardsScreen.routeName: (context) => const IDCardsScreen(),
IdentitiesScreen.routeName: (context) => const IdentitiesScreen(),
IdentityScreen.routeName: (context) => const IdentityScreen(),
ImportScreen.routeName: (context) => const ImportScreen(),
KeyDerivationScreen.routeName: (context) => const KeyDerivationScreen(),
LogScreen.routeName: (context) => const LogScreen(),
LoginScreen.routeName: (context) => const LoginScreen(),
MainScreen.routeName: (context) => const MainScreen(),
ManageServersScreen.routeName: (context) => const ManageServersScreen(),
NoteScreen.routeName: (context) => const NoteScreen(),
NotesScreen.routeName: (context) => const NotesScreen(),
PasswordScreen.routeName: (context) => const PasswordScreen(),
PasswordsScreen.routeName: (context) => const PasswordsScreen(),
PaymentCardScreen.routeName: (context) => const PaymentCardScreen(),
PaymentCardsScreen.routeName: (context) => const PaymentCardsScreen(),
RemoveAccountScreen.routeName: (context) => const RemoveAccountScreen(),
SearchScreen.routeName: (context) => const SearchScreen(),
SecurityScreen.routeName: (context) => const SecurityScreen(),
ServerConnectScreen.routeName: (context) => const ServerConnectScreen(),
ServerSetupScreen.routeName: (context) => const ServerSetupScreen(),
ServersScreen.routeName: (context) => const ServersScreen(),
SettingsScreen.routeName: (context) => const SettingsScreen(),
SetupScreen.routeName: (context) => const SetupScreen(),
SplashScreen.routeName: (context) => const SplashScreen(),
SynchronizationLogsScreen.routeName: (context) =>
const SynchronizationLogsScreen(),
UnlockScreen.routeName: (context) => const UnlockScreen(),
},
builder: (context, child) {
return Stack(
children: [
child!,
Overlay(
initialEntries: [
OverlayEntry(
builder: (context) => FutureBuilder(
future: Future<String>(() async {
while (SplashScreen.loaded != true) {
await Future.delayed(const Duration(seconds: 1));
}
return '';
}),
builder: (ctx, snapshot) {
if (!snapshot.hasData) return const SizedBox.shrink();
return const UnlockScreen();
},
),
),
],
),
],
);
},
localizationsDelegates: const [
AppLocalizations.delegate, // Add this line
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
// LOCALIZATION TEST
//locale: const Locale('it'),
supportedLocales: supportedLocales,
);
}
}
const List<Locale> supportedLocales = [
Locale('en'),
Locale('it'),
Locale('ru'),
Locale('zh'),
Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant'),
];