Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: share button doesn't response under macOS 15 #30

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions frontend/appflowy_flutter/lib/core/frameless_window.dart
Original file line number Diff line number Diff line change
@@ -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._();
Expand Down Expand Up @@ -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();
}

Expand Down
10 changes: 10 additions & 0 deletions frontend/appflowy_flutter/lib/startup/tasks/device_info_task.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading