mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
feat(desktop): show minimized to system tray notification
This commit is contained in:
parent
5536b951cf
commit
296f96cf17
@ -8,6 +8,12 @@ import 'package:window_manager/window_manager.dart';
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||||
import 'dart:io' show Platform;
|
import 'dart:io' show Platform;
|
||||||
|
import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';
|
||||||
|
|
||||||
|
final closeNotification = DesktopTools.createNotification(
|
||||||
|
title: 'Spotube',
|
||||||
|
message: 'Running in background. Minimized to System Tray',
|
||||||
|
);
|
||||||
|
|
||||||
class PageWindowTitleBar extends StatefulHookWidget
|
class PageWindowTitleBar extends StatefulHookWidget
|
||||||
implements PreferredSizeWidget {
|
implements PreferredSizeWidget {
|
||||||
@ -101,11 +107,12 @@ class WindowTitleBarButtons extends HookConsumerWidget {
|
|||||||
final isMaximized = useState<bool?>(null);
|
final isMaximized = useState<bool?>(null);
|
||||||
const type = ThemeType.auto;
|
const type = ThemeType.auto;
|
||||||
|
|
||||||
void onClose() {
|
Future<void> onClose() async {
|
||||||
if (closeBehavior == CloseBehavior.close) {
|
if (closeBehavior == CloseBehavior.close) {
|
||||||
windowManager.close();
|
await windowManager.close();
|
||||||
} else {
|
} else {
|
||||||
windowManager.hide();
|
await windowManager.hide();
|
||||||
|
await closeNotification?.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,9 +8,8 @@
|
|||||||
|
|
||||||
#include <audioplayers_linux/audioplayers_linux_plugin.h>
|
#include <audioplayers_linux/audioplayers_linux_plugin.h>
|
||||||
#include <catcher/catcher_plugin.h>
|
#include <catcher/catcher_plugin.h>
|
||||||
#include <desktop_multi_window/desktop_multi_window_plugin.h>
|
|
||||||
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
|
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
|
||||||
#include <native_context_menu/native_context_menu_plugin.h>
|
#include <local_notifier/local_notifier_plugin.h>
|
||||||
#include <screen_retriever/screen_retriever_plugin.h>
|
#include <screen_retriever/screen_retriever_plugin.h>
|
||||||
#include <system_theme/system_theme_plugin.h>
|
#include <system_theme/system_theme_plugin.h>
|
||||||
#include <system_tray/system_tray_plugin.h>
|
#include <system_tray/system_tray_plugin.h>
|
||||||
@ -25,15 +24,12 @@ void fl_register_plugins(FlPluginRegistry* registry) {
|
|||||||
g_autoptr(FlPluginRegistrar) catcher_registrar =
|
g_autoptr(FlPluginRegistrar) catcher_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "CatcherPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "CatcherPlugin");
|
||||||
catcher_plugin_register_with_registrar(catcher_registrar);
|
catcher_plugin_register_with_registrar(catcher_registrar);
|
||||||
g_autoptr(FlPluginRegistrar) desktop_multi_window_registrar =
|
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "DesktopMultiWindowPlugin");
|
|
||||||
desktop_multi_window_plugin_register_with_registrar(desktop_multi_window_registrar);
|
|
||||||
g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar =
|
g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin");
|
||||||
flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar);
|
flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar);
|
||||||
g_autoptr(FlPluginRegistrar) native_context_menu_registrar =
|
g_autoptr(FlPluginRegistrar) local_notifier_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "NativeContextMenuPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "LocalNotifierPlugin");
|
||||||
native_context_menu_plugin_register_with_registrar(native_context_menu_registrar);
|
local_notifier_plugin_register_with_registrar(local_notifier_registrar);
|
||||||
g_autoptr(FlPluginRegistrar) screen_retriever_registrar =
|
g_autoptr(FlPluginRegistrar) screen_retriever_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin");
|
||||||
screen_retriever_plugin_register_with_registrar(screen_retriever_registrar);
|
screen_retriever_plugin_register_with_registrar(screen_retriever_registrar);
|
||||||
|
@ -5,9 +5,8 @@
|
|||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
audioplayers_linux
|
audioplayers_linux
|
||||||
catcher
|
catcher
|
||||||
desktop_multi_window
|
|
||||||
flutter_secure_storage_linux
|
flutter_secure_storage_linux
|
||||||
native_context_menu
|
local_notifier
|
||||||
screen_retriever
|
screen_retriever
|
||||||
system_theme
|
system_theme
|
||||||
system_tray
|
system_tray
|
||||||
|
@ -9,10 +9,9 @@ import audio_service
|
|||||||
import audio_session
|
import audio_session
|
||||||
import audioplayers_darwin
|
import audioplayers_darwin
|
||||||
import catcher
|
import catcher
|
||||||
import desktop_multi_window
|
|
||||||
import device_info_plus
|
import device_info_plus
|
||||||
import flutter_secure_storage_macos
|
import flutter_secure_storage_macos
|
||||||
import native_context_menu
|
import local_notifier
|
||||||
import package_info_plus
|
import package_info_plus
|
||||||
import path_provider_foundation
|
import path_provider_foundation
|
||||||
import screen_retriever
|
import screen_retriever
|
||||||
@ -29,10 +28,9 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
|||||||
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
|
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
|
||||||
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
|
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
|
||||||
CatcherPlugin.register(with: registry.registrar(forPlugin: "CatcherPlugin"))
|
CatcherPlugin.register(with: registry.registrar(forPlugin: "CatcherPlugin"))
|
||||||
FlutterMultiWindowPlugin.register(with: registry.registrar(forPlugin: "FlutterMultiWindowPlugin"))
|
|
||||||
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
||||||
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
|
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
|
||||||
NativeContextMenuPlugin.register(with: registry.registrar(forPlugin: "NativeContextMenuPlugin"))
|
LocalNotifierPlugin.register(with: registry.registrar(forPlugin: "LocalNotifierPlugin"))
|
||||||
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
|
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
|
||||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||||
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
|
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
|
||||||
|
28
pubspec.lock
28
pubspec.lock
@ -466,14 +466,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.8"
|
version: "0.7.8"
|
||||||
desktop_multi_window:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: desktop_multi_window
|
|
||||||
sha256: "29971186ae0790e32b156f127f9c22c5ee77bdb94b14f7cea23f2356d0c76cfc"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.2.0"
|
|
||||||
device_info_plus:
|
device_info_plus:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -627,8 +619,8 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: "3c07755ad33fb28a042da0ed26e31086ca318e21"
|
ref: "1f0bec3283626dcbd8ee2f54e238d096d8dea50e"
|
||||||
resolved-ref: "3c07755ad33fb28a042da0ed26e31086ca318e21"
|
resolved-ref: "1f0bec3283626dcbd8ee2f54e238d096d8dea50e"
|
||||||
url: "https://github.com/KRTirtho/flutter_desktop_tools.git"
|
url: "https://github.com/KRTirtho/flutter_desktop_tools.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.0.1"
|
version: "0.0.1"
|
||||||
@ -1001,6 +993,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.1"
|
version: "2.0.1"
|
||||||
|
local_notifier:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: local_notifier
|
||||||
|
sha256: cc855aa6362c8840e3d3b35b1c3b058a3a8becdb2b03d5a9aa3f3a1e861f0a03
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.1.5"
|
||||||
logger:
|
logger:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -1073,14 +1073,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.1"
|
version: "3.0.1"
|
||||||
native_context_menu:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: native_context_menu
|
|
||||||
sha256: "566f13d1f55e57bc8aca3b71b157b1ff03c2cc3821f6e9d980f76233ed30c9b7"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.2.2+5"
|
|
||||||
oauth2:
|
oauth2:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -83,7 +83,7 @@ dependencies:
|
|||||||
flutter_desktop_tools:
|
flutter_desktop_tools:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/KRTirtho/flutter_desktop_tools.git
|
url: https://github.com/KRTirtho/flutter_desktop_tools.git
|
||||||
ref: 3c07755ad33fb28a042da0ed26e31086ca318e21
|
ref: 1f0bec3283626dcbd8ee2f54e238d096d8dea50e
|
||||||
smtc_windows:
|
smtc_windows:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/KRTirtho/smtc_windows.git
|
url: https://github.com/KRTirtho/smtc_windows.git
|
||||||
|
@ -8,9 +8,8 @@
|
|||||||
|
|
||||||
#include <audioplayers_windows/audioplayers_windows_plugin.h>
|
#include <audioplayers_windows/audioplayers_windows_plugin.h>
|
||||||
#include <catcher/catcher_plugin.h>
|
#include <catcher/catcher_plugin.h>
|
||||||
#include <desktop_multi_window/desktop_multi_window_plugin.h>
|
|
||||||
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
|
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
|
||||||
#include <native_context_menu/native_context_menu_plugin.h>
|
#include <local_notifier/local_notifier_plugin.h>
|
||||||
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
||||||
#include <screen_retriever/screen_retriever_plugin.h>
|
#include <screen_retriever/screen_retriever_plugin.h>
|
||||||
#include <system_theme/system_theme_plugin.h>
|
#include <system_theme/system_theme_plugin.h>
|
||||||
@ -24,12 +23,10 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
|
|||||||
registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin"));
|
registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin"));
|
||||||
CatcherPluginRegisterWithRegistrar(
|
CatcherPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("CatcherPlugin"));
|
registry->GetRegistrarForPlugin("CatcherPlugin"));
|
||||||
DesktopMultiWindowPluginRegisterWithRegistrar(
|
|
||||||
registry->GetRegistrarForPlugin("DesktopMultiWindowPlugin"));
|
|
||||||
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
|
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
|
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
|
||||||
NativeContextMenuPluginRegisterWithRegistrar(
|
LocalNotifierPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("NativeContextMenuPlugin"));
|
registry->GetRegistrarForPlugin("LocalNotifierPlugin"));
|
||||||
PermissionHandlerWindowsPluginRegisterWithRegistrar(
|
PermissionHandlerWindowsPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
||||||
ScreenRetrieverPluginRegisterWithRegistrar(
|
ScreenRetrieverPluginRegisterWithRegistrar(
|
||||||
|
@ -5,9 +5,8 @@
|
|||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
audioplayers_windows
|
audioplayers_windows
|
||||||
catcher
|
catcher
|
||||||
desktop_multi_window
|
|
||||||
flutter_secure_storage_windows
|
flutter_secure_storage_windows
|
||||||
native_context_menu
|
local_notifier
|
||||||
permission_handler_windows
|
permission_handler_windows
|
||||||
screen_retriever
|
screen_retriever
|
||||||
system_theme
|
system_theme
|
||||||
|
Loading…
Reference in New Issue
Block a user