diff --git a/CHANGELOG.md b/CHANGELOG.md index 48c099b..11c97c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.2.0 + +- Fix typo in README. +- Add `isMainWindow` getter to WindowManipulator. + ## 1.1.3 - Fix multiple `FlutterViewController`s being created, which prevented the apps from exiting properly on Flutter 3.10. diff --git a/README.md b/README.md index 066c2a8..8d3033a 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ and the Flutter guide for + Methods and widgets to add, remove, and modify visual effect subviews. + Methods to set the window's level as well as reorder the window within its level. + Methods to modify the window's style mask. -+ An abstract `NSWindowDelegate` class that can be used detect `NSWindow` events, such as window resizing, moving, exposing, and minimizing. ++ An abstract `NSWindowDelegate` class that can be used to detect `NSWindow` events, such as window resizing, moving, exposing, and minimizing. + An `NSAppPresentationOptions` class that allows modifications to the window's fullscreen presentation options. Additionally, the package ships with an example project that showcases the plugin's features via an intuitive searchable user interface: diff --git a/lib/window_manipulator.dart b/lib/window_manipulator.dart index 14b1ffd..34a231d 100644 --- a/lib/window_manipulator.dart +++ b/lib/window_manipulator.dart @@ -651,4 +651,9 @@ class WindowManipulator { '`enableWindowDelegate` parameter is set to true in your ' 'WindowManipulator.initialize call.'); } + + static Future isMainWindow() async { + await _completer.future; + return await _windowManipulatorMethodChannel.invokeMethod('isMainWindow'); + } } diff --git a/macos/Classes/MacOSWindowUtilsPlugin.swift b/macos/Classes/MacOSWindowUtilsPlugin.swift index 4e5a1a8..78b58d3 100644 --- a/macos/Classes/MacOSWindowUtilsPlugin.swift +++ b/macos/Classes/MacOSWindowUtilsPlugin.swift @@ -413,6 +413,10 @@ public class MacOSWindowUtilsPlugin: NSObject, FlutterPlugin { result(MainFlutterWindowManipulator.addFullScreenPresentationOptions(presentationOptions!)) + case "isMainWindow": + let isMainWindow = MainFlutterWindowManipulator.isMainWindow() + result(isMainWindow) + default: result(FlutterMethodNotImplemented) break diff --git a/macos/Classes/MainFlutterWindowManipulator.swift b/macos/Classes/MainFlutterWindowManipulator.swift index c7aa778..8be3b95 100644 --- a/macos/Classes/MainFlutterWindowManipulator.swift +++ b/macos/Classes/MainFlutterWindowManipulator.swift @@ -566,4 +566,12 @@ public class MainFlutterWindowManipulator { mainFlutterWindowDelegate?.addFullScreenPresentationOptions(presentationOptions) return true } + + public static func isMainWindow() -> Bool { + if (self.mainFlutterWindow == nil) { + start(mainFlutterWindow: nil) + } + + return self.mainFlutterWindow!.isMainWindow + } } diff --git a/pubspec.yaml b/pubspec.yaml index f6c6016..0db71c0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: macos_window_utils description: macos_window_utils is a Flutter package that provides a set of methods for modifying the NSWindow of a Flutter application on macOS. -version: 1.1.3 +version: 1.2.0 repository: https://github.com/Adrian-Samoticha/macos_window_utils.dart environment: