fix: share button doesn't response under macOS 15 (#6487)

* fix: share button doesn't response under macos 15

* chore: enable macos integration test

* Revert "chore: enable macos integration test"

This reverts commit 32c49c9f36c9d41086fbe44d7006b872ed850505.

* chore: update comment
This commit is contained in:
Lucas 2024-10-07 10:18:11 +08:00 committed by GitHub
parent 01d73f2753
commit 552fd39d74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 3 deletions

View File

@ -1,7 +1,7 @@
import 'dart:io';
import 'package:appflowy/startup/tasks/device_info_task.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:universal_platform/universal_platform.dart';
class CocoaWindowChannel {
CocoaWindowChannel._();
@ -44,7 +44,14 @@ class MoveWindowDetectorState extends State<MoveWindowDetector> {
@override
Widget build(BuildContext context) {
if (!Platform.isMacOS) {
// the frameless window is only supported on macOS
if (!UniversalPlatform.isMacOS) {
return widget.child ?? const SizedBox.shrink();
}
// For the macOS version 15 or higher, we can control the window position by using system APIs
if (ApplicationInfo.macOSMajorVersion != null &&
ApplicationInfo.macOSMajorVersion! >= 15) {
return widget.child ?? const SizedBox.shrink();
}

View File

@ -11,6 +11,10 @@ class ApplicationInfo {
static String applicationVersion = '';
static String buildNumber = '';
static String deviceId = '';
// macOS major version
static int? macOSMajorVersion;
static int? macOSMinorVersion;
}
class ApplicationInfoTask extends LaunchTask {
@ -21,6 +25,12 @@ class ApplicationInfoTask extends LaunchTask {
final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
final PackageInfo packageInfo = await PackageInfo.fromPlatform();
if (Platform.isMacOS) {
final macInfo = await deviceInfoPlugin.macOsInfo;
ApplicationInfo.macOSMajorVersion = macInfo.majorVersion;
ApplicationInfo.macOSMinorVersion = macInfo.minorVersion;
}
if (Platform.isAndroid) {
final androidInfo = await deviceInfoPlugin.androidInfo;
ApplicationInfo.androidSDKVersion = androidInfo.version.sdkInt;

View File

@ -75,6 +75,13 @@ class MainFlutterWindow: NSWindow {
self.styleMask.insert(StyleMask.fullSizeContentView)
self.isMovableByWindowBackground = true
// For the macOS version 15 or higher, set it to true to enable the window tiling
if #available(macOS 15.0, *) {
self.isMovable = true
} else {
self.isMovable = false
}
self.layoutTrafficLights()
RegisterGeneratedPlugins(registry: flutterViewController)