diff --git a/lib/main.dart b/lib/main.dart index b8e44e7..061a4c0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,6 @@ +import 'dart:io'; + +import 'package:bitsdojo_window/bitsdojo_window.dart'; import 'package:croppy/croppy.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization_loader/easy_localization_loader.dart'; @@ -49,6 +52,15 @@ void main() async { GoRouter.optionURLReflectsImperativeAPIs = true; usePathUrlStrategy(); + if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { + doWhenWindowReady(() { + appWindow.minSize = Size(480, 640); + appWindow.size = Size(1280, 720); + appWindow.alignment = Alignment.center; + appWindow.show(); + }); + } + await SentryFlutter.init( (options) { options.dsn = diff --git a/lib/widgets/navigation/app_scaffold.dart b/lib/widgets/navigation/app_scaffold.dart index 27ce3f4..12e93d5 100644 --- a/lib/widgets/navigation/app_scaffold.dart +++ b/lib/widgets/navigation/app_scaffold.dart @@ -1,4 +1,8 @@ +import 'dart:io'; + +import 'package:bitsdojo_window/bitsdojo_window.dart'; import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:responsive_framework/responsive_framework.dart'; @@ -98,6 +102,12 @@ class AppRootScaffold extends StatelessWidget { key: globalRootScaffoldKey, body: Column( children: [ + if (!kIsWeb && + (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) + Container( + color: Theme.of(context).colorScheme.surface, + child: WindowTitleBarBox(child: MoveWindow()), + ), ConnectionIndicator(), Expanded(child: innerWidget), ], diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 6e77527..75dd377 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,6 +6,7 @@ #include "generated_plugin_registrant.h" +#include #include #include #include @@ -16,6 +17,9 @@ #include void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) bitsdojo_window_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "BitsdojoWindowPlugin"); + bitsdojo_window_plugin_register_with_registrar(bitsdojo_window_linux_registrar); g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); file_selector_plugin_register_with_registrar(file_selector_linux_registrar); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 38d7bf8..7731fe2 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + bitsdojo_window_linux file_selector_linux flutter_udid flutter_webrtc diff --git a/linux/my_application.cc b/linux/my_application.cc index 835d151..b9e01cb 100644 --- a/linux/my_application.cc +++ b/linux/my_application.cc @@ -1,5 +1,7 @@ #include "my_application.h" +#include + #include #ifdef GDK_WINDOWING_X11 #include @@ -47,7 +49,8 @@ static void my_application_activate(GApplication* application) { gtk_window_set_title(window, "Surface"); } - gtk_window_set_default_size(window, 1280, 720); + auto bdw = bitsdojo_window_from(window); + bdw->setCustomFrame(true); gtk_widget_show(GTK_WIDGET(window)); g_autoptr(FlDartProject) project = fl_dart_project_new(); diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 6aa5aa5..ef449b6 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,6 +5,7 @@ import FlutterMacOS import Foundation +import bitsdojo_window_macos import connectivity_plus import device_info_plus import file_selector_macos @@ -27,6 +28,7 @@ import url_launcher_macos import wakelock_plus func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + BitsdojoWindowPlugin.register(with: registry.registrar(forPlugin: "BitsdojoWindowPlugin")) ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) diff --git a/macos/Podfile.lock b/macos/Podfile.lock index bf907fd..64e9dba 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -1,4 +1,6 @@ PODS: + - bitsdojo_window_macos (0.0.1): + - FlutterMacOS - connectivity_plus (0.0.1): - Flutter - FlutterMacOS @@ -170,6 +172,7 @@ PODS: - WebRTC-SDK (125.6422.06) DEPENDENCIES: + - bitsdojo_window_macos (from `Flutter/ephemeral/.symlinks/plugins/bitsdojo_window_macos/macos`) - connectivity_plus (from `Flutter/ephemeral/.symlinks/plugins/connectivity_plus/darwin`) - croppy (from `Flutter/ephemeral/.symlinks/plugins/croppy/macos`) - cupertino_http (from `Flutter/ephemeral/.symlinks/plugins/cupertino_http/macos`) @@ -213,6 +216,8 @@ SPEC REPOS: - WebRTC-SDK EXTERNAL SOURCES: + bitsdojo_window_macos: + :path: Flutter/ephemeral/.symlinks/plugins/bitsdojo_window_macos/macos connectivity_plus: :path: Flutter/ephemeral/.symlinks/plugins/connectivity_plus/darwin croppy: @@ -263,6 +268,7 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos SPEC CHECKSUMS: + bitsdojo_window_macos: 44e3b8fe3dd463820e0321f6256c5b1c16bb6a00 connectivity_plus: 4c41c08fc6d7c91f63bc7aec70ffe3730b04f563 croppy: 25a638bd7d05411d8c697f481568f261037694fc cupertino_http: 1d506209e339211efa0764caa7b2de4bc55b6818 diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index 5815a69..d84d57c 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -207,7 +207,6 @@ 450EB9DBD4B8BDF042B4AD98 /* Pods-RunnerTests.release.xcconfig */, F8242928618FC0DCAE7048D2 /* Pods-RunnerTests.profile.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; @@ -613,13 +612,18 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = W7HPZ53V6B; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = Surface; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); + MACOSX_DEPLOYMENT_TARGET = 11.0; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; }; @@ -745,13 +749,18 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = W7HPZ53V6B; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = Surface; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); + MACOSX_DEPLOYMENT_TARGET = 11.0; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -765,13 +774,18 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = W7HPZ53V6B; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = Surface; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); + MACOSX_DEPLOYMENT_TARGET = 11.0; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; }; diff --git a/macos/Runner/DebugProfile.entitlements b/macos/Runner/DebugProfile.entitlements index dddb8a3..d8dadb4 100644 --- a/macos/Runner/DebugProfile.entitlements +++ b/macos/Runner/DebugProfile.entitlements @@ -2,10 +2,20 @@ + com.apple.developer.aps-environment + development com.apple.security.app-sandbox com.apple.security.cs.allow-jit + com.apple.security.device.audio-input + + com.apple.security.device.bluetooth + + com.apple.security.files.user-selected.read-write + + com.apple.security.network.client + com.apple.security.network.server diff --git a/macos/Runner/MainFlutterWindow.swift b/macos/Runner/MainFlutterWindow.swift index 3cc05eb..02e747f 100644 --- a/macos/Runner/MainFlutterWindow.swift +++ b/macos/Runner/MainFlutterWindow.swift @@ -1,7 +1,13 @@ import Cocoa import FlutterMacOS -class MainFlutterWindow: NSWindow { +import bitsdojo_window_macos + +class MainFlutterWindow: BitsdojoWindow { + override func bitsdojo_window_configure() -> UInt { + return BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP + } + override func awakeFromNib() { let flutterViewController = FlutterViewController() let windowFrame = self.frame diff --git a/macos/Runner/Release.entitlements b/macos/Runner/Release.entitlements index 852fa1a..c804233 100644 --- a/macos/Runner/Release.entitlements +++ b/macos/Runner/Release.entitlements @@ -2,7 +2,19 @@ + com.apple.developer.aps-environment + development com.apple.security.app-sandbox + com.apple.security.device.audio-input + + com.apple.security.device.bluetooth + + com.apple.security.files.user-selected.read-write + + com.apple.security.network.client + + com.apple.security.network.server + diff --git a/pubspec.lock b/pubspec.lock index b749e84..7b129d2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -70,6 +70,46 @@ packages: url: "https://pub.dev" source: hosted version: "2.11.0" + bitsdojo_window: + dependency: "direct main" + description: + name: bitsdojo_window + sha256: "88ef7765dafe52d97d7a3684960fb5d003e3151e662c18645c1641c22b873195" + url: "https://pub.dev" + source: hosted + version: "0.1.6" + bitsdojo_window_linux: + dependency: transitive + description: + name: bitsdojo_window_linux + sha256: "9519c0614f98be733e0b1b7cb15b827007886f6fe36a4fb62cf3d35b9dd578ab" + url: "https://pub.dev" + source: hosted + version: "0.1.4" + bitsdojo_window_macos: + dependency: transitive + description: + name: bitsdojo_window_macos + sha256: f7c5be82e74568c68c5b8449e2c5d8fd12ec195ecd70745a7b9c0f802bb0268f + url: "https://pub.dev" + source: hosted + version: "0.1.4" + bitsdojo_window_platform_interface: + dependency: transitive + description: + name: bitsdojo_window_platform_interface + sha256: "65daa015a0c6dba749bdd35a0f092e7a8ba8b0766aa0480eb3ef808086f6e27c" + url: "https://pub.dev" + source: hosted + version: "0.1.2" + bitsdojo_window_windows: + dependency: transitive + description: + name: bitsdojo_window_windows + sha256: fa982cf61ede53f483e50b257344a1c250af231a3cdc93a7064dd6dc0d720b68 + url: "https://pub.dev" + source: hosted + version: "0.1.6" boolean_selector: dependency: transitive description: @@ -718,10 +758,10 @@ packages: dependency: "direct main" description: name: go_router - sha256: "8660b74171fafae4aa8202100fa2e55349e078281dadc73a241eb8e758534d9d" + sha256: "2fd11229f59e23e967b0775df8d5948a519cd7e1e8b6e849729e010587b46539" url: "https://pub.dev" source: hosted - version: "14.6.1" + version: "14.6.2" google_fonts: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 5236e3c..5bf6d9f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -94,6 +94,7 @@ dependencies: flutter_staggered_grid_view: ^0.7.0 popover: ^0.3.1 sliver_tools: ^0.2.12 + bitsdojo_window: ^0.1.6 dev_dependencies: flutter_test: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 602792d..28a74a5 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,7 @@ #include "generated_plugin_registrant.h" +#include #include #include #include @@ -21,6 +22,8 @@ #include void RegisterPlugins(flutter::PluginRegistry* registry) { + BitsdojoWindowPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("BitsdojoWindowPlugin")); ConnectivityPlusWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); FileSelectorWindowsRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index a5ce971..fee9a31 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + bitsdojo_window_windows connectivity_plus file_selector_windows firebase_core diff --git a/windows/runner/main.cpp b/windows/runner/main.cpp index e15b276..5794aed 100644 --- a/windows/runner/main.cpp +++ b/windows/runner/main.cpp @@ -2,6 +2,10 @@ #include #include +#include + +auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP) + #include "flutter_window.h" #include "utils.h"