From d35a616ec2113a0d2f85fc323c0d233e9610e331 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Sat, 5 Oct 2024 20:30:26 +0800 Subject: [PATCH 1/4] fix: share button doesn't response under macos 15 --- .../appflowy_flutter/lib/core/frameless_window.dart | 13 ++++++++++--- .../lib/startup/tasks/device_info_task.dart | 10 ++++++++++ .../macos/Runner/MainFlutterWindow.swift | 7 +++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/frontend/appflowy_flutter/lib/core/frameless_window.dart b/frontend/appflowy_flutter/lib/core/frameless_window.dart index 15732f163dfa..341256f33eea 100644 --- a/frontend/appflowy_flutter/lib/core/frameless_window.dart +++ b/frontend/appflowy_flutter/lib/core/frameless_window.dart @@ -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 { @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(); + } + + // above macOS 15, we can control the window position by using system APIs + if (ApplicationInfo.macOSMajorVersion != null && + ApplicationInfo.macOSMajorVersion! >= 15) { return widget.child ?? const SizedBox.shrink(); } diff --git a/frontend/appflowy_flutter/lib/startup/tasks/device_info_task.dart b/frontend/appflowy_flutter/lib/startup/tasks/device_info_task.dart index 61e1f52460bb..1558eefa5362 100644 --- a/frontend/appflowy_flutter/lib/startup/tasks/device_info_task.dart +++ b/frontend/appflowy_flutter/lib/startup/tasks/device_info_task.dart @@ -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; diff --git a/frontend/appflowy_flutter/macos/Runner/MainFlutterWindow.swift b/frontend/appflowy_flutter/macos/Runner/MainFlutterWindow.swift index 4e69e2e7468f..620ad5c9bcf2 100644 --- a/frontend/appflowy_flutter/macos/Runner/MainFlutterWindow.swift +++ b/frontend/appflowy_flutter/macos/Runner/MainFlutterWindow.swift @@ -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) From 32c49c9f36c9d41086fbe44d7006b872ed850505 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Sat, 5 Oct 2024 20:34:56 +0800 Subject: [PATCH 2/4] chore: enable macos integration test --- .github/workflows/flutter_ci.yaml | 73 +++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/.github/workflows/flutter_ci.yaml b/.github/workflows/flutter_ci.yaml index d2eeb7078df5..b1b4ef3279d7 100644 --- a/.github/workflows/flutter_ci.yaml +++ b/.github/workflows/flutter_ci.yaml @@ -410,3 +410,76 @@ jobs: rust_toolchain: ${{ env.RUST_TOOLCHAIN }} cargo_make_version: ${{ env.CARGO_MAKE_VERSION }} rust_target: ${{ matrix.target }} + + # macOS integration tests + macos_integration_test_1: + needs: [prepare-macos] + if: github.event.pull_request.draft != true + strategy: + fail-fast: false + matrix: + os: [macos-latest] + include: + - os: macos-latest + target: "aarch64-apple-darwin" + runs-on: ${{ matrix.os }} + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Flutter Integration Test 1 + uses: ./.github/actions/flutter_integration_test + with: + test_path: integration_test/desktop_runner_1.dart + flutter_version: ${{ env.FLUTTER_VERSION }} + rust_toolchain: ${{ env.RUST_TOOLCHAIN }} + cargo_make_version: ${{ env.CARGO_MAKE_VERSION }} + rust_target: ${{ matrix.target }} + + macos_integration_test_2: + needs: [prepare-macos] + if: github.event.pull_request.draft != true + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + include: + - os: macos-latest + target: "aarch64-apple-darwin" + runs-on: ${{ matrix.os }} + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Flutter Integration Test 2 + uses: ./.github/actions/flutter_integration_test + with: + test_path: integration_test/desktop_runner_2.dart + flutter_version: ${{ env.FLUTTER_VERSION }} + rust_toolchain: ${{ env.RUST_TOOLCHAIN }} + cargo_make_version: ${{ env.CARGO_MAKE_VERSION }} + rust_target: ${{ matrix.target }} + + macos_integration_test_3: + needs: [prepare-macos] + if: github.event.pull_request.draft != true + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + include: + - os: ubuntu-latest + target: "x86_64-unknown-linux-gnu" + runs-on: ${{ matrix.os }} + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Flutter Integration Test 3 + uses: ./.github/actions/flutter_integration_test + with: + test_path: integration_test/desktop_runner_3.dart + flutter_version: ${{ env.FLUTTER_VERSION }} + rust_toolchain: ${{ env.RUST_TOOLCHAIN }} + cargo_make_version: ${{ env.CARGO_MAKE_VERSION }} + rust_target: ${{ matrix.target }} From 391870d26ce150957777b1fceb6dfde25c40419a Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Sat, 5 Oct 2024 21:03:37 +0800 Subject: [PATCH 3/4] Revert "chore: enable macos integration test" This reverts commit 32c49c9f36c9d41086fbe44d7006b872ed850505. --- .github/workflows/flutter_ci.yaml | 73 ------------------------------- 1 file changed, 73 deletions(-) diff --git a/.github/workflows/flutter_ci.yaml b/.github/workflows/flutter_ci.yaml index b1b4ef3279d7..d2eeb7078df5 100644 --- a/.github/workflows/flutter_ci.yaml +++ b/.github/workflows/flutter_ci.yaml @@ -410,76 +410,3 @@ jobs: rust_toolchain: ${{ env.RUST_TOOLCHAIN }} cargo_make_version: ${{ env.CARGO_MAKE_VERSION }} rust_target: ${{ matrix.target }} - - # macOS integration tests - macos_integration_test_1: - needs: [prepare-macos] - if: github.event.pull_request.draft != true - strategy: - fail-fast: false - matrix: - os: [macos-latest] - include: - - os: macos-latest - target: "aarch64-apple-darwin" - runs-on: ${{ matrix.os }} - steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Flutter Integration Test 1 - uses: ./.github/actions/flutter_integration_test - with: - test_path: integration_test/desktop_runner_1.dart - flutter_version: ${{ env.FLUTTER_VERSION }} - rust_toolchain: ${{ env.RUST_TOOLCHAIN }} - cargo_make_version: ${{ env.CARGO_MAKE_VERSION }} - rust_target: ${{ matrix.target }} - - macos_integration_test_2: - needs: [prepare-macos] - if: github.event.pull_request.draft != true - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - include: - - os: macos-latest - target: "aarch64-apple-darwin" - runs-on: ${{ matrix.os }} - steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Flutter Integration Test 2 - uses: ./.github/actions/flutter_integration_test - with: - test_path: integration_test/desktop_runner_2.dart - flutter_version: ${{ env.FLUTTER_VERSION }} - rust_toolchain: ${{ env.RUST_TOOLCHAIN }} - cargo_make_version: ${{ env.CARGO_MAKE_VERSION }} - rust_target: ${{ matrix.target }} - - macos_integration_test_3: - needs: [prepare-macos] - if: github.event.pull_request.draft != true - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - include: - - os: ubuntu-latest - target: "x86_64-unknown-linux-gnu" - runs-on: ${{ matrix.os }} - steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Flutter Integration Test 3 - uses: ./.github/actions/flutter_integration_test - with: - test_path: integration_test/desktop_runner_3.dart - flutter_version: ${{ env.FLUTTER_VERSION }} - rust_toolchain: ${{ env.RUST_TOOLCHAIN }} - cargo_make_version: ${{ env.CARGO_MAKE_VERSION }} - rust_target: ${{ matrix.target }} From 29f4a95dfa16701dc2401d93ef5b74cae8b8cda7 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Sat, 5 Oct 2024 21:09:33 +0800 Subject: [PATCH 4/4] chore: update comment --- frontend/appflowy_flutter/lib/core/frameless_window.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/appflowy_flutter/lib/core/frameless_window.dart b/frontend/appflowy_flutter/lib/core/frameless_window.dart index 341256f33eea..48f043483358 100644 --- a/frontend/appflowy_flutter/lib/core/frameless_window.dart +++ b/frontend/appflowy_flutter/lib/core/frameless_window.dart @@ -49,7 +49,7 @@ class MoveWindowDetectorState extends State { return widget.child ?? const SizedBox.shrink(); } - // above macOS 15, we can control the window position by using system APIs + // 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();