Skip to content

Commit

Permalink
Merge pull request #55 from alexmercerind/macos_issue_54
Browse files Browse the repository at this point in the history
Macos issue #54
  • Loading branch information
Adrian-Samoticha authored Dec 30, 2022
2 parents e02bb65 + abdfe98 commit 68f4bcd
Show file tree
Hide file tree
Showing 40 changed files with 681 additions and 1,762 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 1.1.0
- Added methods to add a toolbar to the window on macOS and change its style.
- Added methods to enable/disable the window's shadow on macOS.
- Added method to make the window fully transparent on macOS.
- Added methods to ignore mouse events on macOS.
- Added method to set the window's subtitle on macOS.
- Added methods and widgets to create visual effect subviews on macOS.
- Improved documentation of various widgets and classes.

**Breaking change:**
Migrated to [macos_window_utils](https://pub.dev/packages/macos_window_utils). See the [migration guide](https://github.com/alexmercerind/flutter_acrylic/blob/master/MIGRATIONGUIDE.md) for more information.

## 1.0.0+2

- Hotfix: Fixes a problem with too many rebuilds in TitlebarSafeArea.
Expand Down
65 changes: 65 additions & 0 deletions MIGRATIONGUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Migration Guide
## ^1.0.0 → 1.1.0
If you have followed the **“Additional setup for macOS”** instructions for flutter_acrylic 1.0.0, your `MainFlutterWindow.swift` file should like like this:

```swift
import Cocoa
import FlutterMacOS
import flutter_acrylic

class MainFlutterWindow: NSWindow {
override func awakeFromNib() {
let windowFrame = self.frame
let blurryContainerViewController = BlurryContainerViewController()
self.contentViewController = blurryContainerViewController
self.setFrame(windowFrame, display: true)

/* Initialize the flutter_acrylic plugin */
MainFlutterWindowManipulator.start(mainFlutterWindow: self)
RegisterGeneratedPlugins(registry: blurryContainerViewController.flutterViewController)

super.awakeFromNib()
}
}
```

In 1.1.0, flutter_acrylic has been made a dependent of [macos_window_utils](https://pub.dev/packages/macos_window_utils), which needs to be initialized instead of flutter_acrylic. To do so, the following changes need to be made:

+ Replace `import flutter_acrylic` with `import macos_window_utils`.
+ Replace `BlurryContainerViewController` with `MacOSWindowUtilsViewController`.

Once you are done, your finished code should like something like this:

```diff
import Cocoa
import FlutterMacOS
-import flutter_acrylic
+import macos_window_utils

class MainFlutterWindow: NSWindow {
override func awakeFromNib() {
let windowFrame = self.frame
- let blurryContainerViewController = BlurryContainerViewController()
- self.contentViewController = blurryContainerViewController
+ let macOSWindowUtilsViewController = MacOSWindowUtilsViewController()
+ self.contentViewController = macOSWindowUtilsViewController
self.setFrame(windowFrame, display: true)

- /* Initialize the flutter_acrylic plugin */
+ /* Initialize the macos_window_utils plugin */
MainFlutterWindowManipulator.start(mainFlutterWindow: self)
- RegisterGeneratedPlugins(registry: blurryContainerViewController.flutterViewController)
+ RegisterGeneratedPlugins(registry: macOSWindowUtilsViewController.flutterViewController)

super.awakeFromNib()
}
}
```

Additionally, you may need to open the `Podfile` in your Xcode project and make sure the deployment target in the first line is set to `10.14.6` or above:

```podspec
platform :osx, '10.14.6'
```

If your app does not support the macOS platform, no migration is necessary.
32 changes: 20 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Mention in your `pubspec.yaml`.
```yaml
dependencies:
...
flutter_acrylic: ^1.0.0
flutter_acrylic: ^1.1.0
```
## Example
Expand Down Expand Up @@ -371,29 +371,31 @@ You can see the [example](https://github.com/alexmercerind/flutter_acrylic/blob/

**Additional setup for macOS:**

flutter_acrylic depends on the [macos_window_utils](https://pub.dev/packages/macos_window_utils) plugin, which needs to be initialized as follows:

Open the `macos/Runner.xcworkspace` folder of your project using Xcode, press ⇧ + ⌘ + O and search for `MainFlutterWindow.swift`.

Insert `import flutter_acrylic` at the top of the file.
Insert `import macos_window_utils` at the top of the file.
Then, replace the code above the `super.awakeFromNib()`-line with the following code:

```swift
let windowFrame = self.frame
let blurryContainerViewController = BlurryContainerViewController()
self.contentViewController = blurryContainerViewController
let macOSWindowUtilsViewController = MacOSWindowUtilsViewController()
self.contentViewController = macOSWindowUtilsViewController
self.setFrame(windowFrame, display: true)

/* Initialize the flutter_acrylic plugin */
/* Initialize the macos_window_utils plugin */
MainFlutterWindowManipulator.start(mainFlutterWindow: self)

RegisterGeneratedPlugins(registry: blurryContainerViewController.flutterViewController)
RegisterGeneratedPlugins(registry: macOSWindowUtilsViewController.flutterViewController)
```

Assuming you're starting with the default configuration, the finished code should look something like this:

```diff
import Cocoa
import FlutterMacOS
+import flutter_acrylic
+import macos_window_utils

class MainFlutterWindow: NSWindow {
override func awakeFromNib() {
Expand All @@ -405,21 +407,27 @@ class MainFlutterWindow: NSWindow {
- RegisterGeneratedPlugins(registry: flutterViewController)

+ let windowFrame = self.frame
+ let blurryContainerViewController = BlurryContainerViewController()
+ self.contentViewController = blurryContainerViewController
+ let macOSWindowUtilsViewController = MacOSWindowUtilsViewController()
+ self.contentViewController = macOSWindowUtilsViewController
+ self.setFrame(windowFrame, display: true)

+ /* Initialize the flutter_acrylic plugin */
+ /* Initialize the macos_window_utils plugin */
+ MainFlutterWindowManipulator.start(mainFlutterWindow: self)

+ RegisterGeneratedPlugins(registry: blurryContainerViewController.flutterViewController)
+ RegisterGeneratedPlugins(registry: macOSWindowUtilsViewController.flutterViewController)

super.awakeFromNib()
}
}
```

Now press ⇧ + ⌘ + O once more and search for `Runner.xcodeproj`. Go to `info` > `Deployment Target` and set the `macOS Deployment Target` to `10.13` or above.
Now press ⇧ + ⌘ + O once more and search for `Runner.xcodeproj`. Go to `info` > `Deployment Target` and set the `macOS Deployment Target` to `10.14.6` or above.

Additionally, you may need to open the `Podfile` in your Xcode project and make sure the deployment target in the first line is set to `10.14.6` or above:

```podspec
platform :osx, '10.14.6'
```

Depending on your use case, you may want to extend the area of the window that Flutter can draw to to the entire window, such that you are able to draw onto the window's title bar as well (for example when you're only trying to make the sidebar transparent while the rest of the window is meant to stay opaque).

Expand Down
Loading

0 comments on commit 68f4bcd

Please sign in to comment.