diff --git a/lib/core/models/configuration/profile.dart b/lib/core/models/configuration/profile.dart index a3c588eb..20bc143f 100644 --- a/lib/core/models/configuration/profile.dart +++ b/lib/core/models/configuration/profile.dart @@ -414,7 +414,7 @@ class ProfileHiveObject extends HiveObject { }; bool get anythingEnabled { - for (LunaModule module in LunaModule.DASHBOARD.allModules()) { + for (final module in LunaModule.active) { if (module.isEnabled) return true; } return false; diff --git a/lib/core/modules.dart b/lib/core/modules.dart index 86740ca4..d23798c6 100644 --- a/lib/core/modules.dart +++ b/lib/core/modules.dart @@ -61,7 +61,18 @@ enum LunaModule { @HiveField(9) TAUTULLI, @HiveField(10) - WAKE_ON_LAN, + WAKE_ON_LAN; + + /// Returns a list of all system-enabled modules. + /// + /// Internal modules (dashboard, settings, etc.) are removed by default. + static List get active { + return LunaModule.values.filter((m) { + if (m == LunaModule.DASHBOARD) return false; + if (m == LunaModule.SETTINGS) return false; + return m.featureFlag; + }).toList(); + } } extension LunaModuleExtension on LunaModule { @@ -95,21 +106,6 @@ extension LunaModuleExtension on LunaModule { } } - /// Returns a list of all system-enabled modules. - /// - /// Internal modules (dashboard, settings, etc.) are removed by default. - List allModules({ - bool removeInternalModules = true, - }) { - List _modules = - LunaModule.values.filter((module) => module.featureFlag).toList(); - if (removeInternalModules) { - _modules.remove(LunaModule.DASHBOARD); - _modules.remove(LunaModule.SETTINGS); - } - return _modules; - } - /// Used to convert a string key back to a [LunaModule] value. /// /// If the key is not found, returns null. diff --git a/lib/database/database.dart b/lib/database/database.dart index 329627ff..0c947f6a 100644 --- a/lib/database/database.dart +++ b/lib/database/database.dart @@ -20,6 +20,7 @@ class LunaDatabase { for (final table in LunaTable.values) table.items[0].registerAdapters(); for (final box in LunaBox.values) await box.open(); if (LunaBox.profiles.box.isEmpty) await bootstrap(); + // await bootstrap(); } Future bootstrap() async { diff --git a/lib/database/tables/lunasea.dart b/lib/database/tables/lunasea.dart index 03dde556..db0051d1 100644 --- a/lib/database/tables/lunasea.dart +++ b/lib/database/tables/lunasea.dart @@ -13,7 +13,7 @@ import 'package:lunasea/widgets/ui.dart'; enum LunaSeaDatabase with LunaTableMixin { DRAWER_AUTOMATIC_MANAGE(true), - DRAWER_MANUAL_ORDER?>(null), + DRAWER_MANUAL_ORDER([]), ENABLED_PROFILE('default'), NETWORKING_TLS_VALIDATION(false), THEME_AMOLED(false), @@ -76,11 +76,12 @@ enum LunaSeaDatabase with LunaTableMixin { return; } if (this == LunaSeaDatabase.DRAWER_MANUAL_ORDER) { - final item = (value as List) - .map((module) => LunaModule.DASHBOARD.fromKey(module)) - .toList(); - item.removeWhere((i) => i == null); - update(item.cast() as T); + List item = []; + (value as List).cast().forEach((val) { + LunaModule? module = LunaModule.DASHBOARD.fromKey(val); + if (module != null) item.add(module); + }); + update(item as T); return; } return super.import(value); diff --git a/lib/database/tables/sonarr.dart b/lib/database/tables/sonarr.dart index 180ef1c4..a0e822d8 100644 --- a/lib/database/tables/sonarr.dart +++ b/lib/database/tables/sonarr.dart @@ -21,7 +21,7 @@ enum SonarrDatabase with LunaTableMixin { ADD_SERIES_DEFAULT_LANGUAGE_PROFILE(null), ADD_SERIES_DEFAULT_QUALITY_PROFILE(null), ADD_SERIES_DEFAULT_ROOT_FOLDER(null), - ADD_SERIES_DEFAULT_TAGS(null), + ADD_SERIES_DEFAULT_TAGS([]), DEFAULT_VIEW_SERIES(LunaListViewOption.BLOCK_VIEW), DEFAULT_FILTERING_SERIES(SonarrSeriesFilter.ALL), DEFAULT_FILTERING_RELEASES(SonarrReleasesFilter.ALL), diff --git a/lib/main.dart b/lib/main.dart index b8cc3757..0d8a5a2e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -68,21 +68,19 @@ class LunaBIOS extends StatelessWidget { LunaSeaDatabase.THEME_AMOLED_BORDER.key, ]), builder: (context, dynamic box, _) { - return Layout( - child: MaterialApp( - localizationsDelegates: context.localizationDelegates, - supportedLocales: context.supportedLocales, - locale: context.locale, - builder: DevicePreview.appBuilder, - routes: router.routes, - useInheritedMediaQuery: true, - onGenerateRoute: LunaRouter.router.generator, - navigatorKey: LunaState.navigatorKey, - darkTheme: theme.activeTheme(), - theme: theme.activeTheme(), - scrollBehavior: LunaScrollBehavior(), - title: 'LunaSea', - ), + return MaterialApp( + localizationsDelegates: context.localizationDelegates, + supportedLocales: context.supportedLocales, + locale: context.locale, + builder: DevicePreview.appBuilder, + routes: router.routes, + useInheritedMediaQuery: true, + onGenerateRoute: LunaRouter.router.generator, + navigatorKey: LunaState.navigatorKey, + darkTheme: theme.activeTheme(), + theme: theme.activeTheme(), + scrollBehavior: LunaScrollBehavior(), + title: 'LunaSea', ); }, ), diff --git a/lib/modules/dashboard/routes/dashboard/pages/modules.dart b/lib/modules/dashboard/routes/dashboard/pages/modules.dart index 1604d733..122b6bb5 100644 --- a/lib/modules/dashboard/routes/dashboard/pages/modules.dart +++ b/lib/modules/dashboard/routes/dashboard/pages/modules.dart @@ -46,7 +46,7 @@ class _State extends State with AutomaticKeepAliveClientMixin { List _buildAlphabeticalList() { List modules = []; int index = 0; - LunaModule.DASHBOARD.allModules() + LunaModule.active ..sort((a, b) => a.name.toLowerCase().compareTo( b.name.toLowerCase(), )) diff --git a/lib/modules/overseerr/routes/issues/route.dart b/lib/modules/overseerr/routes/issues/route.dart index 116c8dee..ac6d3de0 100644 --- a/lib/modules/overseerr/routes/issues/route.dart +++ b/lib/modules/overseerr/routes/issues/route.dart @@ -24,7 +24,6 @@ class _State extends State return LunaScaffold( scaffoldKey: _scaffoldKey, module: LunaModule.OVERSEERR, - hideDrawer: true, body: const OverseerrIssuesListView(), ); } diff --git a/lib/modules/overseerr/routes/requests/route.dart b/lib/modules/overseerr/routes/requests/route.dart index 2d707faa..c56ff528 100644 --- a/lib/modules/overseerr/routes/requests/route.dart +++ b/lib/modules/overseerr/routes/requests/route.dart @@ -24,7 +24,6 @@ class _State extends State return LunaScaffold( scaffoldKey: _scaffoldKey, module: LunaModule.OVERSEERR, - hideDrawer: true, body: const OverseerrRequestsListView(), ); } diff --git a/lib/modules/overseerr/routes/users/route.dart b/lib/modules/overseerr/routes/users/route.dart index 0dffa395..2d088bfb 100644 --- a/lib/modules/overseerr/routes/users/route.dart +++ b/lib/modules/overseerr/routes/users/route.dart @@ -24,7 +24,6 @@ class _State extends State return LunaScaffold( scaffoldKey: _scaffoldKey, module: LunaModule.OVERSEERR, - hideDrawer: true, body: const OverseerrUserListView(), ); } diff --git a/lib/modules/radarr/routes/catalogue/route.dart b/lib/modules/radarr/routes/catalogue/route.dart index ac819d52..b03b4e75 100644 --- a/lib/modules/radarr/routes/catalogue/route.dart +++ b/lib/modules/radarr/routes/catalogue/route.dart @@ -39,12 +39,11 @@ class _State extends State return LunaScaffold( scaffoldKey: _scaffoldKey, body: _body(), - appBar: _appBar() as PreferredSizeWidget?, - hideDrawer: true, + appBar: _appBar(), ); } - Widget _appBar() { + PreferredSizeWidget _appBar() { return LunaAppBar.empty( child: RadarrCatalogueSearchBar( scrollController: RadarrNavigationBar.scrollControllers[0], diff --git a/lib/modules/radarr/routes/missing/route.dart b/lib/modules/radarr/routes/missing/route.dart index ea87f386..dc0f559c 100644 --- a/lib/modules/radarr/routes/missing/route.dart +++ b/lib/modules/radarr/routes/missing/route.dart @@ -27,7 +27,6 @@ class _State extends State return LunaScaffold( scaffoldKey: _scaffoldKey, body: _body, - hideDrawer: true, ); } diff --git a/lib/modules/radarr/routes/more/route.dart b/lib/modules/radarr/routes/more/route.dart index a49a169d..89a8c37d 100644 --- a/lib/modules/radarr/routes/more/route.dart +++ b/lib/modules/radarr/routes/more/route.dart @@ -22,7 +22,6 @@ class _State extends State with AutomaticKeepAliveClientMixin { super.build(context); return LunaScaffold( scaffoldKey: _scaffoldKey, - hideDrawer: true, body: _body(), ); } diff --git a/lib/modules/radarr/routes/movie_details/widgets/page_cast_crew.dart b/lib/modules/radarr/routes/movie_details/widgets/page_cast_crew.dart index 13fb082a..e09cebfb 100644 --- a/lib/modules/radarr/routes/movie_details/widgets/page_cast_crew.dart +++ b/lib/modules/radarr/routes/movie_details/widgets/page_cast_crew.dart @@ -28,7 +28,6 @@ class _State extends State super.build(context); return LunaScaffold( module: LunaModule.RADARR, - hideDrawer: true, scaffoldKey: _scaffoldKey, body: _body(), ); diff --git a/lib/modules/radarr/routes/movie_details/widgets/page_files.dart b/lib/modules/radarr/routes/movie_details/widgets/page_files.dart index 10556444..942aa0b1 100644 --- a/lib/modules/radarr/routes/movie_details/widgets/page_files.dart +++ b/lib/modules/radarr/routes/movie_details/widgets/page_files.dart @@ -25,7 +25,6 @@ class _State extends State super.build(context); return LunaScaffold( module: LunaModule.RADARR, - hideDrawer: true, scaffoldKey: _scaffoldKey, body: _body(), ); diff --git a/lib/modules/radarr/routes/movie_details/widgets/page_history.dart b/lib/modules/radarr/routes/movie_details/widgets/page_history.dart index 7f821172..722fa98e 100644 --- a/lib/modules/radarr/routes/movie_details/widgets/page_history.dart +++ b/lib/modules/radarr/routes/movie_details/widgets/page_history.dart @@ -28,7 +28,6 @@ class _State extends State super.build(context); return LunaScaffold( module: LunaModule.RADARR, - hideDrawer: true, scaffoldKey: _scaffoldKey, body: _body(), ); diff --git a/lib/modules/radarr/routes/movie_details/widgets/page_overview.dart b/lib/modules/radarr/routes/movie_details/widgets/page_overview.dart index d9dc54c5..33c8d572 100644 --- a/lib/modules/radarr/routes/movie_details/widgets/page_overview.dart +++ b/lib/modules/radarr/routes/movie_details/widgets/page_overview.dart @@ -30,7 +30,6 @@ class _State extends State super.build(context); return LunaScaffold( module: LunaModule.RADARR, - hideDrawer: true, scaffoldKey: _scaffoldKey, body: Selector>?>( selector: (_, state) => state.movies, diff --git a/lib/modules/radarr/routes/upcoming/route.dart b/lib/modules/radarr/routes/upcoming/route.dart index 08c1d2cd..11dcb347 100644 --- a/lib/modules/radarr/routes/upcoming/route.dart +++ b/lib/modules/radarr/routes/upcoming/route.dart @@ -27,7 +27,6 @@ class _State extends State return LunaScaffold( scaffoldKey: _scaffoldKey, body: _body, - hideDrawer: true, ); } diff --git a/lib/modules/settings/routes/configuration/route.dart b/lib/modules/settings/routes/configuration/route.dart index eec01941..c1a1122d 100644 --- a/lib/modules/settings/routes/configuration/route.dart +++ b/lib/modules/settings/routes/configuration/route.dart @@ -103,7 +103,7 @@ class _State extends State<_Widget> with LunaScrollControllerMixin { } List _moduleList() { - return ([LunaModule.DASHBOARD, ...LunaModule.DASHBOARD.allModules()]) + return ([LunaModule.DASHBOARD, ...LunaModule.active]) .map(_tileFromModuleMap) .toList(); } diff --git a/lib/modules/settings/routes/configuration_drawer/route.dart b/lib/modules/settings/routes/configuration_drawer/route.dart index b7ae7ad3..d2ef8d25 100644 --- a/lib/modules/settings/routes/configuration_drawer/route.dart +++ b/lib/modules/settings/routes/configuration_drawer/route.dart @@ -75,7 +75,7 @@ class _State extends State<_Widget> with LunaScrollControllerMixin { LunaModule module = _modules![oIndex]; _modules!.remove(module); _modules!.insert(nIndex, module); - LunaSeaDatabase.DRAWER_MANUAL_ORDER.update(_modules); + LunaSeaDatabase.DRAWER_MANUAL_ORDER.update(_modules!); }, ), ), diff --git a/lib/modules/sonarr/routes/add_series_details/state.dart b/lib/modules/sonarr/routes/add_series_details/state.dart index b8736d8e..d11f7b50 100644 --- a/lib/modules/sonarr/routes/add_series_details/state.dart +++ b/lib/modules/sonarr/routes/add_series_details/state.dart @@ -128,8 +128,8 @@ class SonarrSeriesAddDetailsState extends ChangeNotifier { void initializeTags(List tags) { _tags = tags - .where((tag) => (SonarrDatabase.ADD_SERIES_DEFAULT_TAGS.read() ?? []) - .contains(tag.id)) + .where((tag) => + (SonarrDatabase.ADD_SERIES_DEFAULT_TAGS.read()).contains(tag.id)) .toList(); } diff --git a/lib/modules/sonarr/routes/catalogue/route.dart b/lib/modules/sonarr/routes/catalogue/route.dart index 56b72abd..faece760 100644 --- a/lib/modules/sonarr/routes/catalogue/route.dart +++ b/lib/modules/sonarr/routes/catalogue/route.dart @@ -42,13 +42,12 @@ class _State extends State return LunaScaffold( scaffoldKey: _scaffoldKey, module: LunaModule.SONARR, - hideDrawer: true, body: _body(), - appBar: _appBar() as PreferredSizeWidget?, + appBar: _appBar(), ); } - Widget _appBar() { + PreferredSizeWidget _appBar() { return LunaAppBar.empty( child: SonarrSeriesSearchBar( scrollController: SonarrNavigationBar.scrollControllers[0], diff --git a/lib/modules/sonarr/routes/missing/route.dart b/lib/modules/sonarr/routes/missing/route.dart index 01975115..59dd451a 100644 --- a/lib/modules/sonarr/routes/missing/route.dart +++ b/lib/modules/sonarr/routes/missing/route.dart @@ -33,7 +33,6 @@ class _State extends State return LunaScaffold( scaffoldKey: _scaffoldKey, module: LunaModule.SONARR, - hideDrawer: true, body: _body(), ); } diff --git a/lib/modules/sonarr/routes/more/route.dart b/lib/modules/sonarr/routes/more/route.dart index e2988c01..92e52356 100644 --- a/lib/modules/sonarr/routes/more/route.dart +++ b/lib/modules/sonarr/routes/more/route.dart @@ -23,7 +23,6 @@ class _State extends State with AutomaticKeepAliveClientMixin { return LunaScaffold( scaffoldKey: _scaffoldKey, module: LunaModule.SONARR, - hideDrawer: true, body: _body(), ); } diff --git a/lib/modules/sonarr/routes/series_details/widgets/page_history.dart b/lib/modules/sonarr/routes/series_details/widgets/page_history.dart index 5a33c261..b02ab330 100644 --- a/lib/modules/sonarr/routes/series_details/widgets/page_history.dart +++ b/lib/modules/sonarr/routes/series_details/widgets/page_history.dart @@ -26,7 +26,6 @@ class _State extends State return LunaScaffold( scaffoldKey: _scaffoldKey, module: LunaModule.SONARR, - hideDrawer: true, body: _body(), ); } diff --git a/lib/modules/sonarr/routes/series_details/widgets/page_overview.dart b/lib/modules/sonarr/routes/series_details/widgets/page_overview.dart index 817204d3..bfa6e883 100644 --- a/lib/modules/sonarr/routes/series_details/widgets/page_overview.dart +++ b/lib/modules/sonarr/routes/series_details/widgets/page_overview.dart @@ -33,7 +33,6 @@ class _State extends State return LunaScaffold( scaffoldKey: _scaffoldKey, module: LunaModule.SONARR, - hideDrawer: true, body: Selector>?>( selector: (_, state) => state.series, builder: (context, movies, _) => LunaListView( diff --git a/lib/modules/sonarr/routes/series_details/widgets/page_seasons.dart b/lib/modules/sonarr/routes/series_details/widgets/page_seasons.dart index 877849e5..fa95d91f 100644 --- a/lib/modules/sonarr/routes/series_details/widgets/page_seasons.dart +++ b/lib/modules/sonarr/routes/series_details/widgets/page_seasons.dart @@ -23,7 +23,6 @@ class _State extends State { return LunaScaffold( scaffoldKey: _scaffoldKey, module: LunaModule.SONARR, - hideDrawer: true, body: _body(), ); } diff --git a/lib/modules/sonarr/routes/upcoming/route.dart b/lib/modules/sonarr/routes/upcoming/route.dart index 45f0bca6..d642715a 100644 --- a/lib/modules/sonarr/routes/upcoming/route.dart +++ b/lib/modules/sonarr/routes/upcoming/route.dart @@ -32,7 +32,6 @@ class _State extends State return LunaScaffold( scaffoldKey: _scaffoldKey, module: LunaModule.SONARR, - hideDrawer: true, body: _body(), ); } diff --git a/lib/modules/tautulli/routes/activity/route.dart b/lib/modules/tautulli/routes/activity/route.dart index de8d668e..f12684c4 100644 --- a/lib/modules/tautulli/routes/activity/route.dart +++ b/lib/modules/tautulli/routes/activity/route.dart @@ -32,7 +32,6 @@ class _State extends State return LunaScaffold( scaffoldKey: _scaffoldKey, module: LunaModule.TAUTULLI, - hideDrawer: true, body: _body(), ); } diff --git a/lib/modules/tautulli/routes/history/route.dart b/lib/modules/tautulli/routes/history/route.dart index a2ca37d4..48b60f7f 100644 --- a/lib/modules/tautulli/routes/history/route.dart +++ b/lib/modules/tautulli/routes/history/route.dart @@ -32,7 +32,6 @@ class _State extends State return LunaScaffold( scaffoldKey: _scaffoldKey, module: LunaModule.TAUTULLI, - hideDrawer: true, body: _body(), ); } diff --git a/lib/modules/tautulli/routes/more/route.dart b/lib/modules/tautulli/routes/more/route.dart index 36983aea..eac3ffff 100644 --- a/lib/modules/tautulli/routes/more/route.dart +++ b/lib/modules/tautulli/routes/more/route.dart @@ -24,7 +24,6 @@ class _State extends State return LunaScaffold( scaffoldKey: _scaffoldKey, module: LunaModule.TAUTULLI, - hideDrawer: true, body: _body, ); } diff --git a/lib/modules/tautulli/routes/users/route.dart b/lib/modules/tautulli/routes/users/route.dart index 7fa9e8f0..71392028 100644 --- a/lib/modules/tautulli/routes/users/route.dart +++ b/lib/modules/tautulli/routes/users/route.dart @@ -32,7 +32,6 @@ class _State extends State return LunaScaffold( scaffoldKey: _scaffoldKey, module: LunaModule.TAUTULLI, - hideDrawer: true, body: _body(), ); } diff --git a/lib/modules/tautulli/routes/users_details/widgets/history.dart b/lib/modules/tautulli/routes/users_details/widgets/history.dart index eac39753..afca4cc2 100644 --- a/lib/modules/tautulli/routes/users_details/widgets/history.dart +++ b/lib/modules/tautulli/routes/users_details/widgets/history.dart @@ -41,7 +41,6 @@ class _State extends State return LunaScaffold( scaffoldKey: _scaffoldKey, module: LunaModule.TAUTULLI, - hideDrawer: true, body: _body(), ); } diff --git a/lib/modules/tautulli/routes/users_details/widgets/ip_addresses.dart b/lib/modules/tautulli/routes/users_details/widgets/ip_addresses.dart index c743b43f..b886d5db 100644 --- a/lib/modules/tautulli/routes/users_details/widgets/ip_addresses.dart +++ b/lib/modules/tautulli/routes/users_details/widgets/ip_addresses.dart @@ -42,7 +42,6 @@ class _State extends State super.build(context); return LunaScaffold( module: LunaModule.TAUTULLI, - hideDrawer: true, scaffoldKey: _scaffoldKey, body: _body(), ); diff --git a/lib/modules/tautulli/routes/users_details/widgets/profile.dart b/lib/modules/tautulli/routes/users_details/widgets/profile.dart index ec5bb670..43e192b3 100644 --- a/lib/modules/tautulli/routes/users_details/widgets/profile.dart +++ b/lib/modules/tautulli/routes/users_details/widgets/profile.dart @@ -67,7 +67,6 @@ class _State extends State return LunaScaffold( scaffoldKey: _scaffoldKey, module: LunaModule.TAUTULLI, - hideDrawer: true, body: _initialLoad ? _body() : const LunaLoader(), ); } diff --git a/lib/modules/tautulli/routes/users_details/widgets/synced_items.dart b/lib/modules/tautulli/routes/users_details/widgets/synced_items.dart index 25356b57..316d51c5 100644 --- a/lib/modules/tautulli/routes/users_details/widgets/synced_items.dart +++ b/lib/modules/tautulli/routes/users_details/widgets/synced_items.dart @@ -42,7 +42,6 @@ class _State extends State return LunaScaffold( scaffoldKey: _scaffoldKey, module: LunaModule.TAUTULLI, - hideDrawer: true, body: _body(), ); } diff --git a/lib/vendor.dart b/lib/vendor.dart index 0b074e96..c367a764 100644 --- a/lib/vendor.dart +++ b/lib/vendor.dart @@ -16,7 +16,6 @@ export 'package:hive/hive.dart'; export 'package:hive_flutter/hive_flutter.dart'; export 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; export 'package:json_annotation/json_annotation.dart'; -export 'package:layout/layout.dart'; export 'package:package_info_plus/package_info_plus.dart'; export 'package:stash/stash_api.dart'; export 'package:stash_memory/stash_memory.dart'; diff --git a/lib/widgets/appbar.dart b/lib/widgets/appbar.dart index 32e2bf63..0ae6e2dd 100644 --- a/lib/widgets/appbar.dart +++ b/lib/widgets/appbar.dart @@ -1,4 +1,3 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:lunasea/core.dart'; @@ -216,8 +215,6 @@ class _State extends State { Widget? _sharedLeading(BuildContext context) { if (widget.hideLeading) return null; - if (kDebugMode && context.breakpoint >= LayoutBreakpoint.md) return null; - if (widget.useDrawer) return SizedBox( child: LunaIconButton.appBar( diff --git a/lib/widgets/drawer/drawer.dart b/lib/widgets/drawer/drawer.dart index fd3a59af..f3facb50 100644 --- a/lib/widgets/drawer/drawer.dart +++ b/lib/widgets/drawer/drawer.dart @@ -10,18 +10,26 @@ class LunaDrawer extends StatelessWidget { required this.page, }) : super(key: key); + static List moduleAlphabeticalList() { + return LunaModule.active + ..sort((a, b) => a.name.toLowerCase().compareTo(b.name.toLowerCase())); + } + static List moduleOrderedList() { - final db = LunaSeaDatabase.DRAWER_MANUAL_ORDER.read(); - final modules = db?.cast() ?? LunaModule.DASHBOARD.allModules(); + try { + const db = LunaSeaDatabase.DRAWER_MANUAL_ORDER; + final modules = List.from(db.read()); + final missing = LunaModule.active; - // Add any modules that were added after the user set their drawer order preference - List _missing = LunaModule.DASHBOARD.allModules() - ..retainWhere((module) => !modules.contains(module)); - modules - ..addAll(_missing) - ..retainWhere((module) => module.featureFlag); + missing.retainWhere((m) => !modules.contains(m)); + modules.addAll(missing); + modules.retainWhere((m) => (m as LunaModule).featureFlag); - return modules; + return modules.cast(); + } catch (error, stack) { + LunaLogger().error('Failed to create ordered module list', error, stack); + return moduleAlphabeticalList(); + } } @override @@ -39,9 +47,12 @@ class LunaDrawer extends StatelessWidget { Expanded( child: LunaListView( controller: PrimaryScrollController.of(context), - children: LunaSeaDatabase.DRAWER_AUTOMATIC_MANAGE.read() - ? _getAlphabeticalOrder(context) - : _getManualOrder(context), + children: _moduleList( + context, + LunaSeaDatabase.DRAWER_AUTOMATIC_MANAGE.read() + ? moduleAlphabeticalList() + : moduleOrderedList(), + ), physics: const ClampingScrollPhysics(), padding: MediaQuery.of(context).padding.copyWith(top: 0), ), @@ -63,29 +74,10 @@ class LunaDrawer extends StatelessWidget { ]; } - List _getAlphabeticalOrder(BuildContext context) { - List _modules = LunaModule.DASHBOARD.allModules() - ..sort((a, b) => a.name.toLowerCase().compareTo(b.name.toLowerCase())); + List _moduleList(BuildContext context, List modules) { return [ ..._sharedHeader(context), - ..._modules.map((module) { - if (module.isEnabled) { - return _buildEntry( - context: context, - module: module, - onTap: module == LunaModule.WAKE_ON_LAN ? _wakeOnLAN : null, - ); - } - return const SizedBox(height: 0.0); - }), - ]; - } - - List _getManualOrder(BuildContext context) { - List _modules = moduleOrderedList(); - return [ - ..._sharedHeader(context), - ..._modules.map((module) { + ...modules.map((module) { if (module.isEnabled) { return _buildEntry( context: context, @@ -101,7 +93,7 @@ class LunaDrawer extends StatelessWidget { Widget _buildEntry({ required BuildContext context, required LunaModule module, - Function? onTap, + void Function()? onTap, }) { bool currentPage = page == module.key.toLowerCase(); return SizedBox( @@ -126,10 +118,9 @@ class LunaDrawer extends StatelessWidget { ), ], ), - onTap: onTap as void Function()? ?? + onTap: onTap ?? () async { - LayoutBreakpoint _bp = context.breakpoint; - if (_bp < LayoutBreakpoint.md) Navigator.of(context).pop(); + Navigator.of(context).pop(); if (!currentPage) module.launch(); }, ), diff --git a/lib/widgets/scaffold.dart b/lib/widgets/scaffold.dart index b63b4f7c..70b6626c 100644 --- a/lib/widgets/scaffold.dart +++ b/lib/widgets/scaffold.dart @@ -1,4 +1,3 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:lunasea/core.dart'; @@ -12,7 +11,6 @@ class LunaScaffold extends StatelessWidget { final Widget? floatingActionButton; final bool extendBody; final bool extendBodyBehindAppBar; - final bool hideDrawer; /// Called when [LunaSeaDatabase.ENABLED_PROFILE] has changed. Triggered within the build function. final void Function(BuildContext)? onProfileChange; @@ -29,71 +27,32 @@ class LunaScaffold extends StatelessWidget { this.extendBody = false, this.extendBodyBehindAppBar = false, this.onProfileChange, - this.hideDrawer = false, }) : super(key: key); @override Widget build(BuildContext context) { - if (drawer != null) - return LunaWillPopScope( - scaffoldKey: scaffoldKey, - child: scaffold, - ); - return scaffold; + return LunaWillPopScope( + scaffoldKey: scaffoldKey, + child: scaffold, + ); } Widget get scaffold { - return ValueListenableBuilder( - valueListenable: LunaBox.lunasea.box.listenable( - keys: [LunaSeaDatabase.ENABLED_PROFILE.key], - ), - builder: (context, dynamic _, __) { - if (onProfileChange != null) onProfileChange!(context); - return AdaptiveBuilder.builder( - builder: (context, layout, child) { - if (kDebugMode && layout.breakpoint >= LayoutBreakpoint.md) - return _scaffoldMedium(child!); - return _scaffoldSmall(child); - }, - child: body, + return LunaSeaDatabase.ENABLED_PROFILE.listen( + builder: (context, _) { + onProfileChange?.call(context); + return Scaffold( + key: scaffoldKey, + appBar: appBar, + body: body, + drawer: drawer, + bottomNavigationBar: bottomNavigationBar, + floatingActionButton: floatingActionButton, + extendBody: extendBody, + extendBodyBehindAppBar: extendBodyBehindAppBar, + onDrawerChanged: (_) => FocusManager.instance.primaryFocus?.unfocus(), ); }, ); } - - Widget _scaffoldSmall(Widget? child) { - return Scaffold( - key: scaffoldKey, - appBar: appBar, - body: child, - drawer: hideDrawer ? null : drawer, - bottomNavigationBar: bottomNavigationBar, - floatingActionButton: floatingActionButton, - extendBody: extendBody, - extendBodyBehindAppBar: extendBodyBehindAppBar, - onDrawerChanged: (_) => FocusManager.instance.primaryFocus?.unfocus(), - ); - } - - Widget _scaffoldMedium(Widget child) => Scaffold( - key: scaffoldKey, - body: Row( - children: [ - if (!hideDrawer) LunaDrawer(page: module?.key ?? ''), - Expanded( - child: Column( - children: [ - if (appBar != null) appBar!, - Expanded(child: child), - if (bottomNavigationBar != null) bottomNavigationBar!, - ], - ), - ), - ], - ), - floatingActionButton: floatingActionButton, - extendBody: extendBody, - extendBodyBehindAppBar: extendBodyBehindAppBar, - onDrawerChanged: (_) => FocusManager.instance.primaryFocus?.unfocus(), - ); } diff --git a/pubspec.lock b/pubspec.lock index 2735bc67..ad0dd7c5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -56,7 +56,7 @@ packages: name: build url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "2.3.0" build_config: dependency: transitive description: @@ -77,7 +77,7 @@ packages: name: build_resolvers url: "https://pub.dartlang.org" source: hosted - version: "2.0.6" + version: "2.0.9" build_runner: dependency: "direct dev" description: @@ -105,7 +105,7 @@ packages: name: built_value url: "https://pub.dartlang.org" source: hosted - version: "8.1.4" + version: "8.3.2" cached_network_image: dependency: "direct main" description: @@ -134,13 +134,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" checked_yaml: dependency: transitive description: @@ -175,21 +168,21 @@ packages: name: cloud_firestore url: "https://pub.dartlang.org" source: hosted - version: "3.1.16" + version: "3.1.17" cloud_firestore_platform_interface: dependency: transitive description: name: cloud_firestore_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "5.5.6" + version: "5.5.7" cloud_firestore_web: dependency: transitive description: name: cloud_firestore_web url: "https://pub.dartlang.org" source: hosted - version: "2.6.15" + version: "2.6.16" code_builder: dependency: transitive description: @@ -210,14 +203,14 @@ packages: name: convert url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "3.0.2" crypto: dependency: transitive description: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "3.0.2" dart_console: dependency: transitive description: @@ -231,7 +224,7 @@ packages: name: dart_style url: "https://pub.dartlang.org" source: hosted - version: "2.2.2" + version: "2.2.3" device_frame: dependency: transitive description: @@ -322,14 +315,14 @@ packages: name: fading_edge_scrollview url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "3.0.0" ffi: dependency: transitive description: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.2.1" file: dependency: transitive description: @@ -343,35 +336,35 @@ packages: name: file_picker url: "https://pub.dartlang.org" source: hosted - version: "4.5.1" + version: "4.6.0" firebase_auth: dependency: "direct main" description: name: firebase_auth url: "https://pub.dartlang.org" source: hosted - version: "3.3.18" + version: "3.3.19" firebase_auth_platform_interface: dependency: transitive description: name: firebase_auth_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "6.2.6" + version: "6.2.7" firebase_auth_web: dependency: transitive description: name: firebase_auth_web url: "https://pub.dartlang.org" source: hosted - version: "3.3.15" + version: "3.3.16" firebase_core: dependency: "direct main" description: name: firebase_core url: "https://pub.dartlang.org" source: hosted - version: "1.17.0" + version: "1.17.1" firebase_core_platform_interface: dependency: transitive description: @@ -392,49 +385,49 @@ packages: name: firebase_messaging url: "https://pub.dartlang.org" source: hosted - version: "11.4.0" + version: "11.4.1" firebase_messaging_platform_interface: dependency: transitive description: name: firebase_messaging_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "3.5.0" + version: "3.5.1" firebase_messaging_web: dependency: transitive description: name: firebase_messaging_web url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" + version: "2.4.1" firebase_storage: dependency: "direct main" description: name: firebase_storage url: "https://pub.dartlang.org" source: hosted - version: "10.2.16" + version: "10.2.17" firebase_storage_platform_interface: dependency: transitive description: name: firebase_storage_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "4.1.6" + version: "4.1.7" firebase_storage_web: dependency: transitive description: name: firebase_storage_web url: "https://pub.dartlang.org" source: hosted - version: "3.2.15" + version: "3.2.16" fixnum: dependency: transitive description: name: fixnum url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.1" fl_chart: dependency: "direct main" description: @@ -467,7 +460,7 @@ packages: name: flutter_blurhash url: "https://pub.dartlang.org" source: hosted - version: "0.6.4" + version: "0.7.0" flutter_cache_manager: dependency: "direct main" description: @@ -500,14 +493,14 @@ packages: name: flutter_native_splash url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "2.2.2" flutter_plugin_android_lifecycle: dependency: transitive description: name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.0.6" flutter_riverpod: dependency: "direct main" description: @@ -540,7 +533,7 @@ packages: name: frontend_server_client url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.3" gap: dependency: transitive description: @@ -568,7 +561,7 @@ packages: name: go_router url: "https://pub.dartlang.org" source: hosted - version: "3.1.0" + version: "3.1.1" google_nav_bar: dependency: "direct main" description: @@ -624,7 +617,7 @@ packages: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "4.0.0" + version: "4.0.1" image: dependency: transitive description: @@ -645,7 +638,7 @@ packages: name: in_app_purchase_android url: "https://pub.dartlang.org" source: hosted - version: "0.2.2+2" + version: "0.2.2+6" in_app_purchase_platform_interface: dependency: transitive description: @@ -659,7 +652,7 @@ packages: name: in_app_purchase_storekit url: "https://pub.dartlang.org" source: hosted - version: "0.3.0+3" + version: "0.3.0+8" infinite_scroll_pagination: dependency: "direct main" description: @@ -757,7 +750,7 @@ packages: name: mime url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.0.2" modal_bottom_sheet: dependency: "direct main" description: @@ -785,7 +778,7 @@ packages: name: octo_image url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.0.2" package_config: dependency: transitive description: @@ -855,42 +848,42 @@ packages: name: path_provider_android url: "https://pub.dartlang.org" source: hosted - version: "2.0.12" + version: "2.0.14" path_provider_ios: dependency: transitive description: name: path_provider_ios url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.0.9" path_provider_linux: dependency: transitive description: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "2.1.7" path_provider_macos: dependency: transitive description: name: path_provider_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.0.6" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.4" path_provider_windows: dependency: transitive description: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.0.7" pedantic: dependency: transitive description: @@ -932,7 +925,7 @@ packages: name: pointycastle url: "https://pub.dartlang.org" source: hosted - version: "3.5.2" + version: "3.6.0" pool: dependency: transitive description: @@ -953,7 +946,7 @@ packages: name: provider url: "https://pub.dartlang.org" source: hosted - version: "6.0.2" + version: "6.0.3" pub_semver: dependency: transitive description: @@ -981,14 +974,14 @@ packages: name: quick_actions_android url: "https://pub.dartlang.org" source: hosted - version: "0.6.0+9" + version: "0.6.0+10" quick_actions_ios: dependency: transitive description: name: quick_actions_ios url: "https://pub.dartlang.org" source: hosted - version: "0.6.0+9" + version: "0.6.0+10" quick_actions_platform_interface: dependency: transitive description: @@ -1002,7 +995,7 @@ packages: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "3.0.1+1" + version: "3.1.0" retrofit: dependency: "direct main" description: @@ -1030,14 +1023,14 @@ packages: name: rxdart url: "https://pub.dartlang.org" source: hosted - version: "0.27.3" + version: "0.27.4" share_plus: dependency: "direct main" description: name: share_plus url: "https://pub.dartlang.org" source: hosted - version: "4.0.4" + version: "4.0.5" share_plus_linux: dependency: transitive description: @@ -1051,63 +1044,63 @@ packages: name: share_plus_macos url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" share_plus_platform_interface: dependency: transitive description: name: share_plus_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "3.0.2" + version: "3.0.3" share_plus_web: dependency: transitive description: name: share_plus_web url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" share_plus_windows: dependency: transitive description: name: share_plus_windows url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" shared_preferences: dependency: transitive description: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "2.0.13" + version: "2.0.15" shared_preferences_android: dependency: transitive description: name: shared_preferences_android url: "https://pub.dartlang.org" source: hosted - version: "2.0.11" + version: "2.0.12" shared_preferences_ios: dependency: transitive description: name: shared_preferences_ios url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" shared_preferences_macos: dependency: transitive description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.4" shared_preferences_platform_interface: dependency: transitive description: @@ -1121,14 +1114,14 @@ packages: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.4" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" shelf: dependency: transitive description: @@ -1175,42 +1168,42 @@ packages: name: sliver_tools url: "https://pub.dartlang.org" source: hosted - version: "0.2.5" + version: "0.2.6" source_gen: dependency: transitive description: name: source_gen url: "https://pub.dartlang.org" source: hosted - version: "1.2.1" + version: "1.2.2" source_helper: dependency: transitive description: name: source_helper url: "https://pub.dartlang.org" source: hosted - version: "1.3.1" + version: "1.3.2" source_span: dependency: transitive description: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.2" + version: "1.9.0" sqflite: dependency: transitive description: name: sqflite url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.2+1" sqflite_common: dependency: transitive description: name: sqflite_common url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "2.2.1+1" stack_trace: dependency: "direct main" description: @@ -1259,7 +1252,7 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" supercharged: dependency: "direct main" description: @@ -1287,7 +1280,7 @@ packages: name: table_calendar url: "https://pub.dartlang.org" source: hosted - version: "3.0.5" + version: "3.0.6" term_glyph: dependency: transitive description: @@ -1322,7 +1315,7 @@ packages: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" universal_io: dependency: transitive description: @@ -1343,28 +1336,28 @@ packages: name: url_launcher_android url: "https://pub.dartlang.org" source: hosted - version: "6.0.15" + version: "6.0.17" url_launcher_ios: dependency: transitive description: name: url_launcher_ios url: "https://pub.dartlang.org" source: hosted - version: "6.0.15" + version: "6.0.17" url_launcher_linux: dependency: transitive description: name: url_launcher_linux url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" url_launcher_macos: dependency: transitive description: name: url_launcher_macos url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" url_launcher_platform_interface: dependency: transitive description: @@ -1378,14 +1371,14 @@ packages: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.9" + version: "2.0.11" url_launcher_windows: dependency: transitive description: name: url_launcher_windows url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" uuid: dependency: "direct main" description: @@ -1420,14 +1413,14 @@ packages: name: web_socket_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.2.0" win32: dependency: transitive description: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.5.1" + version: "2.6.1" window_manager: dependency: "direct main" description: @@ -1448,7 +1441,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "6.0.1" + version: "6.1.0" yaml: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index fcfd9b37..fb6ce598 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,9 +10,9 @@ dependencies: sdk: flutter badges: ^2.0.2 cached_network_image: ^3.2.1 - cloud_firestore: ^3.1.16 + cloud_firestore: ^3.1.17 collection: ^1.15.0 - convert: ^3.0.1 + convert: ^3.0.2 device_preview: ^1.1.0 dio: ^4.0.6 easy_localization: ^3.0.1 @@ -20,19 +20,19 @@ dependencies: encrypt: ^5.0.1 envify: ^2.0.2 expandable: ^5.0.1 - fading_edge_scrollview: ^2.0.1 - file_picker: ^4.5.1 - firebase_auth: ^3.3.18 - firebase_core: ^1.17.0 - firebase_messaging: ^11.4.0 - firebase_storage: ^10.2.16 + fading_edge_scrollview: ^3.0.0 + file_picker: ^4.6.0 + firebase_auth: ^3.3.19 + firebase_core: ^1.17.1 + firebase_messaging: ^11.4.1 + firebase_storage: ^10.2.17 fl_chart: ^0.46.0 flash: ^2.0.3+2 fluro: ^2.0.3 flutter_cache_manager: ^3.3.0 flutter_riverpod: ^2.0.0-dev.9 flutter_spinkit: ^5.1.0 - go_router: ^3.1.0 + go_router: ^3.1.1 google_nav_bar: ^5.0.6 hive: ^2.2.1 hive_flutter: ^1.1.0 @@ -47,19 +47,19 @@ dependencies: percent_indicator: ^4.2.2 quick_actions: ^0.6.0+11 retrofit: ^3.0.1+1 - share_plus: ^4.0.4 + share_plus: ^4.0.5 shimmer: ^2.0.0 stack_trace: ^1.10.0 stash_memory: ^4.0.1 supercharged: ^2.1.1 - table_calendar: ^3.0.5 + table_calendar: ^3.0.6 transparent_image: ^2.0.0 tuple: ^2.0.0 url_launcher: ^6.1.2 uuid: ^3.0.6 wake_on_lan: ^3.0.0 window_manager: ^0.2.3 - xml: ^6.0.1 + xml: ^6.1.0 simple_icons: ^6.13.0 dev_dependencies: @@ -72,7 +72,7 @@ dev_dependencies: # Tooling flutter_launcher_icons: ^0.9.2 flutter_lints: ^2.0.1 - flutter_native_splash: ^2.2.1 + flutter_native_splash: ^2.2.2 msix: ^3.6.2 dependency_overrides: