Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidebar transparency effect #175

Merged
merged 6 commits into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [0.10.1]
* Added support for transparent sidebar

## [0.10.0+1]
* Update `native_context_menu` dependency

Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,20 @@ class MainFlutterWindow: NSWindow {
self.isMovableByWindowBackground = true
self.styleMask.insert(NSWindow.StyleMask.fullSizeContentView)

self.isOpaque = false
self.backgroundColor = .clear
let contentView = contentViewController!.view;
let superView = contentView.superview!;
let blurView = NSVisualEffectView()
blurView.frame = superView.bounds
blurView.autoresizingMask = [.width, .height]
blurView.blendingMode = NSVisualEffectView.BlendingMode.behindWindow
if #available(macOS 10.14, *) {
blurView.material = .underWindowBackground
}
superView.replaceSubview(contentView, with: blurView)
blurView.addSubview(contentView)

RegisterGeneratedPlugins(registry: flutterViewController)

super.awakeFromNib()
Expand Down
1 change: 0 additions & 1 deletion example/lib/pages/dialogs_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:flutter/material.dart';
import 'package:macos_ui/macos_ui.dart';
import 'package:macos_ui/src/library.dart';

Expand Down
14 changes: 14 additions & 0 deletions example/macos/Runner/MainFlutterWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ class MainFlutterWindow: NSWindow {
self.isMovableByWindowBackground = true
self.styleMask.insert(NSWindow.StyleMask.fullSizeContentView)

self.isOpaque = false
self.backgroundColor = .clear
let contentView = contentViewController!.view;
let superView = contentView.superview!;
let blurView = NSVisualEffectView()
blurView.frame = superView.bounds
blurView.autoresizingMask = [.width, .height]
blurView.blendingMode = NSVisualEffectView.BlendingMode.behindWindow
if #available(macOS 10.14, *) {
blurView.material = .underWindowBackground
}
superView.replaceSubview(contentView, with: blurView)
blurView.addSubview(contentView)

RegisterGeneratedPlugins(registry: flutterViewController)

super.awakeFromNib()
Expand Down
1 change: 0 additions & 1 deletion lib/src/dialogs/macos_alert_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:flutter/material.dart';
import 'package:flutter/physics.dart';
import 'package:macos_ui/macos_ui.dart';
import 'package:macos_ui/src/library.dart';
Expand Down
7 changes: 6 additions & 1 deletion lib/src/layout/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@ class _MacosWindowState extends State<MacosWindow> {
late Color sidebarBackgroundColor;
Color dividerColor = theme.dividerColor;

if (!theme.brightness.isDark) {
// Only show blurry, transparent sidebar when platform brightness and app
// brightness are the same, otherwise it looks awful
if (MediaQuery.of(context).platformBrightness.isDark ==
theme.brightness.isDark) {
sidebarBackgroundColor = Colors.transparent;
} else if (!theme.brightness.isDark) {
mj-shifu marked this conversation as resolved.
Show resolved Hide resolved
sidebarBackgroundColor = widget.sidebar?.decoration?.color ??
CupertinoColors.systemGrey6.color;
} else {
mj-shifu marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
1 change: 0 additions & 1 deletion lib/src/theme/macos_theme.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/foundation.dart';
import 'package:macos_ui/macos_ui.dart';
import 'package:macos_ui/src/icon/macos_icon.dart';
import 'package:macos_ui/src/library.dart';

/// Applies a macOS-style theme to descendant macOS widgets.
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: macos_ui
description: Flutter widgets and themes implementing the current macOS design language.
version: 0.10.0+1
version: 0.10.1
homepage: "https://github.com/GroovinChip/macos_ui"

environment:
Expand Down
1 change: 0 additions & 1 deletion test/theme/icon_button_theme_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:macos_ui/macos_ui.dart';
import 'package:macos_ui/src/library.dart';
Expand Down