mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: use bitsdojo_window on windows (#5477)
Co-authored-by: APPFLOWY\tsuiy <lucas.xu@appflowy.io>
This commit is contained in:
parent
bd7977d8ba
commit
ff93fbf0e6
@ -1,12 +1,14 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:appflowy/core/helpers/helpers.dart';
|
import 'package:appflowy/core/helpers/helpers.dart';
|
||||||
import 'package:appflowy/startup/startup.dart';
|
import 'package:appflowy/startup/startup.dart';
|
||||||
import 'package:appflowy/startup/tasks/app_window_size_manager.dart';
|
import 'package:appflowy/startup/tasks/app_window_size_manager.dart';
|
||||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:bitsdojo_window/bitsdojo_window.dart';
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:scaled_app/scaled_app.dart';
|
import 'package:scaled_app/scaled_app.dart';
|
||||||
import 'package:window_manager/window_manager.dart';
|
import 'package:window_manager/window_manager.dart';
|
||||||
|
|
||||||
@ -17,7 +19,7 @@ class InitAppWindowTask extends LaunchTask with WindowListener {
|
|||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
|
|
||||||
final windowsManager = WindowSizeManager();
|
final windowSizeManager = WindowSizeManager();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> initialize(LaunchContext context) async {
|
Future<void> initialize(LaunchContext context) async {
|
||||||
@ -29,7 +31,7 @@ class InitAppWindowTask extends LaunchTask with WindowListener {
|
|||||||
await windowManager.ensureInitialized();
|
await windowManager.ensureInitialized();
|
||||||
windowManager.addListener(this);
|
windowManager.addListener(this);
|
||||||
|
|
||||||
final windowSize = await windowsManager.getSize();
|
final windowSize = await windowSizeManager.getSize();
|
||||||
final windowOptions = WindowOptions(
|
final windowOptions = WindowOptions(
|
||||||
size: windowSize,
|
size: windowSize,
|
||||||
minimumSize: const Size(
|
minimumSize: const Size(
|
||||||
@ -43,23 +45,38 @@ class InitAppWindowTask extends LaunchTask with WindowListener {
|
|||||||
title: title,
|
title: title,
|
||||||
);
|
);
|
||||||
|
|
||||||
await windowManager.waitUntilReadyToShow(windowOptions, () async {
|
final position = await windowSizeManager.getPosition();
|
||||||
await windowManager.show();
|
|
||||||
await windowManager.focus();
|
|
||||||
|
|
||||||
if (PlatformExtension.isWindows) {
|
if (PlatformExtension.isWindows) {
|
||||||
// Hide title bar on Windows, we implement a custom solution elsewhere
|
doWhenWindowReady(() {
|
||||||
await windowManager.setTitleBarStyle(TitleBarStyle.hidden);
|
appWindow.minSize = windowOptions.minimumSize;
|
||||||
}
|
appWindow.maxSize = windowOptions.maximumSize;
|
||||||
|
appWindow.size = windowSize;
|
||||||
|
|
||||||
final position = await windowsManager.getPosition();
|
if (position != null) {
|
||||||
if (position != null) {
|
appWindow.position = position;
|
||||||
await windowManager.setPosition(position);
|
}
|
||||||
}
|
|
||||||
});
|
appWindow.show();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await windowManager.waitUntilReadyToShow(windowOptions, () async {
|
||||||
|
await windowManager.show();
|
||||||
|
await windowManager.focus();
|
||||||
|
|
||||||
|
if (PlatformExtension.isWindows) {
|
||||||
|
// Hide title bar on Windows, we implement a custom solution elsewhere
|
||||||
|
await windowManager.setTitleBarStyle(TitleBarStyle.hidden);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (position != null) {
|
||||||
|
await windowManager.setPosition(position);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
unawaited(
|
unawaited(
|
||||||
windowsManager.getScaleFactor().then(
|
windowSizeManager.getScaleFactor().then(
|
||||||
(v) => ScaledWidgetsFlutterBinding.instance.scaleFactor = (_) => v,
|
(v) => ScaledWidgetsFlutterBinding.instance.scaleFactor = (_) => v,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -70,7 +87,7 @@ class InitAppWindowTask extends LaunchTask with WindowListener {
|
|||||||
super.onWindowResize();
|
super.onWindowResize();
|
||||||
|
|
||||||
final currentWindowSize = await windowManager.getSize();
|
final currentWindowSize = await windowManager.getSize();
|
||||||
return windowsManager.setSize(currentWindowSize);
|
return windowSizeManager.setSize(currentWindowSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -78,7 +95,7 @@ class InitAppWindowTask extends LaunchTask with WindowListener {
|
|||||||
super.onWindowMaximize();
|
super.onWindowMaximize();
|
||||||
|
|
||||||
final currentWindowSize = await windowManager.getSize();
|
final currentWindowSize = await windowManager.getSize();
|
||||||
return windowsManager.setSize(currentWindowSize);
|
return windowSizeManager.setSize(currentWindowSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -86,7 +103,7 @@ class InitAppWindowTask extends LaunchTask with WindowListener {
|
|||||||
super.onWindowMoved();
|
super.onWindowMoved();
|
||||||
|
|
||||||
final position = await windowManager.getPosition();
|
final position = await windowManager.getPosition();
|
||||||
return windowsManager.setPosition(position);
|
return windowSizeManager.setPosition(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -120,6 +120,46 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.2.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"
|
||||||
bloc:
|
bloc:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -2405,10 +2445,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: window_manager
|
name: window_manager
|
||||||
sha256: b3c895bdf936c77b83c5254bec2e6b3f066710c1f89c38b20b8acc382b525494
|
sha256: "8699323b30da4cdbe2aa2e7c9de567a6abd8a97d9a5c850a3c86dcd0b34bbfbf"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.8"
|
version: "0.3.9"
|
||||||
xdg_directories:
|
xdg_directories:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -94,7 +94,6 @@ dependencies:
|
|||||||
git:
|
git:
|
||||||
url: https://github.com/Xazin/flutter_calendar_view
|
url: https://github.com/Xazin/flutter_calendar_view
|
||||||
ref: "6fe0c98"
|
ref: "6fe0c98"
|
||||||
window_manager: ^0.3.4
|
|
||||||
http: ^1.0.0
|
http: ^1.0.0
|
||||||
path: ^1.8.3
|
path: ^1.8.3
|
||||||
mocktail: ^1.0.1
|
mocktail: ^1.0.1
|
||||||
@ -119,6 +118,7 @@ dependencies:
|
|||||||
# TODO: Consider implementing custom package
|
# TODO: Consider implementing custom package
|
||||||
# to gather notification handling for all platforms
|
# to gather notification handling for all platforms
|
||||||
local_notifier: ^0.1.5
|
local_notifier: ^0.1.5
|
||||||
|
|
||||||
app_links: ^3.5.0
|
app_links: ^3.5.0
|
||||||
flutter_slidable: ^3.0.0
|
flutter_slidable: ^3.0.0
|
||||||
image_picker: ^1.0.4
|
image_picker: ^1.0.4
|
||||||
@ -142,6 +142,12 @@ dependencies:
|
|||||||
reorderable_tabbar: ^1.0.6
|
reorderable_tabbar: ^1.0.6
|
||||||
shimmer: ^3.0.0
|
shimmer: ^3.0.0
|
||||||
|
|
||||||
|
# Window Manager for MacOS and Linux
|
||||||
|
window_manager: ^0.3.9
|
||||||
|
|
||||||
|
# BitsDojo Window for Windows
|
||||||
|
bitsdojo_window: ^0.1.6
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_lints: ^3.0.1
|
flutter_lints: ^3.0.1
|
||||||
analyzer: ^6.3.0
|
analyzer: ^6.3.0
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
#include "flutter_window.h"
|
#include "flutter_window.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
|
||||||
|
auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP);
|
||||||
|
|
||||||
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
||||||
_In_ wchar_t *command_line, _In_ int show_command) {
|
_In_ wchar_t *command_line, _In_ int show_command) {
|
||||||
HANDLE hMutexInstance = CreateMutex(NULL, TRUE, L"AppFlowyMutex");
|
HANDLE hMutexInstance = CreateMutex(NULL, TRUE, L"AppFlowyMutex");
|
||||||
|
Loading…
Reference in New Issue
Block a user