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:ui';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:appflowy/core/helpers/helpers.dart';
|
||||
import 'package:appflowy/startup/startup.dart';
|
||||
import 'package:appflowy/startup/tasks/app_window_size_manager.dart';
|
||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:bitsdojo_window/bitsdojo_window.dart';
|
||||
import 'package:scaled_app/scaled_app.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
@ -17,7 +19,7 @@ class InitAppWindowTask extends LaunchTask with WindowListener {
|
||||
|
||||
final String title;
|
||||
|
||||
final windowsManager = WindowSizeManager();
|
||||
final windowSizeManager = WindowSizeManager();
|
||||
|
||||
@override
|
||||
Future<void> initialize(LaunchContext context) async {
|
||||
@ -29,7 +31,7 @@ class InitAppWindowTask extends LaunchTask with WindowListener {
|
||||
await windowManager.ensureInitialized();
|
||||
windowManager.addListener(this);
|
||||
|
||||
final windowSize = await windowsManager.getSize();
|
||||
final windowSize = await windowSizeManager.getSize();
|
||||
final windowOptions = WindowOptions(
|
||||
size: windowSize,
|
||||
minimumSize: const Size(
|
||||
@ -43,6 +45,21 @@ class InitAppWindowTask extends LaunchTask with WindowListener {
|
||||
title: title,
|
||||
);
|
||||
|
||||
final position = await windowSizeManager.getPosition();
|
||||
|
||||
if (PlatformExtension.isWindows) {
|
||||
doWhenWindowReady(() {
|
||||
appWindow.minSize = windowOptions.minimumSize;
|
||||
appWindow.maxSize = windowOptions.maximumSize;
|
||||
appWindow.size = windowSize;
|
||||
|
||||
if (position != null) {
|
||||
appWindow.position = position;
|
||||
}
|
||||
|
||||
appWindow.show();
|
||||
});
|
||||
} else {
|
||||
await windowManager.waitUntilReadyToShow(windowOptions, () async {
|
||||
await windowManager.show();
|
||||
await windowManager.focus();
|
||||
@ -52,14 +69,14 @@ class InitAppWindowTask extends LaunchTask with WindowListener {
|
||||
await windowManager.setTitleBarStyle(TitleBarStyle.hidden);
|
||||
}
|
||||
|
||||
final position = await windowsManager.getPosition();
|
||||
if (position != null) {
|
||||
await windowManager.setPosition(position);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
unawaited(
|
||||
windowsManager.getScaleFactor().then(
|
||||
windowSizeManager.getScaleFactor().then(
|
||||
(v) => ScaledWidgetsFlutterBinding.instance.scaleFactor = (_) => v,
|
||||
),
|
||||
);
|
||||
@ -70,7 +87,7 @@ class InitAppWindowTask extends LaunchTask with WindowListener {
|
||||
super.onWindowResize();
|
||||
|
||||
final currentWindowSize = await windowManager.getSize();
|
||||
return windowsManager.setSize(currentWindowSize);
|
||||
return windowSizeManager.setSize(currentWindowSize);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -78,7 +95,7 @@ class InitAppWindowTask extends LaunchTask with WindowListener {
|
||||
super.onWindowMaximize();
|
||||
|
||||
final currentWindowSize = await windowManager.getSize();
|
||||
return windowsManager.setSize(currentWindowSize);
|
||||
return windowSizeManager.setSize(currentWindowSize);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -86,7 +103,7 @@ class InitAppWindowTask extends LaunchTask with WindowListener {
|
||||
super.onWindowMoved();
|
||||
|
||||
final position = await windowManager.getPosition();
|
||||
return windowsManager.setPosition(position);
|
||||
return windowSizeManager.setPosition(position);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -120,6 +120,46 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
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:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -2405,10 +2445,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: window_manager
|
||||
sha256: b3c895bdf936c77b83c5254bec2e6b3f066710c1f89c38b20b8acc382b525494
|
||||
sha256: "8699323b30da4cdbe2aa2e7c9de567a6abd8a97d9a5c850a3c86dcd0b34bbfbf"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.8"
|
||||
version: "0.3.9"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -94,7 +94,6 @@ dependencies:
|
||||
git:
|
||||
url: https://github.com/Xazin/flutter_calendar_view
|
||||
ref: "6fe0c98"
|
||||
window_manager: ^0.3.4
|
||||
http: ^1.0.0
|
||||
path: ^1.8.3
|
||||
mocktail: ^1.0.1
|
||||
@ -119,6 +118,7 @@ dependencies:
|
||||
# TODO: Consider implementing custom package
|
||||
# to gather notification handling for all platforms
|
||||
local_notifier: ^0.1.5
|
||||
|
||||
app_links: ^3.5.0
|
||||
flutter_slidable: ^3.0.0
|
||||
image_picker: ^1.0.4
|
||||
@ -142,6 +142,12 @@ dependencies:
|
||||
reorderable_tabbar: ^1.0.6
|
||||
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:
|
||||
flutter_lints: ^3.0.1
|
||||
analyzer: ^6.3.0
|
||||
|
@ -5,6 +5,9 @@
|
||||
#include "flutter_window.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,
|
||||
_In_ wchar_t *command_line, _In_ int show_command) {
|
||||
HANDLE hMutexInstance = CreateMutex(NULL, TRUE, L"AppFlowyMutex");
|
||||
|
Loading…
Reference in New Issue
Block a user