2021-09-20 10:08:00 +02:00
|
|
|
import 'package:flutter/gestures.dart';
|
2021-04-10 06:28:12 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
|
|
import 'package:logging/logging.dart';
|
2021-04-17 11:04:46 +02:00
|
|
|
import 'package:nc_photos/event/event.dart';
|
2021-06-23 10:15:25 +02:00
|
|
|
import 'package:nc_photos/language_util.dart' as language_util;
|
2022-04-22 21:09:44 +02:00
|
|
|
import 'package:nc_photos/navigation_manager.dart';
|
2021-04-17 11:04:46 +02:00
|
|
|
import 'package:nc_photos/pref.dart';
|
2021-04-10 06:28:12 +02:00
|
|
|
import 'package:nc_photos/snack_bar_manager.dart';
|
|
|
|
import 'package:nc_photos/theme.dart';
|
2021-07-31 19:16:14 +02:00
|
|
|
import 'package:nc_photos/widget/album_browser.dart';
|
2021-06-29 11:44:35 +02:00
|
|
|
import 'package:nc_photos/widget/album_dir_picker.dart';
|
2021-07-01 13:32:22 +02:00
|
|
|
import 'package:nc_photos/widget/album_importer.dart';
|
2021-12-10 19:44:56 +01:00
|
|
|
import 'package:nc_photos/widget/album_picker.dart';
|
2021-10-18 11:26:50 +02:00
|
|
|
import 'package:nc_photos/widget/album_share_outlier_browser.dart';
|
2021-07-31 19:02:41 +02:00
|
|
|
import 'package:nc_photos/widget/archive_browser.dart';
|
2021-04-10 06:28:12 +02:00
|
|
|
import 'package:nc_photos/widget/connect.dart';
|
2021-07-31 19:16:14 +02:00
|
|
|
import 'package:nc_photos/widget/dynamic_album_browser.dart';
|
2022-05-06 11:16:56 +02:00
|
|
|
import 'package:nc_photos/widget/enhanced_photo_browser.dart';
|
2022-01-25 11:08:13 +01:00
|
|
|
import 'package:nc_photos/widget/favorite_browser.dart';
|
2021-04-10 06:28:12 +02:00
|
|
|
import 'package:nc_photos/widget/home.dart';
|
2022-05-06 11:16:56 +02:00
|
|
|
import 'package:nc_photos/widget/local_file_viewer.dart';
|
2021-09-08 12:44:14 +02:00
|
|
|
import 'package:nc_photos/widget/people_browser.dart';
|
|
|
|
import 'package:nc_photos/widget/person_browser.dart';
|
2021-04-10 06:28:12 +02:00
|
|
|
import 'package:nc_photos/widget/root_picker.dart';
|
|
|
|
import 'package:nc_photos/widget/settings.dart';
|
|
|
|
import 'package:nc_photos/widget/setup.dart';
|
2021-10-21 18:33:21 +02:00
|
|
|
import 'package:nc_photos/widget/share_folder_picker.dart';
|
2021-10-06 22:32:36 +02:00
|
|
|
import 'package:nc_photos/widget/shared_file_viewer.dart';
|
|
|
|
import 'package:nc_photos/widget/sharing_browser.dart';
|
2021-04-10 06:28:12 +02:00
|
|
|
import 'package:nc_photos/widget/sign_in.dart';
|
2021-09-14 23:00:24 +02:00
|
|
|
import 'package:nc_photos/widget/slideshow_viewer.dart';
|
2022-01-15 11:35:15 +01:00
|
|
|
import 'package:nc_photos/widget/smart_album_browser.dart';
|
2021-04-10 06:28:12 +02:00
|
|
|
import 'package:nc_photos/widget/splash.dart';
|
2021-08-01 22:46:16 +02:00
|
|
|
import 'package:nc_photos/widget/trashbin_browser.dart';
|
|
|
|
import 'package:nc_photos/widget/trashbin_viewer.dart';
|
2021-04-10 06:28:12 +02:00
|
|
|
import 'package:nc_photos/widget/viewer.dart';
|
|
|
|
|
2021-04-17 11:04:46 +02:00
|
|
|
class MyApp extends StatefulWidget {
|
2021-09-15 08:58:06 +02:00
|
|
|
const MyApp({
|
|
|
|
Key? key,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
2021-04-17 11:04:46 +02:00
|
|
|
@override
|
|
|
|
createState() => _MyAppState();
|
2021-07-11 06:48:50 +02:00
|
|
|
|
|
|
|
static RouteObserver get routeObserver => _routeObserver;
|
|
|
|
|
2021-08-29 13:51:43 +02:00
|
|
|
static BuildContext get globalContext => _globalContext;
|
|
|
|
|
2021-07-11 06:48:50 +02:00
|
|
|
static final _routeObserver = RouteObserver<PageRoute>();
|
2021-08-29 13:51:43 +02:00
|
|
|
static late BuildContext _globalContext;
|
2021-04-17 11:04:46 +02:00
|
|
|
}
|
|
|
|
|
2022-04-22 21:09:44 +02:00
|
|
|
class _MyAppState extends State<MyApp>
|
|
|
|
implements SnackBarHandler, NavigationHandler {
|
2021-04-17 11:04:46 +02:00
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
2021-04-10 06:28:12 +02:00
|
|
|
SnackBarManager().registerHandler(this);
|
2022-04-22 21:09:44 +02:00
|
|
|
NavigationManager().setHandler(this);
|
2021-04-17 11:04:46 +02:00
|
|
|
_themeChangedListener =
|
|
|
|
AppEventListener<ThemeChangedEvent>(_onThemeChangedEvent)..begin();
|
2021-06-23 10:15:25 +02:00
|
|
|
_langChangedListener =
|
|
|
|
AppEventListener<LanguageChangedEvent>(_onLangChangedEvent)..begin();
|
2021-04-10 06:28:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
build(BuildContext context) {
|
2021-08-30 18:57:45 +02:00
|
|
|
final ThemeMode themeMode;
|
2021-10-27 22:40:54 +02:00
|
|
|
if (Pref().isFollowSystemThemeOr(false)) {
|
2021-08-30 18:57:45 +02:00
|
|
|
themeMode = ThemeMode.system;
|
|
|
|
} else {
|
|
|
|
themeMode =
|
2021-10-27 22:40:54 +02:00
|
|
|
Pref().isDarkThemeOr(false) ? ThemeMode.dark : ThemeMode.light;
|
2021-08-30 18:57:45 +02:00
|
|
|
}
|
2021-04-10 06:28:12 +02:00
|
|
|
return MaterialApp(
|
2021-08-29 13:51:43 +02:00
|
|
|
onGenerateTitle: (context) => AppLocalizations.of(context)!.appTitle,
|
2022-07-22 18:48:10 +02:00
|
|
|
theme: AppTheme.buildLightThemeData(),
|
|
|
|
darkTheme: AppTheme.buildDarkThemeData(),
|
2021-08-30 18:57:45 +02:00
|
|
|
themeMode: themeMode,
|
2021-04-10 06:28:12 +02:00
|
|
|
initialRoute: Splash.routeName,
|
|
|
|
onGenerateRoute: _onGenerateRoute,
|
2021-07-11 06:48:50 +02:00
|
|
|
navigatorObservers: <NavigatorObserver>[MyApp.routeObserver],
|
2022-04-22 21:09:44 +02:00
|
|
|
navigatorKey: _navigatorKey,
|
2021-04-10 06:28:12 +02:00
|
|
|
scaffoldMessengerKey: _scaffoldMessengerKey,
|
2021-08-29 10:30:37 +02:00
|
|
|
locale: language_util.getSelectedLocale(),
|
2021-04-10 06:28:12 +02:00
|
|
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
2021-09-15 08:58:06 +02:00
|
|
|
supportedLocales: const <Locale>[
|
2021-09-12 23:26:38 +02:00
|
|
|
// the order here doesn't matter, except for the first one, which must
|
|
|
|
// be en
|
2021-08-10 10:04:13 +02:00
|
|
|
Locale("en"),
|
|
|
|
Locale("el"),
|
|
|
|
Locale("es"),
|
|
|
|
Locale("fr"),
|
2021-08-22 23:02:58 +02:00
|
|
|
Locale("ru"),
|
2021-09-12 23:26:38 +02:00
|
|
|
Locale("de"),
|
2021-10-01 21:39:36 +02:00
|
|
|
Locale("cs"),
|
2022-01-05 21:31:29 +01:00
|
|
|
Locale("fi"),
|
2022-01-22 12:20:49 +01:00
|
|
|
Locale("pl"),
|
2022-04-18 21:47:15 +02:00
|
|
|
Locale("pt"),
|
2022-05-14 08:46:31 +02:00
|
|
|
Locale.fromSubtags(languageCode: "zh", scriptCode: "Hans"),
|
|
|
|
Locale.fromSubtags(languageCode: "zh", scriptCode: "Hant"),
|
2021-08-10 10:04:13 +02:00
|
|
|
],
|
2021-08-29 13:51:43 +02:00
|
|
|
builder: (context, child) {
|
|
|
|
MyApp._globalContext = context;
|
|
|
|
return child!;
|
|
|
|
},
|
2021-04-10 06:28:12 +02:00
|
|
|
debugShowCheckedModeBanner: false,
|
2021-09-20 10:08:00 +02:00
|
|
|
scrollBehavior: const _MyScrollBehavior(),
|
2021-04-10 06:28:12 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-04-17 11:04:46 +02:00
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
super.dispose();
|
|
|
|
SnackBarManager().unregisterHandler(this);
|
2022-04-22 21:09:44 +02:00
|
|
|
NavigationManager().unsetHandler(this);
|
2021-04-17 11:04:46 +02:00
|
|
|
_themeChangedListener.end();
|
2021-06-23 10:15:25 +02:00
|
|
|
_langChangedListener.end();
|
2021-04-17 11:04:46 +02:00
|
|
|
}
|
|
|
|
|
2021-04-10 06:28:12 +02:00
|
|
|
@override
|
|
|
|
showSnackBar(SnackBar snackBar) =>
|
|
|
|
_scaffoldMessengerKey.currentState?.showSnackBar(snackBar);
|
|
|
|
|
2022-04-22 21:09:44 +02:00
|
|
|
@override
|
|
|
|
getNavigator() => _navigatorKey.currentState;
|
|
|
|
|
2021-04-10 06:28:12 +02:00
|
|
|
Map<String, WidgetBuilder> _getRouter() => {
|
2021-09-15 08:58:06 +02:00
|
|
|
Setup.routeName: (context) => const Setup(),
|
|
|
|
SignIn.routeName: (context) => const SignIn(),
|
|
|
|
Splash.routeName: (context) => const Splash(),
|
2021-04-10 06:28:12 +02:00
|
|
|
};
|
|
|
|
|
2021-07-23 22:05:57 +02:00
|
|
|
Route<dynamic>? _onGenerateRoute(RouteSettings settings) {
|
2021-04-10 06:28:12 +02:00
|
|
|
_log.info("[_onGenerateRoute] Route: ${settings.name}");
|
2021-07-23 22:05:57 +02:00
|
|
|
Route<dynamic>? route;
|
2021-04-10 06:28:12 +02:00
|
|
|
route ??= _handleBasicRoute(settings);
|
|
|
|
route ??= _handleViewerRoute(settings);
|
|
|
|
route ??= _handleConnectRoute(settings);
|
|
|
|
route ??= _handleHomeRoute(settings);
|
|
|
|
route ??= _handleRootPickerRoute(settings);
|
2021-07-31 19:16:14 +02:00
|
|
|
route ??= _handleAlbumBrowserRoute(settings);
|
2021-04-10 06:28:12 +02:00
|
|
|
route ??= _handleSettingsRoute(settings);
|
2021-07-31 19:02:41 +02:00
|
|
|
route ??= _handleArchiveBrowserRoute(settings);
|
2021-07-31 19:16:14 +02:00
|
|
|
route ??= _handleDynamicAlbumBrowserRoute(settings);
|
2021-06-29 11:44:35 +02:00
|
|
|
route ??= _handleAlbumDirPickerRoute(settings);
|
2021-07-01 13:32:22 +02:00
|
|
|
route ??= _handleAlbumImporterRoute(settings);
|
2021-08-01 22:46:16 +02:00
|
|
|
route ??= _handleTrashbinBrowserRoute(settings);
|
|
|
|
route ??= _handleTrashbinViewerRoute(settings);
|
2021-09-08 12:44:14 +02:00
|
|
|
route ??= _handlePeopleBrowserRoute(settings);
|
|
|
|
route ??= _handlePersonBrowserRoute(settings);
|
2021-09-14 23:00:24 +02:00
|
|
|
route ??= _handleSlideshowViewerRoute(settings);
|
2021-10-06 22:32:36 +02:00
|
|
|
route ??= _handleSharingBrowserRoute(settings);
|
|
|
|
route ??= _handleSharedFileViewerRoute(settings);
|
2021-10-18 11:26:50 +02:00
|
|
|
route ??= _handleAlbumShareOutlierBrowserRoute(settings);
|
2021-10-19 22:11:35 +02:00
|
|
|
route ??= _handleAccountSettingsRoute(settings);
|
2021-10-21 18:33:21 +02:00
|
|
|
route ??= _handleShareFolderPickerRoute(settings);
|
2021-12-10 19:44:56 +01:00
|
|
|
route ??= _handleAlbumPickerRoute(settings);
|
2022-01-15 11:35:15 +01:00
|
|
|
route ??= _handleSmartAlbumBrowserRoute(settings);
|
2022-01-25 11:08:13 +01:00
|
|
|
route ??= _handleFavoriteBrowserRoute(settings);
|
2022-05-06 11:16:56 +02:00
|
|
|
route ??= _handleEnhancedPhotoBrowserRoute(settings);
|
|
|
|
route ??= _handleLocalFileViewerRoute(settings);
|
2022-05-14 16:10:05 +02:00
|
|
|
route ??= _handleEnhancementSettingsRoute(settings);
|
2021-04-10 06:28:12 +02:00
|
|
|
return route;
|
|
|
|
}
|
|
|
|
|
2021-04-17 11:04:46 +02:00
|
|
|
void _onThemeChangedEvent(ThemeChangedEvent ev) {
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
|
2021-06-23 10:15:25 +02:00
|
|
|
void _onLangChangedEvent(LanguageChangedEvent ev) {
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
|
2021-07-23 22:05:57 +02:00
|
|
|
Route<dynamic>? _handleBasicRoute(RouteSettings settings) {
|
2021-04-10 06:28:12 +02:00
|
|
|
for (final e in _getRouter().entries) {
|
|
|
|
if (e.key == settings.name) {
|
|
|
|
return MaterialPageRoute(
|
|
|
|
builder: e.value,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-07-23 22:05:57 +02:00
|
|
|
Route<dynamic>? _handleViewerRoute(RouteSettings settings) {
|
2021-04-10 06:28:12 +02:00
|
|
|
try {
|
|
|
|
if (settings.name == Viewer.routeName && settings.arguments != null) {
|
2021-07-23 22:05:57 +02:00
|
|
|
final args = settings.arguments as ViewerArguments;
|
|
|
|
return Viewer.buildRoute(args);
|
2021-04-10 06:28:12 +02:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe("[_handleViewerRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-07-23 22:05:57 +02:00
|
|
|
Route<dynamic>? _handleConnectRoute(RouteSettings settings) {
|
2021-04-10 06:28:12 +02:00
|
|
|
try {
|
|
|
|
if (settings.name == Connect.routeName && settings.arguments != null) {
|
2021-07-23 22:05:57 +02:00
|
|
|
final args = settings.arguments as ConnectArguments;
|
|
|
|
return Connect.buildRoute(args);
|
2021-04-10 06:28:12 +02:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe("[_handleConnectRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-07-23 22:05:57 +02:00
|
|
|
Route<dynamic>? _handleHomeRoute(RouteSettings settings) {
|
2021-04-10 06:28:12 +02:00
|
|
|
try {
|
|
|
|
if (settings.name == Home.routeName && settings.arguments != null) {
|
2021-07-23 22:05:57 +02:00
|
|
|
final args = settings.arguments as HomeArguments;
|
|
|
|
return Home.buildRoute(args);
|
2021-04-10 06:28:12 +02:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe("[_handleHomeRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-07-23 22:05:57 +02:00
|
|
|
Route<dynamic>? _handleRootPickerRoute(RouteSettings settings) {
|
2021-04-10 06:28:12 +02:00
|
|
|
try {
|
|
|
|
if (settings.name == RootPicker.routeName && settings.arguments != null) {
|
2021-07-23 22:05:57 +02:00
|
|
|
final args = settings.arguments as RootPickerArguments;
|
|
|
|
return RootPicker.buildRoute(args);
|
2021-04-10 06:28:12 +02:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe("[_handleRootPickerRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-07-31 19:16:14 +02:00
|
|
|
Route<dynamic>? _handleAlbumBrowserRoute(RouteSettings settings) {
|
2021-04-10 06:28:12 +02:00
|
|
|
try {
|
2021-07-31 19:16:14 +02:00
|
|
|
if (settings.name == AlbumBrowser.routeName &&
|
2021-04-10 06:28:12 +02:00
|
|
|
settings.arguments != null) {
|
2021-07-31 19:16:14 +02:00
|
|
|
final args = settings.arguments as AlbumBrowserArguments;
|
|
|
|
return AlbumBrowser.buildRoute(args);
|
2021-04-10 06:28:12 +02:00
|
|
|
}
|
|
|
|
} catch (e) {
|
2021-07-31 19:16:14 +02:00
|
|
|
_log.severe("[_handleAlbumBrowserRoute] Failed while handling route", e);
|
2021-04-10 06:28:12 +02:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-07-23 22:05:57 +02:00
|
|
|
Route<dynamic>? _handleSettingsRoute(RouteSettings settings) {
|
2021-04-10 06:28:12 +02:00
|
|
|
try {
|
|
|
|
if (settings.name == Settings.routeName && settings.arguments != null) {
|
2021-07-23 22:05:57 +02:00
|
|
|
final args = settings.arguments as SettingsArguments;
|
|
|
|
return Settings.buildRoute(args);
|
2021-04-10 06:28:12 +02:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe("[_handleSettingsRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-07-31 19:02:41 +02:00
|
|
|
Route<dynamic>? _handleArchiveBrowserRoute(RouteSettings settings) {
|
2021-05-28 21:44:09 +02:00
|
|
|
try {
|
2021-07-31 19:02:41 +02:00
|
|
|
if (settings.name == ArchiveBrowser.routeName &&
|
2021-05-28 21:44:09 +02:00
|
|
|
settings.arguments != null) {
|
2021-07-31 19:02:41 +02:00
|
|
|
final args = settings.arguments as ArchiveBrowserArguments;
|
|
|
|
return ArchiveBrowser.buildRoute(args);
|
2021-05-28 21:44:09 +02:00
|
|
|
}
|
|
|
|
} catch (e) {
|
2021-07-31 19:02:41 +02:00
|
|
|
_log.severe(
|
|
|
|
"[_handleArchiveBrowserRoute] Failed while handling route", e);
|
2021-05-28 21:44:09 +02:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-07-31 19:16:14 +02:00
|
|
|
Route<dynamic>? _handleDynamicAlbumBrowserRoute(RouteSettings settings) {
|
2021-06-26 16:28:21 +02:00
|
|
|
try {
|
2021-07-31 19:16:14 +02:00
|
|
|
if (settings.name == DynamicAlbumBrowser.routeName &&
|
2021-06-26 16:28:21 +02:00
|
|
|
settings.arguments != null) {
|
2021-07-31 19:16:14 +02:00
|
|
|
final args = settings.arguments as DynamicAlbumBrowserArguments;
|
|
|
|
return DynamicAlbumBrowser.buildRoute(args);
|
2021-06-26 16:28:21 +02:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe(
|
2021-07-31 19:16:14 +02:00
|
|
|
"[_handleDynamicAlbumBrowserRoute] Failed while handling route", e);
|
2021-06-26 16:28:21 +02:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-07-23 22:05:57 +02:00
|
|
|
Route<dynamic>? _handleAlbumDirPickerRoute(RouteSettings settings) {
|
2021-06-29 11:44:35 +02:00
|
|
|
try {
|
|
|
|
if (settings.name == AlbumDirPicker.routeName &&
|
|
|
|
settings.arguments != null) {
|
2021-07-23 22:05:57 +02:00
|
|
|
final args = settings.arguments as AlbumDirPickerArguments;
|
|
|
|
return AlbumDirPicker.buildRoute(args);
|
2021-06-29 11:44:35 +02:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe(
|
|
|
|
"[_handleAlbumDirPickerRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-07-23 22:05:57 +02:00
|
|
|
Route<dynamic>? _handleAlbumImporterRoute(RouteSettings settings) {
|
2021-07-01 13:32:22 +02:00
|
|
|
try {
|
|
|
|
if (settings.name == AlbumImporter.routeName &&
|
|
|
|
settings.arguments != null) {
|
2021-07-23 22:05:57 +02:00
|
|
|
final args = settings.arguments as AlbumImporterArguments;
|
|
|
|
return AlbumImporter.buildRoute(args);
|
2021-07-01 13:32:22 +02:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe("[_handleAlbumImporterRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-08-01 22:46:16 +02:00
|
|
|
Route<dynamic>? _handleTrashbinBrowserRoute(RouteSettings settings) {
|
|
|
|
try {
|
|
|
|
if (settings.name == TrashbinBrowser.routeName &&
|
|
|
|
settings.arguments != null) {
|
|
|
|
final args = settings.arguments as TrashbinBrowserArguments;
|
|
|
|
return TrashbinBrowser.buildRoute(args);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe(
|
|
|
|
"[_handleTrashbinBrowserRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
Route<dynamic>? _handleTrashbinViewerRoute(RouteSettings settings) {
|
|
|
|
try {
|
|
|
|
if (settings.name == TrashbinViewer.routeName &&
|
|
|
|
settings.arguments != null) {
|
|
|
|
final args = settings.arguments as TrashbinViewerArguments;
|
|
|
|
return TrashbinViewer.buildRoute(args);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe(
|
|
|
|
"[_handleTrashbinViewerRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-09-08 12:44:14 +02:00
|
|
|
Route<dynamic>? _handlePeopleBrowserRoute(RouteSettings settings) {
|
|
|
|
try {
|
|
|
|
if (settings.name == PeopleBrowser.routeName &&
|
|
|
|
settings.arguments != null) {
|
|
|
|
final args = settings.arguments as PeopleBrowserArguments;
|
|
|
|
return PeopleBrowser.buildRoute(args);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe("[_handlePeopleBrowserRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
Route<dynamic>? _handlePersonBrowserRoute(RouteSettings settings) {
|
|
|
|
try {
|
|
|
|
if (settings.name == PersonBrowser.routeName &&
|
|
|
|
settings.arguments != null) {
|
|
|
|
final args = settings.arguments as PersonBrowserArguments;
|
|
|
|
return PersonBrowser.buildRoute(args);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe("[_handlePersonBrowserRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-09-14 23:00:24 +02:00
|
|
|
Route<dynamic>? _handleSlideshowViewerRoute(RouteSettings settings) {
|
|
|
|
try {
|
|
|
|
if (settings.name == SlideshowViewer.routeName &&
|
|
|
|
settings.arguments != null) {
|
|
|
|
final args = settings.arguments as SlideshowViewerArguments;
|
|
|
|
return SlideshowViewer.buildRoute(args);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe(
|
|
|
|
"[_handleSlideshowViewerRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-10-06 22:32:36 +02:00
|
|
|
Route<dynamic>? _handleSharingBrowserRoute(RouteSettings settings) {
|
|
|
|
try {
|
|
|
|
if (settings.name == SharingBrowser.routeName &&
|
|
|
|
settings.arguments != null) {
|
|
|
|
final args = settings.arguments as SharingBrowserArguments;
|
|
|
|
return SharingBrowser.buildRoute(args);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe(
|
|
|
|
"[_handleSharingBrowserRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
Route<dynamic>? _handleSharedFileViewerRoute(RouteSettings settings) {
|
|
|
|
try {
|
|
|
|
if (settings.name == SharedFileViewer.routeName &&
|
|
|
|
settings.arguments != null) {
|
|
|
|
final args = settings.arguments as SharedFileViewerArguments;
|
|
|
|
return SharedFileViewer.buildRoute(args);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe(
|
|
|
|
"[_handleSharedFileViewerRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-10-18 11:26:50 +02:00
|
|
|
Route<dynamic>? _handleAlbumShareOutlierBrowserRoute(RouteSettings settings) {
|
|
|
|
try {
|
|
|
|
if (settings.name == AlbumShareOutlierBrowser.routeName &&
|
|
|
|
settings.arguments != null) {
|
|
|
|
final args = settings.arguments as AlbumShareOutlierBrowserArguments;
|
|
|
|
return AlbumShareOutlierBrowser.buildRoute(args);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe(
|
|
|
|
"[_handleAlbumShareOutlierBrowserRoute] Failed while handling route",
|
|
|
|
e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-10-19 22:11:35 +02:00
|
|
|
Route<dynamic>? _handleAccountSettingsRoute(RouteSettings settings) {
|
|
|
|
try {
|
|
|
|
if (settings.name == AccountSettingsWidget.routeName &&
|
|
|
|
settings.arguments != null) {
|
|
|
|
final args = settings.arguments as AccountSettingsWidgetArguments;
|
|
|
|
return AccountSettingsWidget.buildRoute(args);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe(
|
|
|
|
"[_handleAccountSettingsRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-10-21 18:33:21 +02:00
|
|
|
Route<dynamic>? _handleShareFolderPickerRoute(RouteSettings settings) {
|
|
|
|
try {
|
|
|
|
if (settings.name == ShareFolderPicker.routeName &&
|
|
|
|
settings.arguments != null) {
|
|
|
|
final args = settings.arguments as ShareFolderPickerArguments;
|
|
|
|
return ShareFolderPicker.buildRoute(args);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe(
|
|
|
|
"[_handleShareFolderPickerRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-12-10 19:44:56 +01:00
|
|
|
Route<dynamic>? _handleAlbumPickerRoute(RouteSettings settings) {
|
|
|
|
try {
|
|
|
|
if (settings.name == AlbumPicker.routeName &&
|
|
|
|
settings.arguments != null) {
|
|
|
|
final args = settings.arguments as AlbumPickerArguments;
|
|
|
|
return AlbumPicker.buildRoute(args);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe("[_handleAlbumPickerRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-01-15 11:35:15 +01:00
|
|
|
Route<dynamic>? _handleSmartAlbumBrowserRoute(RouteSettings settings) {
|
|
|
|
try {
|
|
|
|
if (settings.name == SmartAlbumBrowser.routeName &&
|
|
|
|
settings.arguments != null) {
|
|
|
|
final args = settings.arguments as SmartAlbumBrowserArguments;
|
|
|
|
return SmartAlbumBrowser.buildRoute(args);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe(
|
|
|
|
"[_handleSmartAlbumBrowserRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-01-25 11:08:13 +01:00
|
|
|
Route<dynamic>? _handleFavoriteBrowserRoute(RouteSettings settings) {
|
|
|
|
try {
|
|
|
|
if (settings.name == FavoriteBrowser.routeName &&
|
|
|
|
settings.arguments != null) {
|
|
|
|
final args = settings.arguments as FavoriteBrowserArguments;
|
|
|
|
return FavoriteBrowser.buildRoute(args);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe(
|
|
|
|
"[_handleFavoriteBrowserRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-05-06 11:16:56 +02:00
|
|
|
Route<dynamic>? _handleEnhancedPhotoBrowserRoute(RouteSettings settings) {
|
|
|
|
try {
|
|
|
|
if (settings.name == EnhancedPhotoBrowser.routeName &&
|
|
|
|
settings.arguments != null) {
|
|
|
|
final args = settings.arguments as EnhancedPhotoBrowserArguments;
|
|
|
|
return EnhancedPhotoBrowser.buildRoute(args);
|
2022-05-06 11:44:54 +02:00
|
|
|
} else if (settings.name
|
|
|
|
?.startsWith("${EnhancedPhotoBrowser.routeName}?") ==
|
|
|
|
true) {
|
|
|
|
final queries = Uri.parse(settings.name!).queryParameters;
|
|
|
|
final args = EnhancedPhotoBrowserArguments(queries["filename"]);
|
|
|
|
return EnhancedPhotoBrowser.buildRoute(args);
|
2022-05-06 11:16:56 +02:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe(
|
|
|
|
"[_handleEnhancedPhotoBrowserRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
Route<dynamic>? _handleLocalFileViewerRoute(RouteSettings settings) {
|
|
|
|
try {
|
|
|
|
if (settings.name == LocalFileViewer.routeName &&
|
|
|
|
settings.arguments != null) {
|
|
|
|
final args = settings.arguments as LocalFileViewerArguments;
|
|
|
|
return LocalFileViewer.buildRoute(args);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe(
|
|
|
|
"[_handleLocalFileViewerRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-05-14 16:10:05 +02:00
|
|
|
Route<dynamic>? _handleEnhancementSettingsRoute(RouteSettings settings) {
|
|
|
|
try {
|
|
|
|
if (settings.name == EnhancementSettings.routeName) {
|
|
|
|
return EnhancementSettings.buildRoute();
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_log.severe(
|
|
|
|
"[_handleEnhancementSettingsRoute] Failed while handling route", e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-04-10 06:28:12 +02:00
|
|
|
final _scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
|
2022-04-22 21:09:44 +02:00
|
|
|
final _navigatorKey = GlobalKey<NavigatorState>();
|
2021-04-10 06:28:12 +02:00
|
|
|
|
2021-07-23 22:05:57 +02:00
|
|
|
late AppEventListener<ThemeChangedEvent> _themeChangedListener;
|
|
|
|
late AppEventListener<LanguageChangedEvent> _langChangedListener;
|
2021-04-17 11:04:46 +02:00
|
|
|
|
|
|
|
static final _log = Logger("widget.my_app.MyAppState");
|
2021-04-10 06:28:12 +02:00
|
|
|
}
|
2021-09-20 10:08:00 +02:00
|
|
|
|
|
|
|
class _MyScrollBehavior extends MaterialScrollBehavior {
|
|
|
|
const _MyScrollBehavior();
|
|
|
|
|
|
|
|
@override
|
|
|
|
get dragDevices => {
|
2021-10-06 23:17:19 +02:00
|
|
|
PointerDeviceKind.touch,
|
|
|
|
PointerDeviceKind.stylus,
|
|
|
|
PointerDeviceKind.invertedStylus,
|
|
|
|
PointerDeviceKind.mouse,
|
|
|
|
};
|
2021-09-20 10:08:00 +02:00
|
|
|
}
|