Skip to content

Commit

Permalink
Merge pull request #32 from macosui/issues_22_and_31
Browse files Browse the repository at this point in the history
Issues #22 and #31
  • Loading branch information
Adrian-Samoticha committed Aug 9, 2023
2 parents f8d1dd8 + 7133825 commit ef668ab
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions lib/window_manipulator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -651,4 +651,9 @@ class WindowManipulator {
'`enableWindowDelegate` parameter is set to true in your '
'WindowManipulator.initialize call.');
}

static Future<bool> isMainWindow() async {
await _completer.future;
return await _windowManipulatorMethodChannel.invokeMethod('isMainWindow');
}
}
4 changes: 4 additions & 0 deletions macos/Classes/MacOSWindowUtilsPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions macos/Classes/MainFlutterWindowManipulator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit ef668ab

Please sign in to comment.