From def49ce6ad307a148fce90ba5af61c1b2d0d800f Mon Sep 17 00:00:00 2001 From: Adrian Samoticha <86920182+Adrian-Samoticha@users.noreply.github.com> Date: Thu, 18 Nov 2021 00:02:29 +0100 Subject: [PATCH] MacOS: Address issues #10 and #11 --- lib/flutter_acrylic.dart | 351 +++++++++++++- macos/Classes/FlutterAcrylicPlugin.swift | 567 +++++++++++++++++++++-- 2 files changed, 883 insertions(+), 35 deletions(-) diff --git a/lib/flutter_acrylic.dart b/lib/flutter_acrylic.dart index 0756f64..87963a5 100644 --- a/lib/flutter_acrylic.dart +++ b/lib/flutter_acrylic.dart @@ -25,9 +25,107 @@ const _kEnterFullscreen = "EnterFullscreen"; /// Exits fullscreen. const _kExitFullscreen = "ExitFullscreen"; +/// Gets the height of the titlebar. +const _kGetTitlebarHeight = "GetTitlebarHeight"; + /// Overrides the brightness setting of the window (macOS only). const _kOverrideMacOSBrightness = "OverrideMacOSBrightness"; + +/// (macOS only). +const _kSetDocumentEdited = "SetDocumentEdited"; + +/// (macOS only). +const _kSetDocumentNotEdited = "SetDocumentNotEdited"; + +/// (macOS only). +const _kSetRepresentedFile = "SetRepresentedFile"; + +/// (macOS only). +const _kSetRepresentedURL = "SetRepresentedURL"; + +/// (macOS only). +const _kHideTitlebar = "HideTitlebar"; + +/// (macOS only). +const _kShowTitlebar = "ShowTitlebar"; + +/// (macOS only). +const _kMakeTitlebarTransparent = "MakeTitlebarTransparent"; + +/// (macOS only). +const _kMakeTitlebarOpaque = "MakeTitlebarOpaque"; + +/// (macOS only). +const _kEnableFullSizeContentView = "EnableFullSizeContentView"; + +/// (macOS only). +const _kDisableFullSizeContentView = "DisableFullSizeContentView"; + +/// (macOS only). +const _kZoomWindow = "ZoomWindow"; + +/// (macOS only). +const _kUnzoomWindow = "UnzoomWindow"; + +/// (macOS only). +const _kIsWindowZoomed = "IsWindowZoomed"; + +/// (macOS only). +const _kIsWindowFullscreened = "IsWindowFullscreened"; + +/// (macOS only). +const _kHideZoomButton = "HideZoomButton"; + +/// (macOS only). +const _kShowZoomButton = "ShowZoomButton"; + +/// (macOS only). +const _kHideMiniaturizeButton = "HideMiniaturizeButton"; + +/// (macOS only). +const _kShowMiniaturizeButton = "ShowMiniaturizeButton"; + +/// (macOS only). +const _kHideCloseButton = "HideCloseButton"; + +/// (macOS only). +const _kShowCloseButton = "ShowCloseButton"; + +/// (macOS only). +const _kEnableZoomButton = "EnableZoomButton"; + +/// (macOS only). +const _kDisableZoomButton = "DisableZoomButton"; + +/// (macOS only). +const _kEnableMiniaturizeButton = "EnableMiniaturizeButton"; + +/// (macOS only). +const _kDisableMiniaturizeButton = "DisableMiniaturizeButton"; + +/// (macOS only). +const _kEnableCloseButton = "EnableCloseButton"; + +/// (macOS only). +const _kDisableCloseButton = "DisableCloseButton"; + +/// (macOS only). +const _kIsWindowInLiveResize = "IsWindowInLiveResize"; + +/// (macOS only). +const _kSetWindowAlphaValue = "SetWindowAlphaValue"; + +/// (macOS only). +const _kMakeWindowRestorable = "MakeWindowRestorable"; + +/// (macOS only). +const _kMakeWindowUnrestorable = "MakeWindowUnrestorable"; + +/// (macOS only). +const _kIsWindowVisible = "IsWindowVisible"; + + final MethodChannel _kChannel = const MethodChannel(_kChannelName); final Completer _kCompleter = new Completer(); @@ -179,26 +277,271 @@ class Window { ); } - /// Hides window controls. (Currently not supported on macOS) + /// Hides window controls. static Future hideWindowControls() async { await _kChannel.invokeMethod(_kHideWindowControls); } - /// Shows window controls. (Currently not supported on macOS) + /// Shows window controls. static Future showWindowControls() async { await _kChannel.invokeMethod(_kShowWindowControls); } - /// Makes the Flutter window fullscreen. (Currently not supported on macOS) + /// Makes the Flutter window fullscreen. static Future enterFullscreen() async { await _kChannel.invokeMethod(_kEnterFullscreen); } - /// Restores the Flutter window back to normal from fullscreen mode. (Currently not supported on macOS) + /// Restores the Flutter window back to normal from fullscreen mode. static Future exitFullscreen() async { await _kChannel.invokeMethod(_kExitFullscreen); } + /// Gets the height of the titlebar. + /// This value is used to determine the [[TitlebarSafeArea]] widget. + /// If the full-size content view is enabled, this value will be the height of the titlebar. + /// If the full-size content view is disabled, this value will be 0. + /// This value is only available on macOS. + static Future getTitlebarHeight() async { + await _kCompleter.future; + return await _kChannel.invokeMethod(_kGetTitlebarHeight); + } + + /// Sets the document to be edited. + /// This method is only available on macOS. + static Future setDocumentEdited(bool edited) async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kSetDocumentEdited); + } + + /// Sets the document to not be edited. + /// This method is only available on macOS. + static Future setDocumentNotEdited() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kSetDocumentNotEdited); + } + + /// Sets the represented file of the window. + /// This method is only available on macOS. + static Future setRepresentedFilename(String filename) async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kSetRepresentedFile, { + 'filename': filename, + }); + } + + /// Sets the represented URL of the window. + /// This method is only available on macOS. + static Future setRepresentedUrl(String url) async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kSetRepresentedURL, { + 'url': url, + }); + } + + /// Hides the titlebar of the window. + /// This method is only available on macOS. + static Future hideTitlebar() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kHideTitlebar); + } + + /// Shows the titlebar of the window. + /// This method is only available on macOS. + static Future showTitlebar() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kShowTitlebar); + } + + /// Makes the window's titlebar transparent. + /// This method is only available on macOS. + static Future makeTitlebarTransparent() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kMakeTitlebarTransparent); + } + + /// Makes the window's titlebar opaque. + /// This method is only available on macOS. + static Future makeTitlebarOpaque() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kMakeTitlebarOpaque); + } + + /// Enables the window's full-size content view. + /// It is recommended to enable the full-size content view when making + /// the titlebar transparent. + /// This method is only available on macOS. + static Future enableFullSizeContentView() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kEnableFullSizeContentView); + } + + /// Disables the window's full-size content view. + /// This method is only available on macOS. + static Future disableFullSizeContentView() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kDisableFullSizeContentView); + } + + /// Zooms the window. + /// This method is only available on macOS. + static Future zoomWindow(double scale) async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kZoomWindow); + } + + /// Unzooms the window. + /// This method is only available on macOS. + static Future unzoomWindow() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kUnzoomWindow); + } + + /// Returns if the window is zoomed. + /// This method is only available on macOS. + static Future isWindowZoomed() async { + await _kCompleter.future; + return await _kChannel.invokeMethod(_kIsWindowZoomed); + } + + /// Returns if the window is fullscreened. + /// This method is only available on macOS. + static Future isWindowFullscreened() async { + await _kCompleter.future; + return await _kChannel.invokeMethod(_kIsWindowFullscreened); + } + + /// Hides the window's zoom button. + /// This method is only available on macOS. + static Future hideZoomButton() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kHideZoomButton); + } + + /// Shows the window's zoom button. + /// The zoom button is visible by default. + /// This method is only available on macOS. + static Future showZoomButton() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kShowZoomButton); + } + + /// Hides the window's miniaturize button. + /// This method is only available on macOS. + static Future hideMiniaturizeButton() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kHideMiniaturizeButton); + } + + /// Shows the window's miniaturize button. + /// The miniaturize button is visible by default. + /// This method is only available on macOS. + static Future showMiniaturizeButton() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kShowMiniaturizeButton); + } + + /// Hides the window's close button. + /// This method is only available on macOS. + static Future hideCloseButton() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kHideCloseButton); + } + + /// Shows the window's close button. + /// The close button is visible by default. + /// This method is only available on macOS. + static Future showCloseButton() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kShowCloseButton); + } + + /// Enables the window's zoom button. + /// The zoom button is enabled by default. + /// This method is only available on macOS. + static Future enableZoomButton() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kEnableZoomButton); + } + + /// Disables the window's zoom button. + /// This method is only available on macOS. + static Future disableZoomButton() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kDisableZoomButton); + } + + /// Enables the window's miniaturize button. + /// The miniaturize button is enabled by default. + /// This method is only available on macOS. + static Future enableMiniaturizeButton() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kEnableMiniaturizeButton); + } + + /// Disables the window's miniaturize button. + /// This method is only available on macOS. + static Future disableMiniaturizeButton() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kDisableMiniaturizeButton); + } + + /// Enables the window's close button. + /// The close button is enabled by default. + /// This method is only available on macOS. + static Future enableCloseButton() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kEnableCloseButton); + } + + /// Disables the window's close button. + /// This method is only available on macOS. + static Future disableCloseButton() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kDisableCloseButton); + } + + /// Gets whether the window is currently being resized by the user. + /// This method is only available on macOS. + static Future isWindowInLiveResize() async { + await _kCompleter.future; + return await _kChannel.invokeMethod(_kIsWindowInLiveResize); + } + + /// Sets the window's alpha value. + /// This method is only available on macOS. + static Future setWindowAlphaValue(double value) async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kSetWindowAlphaValue, { + 'value': value, + }); + } + + /// Makes the window restorable. + /// If the window is restorable, its configuration will be preserved between + /// application launches. + /// This method is only available on macOS. + static Future makeWindowRestorable() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kMakeWindowRestorable); + } + + /// Makes the window unrestorable. + /// If the window is unrestorable, its configuration will be cleared between + /// application launches. + /// This method is only available on macOS. + static Future makeWindowUnrestorable() async { + await _kCompleter.future; + await _kChannel.invokeMethod(_kMakeWindowUnrestorable); + } + + /// Gets if the window is visible. + /// This method is only available on macOS. + static Future isWindowVisible() async { + await _kCompleter.future; + return await _kChannel.invokeMethod(_kIsWindowVisible); + } + /// Overrides the brightness setting of the window (macOS only). static Future overrideMacOSBrightness({ required bool dark, diff --git a/macos/Classes/FlutterAcrylicPlugin.swift b/macos/Classes/FlutterAcrylicPlugin.swift index cecef53..4c21b56 100644 --- a/macos/Classes/FlutterAcrylicPlugin.swift +++ b/macos/Classes/FlutterAcrylicPlugin.swift @@ -1,6 +1,39 @@ import Cocoa import FlutterMacOS +public class BlurryContainerViewController: NSViewController { + public let flutterViewController = FlutterViewController() + + public init() { + super.init(nibName: nil, bundle: nil) + } + + required public init?(coder: NSCoder) { + fatalError() + } + + override public func loadView() { + let blurView = NSVisualEffectView() + blurView.autoresizingMask = [.width, .height] + blurView.blendingMode = .behindWindow + blurView.state = .active + if #available(macOS 10.14, *) { + blurView.material = .underWindowBackground + } + self.view = blurView + } + + override public func viewDidLoad() { + super.viewDidLoad() + + self.addChild(flutterViewController) + + flutterViewController.view.frame = self.view.bounds + flutterViewController.view.autoresizingMask = [.width, .height] + self.view.addSubview(flutterViewController.view) + } +} + private class EffectIDToMaterialConverter { @available(macOS 10.14, *) public static func getMaterialFromEffectID(effectID: NSNumber) -> NSVisualEffectView.Material { @@ -74,57 +107,360 @@ private class EffectIDToMaterialConverter { } public class MainFlutterWindowManipulator { - private static var contentView: NSView? - private static var invalidateShadow: () -> Void = {} + private static var mainFlutterWindow: NSWindow? + + private static func printNotStartedWarning() { + print("Warning: The MainFlutterWindowManipulator has not been started. Please make sure the flutter_acrylic plugin is initialized correctly in your MainFlutterWindow.swift file.") + } + + public static func start(mainFlutterWindow: NSWindow) { + self.mainFlutterWindow = mainFlutterWindow + + showTitlebar() + makeTitlebarOpaque() + disableFullSizeContentView() + + mainFlutterWindow.backgroundColor = .clear + } - private static func printMissingContentViewWarning() { - print("Warning: The MainFlutterWindowManipulator's contentView has not been set. Please make sure the flutter_acrylic plugin is initialized correctly in your MainFlutterWindow.swift file.") + public static func hideTitlebar() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.titleVisibility = NSWindow.TitleVisibility.hidden + } + + public static func showTitlebar() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.titleVisibility = NSWindow.TitleVisibility.visible } - public static func setContentView(contentView: NSView) { - self.contentView = contentView + public static func makeTitlebarTransparent() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.titlebarAppearsTransparent = true } - public static func setInvalidateShadowFunction(invalidateShadow: @escaping () -> Void) { - self.invalidateShadow = invalidateShadow + public static func makeTitlebarOpaque() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.titlebarAppearsTransparent = false + } + + public static func enableFullSizeContentView() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.styleMask.insert(.fullSizeContentView) + } + + public static func disableFullSizeContentView() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.styleMask.remove(.fullSizeContentView) + } + + public static func zoomWindow() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.setIsZoomed(true) + } + + public static func unzoomWindow() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.setIsZoomed(false) + } + + public static func isWindowZoomed() -> Bool { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return false + } + + return self.mainFlutterWindow!.isZoomed + } + + public static func enterFullscreen() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + if (!isWindowFullscreened()) { + self.mainFlutterWindow!.toggleFullScreen(self) + } + } + + public static func exitFullscreen() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + if (isWindowFullscreened()) { + self.mainFlutterWindow!.toggleFullScreen(self) + } + } + + public static func isWindowFullscreened() -> Bool { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return false + } + + let isFullscreenEnabled = self.mainFlutterWindow!.styleMask.contains(NSWindow.StyleMask.fullScreen) + return isFullscreenEnabled + } + + public static func hideZoomButton() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.standardWindowButton(.zoomButton)!.isHidden = true + } + + public static func showZoomButton() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.standardWindowButton(.zoomButton)!.isHidden = false + } + + public static func hideMiniaturizeButton() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.standardWindowButton(.miniaturizeButton)!.isHidden = true + } + + public static func showMiniaturizeButton() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.standardWindowButton(.miniaturizeButton)!.isHidden = false + } + + public static func hideCloseButton() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.standardWindowButton(.closeButton)!.isHidden = true + } + + public static func showCloseButton() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.standardWindowButton(.closeButton)!.isHidden = false + } + + public static func enableZoomButton() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.standardWindowButton(.zoomButton)!.isEnabled = true + } + + public static func disableZoomButton() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.standardWindowButton(.zoomButton)!.isEnabled = false + } + + public static func enableMiniaturizeButton() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.standardWindowButton(.miniaturizeButton)!.isEnabled = true + } + + public static func disableMiniaturizeButton() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.standardWindowButton(.miniaturizeButton)!.isEnabled = false + } + + public static func enableCloseButton() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.standardWindowButton(.closeButton)!.isEnabled = true + } + + public static func disableCloseButton() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.standardWindowButton(.closeButton)!.isEnabled = false + } + + public static func setDocumentEdited() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.isDocumentEdited = true + } + + public static func setDocumentNotEdited() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.isDocumentEdited = false + } + + public static func setRepresentedFilename(filename: String) { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.representedFilename = filename + } + + public static func setRepresentedURL(url: String) { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.representedURL = URL(string: url) + } + + public static func isWindowInLiveResize() -> Bool { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return false + } + + return self.mainFlutterWindow!.inLiveResize + } + + public static func setWindowAlphaValue(alphaValue: CGFloat) { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.alphaValue = alphaValue + } + + public static func makeWindowRestorable() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.isRestorable = true + } + + public static func makeWindowUnrestorable() { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow!.isRestorable = false + } + + public static func isWindowVisible() -> Bool { + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return false + } + + return self.mainFlutterWindow!.isVisible } @available(macOS 10.14, *) public static func setAppearance(dark: Bool) { - let superView = contentView!.superview! - superView.appearance = NSAppearance(named: dark ? .darkAqua : .aqua) + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() + return + } + + self.mainFlutterWindow?.contentView?.superview?.appearance = NSAppearance(named: dark ? .darkAqua : .aqua) - self.invalidateShadow() + self.mainFlutterWindow?.invalidateShadow() } @available(macOS 10.14, *) public static func setMaterial(material: NSVisualEffectView.Material) { - if (self.contentView == nil) { - printMissingContentViewWarning() + if (self.mainFlutterWindow == nil) { + printNotStartedWarning() return } - let superView = contentView!.superview! - - let blurView = NSVisualEffectView() - blurView.frame = superView.bounds - blurView.autoresizingMask = [.width, .height] - blurView.blendingMode = NSVisualEffectView.BlendingMode.behindWindow - - /* Pick the correct material for the task */ - blurView.material = material - - /* Replace the contentView and the background view */ - superView.replaceSubview(contentView!, with: blurView) - blurView.addSubview(contentView!) + let blurryContainerViewController = self.mainFlutterWindow?.contentViewController as! BlurryContainerViewController; + (blurryContainerViewController.view as! NSVisualEffectView).material = material - self.invalidateShadow() + self.mainFlutterWindow?.invalidateShadow() } @available(macOS 10.14, *) public static func setEffect(material: NSVisualEffectView.Material) { setMaterial(material: material) } + + public static func getTitlebarHeight() -> CGFloat { + let windowFrameHeight = (self.mainFlutterWindow!.contentView?.frame.height)! + let contentLayoutRectHeight = self.mainFlutterWindow!.contentLayoutRect.height + let fullSizeContentViewNoContentAreaHeight = windowFrameHeight - contentLayoutRectHeight + return fullSizeContentViewNoContentAreaHeight + } } public class FlutterAcrylicPlugin: NSObject, FlutterPlugin { @@ -176,22 +512,26 @@ public class FlutterAcrylicPlugin: NSObject, FlutterPlugin { break case "HideWindowControls": - print("Warning: Hiding window controls is currently not supported on macOS.") + MainFlutterWindowManipulator.hideZoomButton() + MainFlutterWindowManipulator.hideMiniaturizeButton() + MainFlutterWindowManipulator.hideCloseButton() result(true) break case "ShowWindowControls": - print("Warning: Showing window controls is currently not supported on macOS.") + MainFlutterWindowManipulator.showZoomButton() + MainFlutterWindowManipulator.showMiniaturizeButton() + MainFlutterWindowManipulator.showCloseButton() result(true) break case "EnterFullscreen": - print("Warning: Entering fullscreen mode is currently not supported on macOS.") + MainFlutterWindowManipulator.enterFullscreen() result(true) break case "ExitFullscreen": - print("Warning: Exiting fullscreen mode is currently not supported on macOS.") + MainFlutterWindowManipulator.exitFullscreen() result(true) break @@ -206,6 +546,171 @@ public class FlutterAcrylicPlugin: NSObject, FlutterPlugin { result(true) break + case "SetDocumentEdited": + MainFlutterWindowManipulator.setDocumentEdited() + result(true) + break + + case "SetDocumentNotEdited": + MainFlutterWindowManipulator.setDocumentNotEdited() + result(true) + break + + case "SetRepresentedFile": + let filename = args["filename"] as! String + + MainFlutterWindowManipulator.setRepresentedFilename(filename: filename) + result(true) + break + + case "SetRepresentedURL": + let url = args["url"] as! String + + MainFlutterWindowManipulator.setRepresentedFilename(filename: url) + result(true) + break + + case "GetTitlebarHeight": + let titlebarHeight = MainFlutterWindowManipulator.getTitlebarHeight() as NSNumber + result(titlebarHeight) + break + + case "HideTitlebar": + MainFlutterWindowManipulator.hideTitlebar() + result(true) + break + + case "ShowTitlebar": + MainFlutterWindowManipulator.showTitlebar() + result(true) + break + + case "MakeTitlebarTransparent": + MainFlutterWindowManipulator.makeTitlebarTransparent() + result(true) + break + + case "MakeTitlebarOpaque": + MainFlutterWindowManipulator.makeTitlebarOpaque() + result(true) + break + + case "EnableFullSizeContentView": + MainFlutterWindowManipulator.enableFullSizeContentView() + result(true) + break + + case "DisableFullSizeContentView": + MainFlutterWindowManipulator.disableFullSizeContentView() + result(true) + break + + case "ZoomWindow": + MainFlutterWindowManipulator.zoomWindow() + result(true) + break + + case "UnzoomWindow": + MainFlutterWindowManipulator.unzoomWindow() + result(true) + break + + case "IsWindowZoomed": + let isWindowZoomed = MainFlutterWindowManipulator.isWindowZoomed() + result(isWindowZoomed) + break + + case "IsWindowFullscreened": + let isWindowFullscreened = MainFlutterWindowManipulator.isWindowFullscreened() + result(isWindowFullscreened) + break + + case "HideZoomButton": + MainFlutterWindowManipulator.hideZoomButton() + result(true) + break + + case "ShowZoomButton": + MainFlutterWindowManipulator.showZoomButton() + result(true) + break + + case "HideMiniaturizeButton": + MainFlutterWindowManipulator.hideMiniaturizeButton() + result(true) + break + + case "ShowMiniaturizeButton": + MainFlutterWindowManipulator.showMiniaturizeButton() + result(true) + break + + case "HideCloseButton": + MainFlutterWindowManipulator.hideCloseButton() + result(true) + break + + case "ShowCloseButton": + MainFlutterWindowManipulator.showCloseButton() + result(true) + break + + case "EnableZoomButton": + MainFlutterWindowManipulator.enableZoomButton() + result(true) + break + + case "DisableZoomButton": + MainFlutterWindowManipulator.disableZoomButton() + result(true) + break + + case "EnableMiniaturizeButton": + MainFlutterWindowManipulator.enableMiniaturizeButton() + result(true) + break + + case "DisableMiniaturizeButton": + MainFlutterWindowManipulator.disableMiniaturizeButton() + result(true) + break + + case "EnableCloseButton": + MainFlutterWindowManipulator.enableCloseButton() + result(true) + break + + case "DisableCloseButton": + MainFlutterWindowManipulator.disableCloseButton() + result(true) + break + + case "IsWindowInLiveResize": + let isWindowInLiveResize = MainFlutterWindowManipulator.isWindowInLiveResize() + result(isWindowInLiveResize) + break + + case "SetWindowAlphaValue": + let alphaValue = args["value"] as! NSNumber + MainFlutterWindowManipulator.setWindowAlphaValue(alphaValue: alphaValue as! CGFloat) + result(true) + break + + case "MakeWindowRestorable": + MainFlutterWindowManipulator.makeWindowRestorable() + result(true) + break + + case "MakeWindowUnrestorable": + MainFlutterWindowManipulator.makeWindowUnrestorable() + result(true) + break + + case "IsWindowVisible": + let isWindowVisible = MainFlutterWindowManipulator.isWindowVisible() + result(isWindowVisible) + break + default: result(FlutterMethodNotImplemented) break