From c54204d8a457e5b63a884ddd7373e4b516621ad6 Mon Sep 17 00:00:00 2001 From: bai-3 Date: Mon, 28 Oct 2024 21:58:46 +0800 Subject: [PATCH] add linux shadow --- lib/infra/components/window.dart | 13 +++--- lib/main.dart | 3 +- linux/flutter/generated_plugin_registrant.cc | 8 ++-- linux/flutter/generated_plugins.cmake | 2 +- macos/Flutter/GeneratedPluginRegistrant.swift | 4 +- pubspec.lock | 40 +++++++++++++++++-- pubspec.yaml | 2 +- .../flutter/generated_plugin_registrant.cc | 6 +-- windows/flutter/generated_plugins.cmake | 2 +- 9 files changed, 56 insertions(+), 24 deletions(-) diff --git a/lib/infra/components/window.dart b/lib/infra/components/window.dart index 1bca21ad..f287e6e4 100644 --- a/lib/infra/components/window.dart +++ b/lib/infra/components/window.dart @@ -41,7 +41,7 @@ class _WindowFrameState extends State with WindowListener { Widget _buildWindowFrame(BuildContext context) { final constTheme = Theme.of(context).extension()!; - return DecoratedBox( + return Container( decoration: BoxDecoration( color: constTheme.sidebarBg.withOpacity(0.70), border: Border.all( @@ -49,17 +49,18 @@ class _WindowFrameState extends State with WindowListener { width: (_isMaximized || _isFullScreen) ? 0 : 1, ), borderRadius: BorderRadius.circular( - (_isMaximized || _isFullScreen) ? 0 : 16, + (_isMaximized || _isFullScreen) ? 0 : 23 ), boxShadow: [ if (!_isMaximized && !_isFullScreen) BoxShadow( - color: Colors.black.withOpacity(0.1), - offset: Offset(0.0, _isFocused ? 4 : 2), - blurRadius: 16, + color: Colors.black.withOpacity(0.4), + // offset: Offset(0.0, _isFocused ? 4 : 2), + blurRadius: 5 ), ], ), + margin: const EdgeInsets.all(5), child: ClipRRect( // clipBehavior: Clip.hardEdge, borderRadius: BorderRadius.circular( @@ -70,7 +71,7 @@ class _WindowFrameState extends State with WindowListener { child: ClipRRect( clipBehavior: Clip.hardEdge, borderRadius: BorderRadius.circular( - (_isMaximized || _isFullScreen) ? 0 : 12, + (_isMaximized || _isFullScreen) ? 0 : 20, ), child: widget.child, ), diff --git a/lib/main.dart b/lib/main.dart index ba915cf3..76155c08 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -29,7 +29,6 @@ Future main() async { WidgetsFlutterBinding.ensureInitialized(); if (isPc()) { await windowManager.ensureInitialized(); - // await windowManager.hide(); } AdaptiveDialog.instance.updateConfiguration(defaultStyle: AdaptiveStyle.material); @@ -76,7 +75,7 @@ Future main() async { await windowManager.setAsFrameless(); } await windowManager.setSize(winSize); - await windowManager.show(); + // await windowManager.show(); await showtray(); await windowManager.focus(); }); diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 27da6a66..61087057 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -44,9 +44,9 @@ void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) record_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "RecordLinuxPlugin"); record_linux_plugin_register_with_registrar(record_linux_registrar); - g_autoptr(FlPluginRegistrar) screen_retriever_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin"); - screen_retriever_plugin_register_with_registrar(screen_retriever_registrar); + g_autoptr(FlPluginRegistrar) screen_retriever_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverLinuxPlugin"); + screen_retriever_linux_plugin_register_with_registrar(screen_retriever_linux_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); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 801568b9..3c517793 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -11,7 +11,7 @@ list(APPEND FLUTTER_PLUGIN_LIST flutter_secure_storage_linux flutter_webrtc record_linux - screen_retriever + screen_retriever_linux tray_manager url_launcher_linux window_manager diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 68d9440d..8bd0e205 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -19,7 +19,7 @@ import macos_window_utils import package_info_plus import path_provider_foundation import record_darwin -import screen_retriever +import screen_retriever_macos import shared_preferences_foundation import tray_manager import url_launcher_macos @@ -43,7 +43,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) RecordPlugin.register(with: registry.registrar(forPlugin: "RecordPlugin")) - ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin")) + ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) TrayManagerPlugin.register(with: registry.registrar(forPlugin: "TrayManagerPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) diff --git a/pubspec.lock b/pubspec.lock index cc796488..1b526c23 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1568,10 +1568,42 @@ packages: dependency: transitive description: name: screen_retriever - sha256: "6ee02c8a1158e6dae7ca430da79436e3b1c9563c8cf02f524af997c201ac2b90" + sha256: "570dbc8e4f70bac451e0efc9c9bb19fa2d6799a11e6ef04f946d7886d2e23d0c" url: "https://pub.flutter-io.cn" source: hosted - version: "0.1.9" + version: "0.2.0" + screen_retriever_linux: + dependency: transitive + description: + name: screen_retriever_linux + sha256: f7f8120c92ef0784e58491ab664d01efda79a922b025ff286e29aa123ea3dd18 + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.2.0" + screen_retriever_macos: + dependency: transitive + description: + name: screen_retriever_macos + sha256: "71f956e65c97315dd661d71f828708bd97b6d358e776f1a30d5aa7d22d78a149" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.2.0" + screen_retriever_platform_interface: + dependency: transitive + description: + name: screen_retriever_platform_interface + sha256: ee197f4581ff0d5608587819af40490748e1e39e648d7680ecf95c05197240c0 + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.2.0" + screen_retriever_windows: + dependency: transitive + description: + name: screen_retriever_windows + sha256: "449ee257f03ca98a57288ee526a301a430a344a161f9202b4fcc38576716fe13" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.2.0" sdp_transform: dependency: transitive description: @@ -2149,10 +2181,10 @@ packages: dependency: "direct main" description: name: window_manager - sha256: ab8b2a7f97543d3db2b506c9d875e637149d48ee0c6a5cb5f5fd6e0dac463792 + sha256: "732896e1416297c63c9e3fb95aea72d0355f61390263982a47fd519169dc5059" url: "https://pub.flutter-io.cn" source: hosted - version: "0.4.2" + version: "0.4.3" wkt_parser: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 3885271d..fd5f539b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -30,7 +30,7 @@ dependencies: # 主题 adaptive_theme: ^3.2.0 # 桌面客户端样式 - window_manager: ^0.4.2 + window_manager: ^0.4.3 # nosql 数据库 hive: ^2.2.3 # 全局状态树 diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 76453230..9a300b64 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -36,8 +36,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("FlutterWebRTCPlugin")); RecordWindowsPluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("RecordWindowsPluginCApi")); - ScreenRetrieverPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("ScreenRetrieverPlugin")); + ScreenRetrieverWindowsPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("ScreenRetrieverWindowsPluginCApi")); TrayManagerPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("TrayManagerPlugin")); UrlLauncherWindowsRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index b7d5402c..d627e637 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -11,7 +11,7 @@ list(APPEND FLUTTER_PLUGIN_LIST flutter_secure_storage_windows flutter_webrtc record_windows - screen_retriever + screen_retriever_windows tray_manager url_launcher_windows window_manager