From 333bc458a0e2449246ef31f22eadf329fd7aceb8 Mon Sep 17 00:00:00 2001 From: Jagandeep Brar Date: Sun, 11 Apr 2021 16:42:09 -0500 Subject: [PATCH] (fix): [Desktop] Set minimum window size to prevent reactive overflow issues (#416) * (flutter): Added window_size package for desktop * (tweak): [UI] Highlight active profile in profile switcher popup menus * (fix): [Desktop] Set minimum window size to prevent reactive overflow issues * (tweak): [Radarr] Add headers for sections in disk space * (tweak): [macOS] Reduce minimum window dimension to 400px --- CHANGELOG.md | 2 ++ lib/core/system.dart | 1 + lib/core/system/desktop_window.dart | 16 ++++++++++ lib/core/ui/appbar.dart | 3 ++ lib/core/ui/drawer/drawer_header.dart | 3 ++ lib/core/ui/theme.dart | 10 +++++++ lib/main.dart | 12 ++------ .../system_status/pages/page_disk_space.dart | 29 +++++++++++++------ .../widgets/disk_space_tile.dart | 2 +- lib/modules/search/core/dialogs.dart | 3 ++ macos/Flutter/GeneratedPluginRegistrant.swift | 2 ++ macos/Podfile.lock | 6 ++++ pubspec.lock | 9 ++++++ pubspec.yaml | 5 ++++ 14 files changed, 83 insertions(+), 20 deletions(-) create mode 100644 lib/core/system/desktop_window.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index fec26ca5..91c81a84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - `[Radarr/System Status]` Show root folders on the disk space page #### TWEAKS +- `[UI/UX]` Highlight active profile in profile switcher popup menus #### FIXES - `[Radarr/Catalogue]` Update filters to more closely match the web GUI filtering @@ -19,6 +20,7 @@ - `[macOS]` (new) Enabled notification support - `[macOS]` (new) Enable hardening runtime and set development signing certificate - `[macOS]` (tweak) Set minimum macOS version to 10.14 (Mojave) +- `[macOS]` (fix) Set minimum window size to prevent reactive overflow issues - `[macOS]` (fix) Updated about dialog to have correct information - `[macOS]` (fix) Set application/window title - `[macOS]` (fix) Add platform compatability checks for all native linking packages diff --git a/lib/core/system.dart b/lib/core/system.dart index 761a51b6..753ce365 100644 --- a/lib/core/system.dart +++ b/lib/core/system.dart @@ -1,3 +1,4 @@ +export 'system/desktop_window.dart'; export 'system/firebase.dart'; export 'system/image_cache.dart'; export 'system/in_app_purchases.dart'; diff --git a/lib/core/system/desktop_window.dart b/lib/core/system/desktop_window.dart new file mode 100644 index 00000000..24859a77 --- /dev/null +++ b/lib/core/system/desktop_window.dart @@ -0,0 +1,16 @@ +import 'dart:io'; +import 'package:flutter/material.dart'; +import 'package:window_size/window_size.dart' as WindowSize; + +class LunaDesktopWindow { + static const double _MINIMUM_WINDOW_SIZE = 400; + static bool get isPlatformCompatible => Platform.isWindows || Platform.isMacOS || Platform.isLinux; + + /// Initialize the Desktop window: + /// - Sets the minimum window size + void initialize() { + if(isPlatformCompatible) { + WindowSize.setWindowMinSize(Size(_MINIMUM_WINDOW_SIZE, _MINIMUM_WINDOW_SIZE)); + } + } +} diff --git a/lib/core/ui/appbar.dart b/lib/core/ui/appbar.dart index 14792858..b8ef1628 100644 --- a/lib/core/ui/appbar.dart +++ b/lib/core/ui/appbar.dart @@ -272,6 +272,9 @@ class _State extends State { profile, style: TextStyle( fontSize: LunaUI.FONT_SIZE_SUBTITLE, + color: (LunaDatabaseValue.ENABLED_PROFILE.data ?? 'default') == profile + ? LunaColours.accent + : Colors.white, ), ), )]; diff --git a/lib/core/ui/drawer/drawer_header.dart b/lib/core/ui/drawer/drawer_header.dart index b99f40f3..efc307a5 100644 --- a/lib/core/ui/drawer/drawer_header.dart +++ b/lib/core/ui/drawer/drawer_header.dart @@ -38,6 +38,9 @@ class LunaDrawerHeader extends UserAccountsDrawerHeader { profile, style: TextStyle( fontSize: LunaUI.FONT_SIZE_SUBTITLE, + color: (LunaDatabaseValue.ENABLED_PROFILE.data ?? 'default') == profile + ? LunaColours.accent + : Colors.white, ), ), )]; diff --git a/lib/core/ui/theme.dart b/lib/core/ui/theme.dart index a8aa83d0..e382a523 100644 --- a/lib/core/ui/theme.dart +++ b/lib/core/ui/theme.dart @@ -3,6 +3,16 @@ import 'package:flutter/services.dart'; import 'package:lunasea/core.dart'; class LunaTheme { + /// Initialize the theme by setting the system navigation and system colours. + void intialize() { + //Set system UI overlay style (navbar, statusbar) + SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( + systemNavigationBarColor: Colors.black, + systemNavigationBarDividerColor: Colors.black, + statusBarColor: Colors.transparent, + )); + } + /// Returns the active [ThemeData] by checking the theme database value. ThemeData activeTheme() { return isAMOLEDTheme ? _pureBlackTheme() : _midnightTheme(); diff --git a/lib/main.dart b/lib/main.dart index 6bbb219a..704ca7a4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,8 +1,6 @@ import 'dart:async'; -import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; -import 'package:flutter/services.dart'; import 'package:lunasea/core.dart'; /// LunaSea Entry Point: Initialize & Run Application @@ -37,18 +35,12 @@ Future main() async { /// - Database Future _init() async { WidgetsFlutterBinding.ensureInitialized(); - //Set system UI overlay style (navbar, statusbar) - SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( - systemNavigationBarColor: Colors.black, - systemNavigationBarDividerColor: Colors.black, - statusBarColor: Colors.transparent, - )); - // Set window-related things for Desktop - if(Platform.isWindows || Platform.isMacOS || Platform.isLinux) {} //LunaSea initialization await Database().initialize(); await LunaFirebase().initialize(); LunaLogger().initialize(); + LunaTheme().intialize(); + LunaDesktopWindow().initialize(); LunaNetworking().initialize(); LunaImageCache().initialize(); LunaRouter().intialize(); diff --git a/lib/modules/radarr/routes/system_status/pages/page_disk_space.dart b/lib/modules/radarr/routes/system_status/pages/page_disk_space.dart index a7868cd1..ef54a870 100644 --- a/lib/modules/radarr/routes/system_status/pages/page_disk_space.dart +++ b/lib/modules/radarr/routes/system_status/pages/page_disk_space.dart @@ -67,18 +67,29 @@ class _State extends State with AutomaticKeepAl buttonText: 'Try Again', onTap: _refreshKey.currentState.show, ); + // Compile Disks + List _disks = [LunaMessage.inList(text: 'No Disks Found')]; + if((diskSpace?.length ?? 0) != 0) _disks = [ + LunaHeader(text: 'Disks'), + ...List.generate( + diskSpace.length, + (index) => RadarrDiskSpaceTile(diskSpace: diskSpace[index]), + ), + ]; + // Compile root folders + List _rootFolders = [LunaMessage.inList(text: 'No Root Folders Found')]; + if((rootFolders?.length ?? 0) != 0) _rootFolders = [ + LunaHeader(text: 'Root Folders'), + ...List.generate( + rootFolders.length, + (index) => RadarrDiskSpaceTile(rootFolder: rootFolders[index]), + ), + ]; return LunaListView( controller: RadarrSystemStatusNavigationBar.scrollControllers[1], children: [ - if((diskSpace?.length ?? 0) != 0) ...List.generate( - diskSpace.length, - (index) => RadarrDiskSpaceTile(diskSpace: diskSpace[index]), - ), - if((diskSpace?.length ?? 0) != 0 && (rootFolders?.length ?? 0) != 0) LunaDivider(), - if((rootFolders?.length ?? 0) != 0) ...List.generate( - rootFolders.length, - (index) => RadarrDiskSpaceTile(rootFolder: rootFolders[index]), - ), + ..._disks, + ..._rootFolders, ], ); } diff --git a/lib/modules/radarr/routes/system_status/widgets/disk_space_tile.dart b/lib/modules/radarr/routes/system_status/widgets/disk_space_tile.dart index 3b70c41a..2620cada 100644 --- a/lib/modules/radarr/routes/system_status/widgets/disk_space_tile.dart +++ b/lib/modules/radarr/routes/system_status/widgets/disk_space_tile.dart @@ -32,7 +32,7 @@ class RadarrDiskSpaceTile extends StatelessWidget { ), trailing: LunaIconButton( text: diskSpace?.lunaPercentageString ?? (rootFolder?.unmappedFolders?.length ?? 0).toString(), - color: diskSpace?.lunaColor ?? Colors.white, + color: diskSpace?.lunaColor ?? LunaColours.accent, ), contentPadding: diskSpace != null, ); diff --git a/lib/modules/search/core/dialogs.dart b/lib/modules/search/core/dialogs.dart index e12285f8..79fa9142 100644 --- a/lib/modules/search/core/dialogs.dart +++ b/lib/modules/search/core/dialogs.dart @@ -63,6 +63,9 @@ class SearchDialogs { profile, style: TextStyle( fontSize: LunaUI.FONT_SIZE_SUBTITLE, + color: (LunaDatabaseValue.ENABLED_PROFILE.data ?? 'default') == profile + ? LunaColours.accent + : Colors.white, ), ), )]; diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 4817e850..1ea27dcf 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -17,6 +17,7 @@ import package_info_plus_macos import path_provider_macos import shared_preferences_macos import url_launcher_macos +import window_size func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin")) @@ -31,4 +32,5 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) + WindowSizePlugin.register(with: registry.registrar(forPlugin: "WindowSizePlugin")) } diff --git a/macos/Podfile.lock b/macos/Podfile.lock index 663a95d5..e1e8e429 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -129,6 +129,8 @@ PODS: - FlutterMacOS - url_launcher_macos (0.0.1): - FlutterMacOS + - window_size (0.0.2): + - FlutterMacOS DEPENDENCIES: - cloud_firestore (from `Flutter/ephemeral/.symlinks/plugins/cloud_firestore/macos`) @@ -145,6 +147,7 @@ DEPENDENCIES: - path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`) - shared_preferences_macos (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) + - window_size (from `Flutter/ephemeral/.symlinks/plugins/window_size/macos`) SPEC REPOS: trunk: @@ -194,6 +197,8 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos url_launcher_macos: :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos + window_size: + :path: Flutter/ephemeral/.symlinks/plugins/window_size/macos CHECKOUT OPTIONS: FirebaseFirestore: @@ -230,6 +235,7 @@ SPEC CHECKSUMS: Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 shared_preferences_macos: 480ce071d0666e37cef23fe6c702293a3d21799e url_launcher_macos: 45af3d61de06997666568a7149c1be98b41c95d4 + window_size: 339dafa0b27a95a62a843042038fa6c3c48de195 PODFILE CHECKSUM: 817265f65ab6c0f9a801d1d2c4e1a525a6d63569 diff --git a/pubspec.lock b/pubspec.lock index 93e18b38..9a2c51f2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1169,6 +1169,15 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.5" + window_size: + dependency: "direct main" + description: + path: "plugins/window_size" + ref: "57a2cd88486105d3d813583339eb0e23c9bfd6d2" + resolved-ref: "57a2cd88486105d3d813583339eb0e23c9bfd6d2" + url: "git://github.com/google/flutter-desktop-embedding.git" + source: git + version: "0.1.0" xdg_directories: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 944a8220..bf71c45e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -56,6 +56,11 @@ dependencies: uuid: ^3.0.4 # ANDROID IOS LINUX MACOS WEB WINDOWS wake_on_lan: ^2.0.1+1 # ANDROID IOS LINUX MACOS WINDOWS xml: ^5.1.0 # ANDROID IOS LINUX MACOS WEB WINDOWS + window_size: + git: + url: git://github.com/google/flutter-desktop-embedding.git + path: plugins/window_size + ref: 57a2cd88486105d3d813583339eb0e23c9bfd6d2 dev_dependencies: build_runner: ^1.12.2