mirror of
https://github.com/jagandeepbrar/lunasea.git
synced 2026-08-30 20:24:25 +00:00
chore: refactor and move some system services
This commit is contained in:
@@ -12,7 +12,7 @@ targets:
|
||||
exclude:
|
||||
- lib
|
||||
include:
|
||||
- lib/system/build/environment.dart
|
||||
- lib/system/environment.dart
|
||||
# Hive
|
||||
hive_generator:
|
||||
enabled: true
|
||||
|
||||
@@ -4,7 +4,6 @@ export 'core/database.dart';
|
||||
export 'core/dialogs.dart';
|
||||
export 'core/extensions.dart';
|
||||
export 'core/firebase.dart';
|
||||
export 'core/mixins.dart';
|
||||
export 'core/models.dart';
|
||||
export 'core/modules.dart';
|
||||
export 'core/pages.dart';
|
||||
@@ -12,9 +11,9 @@ export 'core/router.dart';
|
||||
export 'core/services.dart';
|
||||
export 'core/state.dart';
|
||||
export 'core/system.dart';
|
||||
export 'core/ui.dart';
|
||||
export 'core/utilities.dart';
|
||||
|
||||
export 'ui/ui.dart';
|
||||
export 'vendor.dart'
|
||||
hide
|
||||
StreamProvider,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||
|
||||
import '../../../system/platform.dart';
|
||||
import '../../../../system/platform.dart';
|
||||
import '../image_cache.dart';
|
||||
|
||||
bool isPlatformSupported() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:lunasea/core.dart';
|
||||
|
||||
import '../system/platform.dart';
|
||||
import '../../system/platform.dart';
|
||||
|
||||
class Database {
|
||||
static const String _DATABASE_LEGACY_PATH = 'database';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import '../../firebase_options.dart';
|
||||
import '../system/platform.dart';
|
||||
import '../../system/platform.dart';
|
||||
|
||||
class LunaFirebase {
|
||||
static bool get isSupported {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
|
||||
import '../system/platform.dart';
|
||||
import '../../system/platform.dart';
|
||||
|
||||
class LunaFirebaseMessaging {
|
||||
static const _VAPID_KEY =
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
|
||||
import '../../../system/build/environment.dart';
|
||||
import '../../../system/build/flavor.dart';
|
||||
import '../../../system/environment.dart';
|
||||
import '../../../system/flavor.dart';
|
||||
|
||||
part 'log_type.g.dart';
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ import '../modules/dashboard/core/database.dart';
|
||||
import '../modules/dashboard/core/state.dart' as dashboard_state;
|
||||
import '../modules/dashboard/routes/dashboard/route.dart' as dashboard_home;
|
||||
import '../modules/wake_on_lan/api/wake_on_lan.dart';
|
||||
import '../system/build/environment.dart';
|
||||
import '../system/build/flavor.dart';
|
||||
import '../system/environment.dart';
|
||||
import '../system/flavor.dart';
|
||||
|
||||
part 'modules.g.dart';
|
||||
|
||||
@@ -542,7 +542,7 @@ extension LunaModuleExtension on LunaModule {
|
||||
}
|
||||
|
||||
/// Return the [ShortcutItem] for the module.
|
||||
ShortcutItem? get shortcutItem {
|
||||
ShortcutItem get shortcutItem {
|
||||
switch (this) {
|
||||
case LunaModule.DASHBOARD:
|
||||
return ShortcutItem(type: key, localizedTitle: name);
|
||||
@@ -565,7 +565,7 @@ extension LunaModuleExtension on LunaModule {
|
||||
case LunaModule.OVERSEERR:
|
||||
return ShortcutItem(type: key, localizedTitle: name);
|
||||
case LunaModule.WAKE_ON_LAN:
|
||||
return null;
|
||||
throw Exception('WAKE_ON_LAN does not have a shortcut item');
|
||||
case LunaModule.EXTERNAL_MODULES:
|
||||
return ShortcutItem(type: key, localizedTitle: name);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
export 'system/configuration.dart';
|
||||
export 'system/in_app_purchases.dart';
|
||||
export 'system/localization.dart';
|
||||
export 'system/profile.dart';
|
||||
export 'system/quick_actions.dart';
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:in_app_purchase/in_app_purchase.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
|
||||
import 'platform.dart';
|
||||
import '../../system/platform.dart';
|
||||
|
||||
extension ProductDetailsExtension on ProductDetails {
|
||||
IconData get icon {
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import 'platform/networking_stub.dart'
|
||||
if (dart.library.io) 'platform/networking_io.dart'
|
||||
if (dart.library.html) 'platform/networking_html.dart';
|
||||
|
||||
abstract class LunaNetworking {
|
||||
static bool get isSupported => isPlatformSupported();
|
||||
factory LunaNetworking() => getNetworking();
|
||||
|
||||
void initialize();
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import '../networking.dart';
|
||||
|
||||
bool isPlatformSupported() => false;
|
||||
LunaNetworking getNetworking() =>
|
||||
throw UnsupportedError('LunaNetworking unsupported');
|
||||
@@ -1,5 +0,0 @@
|
||||
import '../networking.dart';
|
||||
|
||||
bool isPlatformSupported() => false;
|
||||
LunaNetworking getNetworking() =>
|
||||
throw UnsupportedError('LunaNetworking unsupported');
|
||||
@@ -1,45 +0,0 @@
|
||||
import 'package:lunasea/core.dart';
|
||||
import 'package:quick_actions/quick_actions.dart';
|
||||
|
||||
import 'platform.dart';
|
||||
|
||||
class LunaQuickActions {
|
||||
static const QuickActions _quickActions = QuickActions();
|
||||
|
||||
static bool get isPlatformCompatible => LunaPlatform().isMobile;
|
||||
|
||||
/// Initialize the quick actions by setting the action handler.
|
||||
///
|
||||
/// Required before the handler can actually receive any intents.
|
||||
void initialize() {
|
||||
if (isPlatformCompatible) _quickActions.initialize(_handler);
|
||||
setShortcutItems();
|
||||
}
|
||||
|
||||
/// Sets the shortcut items by checking the database and enabling the respective action if enabled.
|
||||
void setShortcutItems() {
|
||||
if (isPlatformCompatible)
|
||||
_quickActions.setShortcutItems(<ShortcutItem>[
|
||||
if (LunaDatabaseValue.QUICK_ACTIONS_TAUTULLI.data)
|
||||
LunaModule.TAUTULLI.shortcutItem!,
|
||||
if (LunaDatabaseValue.QUICK_ACTIONS_SONARR.data)
|
||||
LunaModule.SONARR.shortcutItem!,
|
||||
if (LunaDatabaseValue.QUICK_ACTIONS_SEARCH.data)
|
||||
LunaModule.SEARCH.shortcutItem!,
|
||||
if (LunaDatabaseValue.QUICK_ACTIONS_SABNZBD.data)
|
||||
LunaModule.SABNZBD.shortcutItem!,
|
||||
if (LunaDatabaseValue.QUICK_ACTIONS_RADARR.data)
|
||||
LunaModule.RADARR.shortcutItem!,
|
||||
if (LunaDatabaseValue.QUICK_ACTIONS_OVERSEERR.data)
|
||||
LunaModule.OVERSEERR.shortcutItem!,
|
||||
if (LunaDatabaseValue.QUICK_ACTIONS_NZBGET.data)
|
||||
LunaModule.NZBGET.shortcutItem!,
|
||||
if (LunaDatabaseValue.QUICK_ACTIONS_LIDARR.data)
|
||||
LunaModule.LIDARR.shortcutItem!,
|
||||
LunaModule.SETTINGS.shortcutItem!,
|
||||
]);
|
||||
}
|
||||
|
||||
/// The actual shortcut command handler
|
||||
void _handler(String action) => LunaModule.LIDARR.fromKey(action)?.launch();
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
|
||||
import '../../system/build/environment.dart';
|
||||
import '../../system/build/flavor.dart';
|
||||
import '../../system/environment.dart';
|
||||
import '../../system/flavor.dart';
|
||||
|
||||
class LunaChangelogSheet extends LunaBottomModalSheet {
|
||||
late _Changelog _changelog;
|
||||
|
||||
@@ -6,9 +6,11 @@ import 'package:flutter/scheduler.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
|
||||
import 'core/cache/image_cache/image_cache.dart';
|
||||
import 'core/system/networking/networking.dart';
|
||||
import 'core/system/window_manager/window_manager.dart';
|
||||
import 'core/system/platform.dart';
|
||||
import 'system/localization.dart';
|
||||
import 'system/network/network.dart';
|
||||
import 'system/quick_actions/quick_actions.dart';
|
||||
import 'system/window_manager/window_manager.dart';
|
||||
import 'system/platform.dart';
|
||||
import 'modules/dashboard/routes/dashboard/route.dart' show HomeRouter;
|
||||
|
||||
/// LunaSea Entry Point: Initialize & Run Application
|
||||
@@ -24,7 +26,7 @@ Future<void> main() async {
|
||||
LunaLogger().initialize();
|
||||
LunaTheme().initialize();
|
||||
if (LunaWindowManager.isSupported) await LunaWindowManager().initialize();
|
||||
if (LunaNetworking.isSupported) LunaNetworking().initialize();
|
||||
if (LunaNetwork.isSupported) LunaNetwork().initialize();
|
||||
if (LunaImageCache.isSupported) LunaImageCache().initialize();
|
||||
LunaRouter().initialize();
|
||||
await LunaInAppPurchases().initialize();
|
||||
@@ -43,7 +45,6 @@ class LunaBIOS extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
LunaLocalization localization = LunaLocalization();
|
||||
LunaTheme theme = LunaTheme();
|
||||
LunaRouter router = LunaRouter();
|
||||
|
||||
@@ -51,10 +52,10 @@ class LunaBIOS extends StatelessWidget {
|
||||
child: DevicePreview(
|
||||
enabled: kDebugMode && LunaPlatform().isDesktop,
|
||||
builder: (context) => EasyLocalization(
|
||||
supportedLocales: localization.supportedLocales as List<Locale>,
|
||||
path: localization.fileDirectory,
|
||||
fallbackLocale: localization.fallbackLocale,
|
||||
startLocale: localization.fallbackLocale,
|
||||
supportedLocales: LunaLocalization().supportedLocales(),
|
||||
path: LunaLocalization.fileDirectory,
|
||||
fallbackLocale: LunaLocalization.fallbackLocale,
|
||||
startLocale: LunaLocalization.fallbackLocale,
|
||||
useFallbackTranslations: true,
|
||||
child: LunaState.providers(
|
||||
child: ValueListenableBuilder(
|
||||
@@ -122,7 +123,7 @@ class _State extends State<LunaOS> {
|
||||
tag ??= LunaLanguage.ENGLISH.languageTag;
|
||||
Intl.defaultLocale = tag;
|
||||
|
||||
LunaQuickActions().initialize();
|
||||
if (LunaQuickActions.isSupported) LunaQuickActions().initialize();
|
||||
LunaChangelogSheet().show(
|
||||
context: LunaState.navigatorKey.currentContext!,
|
||||
checkBuildVersion: true,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import '../../../../core/models/configuration/profile.dart';
|
||||
import '../../../../core/extensions.dart';
|
||||
import '../../../../core/ui.dart';
|
||||
import '../../../../ui/ui.dart';
|
||||
import '../../../../vendor.dart';
|
||||
import '../database.dart';
|
||||
import 'data/abstract.dart';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../core/system/profile.dart';
|
||||
import '../../../../../core/ui.dart';
|
||||
import '../../../../../ui/ui.dart';
|
||||
import '../../../../lidarr/core/api/api.dart';
|
||||
import '../../../../lidarr/routes/details_artist.dart';
|
||||
import '../../../../lidarr/routes/search_results.dart';
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../../../core/system/profile.dart';
|
||||
import '../../../../../core/extensions.dart';
|
||||
import '../../../../../core/ui.dart';
|
||||
import '../../../../../ui/ui.dart';
|
||||
import '../../../../../vendor.dart';
|
||||
import '../../../../radarr/core/api_helper.dart';
|
||||
import '../../../../radarr/core/state.dart';
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:provider/provider.dart';
|
||||
import '../../../../../core/database/luna_database.dart';
|
||||
import '../../../../../core/system/profile.dart';
|
||||
import '../../../../../core/extensions.dart';
|
||||
import '../../../../../core/ui.dart';
|
||||
import '../../../../../ui/ui.dart';
|
||||
import '../../../../../core/utilities/logger.dart';
|
||||
import '../../../../../vendor.dart';
|
||||
import '../../../../sonarr/core/state.dart';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/ui.dart';
|
||||
import '../../../ui/ui.dart';
|
||||
import '../../../vendor.dart';
|
||||
import '../routes/dashboard/widgets/navigation_bar.dart';
|
||||
import 'database.dart';
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../../../core/mixins/load_callback.dart';
|
||||
import '../../../../../core/extensions.dart';
|
||||
import '../../../../../core/ui.dart';
|
||||
import '../../../../../ui/ui.dart';
|
||||
import '../../../../../core/utilities/logger.dart';
|
||||
import '../../../../../vendor.dart';
|
||||
import '../../../core/adapters/calendar_starting_type.dart';
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import '../../../../../../core/database/luna_database.dart';
|
||||
import '../../../../../../core/modules.dart';
|
||||
import '../../../../../../core/system/profile.dart';
|
||||
import '../../../../../../core/ui.dart';
|
||||
import '../../../../../../ui/ui.dart';
|
||||
import '../../../../wake_on_lan/api/wake_on_lan.dart';
|
||||
import '../widgets/navigation_bar.dart';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/database/luna_database.dart';
|
||||
import '../../../../core/modules.dart';
|
||||
import '../../../../core/ui.dart';
|
||||
import '../../../../ui/ui.dart';
|
||||
import '../../../../vendor.dart';
|
||||
import '../../core/database.dart';
|
||||
import '../routes.dart';
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../../../core/database/database.dart';
|
||||
import '../../../../../core/extensions.dart';
|
||||
import '../../../../../core/ui.dart';
|
||||
import '../../../../../ui/ui.dart';
|
||||
import '../../../../../vendor.dart';
|
||||
import '../../../core/adapters/calendar_starting_day.dart';
|
||||
import '../../../core/adapters/calendar_starting_size.dart';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../core/system/profile.dart';
|
||||
import '../../../../../core/ui.dart';
|
||||
import '../../../../../ui/ui.dart';
|
||||
import '../../../core/api/data/abstract.dart';
|
||||
import '../../../core/api/data/lidarr.dart';
|
||||
import '../../../core/api/data/radarr.dart';
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../../../core/extensions.dart';
|
||||
import '../../../../../core/ui.dart';
|
||||
import '../../../../../ui/ui.dart';
|
||||
import '../../../core/api/data/abstract.dart';
|
||||
import '../../../core/database.dart';
|
||||
import '../../../core/state.dart';
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../../../core/mixins/load_callback.dart';
|
||||
import '../../../../../core/ui.dart';
|
||||
import '../../../../../ui/ui.dart';
|
||||
import '../../../../../vendor.dart';
|
||||
import '../../../core/adapters/calendar_starting_type.dart';
|
||||
import '../../../core/state.dart';
|
||||
|
||||
@@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
import 'package:lunasea/modules/nzbget.dart';
|
||||
|
||||
import '../../../core/system/filesystem/file.dart';
|
||||
import '../../../core/system/filesystem/filesystem.dart';
|
||||
import '../../../system/filesystem/file.dart';
|
||||
import '../../../system/filesystem/filesystem.dart';
|
||||
|
||||
class NZBGet extends StatefulWidget {
|
||||
static const ROUTE_NAME = '/nzbget';
|
||||
|
||||
@@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
import 'package:lunasea/modules/sabnzbd.dart';
|
||||
|
||||
import '../../../core/system/filesystem/file.dart';
|
||||
import '../../../core/system/filesystem/filesystem.dart';
|
||||
import '../../../system/filesystem/file.dart';
|
||||
import '../../../system/filesystem/filesystem.dart';
|
||||
|
||||
class SABnzbd extends StatefulWidget {
|
||||
static const ROUTE_NAME = '/sabnzbd';
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:lunasea/modules/nzbget.dart';
|
||||
import 'package:lunasea/modules/sabnzbd.dart';
|
||||
import 'package:lunasea/modules/search.dart';
|
||||
|
||||
import '../../../../core/system/filesystem/filesystem.dart';
|
||||
import '../../../../system/filesystem/filesystem.dart';
|
||||
|
||||
enum SearchDownloadType {
|
||||
NZBGET,
|
||||
|
||||
@@ -7,8 +7,8 @@ import 'package:wake_on_lan/wake_on_lan.dart';
|
||||
import '../../../core/database/luna_database.dart';
|
||||
import '../../../core/firebase/types/backup_document.dart';
|
||||
import '../../../core/models/types/browser.dart';
|
||||
import '../../../core/system/localization.dart';
|
||||
import '../../../core/ui.dart';
|
||||
import '../../../system/localization.dart';
|
||||
import '../../../ui/ui.dart';
|
||||
import '../../dashboard/core/adapters/calendar_starting_day.dart';
|
||||
import '../../dashboard/core/adapters/calendar_starting_size.dart';
|
||||
import '../../dashboard/core/adapters/calendar_starting_type.dart';
|
||||
@@ -892,7 +892,7 @@ class SettingsDialogs {
|
||||
Future<Tuple2<bool, LunaLanguage?>> changeLanguage(
|
||||
BuildContext context,
|
||||
) async {
|
||||
List<LunaLanguage> languages = LunaLocalization().supportedLanguages;
|
||||
List<LunaLanguage> languages = LunaLocalization().supportedLanguages();
|
||||
bool _flag = false;
|
||||
LunaLanguage? _language;
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
import 'package:lunasea/modules/settings.dart';
|
||||
|
||||
import '../../../../core/system/networking/networking.dart';
|
||||
import '../../../../core/system/platform.dart';
|
||||
import '../../../../system/network/network.dart';
|
||||
import '../../../../system/platform.dart';
|
||||
import '../../../../system/quick_actions/quick_actions.dart';
|
||||
|
||||
class SettingsConfigurationRouter extends SettingsPageRouter {
|
||||
SettingsConfigurationRouter() : super('/settings/configuration');
|
||||
@@ -81,7 +82,7 @@ class _State extends State<_Widget> with LunaScrollControllerMixin {
|
||||
onTap: () async =>
|
||||
SettingsConfigurationLocalizationRouter().navigateTo(context),
|
||||
),
|
||||
if (LunaNetworking.isSupported)
|
||||
if (LunaNetwork.isSupported)
|
||||
LunaBlock(
|
||||
title: 'settings.Network'.tr(),
|
||||
body: [TextSpan(text: 'settings.NetworkDescription'.tr())],
|
||||
@@ -105,7 +106,7 @@ class _State extends State<_Widget> with LunaScrollControllerMixin {
|
||||
);
|
||||
},
|
||||
),
|
||||
if (LunaQuickActions.isPlatformCompatible)
|
||||
if (LunaQuickActions.isSupported)
|
||||
LunaBlock(
|
||||
title: 'settings.QuickActions'.tr(),
|
||||
body: [TextSpan(text: 'settings.QuickActionsDescription'.tr())],
|
||||
|
||||
@@ -2,9 +2,8 @@ import 'package:fluro/fluro.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
import '../../../../../core/mixins/scroll_controller.dart';
|
||||
import '../../../../../core/modules.dart';
|
||||
import '../../../../../core/ui.dart';
|
||||
import '../../../../../ui/ui.dart';
|
||||
import '../../../../dashboard/core/adapters/calendar_starting_day.dart';
|
||||
import '../../../../dashboard/core/adapters/calendar_starting_size.dart';
|
||||
import '../../../../dashboard/core/adapters/calendar_starting_type.dart';
|
||||
|
||||
@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
import 'package:lunasea/modules/settings.dart';
|
||||
|
||||
import '../../../../system/localization.dart';
|
||||
|
||||
class SettingsConfigurationLocalizationRouter extends SettingsPageRouter {
|
||||
SettingsConfigurationLocalizationRouter()
|
||||
: super('/settings/configuration/localization');
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
import 'package:lunasea/modules/settings.dart';
|
||||
|
||||
import '../../../../core/system/networking/networking.dart';
|
||||
import '../../../../system/network/network.dart';
|
||||
|
||||
class SettingsConfigurationNetworkRouter extends SettingsPageRouter {
|
||||
SettingsConfigurationNetworkRouter()
|
||||
@@ -62,7 +62,7 @@ class _State extends State<_Widget> with LunaScrollControllerMixin {
|
||||
value: _db.data,
|
||||
onChanged: (data) {
|
||||
_db.put(data);
|
||||
if (LunaNetworking.isSupported) LunaNetworking().initialize();
|
||||
if (LunaNetwork.isSupported) LunaNetwork().initialize();
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
import 'package:lunasea/modules/settings.dart';
|
||||
|
||||
import '../../../../system/quick_actions/quick_actions.dart';
|
||||
|
||||
class SettingsConfigurationQuickActionsRouter extends SettingsPageRouter {
|
||||
SettingsConfigurationQuickActionsRouter()
|
||||
: super('/settings/configuration/quickactions');
|
||||
@@ -90,7 +92,8 @@ class _State extends State<_Widget> with LunaScrollControllerMixin {
|
||||
value: action.data,
|
||||
onChanged: (value) {
|
||||
action.put(value);
|
||||
LunaQuickActions().setShortcutItems();
|
||||
if (LunaQuickActions.isSupported)
|
||||
LunaQuickActions().setActionItems();
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
import 'package:lunasea/modules/settings.dart';
|
||||
|
||||
import '../../../../system/build/environment.dart';
|
||||
import '../../../../system/build/flavor.dart';
|
||||
import '../../../../system/environment.dart';
|
||||
import '../../../../system/flavor.dart';
|
||||
|
||||
class SettingsHomeRouter extends SettingsPageRouter {
|
||||
SettingsHomeRouter() : super('/settings');
|
||||
|
||||
@@ -3,8 +3,8 @@ import 'package:lunasea/core.dart';
|
||||
import 'package:lunasea/modules/settings.dart';
|
||||
|
||||
import '../../../../core/cache/image_cache/image_cache.dart';
|
||||
import '../../../../system/build/environment.dart';
|
||||
import '../../../../system/build/flavor.dart';
|
||||
import '../../../../system/environment.dart';
|
||||
import '../../../../system/flavor.dart';
|
||||
|
||||
class SettingsSystemRouter extends SettingsPageRouter {
|
||||
SettingsSystemRouter() : super('/settings/system');
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
import 'package:lunasea/modules/settings.dart';
|
||||
|
||||
import '../../../../../core/system/filesystem/filesystem.dart';
|
||||
import '../../../../../system/filesystem/filesystem.dart';
|
||||
|
||||
class SettingsSystemBackupRestoreBackupTile extends StatelessWidget {
|
||||
const SettingsSystemBackupRestoreBackupTile({
|
||||
|
||||
@@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
import 'package:lunasea/modules/settings.dart';
|
||||
|
||||
import '../../../../../core/system/filesystem/file.dart';
|
||||
import '../../../../../core/system/filesystem/filesystem.dart';
|
||||
import '../../../../../system/filesystem/file.dart';
|
||||
import '../../../../../system/filesystem/filesystem.dart';
|
||||
|
||||
class SettingsSystemBackupRestoreRestoreTile extends StatelessWidget {
|
||||
const SettingsSystemBackupRestoreRestoreTile({
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
import 'package:lunasea/modules/settings.dart';
|
||||
|
||||
import '../../../../core/system/filesystem/filesystem.dart';
|
||||
import '../../../../system/filesystem/filesystem.dart';
|
||||
|
||||
class SettingsSystemLogsRouter extends SettingsPageRouter {
|
||||
SettingsSystemLogsRouter() : super('/settings/logs');
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:wake_on_lan/wake_on_lan.dart';
|
||||
|
||||
import '../../../../core/models/configuration/profile.dart';
|
||||
import '../../../../core/system/profile.dart';
|
||||
import '../../../../core/ui.dart';
|
||||
import '../../../../ui/ui.dart';
|
||||
import '../../../../core/utilities/logger.dart';
|
||||
import '../wake_on_lan.dart';
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class LunaEnvironment {
|
||||
}
|
||||
|
||||
/// Returns if the given flavor is "lower" than the given environment.
|
||||
/// For example, `alpha` is lower than `beta` but is not lower than `develop`.
|
||||
/// For example, `beta` is lower than `candidate` but is not lower than `edge`.
|
||||
bool isFlavorSupported(LunaFlavor env) {
|
||||
LunaFlavor _flavor = LunaFlavor.EDGE.from(flavor);
|
||||
if (_flavor == env) return true;
|
||||
@@ -5,8 +5,8 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
import '../../../ui.dart';
|
||||
import '../../../utilities/logger.dart';
|
||||
import '../../../ui/ui.dart';
|
||||
import '../../../core/utilities/logger.dart';
|
||||
import '../../platform.dart';
|
||||
import '../file.dart';
|
||||
import '../filesystem.dart';
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/ui.dart';
|
||||
import '../../ui/ui.dart';
|
||||
|
||||
const _EDGE = 'edge';
|
||||
const _BETA = 'beta';
|
||||
@@ -1,24 +1,21 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:lunasea/core.dart';
|
||||
|
||||
import '../../system/build/environment.dart';
|
||||
import '../../system/build/flavor.dart';
|
||||
import 'environment.dart';
|
||||
import 'flavor.dart';
|
||||
|
||||
class LunaLocalization {
|
||||
/// List of [LunaLanguage] values with all currently supported languages
|
||||
List<LunaLanguage> get supportedLanguages =>
|
||||
LunaLanguage.values.where((lang) => lang.enabled).toList();
|
||||
static const fileDirectory = 'assets/localization';
|
||||
static final fallbackLocale = LunaLanguage.ENGLISH.locale;
|
||||
|
||||
/// Returns an iterable list of [Locale] objects containing all supported & enabled locales.
|
||||
Iterable<Locale> get supportedLocales =>
|
||||
supportedLanguages.map<Locale>((lang) => lang.locale).toList();
|
||||
List<LunaLanguage> supportedLanguages() {
|
||||
return LunaLanguage.values.where((lang) => lang.enabled).toList();
|
||||
}
|
||||
|
||||
Locale get fallbackLocale => LunaLanguage.ENGLISH.locale;
|
||||
List<Locale> supportedLocales() {
|
||||
return supportedLanguages().map<Locale>((lang) => lang.locale).toList();
|
||||
}
|
||||
|
||||
/// Directory containing all localization files
|
||||
String get fileDirectory => 'assets/localization';
|
||||
|
||||
/// Initialize the localization system.
|
||||
Future<void> initialize() async {
|
||||
await EasyLocalization.ensureInitialized();
|
||||
}
|
||||
@@ -75,7 +72,6 @@ extension LunaLanguageExtension on LunaLanguage {
|
||||
switch (this) {
|
||||
case LunaLanguage.ENGLISH:
|
||||
return true;
|
||||
// Keep all languages enabled in debug mode while LunaSea is being adapted for localization
|
||||
case LunaLanguage.FRENCH:
|
||||
case LunaLanguage.GERMAN:
|
||||
case LunaLanguage.ITALIAN:
|
||||
10
lib/system/network/network.dart
Normal file
10
lib/system/network/network.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
import 'platform/network_stub.dart'
|
||||
if (dart.library.io) 'platform/network_io.dart'
|
||||
if (dart.library.html) 'platform/network_html.dart';
|
||||
|
||||
abstract class LunaNetwork {
|
||||
static bool get isSupported => isPlatformSupported();
|
||||
factory LunaNetwork() => getNetwork();
|
||||
|
||||
void initialize();
|
||||
}
|
||||
4
lib/system/network/platform/network_html.dart
Normal file
4
lib/system/network/platform/network_html.dart
Normal file
@@ -0,0 +1,4 @@
|
||||
import '../network.dart';
|
||||
|
||||
bool isPlatformSupported() => false;
|
||||
LunaNetwork getNetwork() => throw UnsupportedError('LunaNetwork unsupported');
|
||||
@@ -1,13 +1,13 @@
|
||||
import 'dart:io';
|
||||
|
||||
import '../../../../vendor.dart';
|
||||
import '../../../database/luna_database.dart';
|
||||
import '../networking.dart';
|
||||
import '../../../core/database/luna_database.dart';
|
||||
import '../network.dart';
|
||||
|
||||
bool isPlatformSupported() => true;
|
||||
LunaNetworking getNetworking() => IO();
|
||||
LunaNetwork getNetwork() => IO();
|
||||
|
||||
class IO extends HttpOverrides implements LunaNetworking {
|
||||
class IO extends HttpOverrides implements LunaNetwork {
|
||||
@override
|
||||
void initialize() {
|
||||
HttpOverrides.global = IO();
|
||||
4
lib/system/network/platform/network_stub.dart
Normal file
4
lib/system/network/platform/network_stub.dart
Normal file
@@ -0,0 +1,4 @@
|
||||
import '../network.dart';
|
||||
|
||||
bool isPlatformSupported() => false;
|
||||
LunaNetwork getNetwork() => throw UnsupportedError('LunaNetwork unsupported');
|
||||
@@ -0,0 +1,5 @@
|
||||
import '../quick_actions.dart';
|
||||
|
||||
bool isPlatformSupported() => false;
|
||||
LunaQuickActions getQuickActions() =>
|
||||
throw UnsupportedError('LunaQuickActions unsupported');
|
||||
50
lib/system/quick_actions/platform/quick_actions_io.dart
Normal file
50
lib/system/quick_actions/platform/quick_actions_io.dart
Normal file
@@ -0,0 +1,50 @@
|
||||
import 'package:quick_actions/quick_actions.dart';
|
||||
|
||||
import '../../../core/database/luna_database.dart';
|
||||
import '../../../core/modules.dart';
|
||||
import '../../platform.dart';
|
||||
import '../quick_actions.dart';
|
||||
|
||||
bool isPlatformSupported() => LunaPlatform().isMobile;
|
||||
LunaQuickActions getQuickActions() {
|
||||
if (isPlatformSupported()) return IO();
|
||||
throw UnsupportedError('LunaQuickActions unsupported');
|
||||
}
|
||||
|
||||
class IO implements LunaQuickActions {
|
||||
final QuickActions _quickActions = const QuickActions();
|
||||
|
||||
@override
|
||||
Future<void> initialize() async {
|
||||
_quickActions.initialize(actionHandler);
|
||||
setActionItems();
|
||||
}
|
||||
|
||||
@override
|
||||
void actionHandler(String action) {
|
||||
LunaModule.LIDARR.fromKey(action)?.launch();
|
||||
}
|
||||
|
||||
@override
|
||||
void setActionItems() {
|
||||
_quickActions.setShortcutItems(<ShortcutItem>[
|
||||
if (LunaDatabaseValue.QUICK_ACTIONS_TAUTULLI.data)
|
||||
LunaModule.TAUTULLI.shortcutItem,
|
||||
if (LunaDatabaseValue.QUICK_ACTIONS_SONARR.data)
|
||||
LunaModule.SONARR.shortcutItem,
|
||||
if (LunaDatabaseValue.QUICK_ACTIONS_SEARCH.data)
|
||||
LunaModule.SEARCH.shortcutItem,
|
||||
if (LunaDatabaseValue.QUICK_ACTIONS_SABNZBD.data)
|
||||
LunaModule.SABNZBD.shortcutItem,
|
||||
if (LunaDatabaseValue.QUICK_ACTIONS_RADARR.data)
|
||||
LunaModule.RADARR.shortcutItem,
|
||||
if (LunaDatabaseValue.QUICK_ACTIONS_OVERSEERR.data)
|
||||
LunaModule.OVERSEERR.shortcutItem,
|
||||
if (LunaDatabaseValue.QUICK_ACTIONS_NZBGET.data)
|
||||
LunaModule.NZBGET.shortcutItem,
|
||||
if (LunaDatabaseValue.QUICK_ACTIONS_LIDARR.data)
|
||||
LunaModule.LIDARR.shortcutItem,
|
||||
LunaModule.SETTINGS.shortcutItem,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import '../quick_actions.dart';
|
||||
|
||||
bool isPlatformSupported() => false;
|
||||
LunaQuickActions getQuickActions() =>
|
||||
throw UnsupportedError('LunaQuickActions unsupported');
|
||||
12
lib/system/quick_actions/quick_actions.dart
Normal file
12
lib/system/quick_actions/quick_actions.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
import 'platform/quick_actions_stub.dart'
|
||||
if (dart.library.io) 'platform/quick_actions_io.dart'
|
||||
if (dart.library.html) 'platform/quick_actions_html.dart';
|
||||
|
||||
abstract class LunaQuickActions {
|
||||
static bool get isSupported => isPlatformSupported();
|
||||
factory LunaQuickActions() => getQuickActions();
|
||||
|
||||
Future<void> initialize();
|
||||
void setActionItems();
|
||||
void actionHandler(String action);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user