From b2eb96ec1652bfbcc504d79def993eee9b050bb8 Mon Sep 17 00:00:00 2001 From: lollipopkit Date: Sat, 9 Dec 2023 16:31:18 +0800 Subject: [PATCH] new: `no titlebar` on desktop --- ios/Runner.xcodeproj/project.pbxproj | 36 +++---- lib/data/model/app/error.dart | 12 +-- lib/data/res/build_data.dart | 6 +- lib/main.dart | 30 +++--- lib/view/page/setting/android.dart | 4 +- lib/view/page/setting/entry.dart | 46 +++++---- lib/view/page/setting/ios.dart | 4 +- lib/view/widget/custom_appbar.dart | 99 ++++++++++++++++--- linux/flutter/generated_plugin_registrant.cc | 8 ++ linux/flutter/generated_plugins.cmake | 2 + macos/Flutter/GeneratedPluginRegistrant.swift | 6 +- macos/Podfile.lock | 18 ++-- macos/Runner.xcodeproj/project.pbxproj | 6 +- macos/Runner/Configs/AppInfo.xcconfig | 6 -- make.dart | 41 ++++---- pubspec.lock | 24 +++-- pubspec.yaml | 4 +- .../flutter/generated_plugin_registrant.cc | 6 ++ windows/flutter/generated_plugins.cmake | 2 + 19 files changed, 237 insertions(+), 123 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 6965abbc..2b7f0c08 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -586,7 +586,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 665; + CURRENT_PROJECT_VERSION = 667; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -596,7 +596,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.665; + MARKETING_VERSION = 1.0.667; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -720,7 +720,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 665; + CURRENT_PROJECT_VERSION = 667; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -730,7 +730,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.665; + MARKETING_VERSION = 1.0.667; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -748,7 +748,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 665; + CURRENT_PROJECT_VERSION = 667; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -758,7 +758,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.665; + MARKETING_VERSION = 1.0.667; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -779,7 +779,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 665; + CURRENT_PROJECT_VERSION = 667; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -792,7 +792,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.665; + MARKETING_VERSION = 1.0.667; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; @@ -818,7 +818,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 665; + CURRENT_PROJECT_VERSION = 667; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -831,7 +831,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.665; + MARKETING_VERSION = 1.0.667; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -854,7 +854,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 665; + CURRENT_PROJECT_VERSION = 667; DEVELOPMENT_TEAM = BA88US33G6; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = YES; @@ -867,7 +867,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0.665; + MARKETING_VERSION = 1.0.667; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -890,7 +890,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 665; + CURRENT_PROJECT_VERSION = 667; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -902,7 +902,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.665; + MARKETING_VERSION = 1.0.667; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; @@ -931,7 +931,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 665; + CURRENT_PROJECT_VERSION = 667; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -943,7 +943,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.665; + MARKETING_VERSION = 1.0.667; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; PRODUCT_NAME = ServerBox; @@ -969,7 +969,7 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 665; + CURRENT_PROJECT_VERSION = 667; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_PREVIEWS = YES; @@ -981,7 +981,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.665; + MARKETING_VERSION = 1.0.667; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; PRODUCT_NAME = ServerBox; diff --git a/lib/data/model/app/error.dart b/lib/data/model/app/error.dart index 10d760e0..e57b9819 100644 --- a/lib/data/model/app/error.dart +++ b/lib/data/model/app/error.dart @@ -25,8 +25,7 @@ enum SSHErrType { } class SSHErr extends Err { - SSHErr({required super.type, super.message}) - : super(from: ErrFrom.ssh); + SSHErr({required super.type, super.message}) : super(from: ErrFrom.ssh); @override String toString() { @@ -47,8 +46,7 @@ enum DockerErrType { } class DockerErr extends Err { - DockerErr({required super.type, super.message}) - : super(from: ErrFrom.docker); + DockerErr({required super.type, super.message}) : super(from: ErrFrom.docker); @override String toString() { @@ -63,8 +61,7 @@ enum ICloudErrType { } class ICloudErr extends Err { - ICloudErr({required super.type, super.message}) - : super(from: ErrFrom.icloud); + ICloudErr({required super.type, super.message}) : super(from: ErrFrom.icloud); @override String toString() { @@ -79,8 +76,7 @@ enum WebdavErrType { } class WebdavErr extends Err { - WebdavErr({required super.type, super.message}) - : super(from: ErrFrom.webdav); + WebdavErr({required super.type, super.message}) : super(from: ErrFrom.webdav); @override String toString() { diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index c44296d8..77951b58 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,9 +2,9 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 665; + static const int build = 667; static const String engine = "3.16.2"; - static const String buildAt = "2023-12-05 18:58:17"; - static const int modifications = 1; + static const String buildAt = "2023-12-09 14:56:57"; + static const int modifications = 11; static const int script = 31; } diff --git a/lib/main.dart b/lib/main.dart index c50e50b6..6e01da4c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -5,7 +5,6 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:hive_flutter/hive_flutter.dart'; import 'package:logging/logging.dart'; -import 'package:macos_window_utils/window_manipulator.dart'; import 'package:provider/provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:toolbox/core/channel/bg_run.dart'; @@ -15,6 +14,7 @@ import 'package:toolbox/core/utils/sync/webdav.dart'; import 'package:toolbox/data/res/logger.dart'; import 'package:toolbox/data/res/provider.dart'; import 'package:toolbox/data/res/store.dart'; +import 'package:window_manager/window_manager.dart'; import 'app.dart'; import 'core/analysis.dart'; @@ -66,14 +66,15 @@ void _runInZone(void Function() body) { body, (obj, trace) { Analysis.recordException(trace); - Loggers.root.warning(obj); + Loggers.root.warning(obj, null, trace); }, zoneSpecification: zoneSpec, ); } Future initApp() async { - await _initMacOSWindow(); + WidgetsFlutterBinding.ensureInitialized(); + await _initDesktopWindow(); // Base of all data. await _initDb(); @@ -125,12 +126,19 @@ void _setupLogger() { }); } -Future _initMacOSWindow() async { - if (!isMacOS) return; - WidgetsFlutterBinding.ensureInitialized(); - await WindowManipulator.initialize(); - WindowManipulator.makeTitlebarTransparent(); - WindowManipulator.enableFullSizeContentView(); - WindowManipulator.hideTitle(); - await CustomAppBar.updateTitlebarHeight(); +Future _initDesktopWindow() async { + if (!isDesktop) return; + await windowManager.ensureInitialized(); + const windowOptions = WindowOptions( + size: Size(400, 777), + center: true, + backgroundColor: Colors.transparent, + skipTaskbar: false, + titleBarStyle: TitleBarStyle.hidden, + ); + if (isMacOS) await CustomAppBar.updateTitlebarHeight(); + windowManager.waitUntilReadyToShow(windowOptions, () async { + await windowManager.show(); + await windowManager.focus(); + }); } diff --git a/lib/view/page/setting/android.dart b/lib/view/page/setting/android.dart index c2ba7599..7d6d9bc6 100644 --- a/lib/view/page/setting/android.dart +++ b/lib/view/page/setting/android.dart @@ -33,8 +33,8 @@ class _AndroidSettingsPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: CustomAppBar( - title: const Text('Android'), + appBar: const CustomAppBar( + title: Text('Android'), ), body: ListView( padding: const EdgeInsets.symmetric(horizontal: 17), diff --git a/lib/view/page/setting/entry.dart b/lib/view/page/setting/entry.dart index 92a7a118..f4f8b472 100644 --- a/lib/view/page/setting/entry.dart +++ b/lib/view/page/setting/entry.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_highlight/theme_map.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:provider/provider.dart'; +import 'package:toolbox/core/build_mode.dart'; import 'package:toolbox/core/extension/colorx.dart'; import 'package:toolbox/core/extension/context/common.dart'; import 'package:toolbox/core/extension/context/locale.dart'; @@ -123,25 +124,28 @@ class _SettingPageState extends State { ), /// Only for debug, this will cause the app to crash - // onDoubleTap: () => context.showRoundDialog( - // title: Text(l10n.attention), - // child: Text(l10n.sureDelete(l10n.all)), - // actions: [ - // TextButton( - // onPressed: () { - // Stores.docker.box.deleteFromDisk(); - // Stores.server.box.deleteFromDisk(); - // Stores.setting.box.deleteFromDisk(); - // Stores.history.box.deleteFromDisk(); - // Stores.snippet.box.deleteFromDisk(); - // Stores.key.box.deleteFromDisk(); - // exit(0); - // }, - // child: Text(l10n.ok, - // style: const TextStyle(color: Colors.red)), - // ), - // ], - // ), + onDoubleTap: () => context.showRoundDialog( + title: Text(l10n.attention), + child: Text(l10n.askContinue( + 'Delete all data from disk, and exit the app?', + )), + actions: [ + TextButton( + onPressed: () { + if (!BuildMode.isDebug) return; + Stores.docker.box.deleteFromDisk(); + Stores.server.box.deleteFromDisk(); + Stores.setting.box.deleteFromDisk(); + Stores.history.box.deleteFromDisk(); + Stores.snippet.box.deleteFromDisk(); + Stores.key.box.deleteFromDisk(); + exit(0); + }, + child: Text(l10n.ok, + style: const TextStyle(color: Colors.red)), + ), + ], + ), child: const Icon(Icons.delete), ), ), @@ -160,8 +164,8 @@ class _SettingPageState extends State { _buildSFTP(), _buildTitle(l10n.editor), _buildEditor(), - _buildTitle(l10n.fullScreen), - _buildFullScreen(), + if (isDesktop) _buildTitle(l10n.fullScreen), + if (isDesktop) _buildFullScreen(), const SizedBox(height: 37), ], ), diff --git a/lib/view/page/setting/ios.dart b/lib/view/page/setting/ios.dart index c1e3ba67..074df062 100644 --- a/lib/view/page/setting/ios.dart +++ b/lib/view/page/setting/ios.dart @@ -34,8 +34,8 @@ class _IOSSettingsPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: CustomAppBar( - title: const Text('iOS'), + appBar: const CustomAppBar( + title: Text('iOS'), ), body: ListView( padding: const EdgeInsets.symmetric(horizontal: 17), diff --git a/lib/view/widget/custom_appbar.dart b/lib/view/widget/custom_appbar.dart index ebd5ae79..13c3dcdf 100644 --- a/lib/view/widget/custom_appbar.dart +++ b/lib/view/widget/custom_appbar.dart @@ -1,22 +1,95 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; -import 'package:macos_window_utils/window_manipulator.dart'; +import 'package:window_manager/window_manager.dart'; -double? _titlebarHeight; +int? _titlebarHeight; +bool _drawTitlebar = false; -class CustomAppBar extends AppBar implements PreferredSizeWidget { - CustomAppBar({ +class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { + const CustomAppBar({ super.key, - super.title, - super.actions, - super.centerTitle, - super.leading, - super.backgroundColor, - }) : super(toolbarHeight: (_titlebarHeight ?? 0) + kToolbarHeight); + this.title, + this.actions, + this.centerTitle, + this.leading, + this.backgroundColor, + }); + + final Widget? title; + final List? actions; + final bool? centerTitle; + final Widget? leading; + final Color? backgroundColor; + + @override + Widget build(BuildContext context) { + final bar = AppBar( + key: key, + title: title, + actions: actions, + centerTitle: centerTitle, + leading: leading, + backgroundColor: backgroundColor, + toolbarHeight: (_titlebarHeight ?? 0) + kToolbarHeight, + ); + if (!_drawTitlebar) return bar; + return Stack( + children: [ + bar, + Positioned( + right: 0, + top: 0, + child: Row( + children: [ + const SizedBox(width: 8), + IconButton( + icon: const Icon(Icons.minimize), + onPressed: () => windowManager.minimize(), + ), + const SizedBox(width: 8), + IconButton( + icon: const Icon(Icons.crop_square), + onPressed: () async { + if (await windowManager.isMaximized()) { + windowManager.unmaximize(); + } else { + windowManager.maximize(); + } + }, + ), + const SizedBox(width: 8), + IconButton( + icon: const Icon(Icons.close), + onPressed: () => windowManager.close(), + ), + const SizedBox(width: 8), + ], + ), + ), + ], + ); + } static Future updateTitlebarHeight() async { - final newTitlebarHeight = await WindowManipulator.getTitlebarHeight(); - if (_titlebarHeight != newTitlebarHeight) { - _titlebarHeight = newTitlebarHeight; + switch (Platform.operatingSystem) { + case 'macos': + final newTitlebarHeight = await windowManager.getTitleBarHeight(); + if (_titlebarHeight != newTitlebarHeight) { + _titlebarHeight = newTitlebarHeight; + } + break; + // Draw a titlebar on Linux + case 'linux' || 'windows': + _titlebarHeight = 27; + _drawTitlebar = true; + break; + default: + break; } } + + @override + Size get preferredSize => + Size.fromHeight((_titlebarHeight ?? 0) + kToolbarHeight); } diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index fe56f8d8..965f5cf6 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -7,13 +7,21 @@ #include "generated_plugin_registrant.h" #include +#include #include +#include void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) dynamic_color_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "DynamicColorPlugin"); dynamic_color_plugin_register_with_registrar(dynamic_color_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) url_launcher_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); + g_autoptr(FlPluginRegistrar) window_manager_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin"); + window_manager_plugin_register_with_registrar(window_manager_registrar); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 18366213..dacf00d7 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -4,7 +4,9 @@ list(APPEND FLUTTER_PLUGIN_LIST dynamic_color + screen_retriever url_launcher_linux + window_manager ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index d192c478..b2a0347a 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -7,18 +7,20 @@ import Foundation import dynamic_color import icloud_storage -import macos_window_utils import path_provider_foundation +import screen_retriever import share_plus import shared_preferences_foundation import url_launcher_macos +import window_manager func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin")) IcloudStoragePlugin.register(with: registry.registrar(forPlugin: "IcloudStoragePlugin")) - MacOSWindowUtilsPlugin.register(with: registry.registrar(forPlugin: "MacOSWindowUtilsPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin")) SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) + WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin")) } diff --git a/macos/Podfile.lock b/macos/Podfile.lock index d9d0c1ad..8fdb3da5 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -4,11 +4,11 @@ PODS: - FlutterMacOS (1.0.0) - icloud_storage (0.0.1): - FlutterMacOS - - macos_window_utils (1.0.0): - - FlutterMacOS - path_provider_foundation (0.0.1): - Flutter - FlutterMacOS + - screen_retriever (0.0.1): + - FlutterMacOS - share_plus (0.0.1): - FlutterMacOS - shared_preferences_foundation (0.0.1): @@ -16,16 +16,19 @@ PODS: - FlutterMacOS - url_launcher_macos (0.0.1): - FlutterMacOS + - window_manager (0.2.0): + - FlutterMacOS DEPENDENCIES: - dynamic_color (from `Flutter/ephemeral/.symlinks/plugins/dynamic_color/macos`) - FlutterMacOS (from `Flutter/ephemeral`) - icloud_storage (from `Flutter/ephemeral/.symlinks/plugins/icloud_storage/macos`) - - macos_window_utils (from `Flutter/ephemeral/.symlinks/plugins/macos_window_utils/macos`) - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) + - screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`) - share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`) - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) + - window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`) EXTERNAL SOURCES: dynamic_color: @@ -34,26 +37,29 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral icloud_storage: :path: Flutter/ephemeral/.symlinks/plugins/icloud_storage/macos - macos_window_utils: - :path: Flutter/ephemeral/.symlinks/plugins/macos_window_utils/macos path_provider_foundation: :path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin + screen_retriever: + :path: Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos share_plus: :path: Flutter/ephemeral/.symlinks/plugins/share_plus/macos shared_preferences_foundation: :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin url_launcher_macos: :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos + window_manager: + :path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos SPEC CHECKSUMS: dynamic_color: 2eaa27267de1ca20d879fbd6e01259773fb1670f FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 icloud_storage: 33b05299e26d1391d724da8d62860e702380a1cd - macos_window_utils: 933f91f64805e2eb91a5bd057cf97cd097276663 path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 + screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38 share_plus: 76dd39142738f7a68dd57b05093b5e8193f220f7 shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126 url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95 + window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8 PODFILE CHECKSUM: 8cdf29216ea1ab6b9743188287968d22b4579c1d diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index 9f53f265..496b2325 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -226,7 +226,6 @@ 33CC10EC2044A3C60003C045 = { CreatedOnToolsVersion = 9.2; LastSwiftMigration = 1100; - ProvisioningStyle = Automatic; SystemCapabilities = { com.apple.Sandbox = { enabled = 1; @@ -442,6 +441,7 @@ COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = BA88US33G6; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = "Server Box"; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -574,6 +574,7 @@ COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = BA88US33G6; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = "Server Box"; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -595,11 +596,12 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; - "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = BA88US33G6; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = "Server Box"; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", diff --git a/macos/Runner/Configs/AppInfo.xcconfig b/macos/Runner/Configs/AppInfo.xcconfig index 6713dce0..b1704c3f 100644 --- a/macos/Runner/Configs/AppInfo.xcconfig +++ b/macos/Runner/Configs/AppInfo.xcconfig @@ -4,11 +4,5 @@ // future. If not, the values below would default to using the project name when this becomes a // 'flutter create' template. -// The application's name. By default this is also the title of the Flutter window. -PRODUCT_NAME = server_box - -// The application's bundle identifier -PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox - // The copyright displayed in application information PRODUCT_COPYRIGHT = Copyright © 2023 tech.lolli. All rights reserved. diff --git a/make.dart b/make.dart index 37252854..775ed5ba 100755 --- a/make.dart +++ b/make.dart @@ -5,6 +5,7 @@ import 'dart:convert'; import 'dart:io'; const appName = 'ServerBox'; +final appNameLower = appName.toLowerCase(); const buildDataFilePath = 'lib/data/res/build_data.dart'; const apkPath = 'build/app/outputs/flutter-apk/app-release.apk'; @@ -159,47 +160,49 @@ Future flutterBuildAndroid() async { Future flutterBuildLinux() async { await flutterBuild('linux'); - // mkdir ServerBox.AppDir - await Process.run('mkdir', ['ServerBox.AppDir']); - // cp -r build/linux/x64/release/bundle/* ServerBox.AppDir + const appDirName = '$appName.AppDir'; + // mkdir appName.AppDir + await Process.run('mkdir', [appDirName]); + // cp -r build/linux/x64/release/bundle/* appName.AppDir await Process.run('cp', [ '-r', './build/linux/x64/release/bundle/*', - 'ServerBox.AppDir', + appDirName, ]); // cp -r assets/app_icon.png ServerBox.AppDir await Process.run('cp', [ '-r', './assets/app_icon.png', - 'ServerBox.AppDir', + appDirName, ]); // Create AppRun const appRun = ''' #!/bin/sh cd "\$(dirname "\$0")" -exec ./ServerBox +exec ./$appName '''; - await File('ServerBox.AppDir/AppRun').writeAsString(appRun); + const appRunName = '$appDirName/AppRun'; + await File(appRunName).writeAsString(appRun); // chmod +x AppRun - await Process.run('chmod', ['+x', 'ServerBox.AppDir/AppRun']); + await Process.run('chmod', ['+x', appRunName]); // Create .desktop const desktop = ''' [Desktop Entry] -Name=ServerBox -Exec=ServerBox +Name=$appName +Exec=$appName Icon=app_icon Type=Application Categories=Network; '''; - await File('ServerBox.AppDir/ServerBox.desktop').writeAsString(desktop); + await File('$appDirName/$appName.desktop').writeAsString(desktop); // Run appimagetool - await Process.run('appimagetool', ['ServerBox.AppDir']); + await Process.run('appimagetool', [appDirName]); await scpLinux2CDN(); // Clean build files - await Process.run('rm', ['-r', 'ServerBox.AppDir']); - await Process.run('rm', ['ServerBox-x86_64.AppImage']); + await Process.run('rm', ['-r', appDirName]); + await Process.run('rm', ['$appName-x86_64.AppImage']); } Future flutterBuildWin() async { @@ -212,7 +215,7 @@ Future scpApk2CDN() async { print('SHA256: $sha256'); final result = await Process.run( 'scp', - [apkPath, 'hk:/var/www/res/serverbox/$sha256.apk'], + [apkPath, 'hk:/var/www/res/$appNameLower/$sha256.apk'], runInShell: true, ); if (result.exitCode != 0) { @@ -225,8 +228,8 @@ Future scpLinux2CDN() async { final result = await Process.run( 'scp', [ - 'ServerBox-x86_64.AppImage', - 'hk:/var/www/res/serverbox/$build.AppImage', + '$appName-x86_64.AppImage', + 'hk:/var/www/res/$appNameLower/$build.AppImage', ], runInShell: true, ); @@ -241,8 +244,8 @@ Future scpWindows2CDN() async { final result = await Process.run( 'scp', [ - './build/windows/runner/Release/server_box.zip', - 'hk:/var/www/res/serverbox/$build.zip', + './build/windows/runner/Release/$appName.zip', + 'hk:/var/www/res/$appNameLower/$build.zip', ], runInShell: true, ); diff --git a/pubspec.lock b/pubspec.lock index 016cd5d2..32e87afe 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -582,14 +582,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" - macos_window_utils: - dependency: "direct main" - description: - name: macos_window_utils - sha256: b3dfd47bbc605f0e315af684b50370a8f84932267aaa542098063fa384d593bd - url: "https://pub.dev" - source: hosted - version: "1.4.0" matcher: dependency: transitive description: @@ -798,6 +790,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.3.8+2" + screen_retriever: + dependency: transitive + description: + name: screen_retriever + sha256: "6ee02c8a1158e6dae7ca430da79436e3b1c9563c8cf02f524af997c201ac2b90" + url: "https://pub.dev" + source: hosted + version: "0.1.9" share_plus: dependency: "direct main" description: @@ -1133,6 +1133,14 @@ packages: url: "https://pub.dev" source: hosted version: "5.1.1" + window_manager: + dependency: "direct main" + description: + name: window_manager + sha256: dcc865277f26a7dad263a47d0e405d77e21f12cb71f30333a52710a408690bd7 + url: "https://pub.dev" + source: hosted + version: "0.3.7" xdg_directories: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 5a8d3c53..59c00ee7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -49,7 +49,6 @@ dependencies: flutter_highlight: ^0.7.0 code_text_field: ^1.1.0 shared_preferences: ^2.1.1 - macos_window_utils: ^1.2.0 dynamic_color: ^1.6.6 icloud_storage: ^2.2.0 local_auth: ^2.1.7 @@ -60,11 +59,12 @@ dependencies: url: https://github.com/lollipopkit/watch_connectivity choice: ^2.0.0 #flutter_secure_storage: ^9.0.0 - xml: ^6.4.2 + xml: ^6.4.2 # for parsing nvidia-smi webdav_client: git: ref: main url: https://github.com/lollipopkit/webdav_client + window_manager: ^0.3.7 dev_dependencies: flutter_native_splash: ^2.1.6 diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 7a68426d..b29d6496 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -8,16 +8,22 @@ #include #include +#include #include #include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { DynamicColorPluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("DynamicColorPluginCApi")); LocalAuthPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("LocalAuthPlugin")); + ScreenRetrieverPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("ScreenRetrieverPlugin")); SharePlusWindowsPluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi")); UrlLauncherWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("UrlLauncherWindows")); + WindowManagerPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("WindowManagerPlugin")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index d8bef0fa..16e54273 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -5,8 +5,10 @@ list(APPEND FLUTTER_PLUGIN_LIST dynamic_color local_auth_windows + screen_retriever share_plus url_launcher_windows + window_manager ) list(APPEND FLUTTER_FFI_PLUGIN_LIST