mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 16:05:18 +00:00
refactor: replace bitsdojo_window with window_manager for faster startups
This commit is contained in:
parent
a4a7f1a74f
commit
6902060cdd
@ -1,4 +1,3 @@
|
|||||||
import 'package:bitsdojo_window/bitsdojo_window.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
@ -9,6 +8,7 @@ import 'package:spotube/collections/routes.dart';
|
|||||||
import 'package:spotube/models/logger.dart';
|
import 'package:spotube/models/logger.dart';
|
||||||
import 'package:spotube/provider/playback_provider.dart';
|
import 'package:spotube/provider/playback_provider.dart';
|
||||||
import 'package:spotube/utils/platform.dart';
|
import 'package:spotube/utils/platform.dart';
|
||||||
|
import 'package:window_manager/window_manager.dart';
|
||||||
|
|
||||||
class PlayPauseIntent extends Intent {
|
class PlayPauseIntent extends Intent {
|
||||||
final WidgetRef ref;
|
final WidgetRef ref;
|
||||||
@ -134,7 +134,7 @@ class CloseAppAction extends Action<CloseAppIntent> {
|
|||||||
@override
|
@override
|
||||||
invoke(intent) {
|
invoke(intent) {
|
||||||
if (kIsDesktop) {
|
if (kIsDesktop) {
|
||||||
appWindow.close();
|
windowManager.close();
|
||||||
} else {
|
} else {
|
||||||
SystemNavigator.pop();
|
SystemNavigator.pop();
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import 'package:bitsdojo_window/bitsdojo_window.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:platform_ui/platform_ui.dart';
|
import 'package:platform_ui/platform_ui.dart';
|
||||||
import 'package:spotube/utils/platform.dart';
|
import 'package:spotube/utils/platform.dart';
|
||||||
|
import 'package:window_manager/window_manager.dart';
|
||||||
|
|
||||||
class PageWindowTitleBar extends StatefulHookWidget with PreferredSizeWidget {
|
class PageWindowTitleBar extends StatefulHookWidget with PreferredSizeWidget {
|
||||||
final Widget? leading;
|
final Widget? leading;
|
||||||
@ -52,7 +52,7 @@ class PageWindowTitleBar extends StatefulHookWidget with PreferredSizeWidget {
|
|||||||
class _PageWindowTitleBarState extends State<PageWindowTitleBar> {
|
class _PageWindowTitleBarState extends State<PageWindowTitleBar> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final isMaximized = useState(kIsDesktop ? appWindow.isMaximized : false);
|
final isMaximized = useState<bool?>(null);
|
||||||
|
|
||||||
useEffect(() {
|
useEffect(() {
|
||||||
if (platform == TargetPlatform.windows &&
|
if (platform == TargetPlatform.windows &&
|
||||||
@ -81,24 +81,38 @@ class _PageWindowTitleBarState extends State<PageWindowTitleBar> {
|
|||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maximizeOrRestore() async {
|
||||||
|
if (await windowManager.isMaximized()) {
|
||||||
|
await windowManager.unmaximize();
|
||||||
|
isMaximized.value = false;
|
||||||
|
} else {
|
||||||
|
await windowManager.maximize();
|
||||||
|
isMaximized.value = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return PlatformAppBar(
|
return PlatformAppBar(
|
||||||
actions: [
|
actions: [
|
||||||
...?widget.actions,
|
...?widget.actions,
|
||||||
if (!kIsMacOS && !kIsMobile)
|
if (!kIsMacOS && !kIsMobile)
|
||||||
PlatformWindowButtons(
|
PlatformWindowButtons(
|
||||||
isMaximized: () => isMaximized.value,
|
isMaximized: () async =>
|
||||||
onMaximize: () {
|
isMaximized.value ?? await windowManager.isMaximized(),
|
||||||
appWindow.maximize();
|
onMaximize: maximizeOrRestore,
|
||||||
isMaximized.value = true;
|
onRestore: maximizeOrRestore,
|
||||||
|
onMinimize: () {
|
||||||
|
windowManager.minimize();
|
||||||
},
|
},
|
||||||
onRestore: () {
|
onClose: () {
|
||||||
appWindow.restore();
|
windowManager.close();
|
||||||
isMaximized.value = false;
|
|
||||||
},
|
},
|
||||||
|
showCloseButton: true,
|
||||||
|
showMaximizeButton: true,
|
||||||
|
showMinimizeButton: true,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
onDrag: () {
|
onDrag: () {
|
||||||
if (kIsDesktop) appWindow.startDragging();
|
if (kIsDesktop) windowManager.startDragging();
|
||||||
},
|
},
|
||||||
title: widget.center,
|
title: widget.center,
|
||||||
toolbarOpacity: widget.toolbarOpacity,
|
toolbarOpacity: widget.toolbarOpacity,
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:audio_service/audio_service.dart';
|
import 'package:audio_service/audio_service.dart';
|
||||||
import 'package:bitsdojo_window/bitsdojo_window.dart';
|
|
||||||
import 'package:fl_query/fl_query.dart';
|
import 'package:fl_query/fl_query.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -26,30 +25,39 @@ import 'package:spotube/services/mobile_audio_service.dart';
|
|||||||
import 'package:spotube/themes/dark_theme.dart';
|
import 'package:spotube/themes/dark_theme.dart';
|
||||||
import 'package:spotube/themes/light_theme.dart';
|
import 'package:spotube/themes/light_theme.dart';
|
||||||
import 'package:spotube/utils/platform.dart';
|
import 'package:spotube/utils/platform.dart';
|
||||||
|
import 'package:window_manager/window_manager.dart';
|
||||||
|
import 'package:window_size/window_size.dart';
|
||||||
|
|
||||||
final bowl = QueryBowl();
|
final bowl = QueryBowl();
|
||||||
void main() async {
|
void main() async {
|
||||||
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await Hive.initFlutter();
|
await Hive.initFlutter();
|
||||||
Hive.registerAdapter(CacheTrackAdapter());
|
Hive.registerAdapter(CacheTrackAdapter());
|
||||||
Hive.registerAdapter(CacheTrackEngagementAdapter());
|
Hive.registerAdapter(CacheTrackEngagementAdapter());
|
||||||
Hive.registerAdapter(CacheTrackSkipSegmentAdapter());
|
Hive.registerAdapter(CacheTrackSkipSegmentAdapter());
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
|
||||||
if (kIsDesktop) {
|
if (kIsDesktop) {
|
||||||
doWhenWindowReady(() async {
|
await windowManager.ensureInitialized();
|
||||||
|
WindowOptions windowOptions = const WindowOptions(
|
||||||
|
center: true,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
titleBarStyle: TitleBarStyle.hidden,
|
||||||
|
title: "Spotube",
|
||||||
|
);
|
||||||
|
setWindowMinSize(const Size(kReleaseMode ? 1020 : 300, 700));
|
||||||
|
await windowManager.waitUntilReadyToShow(windowOptions, () async {
|
||||||
final localStorage = await SharedPreferences.getInstance();
|
final localStorage = await SharedPreferences.getInstance();
|
||||||
final rawSize = localStorage.getString(LocalStorageKeys.windowSizeInfo);
|
final rawSize = localStorage.getString(LocalStorageKeys.windowSizeInfo);
|
||||||
final savedSize = rawSize != null ? json.decode(rawSize) : null;
|
final savedSize = rawSize != null ? json.decode(rawSize) : null;
|
||||||
|
final wasMaximized = savedSize?["maximized"] ?? false;
|
||||||
final double? height = savedSize?["height"];
|
final double? height = savedSize?["height"];
|
||||||
final double? width = savedSize?["width"];
|
final double? width = savedSize?["width"];
|
||||||
appWindow.minSize = const Size(kReleaseMode ? 1020 : 300, 700);
|
await windowManager.setResizable(true);
|
||||||
appWindow.alignment = Alignment.center;
|
if (wasMaximized) {
|
||||||
appWindow.title = "Spotube";
|
await windowManager.maximize();
|
||||||
if (height != null && width != null && height >= 700 && width >= 359) {
|
} else if (height != null && width != null) {
|
||||||
appWindow.size = Size(width, height);
|
await windowManager.setSize(Size(width, height));
|
||||||
} else {
|
|
||||||
appWindow.maximize();
|
|
||||||
}
|
}
|
||||||
appWindow.show();
|
await windowManager.show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
MobileAudioService? audioServiceHandler;
|
MobileAudioService? audioServiceHandler;
|
||||||
@ -169,22 +177,24 @@ class SpotubeState extends ConsumerState<Spotube> with WidgetsBindingObserver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didChangeMetrics() {
|
void didChangeMetrics() async {
|
||||||
super.didChangeMetrics();
|
super.didChangeMetrics();
|
||||||
final windowSameDimension = kIsMobile
|
if (kIsMobile) return;
|
||||||
? false
|
final size = await windowManager.getSize();
|
||||||
: prevSize?.width == appWindow.size.width &&
|
final windowSameDimension =
|
||||||
prevSize?.height == appWindow.size.height;
|
prevSize?.width == size.width && prevSize?.height == size.height;
|
||||||
|
|
||||||
if (localStorage == null || windowSameDimension || kIsMobile) return;
|
if (localStorage == null || windowSameDimension) return;
|
||||||
|
final isMaximized = await windowManager.isMaximized();
|
||||||
localStorage!.setString(
|
localStorage!.setString(
|
||||||
LocalStorageKeys.windowSizeInfo,
|
LocalStorageKeys.windowSizeInfo,
|
||||||
jsonEncode({
|
jsonEncode({
|
||||||
'width': appWindow.isMaximized ? 0.0 : appWindow.size.width,
|
'maximized': isMaximized,
|
||||||
'height': appWindow.isMaximized ? 0.0 : appWindow.size.height,
|
'width': size.width,
|
||||||
|
'height': size.height,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
prevSize = appWindow.size;
|
prevSize = await windowManager.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
TargetPlatform appPlatform = TargetPlatform.android;
|
TargetPlatform appPlatform = TargetPlatform.android;
|
||||||
@ -220,6 +230,9 @@ class SpotubeState extends ConsumerState<Spotube> with WidgetsBindingObserver {
|
|||||||
routeInformationProvider: router.routeInformationProvider,
|
routeInformationProvider: router.routeInformationProvider,
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
title: 'Spotube',
|
title: 'Spotube',
|
||||||
|
builder: (context, child) {
|
||||||
|
return DragToResizeArea(child: child!);
|
||||||
|
},
|
||||||
androidTheme: lightTheme(
|
androidTheme: lightTheme(
|
||||||
accentMaterialColor: accentMaterialColor,
|
accentMaterialColor: accentMaterialColor,
|
||||||
backgroundMaterialColor: backgroundMaterialColor,
|
backgroundMaterialColor: backgroundMaterialColor,
|
||||||
@ -236,15 +249,6 @@ class SpotubeState extends ConsumerState<Spotube> with WidgetsBindingObserver {
|
|||||||
macosTheme: macosTheme,
|
macosTheme: macosTheme,
|
||||||
macosDarkTheme: macosDarkTheme,
|
macosDarkTheme: macosDarkTheme,
|
||||||
themeMode: themeMode,
|
themeMode: themeMode,
|
||||||
windowButtonConfig: kIsDesktop
|
|
||||||
? PlatformWindowButtonConfig(
|
|
||||||
isMaximized: () async => Future.value(appWindow.isMaximized),
|
|
||||||
onClose: () async => appWindow.close(),
|
|
||||||
onRestore: () async => appWindow.restore(),
|
|
||||||
onMaximize: () async => appWindow.maximize(),
|
|
||||||
onMinimize: () async => appWindow.minimize(),
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
shortcuts: PlatformProperty.all({
|
shortcuts: PlatformProperty.all({
|
||||||
...WidgetsApp.defaultShortcuts.map((key, value) {
|
...WidgetsApp.defaultShortcuts.map((key, value) {
|
||||||
return MapEntry(
|
return MapEntry(
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:bitsdojo_window/bitsdojo_window.dart';
|
|
||||||
import 'package:dbus/dbus.dart';
|
import 'package:dbus/dbus.dart';
|
||||||
|
|
||||||
import 'package:spotube/provider/dbus_provider.dart';
|
import 'package:spotube/provider/dbus_provider.dart';
|
||||||
import 'package:spotube/models/spotube_track.dart';
|
import 'package:spotube/models/spotube_track.dart';
|
||||||
import 'package:spotube/provider/playback_provider.dart';
|
import 'package:spotube/provider/playback_provider.dart';
|
||||||
import 'package:spotube/utils/type_conversion_utils.dart';
|
import 'package:spotube/utils/type_conversion_utils.dart';
|
||||||
|
import 'package:window_manager/window_manager.dart';
|
||||||
|
|
||||||
class _MprisMediaPlayer2 extends DBusObject {
|
class _MprisMediaPlayer2 extends DBusObject {
|
||||||
/// Creates a new object to expose on [path].
|
/// Creates a new object to expose on [path].
|
||||||
@ -79,7 +79,7 @@ class _MprisMediaPlayer2 extends DBusObject {
|
|||||||
|
|
||||||
/// Implementation of org.mpris.MediaPlayer2.Quit()
|
/// Implementation of org.mpris.MediaPlayer2.Quit()
|
||||||
Future<DBusMethodResponse> doQuit() async {
|
Future<DBusMethodResponse> doQuit() async {
|
||||||
appWindow.close();
|
await windowManager.close();
|
||||||
return DBusMethodSuccessResponse();
|
return DBusMethodSuccessResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,21 +7,29 @@
|
|||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <audioplayers_linux/audioplayers_linux_plugin.h>
|
#include <audioplayers_linux/audioplayers_linux_plugin.h>
|
||||||
#include <bitsdojo_window_linux/bitsdojo_window_plugin.h>
|
|
||||||
#include <metadata_god/metadata_god_plugin.h>
|
#include <metadata_god/metadata_god_plugin.h>
|
||||||
|
#include <screen_retriever/screen_retriever_plugin.h>
|
||||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||||
|
#include <window_manager/window_manager_plugin.h>
|
||||||
|
#include <window_size/window_size_plugin.h>
|
||||||
|
|
||||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||||
g_autoptr(FlPluginRegistrar) audioplayers_linux_registrar =
|
g_autoptr(FlPluginRegistrar) audioplayers_linux_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "AudioplayersLinuxPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "AudioplayersLinuxPlugin");
|
||||||
audioplayers_linux_plugin_register_with_registrar(audioplayers_linux_registrar);
|
audioplayers_linux_plugin_register_with_registrar(audioplayers_linux_registrar);
|
||||||
g_autoptr(FlPluginRegistrar) bitsdojo_window_linux_registrar =
|
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "BitsdojoWindowPlugin");
|
|
||||||
bitsdojo_window_plugin_register_with_registrar(bitsdojo_window_linux_registrar);
|
|
||||||
g_autoptr(FlPluginRegistrar) metadata_god_registrar =
|
g_autoptr(FlPluginRegistrar) metadata_god_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "MetadataGodPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "MetadataGodPlugin");
|
||||||
metadata_god_plugin_register_with_registrar(metadata_god_registrar);
|
metadata_god_plugin_register_with_registrar(metadata_god_registrar);
|
||||||
|
g_autoptr(FlPluginRegistrar) screen_retriever_registrar =
|
||||||
|
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin");
|
||||||
|
screen_retriever_plugin_register_with_registrar(screen_retriever_registrar);
|
||||||
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
||||||
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
||||||
|
g_autoptr(FlPluginRegistrar) window_manager_registrar =
|
||||||
|
fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin");
|
||||||
|
window_manager_plugin_register_with_registrar(window_manager_registrar);
|
||||||
|
g_autoptr(FlPluginRegistrar) window_size_registrar =
|
||||||
|
fl_plugin_registry_get_registrar_for_plugin(registry, "WindowSizePlugin");
|
||||||
|
window_size_plugin_register_with_registrar(window_size_registrar);
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
audioplayers_linux
|
audioplayers_linux
|
||||||
bitsdojo_window_linux
|
|
||||||
metadata_god
|
metadata_god
|
||||||
|
screen_retriever
|
||||||
url_launcher_linux
|
url_launcher_linux
|
||||||
|
window_manager
|
||||||
|
window_size
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#include <bitsdojo_window_linux/bitsdojo_window_plugin.h>
|
|
||||||
#include "my_application.h"
|
#include "my_application.h"
|
||||||
|
|
||||||
#include <flutter_linux/flutter_linux.h>
|
#include <flutter_linux/flutter_linux.h>
|
||||||
@ -48,10 +47,8 @@ static void my_application_activate(GApplication* application) {
|
|||||||
gtk_window_set_title(window, "spotube");
|
gtk_window_set_title(window, "spotube");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto bdw = bitsdojo_window_from(window);
|
gtk_window_set_default_size(window, 1280, 720);
|
||||||
bdw->setCustomFrame(true);
|
gtk_widget_realize(GTK_WIDGET(window));
|
||||||
// gtk_window_set_default_size(window, 1280, 720);
|
|
||||||
gtk_widget_show(GTK_WIDGET(window));
|
|
||||||
|
|
||||||
g_autoptr(FlDartProject) project = fl_dart_project_new();
|
g_autoptr(FlDartProject) project = fl_dart_project_new();
|
||||||
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
|
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
|
||||||
|
@ -8,27 +8,31 @@ import Foundation
|
|||||||
import audio_service
|
import audio_service
|
||||||
import audio_session
|
import audio_session
|
||||||
import audioplayers_darwin
|
import audioplayers_darwin
|
||||||
import bitsdojo_window_macos
|
|
||||||
import connectivity_plus_macos
|
import connectivity_plus_macos
|
||||||
import macos_ui
|
import macos_ui
|
||||||
import metadata_god
|
import metadata_god
|
||||||
import package_info_plus_macos
|
import package_info_plus_macos
|
||||||
import path_provider_macos
|
import path_provider_macos
|
||||||
|
import screen_retriever
|
||||||
import shared_preferences_macos
|
import shared_preferences_macos
|
||||||
import sqflite
|
import sqflite
|
||||||
import url_launcher_macos
|
import url_launcher_macos
|
||||||
|
import window_manager
|
||||||
|
import window_size
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
AudioServicePlugin.register(with: registry.registrar(forPlugin: "AudioServicePlugin"))
|
AudioServicePlugin.register(with: registry.registrar(forPlugin: "AudioServicePlugin"))
|
||||||
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
|
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
|
||||||
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
|
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
|
||||||
BitsdojoWindowPlugin.register(with: registry.registrar(forPlugin: "BitsdojoWindowPlugin"))
|
|
||||||
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
|
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
|
||||||
MacOSUiPlugin.register(with: registry.registrar(forPlugin: "MacOSUiPlugin"))
|
MacOSUiPlugin.register(with: registry.registrar(forPlugin: "MacOSUiPlugin"))
|
||||||
MetadataGodPlugin.register(with: registry.registrar(forPlugin: "MetadataGodPlugin"))
|
MetadataGodPlugin.register(with: registry.registrar(forPlugin: "MetadataGodPlugin"))
|
||||||
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
|
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
|
||||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||||
|
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
|
||||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||||
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
||||||
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||||
|
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
|
||||||
|
WindowSizePlugin.register(with: registry.registrar(forPlugin: "WindowSizePlugin"))
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
import Cocoa
|
import Cocoa
|
||||||
import FlutterMacOS
|
import FlutterMacOS
|
||||||
import bitsdojo_window_macos
|
import window_manager
|
||||||
|
|
||||||
class MainFlutterWindow: BitsdojoWindow {
|
|
||||||
override func bitsdojo_window_configure() -> UInt {
|
|
||||||
return BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP
|
|
||||||
}
|
|
||||||
|
|
||||||
|
class MainFlutterWindow: NSWindow {
|
||||||
override func awakeFromNib() {
|
override func awakeFromNib() {
|
||||||
let flutterViewController = FlutterViewController.init()
|
let flutterViewController = FlutterViewController.init()
|
||||||
let windowFrame = self.frame
|
let windowFrame = self.frame
|
||||||
@ -17,4 +13,9 @@ class MainFlutterWindow: BitsdojoWindow {
|
|||||||
|
|
||||||
super.awakeFromNib()
|
super.awakeFromNib()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override public func order(_ place: NSWindow.OrderingMode, relativeTo otherWin: Int) {
|
||||||
|
super.order(place, relativeTo: otherWin)
|
||||||
|
hiddenWindowAtLaunch()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
58
pubspec.lock
58
pubspec.lock
@ -190,41 +190,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.3"
|
version: "2.0.3"
|
||||||
bitsdojo_window:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: bitsdojo_window
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "0.1.5"
|
|
||||||
bitsdojo_window_linux:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: bitsdojo_window_linux
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "0.1.3"
|
|
||||||
bitsdojo_window_macos:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: bitsdojo_window_macos
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "0.1.3"
|
|
||||||
bitsdojo_window_platform_interface:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: bitsdojo_window_platform_interface
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "0.1.2"
|
|
||||||
bitsdojo_window_windows:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: bitsdojo_window_windows
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "0.1.5"
|
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1157,6 +1122,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.27.3"
|
version: "0.27.3"
|
||||||
|
screen_retriever:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: screen_retriever
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.1.5"
|
||||||
scroll_pos:
|
scroll_pos:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1484,6 +1456,22 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.0"
|
version: "3.0.0"
|
||||||
|
window_manager:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: window_manager
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.8"
|
||||||
|
window_size:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
path: "plugins/window_size"
|
||||||
|
ref: a738913c8ce2c9f47515382d40827e794a334274
|
||||||
|
resolved-ref: a738913c8ce2c9f47515382d40827e794a334274
|
||||||
|
url: "https://github.com/google/flutter-desktop-embedding.git"
|
||||||
|
source: git
|
||||||
|
version: "0.1.0"
|
||||||
xdg_directories:
|
xdg_directories:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -19,7 +19,6 @@ dependencies:
|
|||||||
spotify: ^0.8.0
|
spotify: ^0.8.0
|
||||||
url_launcher: ^6.1.7
|
url_launcher: ^6.1.7
|
||||||
youtube_explode_dart: ^1.12.1
|
youtube_explode_dart: ^1.12.1
|
||||||
bitsdojo_window: ^0.1.5
|
|
||||||
path: ^1.8.0
|
path: ^1.8.0
|
||||||
path_provider: ^2.0.8
|
path_provider: ^2.0.8
|
||||||
collection: ^1.15.0
|
collection: ^1.15.0
|
||||||
@ -65,6 +64,12 @@ dependencies:
|
|||||||
adwaita: ^0.5.2
|
adwaita: ^0.5.2
|
||||||
flutter_svg: ^1.1.6
|
flutter_svg: ^1.1.6
|
||||||
fuzzywuzzy: ^0.2.0
|
fuzzywuzzy: ^0.2.0
|
||||||
|
window_manager: 0.2.8
|
||||||
|
window_size:
|
||||||
|
git:
|
||||||
|
url: https://github.com/google/flutter-desktop-embedding.git
|
||||||
|
ref: a738913c8ce2c9f47515382d40827e794a334274
|
||||||
|
path: plugins/window_size
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
@ -7,23 +7,29 @@
|
|||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <audioplayers_windows/audioplayers_windows_plugin.h>
|
#include <audioplayers_windows/audioplayers_windows_plugin.h>
|
||||||
#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
|
|
||||||
#include <connectivity_plus_windows/connectivity_plus_windows_plugin.h>
|
#include <connectivity_plus_windows/connectivity_plus_windows_plugin.h>
|
||||||
#include <metadata_god/metadata_god_plugin_c_api.h>
|
#include <metadata_god/metadata_god_plugin_c_api.h>
|
||||||
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
||||||
|
#include <screen_retriever/screen_retriever_plugin.h>
|
||||||
#include <url_launcher_windows/url_launcher_windows.h>
|
#include <url_launcher_windows/url_launcher_windows.h>
|
||||||
|
#include <window_manager/window_manager_plugin.h>
|
||||||
|
#include <window_size/window_size_plugin.h>
|
||||||
|
|
||||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||||
AudioplayersWindowsPluginRegisterWithRegistrar(
|
AudioplayersWindowsPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin"));
|
registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin"));
|
||||||
BitsdojoWindowPluginRegisterWithRegistrar(
|
|
||||||
registry->GetRegistrarForPlugin("BitsdojoWindowPlugin"));
|
|
||||||
ConnectivityPlusWindowsPluginRegisterWithRegistrar(
|
ConnectivityPlusWindowsPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
|
registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
|
||||||
MetadataGodPluginCApiRegisterWithRegistrar(
|
MetadataGodPluginCApiRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("MetadataGodPluginCApi"));
|
registry->GetRegistrarForPlugin("MetadataGodPluginCApi"));
|
||||||
PermissionHandlerWindowsPluginRegisterWithRegistrar(
|
PermissionHandlerWindowsPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
||||||
|
ScreenRetrieverPluginRegisterWithRegistrar(
|
||||||
|
registry->GetRegistrarForPlugin("ScreenRetrieverPlugin"));
|
||||||
UrlLauncherWindowsRegisterWithRegistrar(
|
UrlLauncherWindowsRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
|
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
|
||||||
|
WindowManagerPluginRegisterWithRegistrar(
|
||||||
|
registry->GetRegistrarForPlugin("WindowManagerPlugin"));
|
||||||
|
WindowSizePluginRegisterWithRegistrar(
|
||||||
|
registry->GetRegistrarForPlugin("WindowSizePlugin"));
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,13 @@
|
|||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
audioplayers_windows
|
audioplayers_windows
|
||||||
bitsdojo_window_windows
|
|
||||||
connectivity_plus_windows
|
connectivity_plus_windows
|
||||||
metadata_god
|
metadata_god
|
||||||
permission_handler_windows
|
permission_handler_windows
|
||||||
|
screen_retriever
|
||||||
url_launcher_windows
|
url_launcher_windows
|
||||||
|
window_manager
|
||||||
|
window_size
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
|
|
||||||
auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP);
|
|
||||||
|
|
||||||
#include <flutter/dart_project.h>
|
#include <flutter/dart_project.h>
|
||||||
#include <flutter/flutter_view_controller.h>
|
#include <flutter/flutter_view_controller.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -117,7 +117,8 @@ bool Win32Window::CreateAndShow(const std::wstring& title,
|
|||||||
double scale_factor = dpi / 96.0;
|
double scale_factor = dpi / 96.0;
|
||||||
|
|
||||||
HWND window = CreateWindow(
|
HWND window = CreateWindow(
|
||||||
window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
window_class, title.c_str(),
|
||||||
|
WS_OVERLAPPEDWINDOW, // do not add WS_VISIBLE since the window will be shown later
|
||||||
Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
|
Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
|
||||||
Scale(size.width, scale_factor), Scale(size.height, scale_factor),
|
Scale(size.width, scale_factor), Scale(size.height, scale_factor),
|
||||||
nullptr, nullptr, GetModuleHandle(nullptr), this);
|
nullptr, nullptr, GetModuleHandle(nullptr), this);
|
||||||
|
Loading…
Reference in New Issue
Block a user