Comments (10)
Well, well. Things are going well so far.
Screen.Recording.2021-10-25.at.23.33.27.mov
from flutter_acrylic.
I have attempted to implement this on macOS and have so far achieved the following result:
The transparency effect works and is even sensitive to macOS' dark mode setting. This is what it looks like when dark mode is enabled:
That said, it seems that moving the window between workspaces causes the window's shadow to break:
Resizing the window fixes the issue. I wonder if the issue could be resolved somehow by calling MainFlutterWindow
's invalidateShadow()
method when a workspace change is detected, though I'm not sure.
Either way, the way I achieved this is by replacing the MainFlutterWindow.swift
file in the Xcode workspace with Oryan Moshe's code I copied from the link you posted above:
import Cocoa
import FlutterMacOS
class MainFlutterWindow: NSWindow {
override func awakeFromNib() {
let flutterViewController = FlutterViewController.init()
let windowFrame = self.frame
self.contentViewController = flutterViewController
self.setFrame(windowFrame, display: true)
RegisterGeneratedPlugins(registry: flutterViewController)
/* Hiding the window titlebar */
self.titleVisibility = NSWindow.TitleVisibility.hidden;
self.titlebarAppearsTransparent = true;
self.isMovableByWindowBackground = true;
self.standardWindowButton(NSWindow.ButtonType.miniaturizeButton)?.isEnabled = false;
/* Making the window transparent */
self.isOpaque = false
self.backgroundColor = .clear
/* Adding a NSVisualEffectView to act as a translucent background */
let contentView = contentViewController!.view;
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 = NSVisualEffectView.Material.underWindowBackground
/* Replace the contentView and the background view */
superView.replaceSubview(contentView, with: blurView)
blurView.addSubview(contentView)
super.awakeFromNib()
}
}
Note: You need to change the Deployment Target to 10.11 (or higher) for this to compile.
I've also edited the MainMenu.xib
file, such that the Full Size Content View
setting was enabled:
This expands the area of the window that your Flutter app can draw to and would allow you to e.g. recreate the transparent sidebar that has become common these days while keeping the rest of the window opaque.
That said, I am not fluent in Swift and currently have a rather shallow understanding of how Flutter's platform channels work, but I'd assume if I did some reading on these subjects I could successfully implement that functionality into a Flutter package.
from flutter_acrylic.
Not assigning myself, I don't have a mac.
from flutter_acrylic.
Alright, this is how far I've gotten thus far.
Screen.Recording.2021-10-29.at.23.19.29.mov
The extra functions that let you enter and exit out of fullscreen mode or hide and show the window controls are (currently) not supported, but the transparency effects work fine.
from flutter_acrylic.
@alexmercerind Alright. I've seen that you have approved my pull request. 🙂
The transparency effects are now fully supported, but the extra functions are not. I've decided to close this issue in favor of a newer one that addresses this issue: #10
from flutter_acrylic.
I have attempted to implement this on macOS and have so far achieved the following result:
The transparency effect works and is even sensitive to macOS' dark mode setting. This is what it looks like when dark mode is enabled:
That said, it seems that moving the window between workspaces causes the window's shadow to break:
Resizing the window fixes the issue. I wonder if the issue could be resolved somehow by calling
MainFlutterWindow
'sinvalidateShadow()
method when a workspace change is detected, though I'm not sure.Either way, the way I achieved this is by replacing the
MainFlutterWindow.swift
file in the Xcode workspace with Oryan Moshe's code I copied from the link you posted above:import Cocoa import FlutterMacOS class MainFlutterWindow: NSWindow { override func awakeFromNib() { let flutterViewController = FlutterViewController.init() let windowFrame = self.frame self.contentViewController = flutterViewController self.setFrame(windowFrame, display: true) RegisterGeneratedPlugins(registry: flutterViewController) /* Hiding the window titlebar */ self.titleVisibility = NSWindow.TitleVisibility.hidden; self.titlebarAppearsTransparent = true; self.isMovableByWindowBackground = true; self.standardWindowButton(NSWindow.ButtonType.miniaturizeButton)?.isEnabled = false; /* Making the window transparent */ self.isOpaque = false self.backgroundColor = .clear /* Adding a NSVisualEffectView to act as a translucent background */ let contentView = contentViewController!.view; 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 = NSVisualEffectView.Material.underWindowBackground /* Replace the contentView and the background view */ superView.replaceSubview(contentView, with: blurView) blurView.addSubview(contentView) super.awakeFromNib() } }Note: You need to change the Deployment Target to 10.11 (or higher) for this to compile.
I've also edited the
MainMenu.xib
file, such that theFull Size Content View
setting was enabled:This expands the area of the window that your Flutter app can draw to and would allow you to e.g. recreate the transparent sidebar that has become common these days while keeping the rest of the window opaque.
That said, I am not fluent in Swift and currently have a rather shallow understanding of how Flutter's platform channels work, but I'd assume if I did some reading on these subjects I could successfully implement that functionality into a Flutter package.
I'm glad to see I was helpful for your project! It's common practice to mention people using the @ sign in order for them to see that, but as long as someone found my research useful I'm happy (:
from flutter_acrylic.
@Adrian-Samoticha I have added you as a collaborator to the repository, feel free to make your changes to branch & make pull request to master
. It will be awesome to get this working on all three platforms.
I'll add you to the README for same contribution.
from flutter_acrylic.
is there any progress about the macOS support?
from flutter_acrylic.
@hzlgnn few people have found way to achieve the blur effect on macOS: here. Although, its not part of any plugin yet. Assuming blur APIs on macOS are well documented, it might not be wrong to enable it globally.
from flutter_acrylic.
@Adrian-Samoticha thanks a lot for your detailed comment, I assume a lot of time went into this study.
I'll appreciate your contribution to the project & it will really help users of the plugin.
Thankyou.
from flutter_acrylic.
Related Issues (20)
- windows10 aero effect color adjustment
- It doesn't open HOT 3
- expose aera transparent ratio API on windows10
- macOS broken HOT 10
- Usage of `macos_window_utils` broken in 1.1.1 HOT 6
- [Question] is there any way for customize unfocused window color of Window Effects like mica/acrylic/tabbed?
- windows11 acrylic effect changed
- Upgrade to macos_window_utils 1.1.2
- Replace the deprecated `backgroundColor` with `colorScheme.background` in `/example/lib/widgets/macos_action_menu/description_display.dart`
- Setup linting and fix linter errors
- Improve macos_window_utils import
- hideTitle takes no effect HOT 3
- Facing error after upgrading to 1.1.2 HOT 12
- Not working on macOS 12.3.1 (21E258) and flutter 3.7.11 HOT 8
- Not work after importing flutter_easyloading HOT 2
- macOS - Running in release mode causes program to hang HOT 9
- flutter_acrylic.Window.hideWindowControls() not support on linux HOT 1
- Not Working on Android ,
- Tint colour does not work on Mac OS when using WindowEffect.acrylic HOT 2
- WindowEffect.aero not working properly in windows 11 its just transparent
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_acrylic.