diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1702c555a..077edd402 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -49,6 +49,6 @@ jobs: channel: 'stable' flutter-version: ${{env.FLUTTER_VERSION}} - run: sudo apt update - - run: sudo apt install -y clang cmake curl libgtk-3-dev ninja-build pkg-config unzip libunwind-dev libmpv-dev libayatana-appindicator3-dev + - run: sudo apt install -y clang cmake curl libgtk-3-dev ninja-build pkg-config unzip libunwind-dev libmpv-dev - run: flutter pub get - run: flutter build linux -v \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 17bcfd12e..c4550d41e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -96,7 +96,7 @@ jobs: # channel: 'stable' # flutter-version: ${{env.FLUTTER_VERSION}} # - run: sudo apt update - # - run: sudo apt install -y clang cmake curl libgtk-3-dev ninja-build pkg-config unzip libunwind-dev libmpv-dev libayatana-appindicator3-dev + # - run: sudo apt install -y clang cmake curl libgtk-3-dev ninja-build pkg-config unzip libunwind-dev libmpv-dev # - run: flutter pub get # - uses: snapcore/action-build@v1 diff --git a/lib/app/view/app.dart b/lib/app/view/app.dart index 53ec02a19..d6d377312 100644 --- a/lib/app/view/app.dart +++ b/lib/app/view/app.dart @@ -1,12 +1,9 @@ -import 'dart:io'; import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:phoenix_theme/phoenix_theme.dart' hide ColorX, isMobile; import 'package:system_theme/system_theme.dart'; -import 'package:tray_manager/tray_manager.dart'; import 'package:watch_it/watch_it.dart'; -import 'package:window_manager/window_manager.dart'; import 'package:yaru/yaru.dart'; import '../../common/view/theme.dart'; @@ -17,7 +14,6 @@ import '../../settings/settings_model.dart'; import '../connectivity_model.dart'; import 'scaffold.dart'; import 'splash_screen.dart'; -import 'system_tray.dart'; class YaruMusicPodApp extends StatelessWidget { const YaruMusicPodApp({super.key}); @@ -67,8 +63,7 @@ class _MusicPodApp extends StatefulWidget with WatchItStatefulWidgetMixin { State<_MusicPodApp> createState() => _MusicPodAppState(); } -class _MusicPodAppState extends State<_MusicPodApp> - with WindowListener, TrayListener { +class _MusicPodAppState extends State<_MusicPodApp> { late Future _initFuture; @override @@ -82,38 +77,9 @@ class _MusicPodAppState extends State<_MusicPodApp> await di().init(); if (!mounted) return false; di().init(); - if (Platform.isLinux) { - windowManager.addListener(this); - trayManager.addListener(this); - } return true; } - @override - void dispose() { - if (Platform.isLinux) { - windowManager.removeListener(this); - trayManager.removeListener(this); - } - super.dispose(); - } - - @override - void onTrayIconMouseDown() { - trayManager.popUpContextMenu(); - } - - @override - void onWindowEvent(String eventName) { - if ('show' == eventName || 'hide' == eventName) { - updateTrayItems(context); - } - super.onWindowEvent(eventName); - } - - @override - void onTrayMenuItemClick(MenuItem menuItem) => reactToTray(menuItem); - @override Widget build(BuildContext context) { final themeIndex = watchPropertyValue((SettingsModel m) => m.themeIndex); diff --git a/lib/app/view/system_tray.dart b/lib/app/view/system_tray.dart deleted file mode 100644 index 1792c3ba9..000000000 --- a/lib/app/view/system_tray.dart +++ /dev/null @@ -1,72 +0,0 @@ -import 'dart:io'; - -import 'package:flutter/material.dart'; -import 'package:tray_manager/tray_manager.dart'; -import 'package:window_manager/window_manager.dart'; - -import '../../constants.dart'; -import '../../l10n/l10n.dart'; - -const _exitAppMenuKey = 'exit_app'; -const _showHideWindowMenuKey = 'show_hide_window'; - -Future initTray() async { - await trayManager.setIcon(_icon()); - Menu menu = Menu( - items: [ - MenuItem( - key: _showHideWindowMenuKey, - label: 'Show Window', - ), - MenuItem.separator(), - MenuItem( - key: _exitAppMenuKey, - label: 'Exit App', - ), - ], - ); - await trayManager.setContextMenu(menu); -} - -String _icon() { - if (Platform.isLinux) { - return kAppId; - } else if (Platform.isWindows) { - return 'assets/images/tray_icon.ico'; - } else { - return 'assets/images/tray_icon.png'; - } -} - -Future updateTrayItems(BuildContext context) async { - bool isVisible = await windowManager.isVisible(); - if (!context.mounted) return; - final trayMenuItems = [ - MenuItem( - key: _showHideWindowMenuKey, - label: isVisible ? context.l10n.hideToTray : context.l10n.closeApp, - ), - MenuItem.separator(), - MenuItem( - key: _exitAppMenuKey, - label: context.l10n.closeApp, - ), - ]; - - await trayManager.setContextMenu(Menu(items: trayMenuItems)); -} - -void reactToTray(MenuItem menuItem) { - switch (menuItem.key) { - case _showHideWindowMenuKey: - windowManager.isVisible().then((value) { - if (value) { - windowManager.hide(); - } else { - windowManager.show(); - } - }); - case _exitAppMenuKey: - windowManager.close(); - } -} diff --git a/lib/common/view/header_bar.dart b/lib/common/view/header_bar.dart index 85bfb1362..225b5cb42 100644 --- a/lib/common/view/header_bar.dart +++ b/lib/common/view/header_bar.dart @@ -1,5 +1,10 @@ import 'dart:io'; +import 'package:flutter/material.dart'; +import 'package:phoenix_theme/phoenix_theme.dart' hide isMobile; +import 'package:watch_it/watch_it.dart'; +import 'package:yaru/yaru.dart'; + import '../../app/app_model.dart'; import '../../extensions/build_context_x.dart'; import '../../l10n/l10n.dart'; @@ -9,11 +14,6 @@ import '../data/close_btn_action.dart'; import 'global_keys.dart'; import 'icons.dart'; import 'nav_back_button.dart'; -import 'package:flutter/material.dart'; -import 'package:phoenix_theme/phoenix_theme.dart' hide isMobile; -import 'package:watch_it/watch_it.dart'; -import 'package:yaru/yaru.dart'; - import 'theme.dart'; class HeaderBar extends StatelessWidget @@ -45,8 +45,6 @@ class HeaderBar extends StatelessWidget @override Widget build(BuildContext context) { final canPop = watchPropertyValue((LibraryModel m) => m.canPop); - final closeBtnAction = - watchPropertyValue((SettingsModel m) => m.closeBtnActionIndex); Widget? leading; @@ -103,21 +101,6 @@ class HeaderBar extends StatelessWidget backgroundColor ?? context.theme.scaffoldBackgroundColor, style: theStyle, foregroundColor: foregroundColor, - onClose: Platform.isLinux - ? (context) { - switch (closeBtnAction) { - case CloseBtnAction.alwaysAsk: - showDialog( - context: context, - builder: (_) => const CloseWindowActionConfirmDialog(), - ); - case CloseBtnAction.hideToTray: - YaruWindow.hide(context); - case CloseBtnAction.close: - YaruWindow.close(context); - } - } - : null, ), ); } diff --git a/lib/main.dart b/lib/main.dart index 21bbe2840..827c31699 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -19,7 +19,6 @@ import '../../library/library_model.dart'; import 'app/app_model.dart'; import 'app/connectivity_model.dart'; import 'app/view/app.dart'; -import 'app/view/system_tray.dart'; import 'constants.dart'; import 'library/library_service.dart'; import 'local_audio/local_audio_model.dart'; @@ -44,9 +43,7 @@ Future main(List args) async { WindowManager.instance ..setMinimumSize(const Size(500, 700)) ..setSize(const Size(950, 820)); - if (Platform.isLinux) { - await initTray(); - } else { + if (!Platform.isLinux) { SystemTheme.fallbackColor = Colors.greenAccent; await SystemTheme.accentColor.load(); } diff --git a/lib/settings/view/settings_page.dart b/lib/settings/view/settings_page.dart index 78d16e59d..7ef32de5e 100644 --- a/lib/settings/view/settings_page.dart +++ b/lib/settings/view/settings_page.dart @@ -1,5 +1,3 @@ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:path/path.dart' as p; import 'package:url_launcher/url_launcher.dart'; @@ -42,12 +40,11 @@ class SettingsPage extends StatelessWidget { ), Expanded( child: ListView( - children: [ - const _ThemeSection(), - if (Platform.isLinux) const _CloseActionSection(), - const _PodcastSection(), - const _LocalAudioSection(), - const _AboutSection(), + children: const [ + _ThemeSection(), + _PodcastSection(), + _LocalAudioSection(), + _AboutSection(), ], ), ), @@ -103,6 +100,10 @@ class _ThemeSection extends StatelessWidget with WatchItMixin { } } +// TODO: figure out how to show the window from clicking the dock icon in macos, windows and linux +// Also figure out how to show the window again, when the gtk window is triggered from the outside (open with) +// if we can not figure this out, we can not land this feature. +// ignore: unused_element class _CloseActionSection extends StatelessWidget with WatchItMixin { const _CloseActionSection(); diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 6bc70a71e..1af123b9b 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -48,9 +47,6 @@ void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) system_theme_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "SystemThemePlugin"); system_theme_plugin_register_with_registrar(system_theme_registrar); - g_autoptr(FlPluginRegistrar) tray_manager_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "TrayManagerPlugin"); - tray_manager_plugin_register_with_registrar(tray_manager_registrar); g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index a5d30a295..d52676c1e 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -12,7 +12,6 @@ list(APPEND FLUTTER_PLUGIN_LIST screen_retriever super_native_extensions system_theme - tray_manager url_launcher_linux window_manager yaru_window_linux diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 712af2624..9e16b13bf 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -21,7 +21,6 @@ import shared_preferences_foundation import sqflite import super_native_extensions import system_theme -import tray_manager import url_launcher_macos import wakelock_plus import window_manager @@ -43,7 +42,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) SuperNativeExtensionsPlugin.register(with: registry.registrar(forPlugin: "SuperNativeExtensionsPlugin")) SystemThemePlugin.register(with: registry.registrar(forPlugin: "SystemThemePlugin")) - TrayManagerPlugin.register(with: registry.registrar(forPlugin: "TrayManagerPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin")) WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin")) diff --git a/pubspec.lock b/pubspec.lock index 904b401ce..80ab9772a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -901,14 +901,6 @@ packages: url: "https://github.com/media-kit/media-kit" source: git version: "1.2.4" - menu_base: - dependency: transitive - description: - name: menu_base - sha256: "820368014a171bd1241030278e6c2617354f492f5c703d7b7d4570a6b8b84405" - url: "https://pub.dev" - source: hosted - version: "0.1.1" meta: dependency: transitive description: @@ -1358,14 +1350,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.0" - shortid: - dependency: transitive - description: - name: shortid - sha256: d0b40e3dbb50497dad107e19c54ca7de0d1a274eb9b4404991e443dadb9ebedb - url: "https://pub.dev" - source: hosted - version: "0.1.2" sky_engine: dependency: transitive description: flutter @@ -1531,14 +1515,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.1" - tray_manager: - dependency: "direct main" - description: - name: tray_manager - sha256: c9a63fd88bd3546287a7eb8ccc978d707eef82c775397af17dda3a4f4c039e64 - url: "https://pub.dev" - source: hosted - version: "0.2.3" tuple: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 35bbce93a..25662be7d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -71,7 +71,6 @@ dependencies: smtc_windows: ^0.1.3 super_drag_and_drop: ^0.8.18 system_theme: ^3.0.0 - tray_manager: ^0.2.3 url_launcher: ^6.3.0 watch_it: ^1.4.2 win32: ^5.5.4 diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index e0ae59cff..83f0001f2 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -98,8 +98,6 @@ parts: dart pub get flutter build linux --release -v cp -r build/linux/*/release/bundle/* $CRAFT_PART_INSTALL/bin/ - build-packages: - - libayatana-appindicator3-dev deps: plugin: nil diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 820f3252e..b34aa2b54 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -15,7 +15,6 @@ #include #include #include -#include #include #include @@ -38,8 +37,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("SuperNativeExtensionsPluginCApi")); SystemThemePluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("SystemThemePlugin")); - TrayManagerPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("TrayManagerPlugin")); UrlLauncherWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("UrlLauncherWindows")); WindowManagerPluginRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index f2b18ea3c..8b941b22e 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -12,7 +12,6 @@ list(APPEND FLUTTER_PLUGIN_LIST screen_retriever super_native_extensions system_theme - tray_manager url_launcher_windows window_manager )