Skip to content

Commit b3a8e53

Browse files
committed
Merge branch 'stable' into dev
# Conflicts: # CHANGELOG.md # example/pubspec.lock # lib/src/buttons/push_button.dart # pubspec.lock # pubspec.yaml # test/theme/push_button_theme_test.dart
2 parents 328f9cb + cbdf95b commit b3a8e53

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
## [2.0.1]
66
### 🔄 Updated 🔄
77
* `PushButton` has received a facelift. It now mimics the look and feel of native macOS buttons more closely.
8-
* **Note:** As a result, its `pressedOpacity` property and the `PushButtonTheme` class have been deprecated.
8+
* **Note:** As a result, its `pressedOpacity` property and the `PushButtonTheme` class have been deprecated.
99

1010
## [2.0.0]
1111
### 🚨 Breaking Changes 🚨

lib/src/utils/utils.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import 'dart:io';
2+
3+
import 'package:flutter/foundation.dart';
14
import 'package:macos_ui/macos_ui.dart';
25
import 'package:macos_ui/src/library.dart';
36

@@ -66,3 +69,24 @@ class Unsupported {
6669

6770
final String message;
6871
}
72+
73+
/// A class that ensures that the application's macOS window's brightness
74+
/// matches the given brightness.
75+
class MacOSBrightnessOverrideHandler {
76+
static Brightness? _lastBrightness;
77+
78+
/// Ensures that the application's macOS window's brightness matches
79+
/// [currentBrightness].
80+
///
81+
/// For performance reasons, the brightness setting will only be overridden if
82+
/// [currentBrightness] differs from the value it had when this method was
83+
/// previously called. Therefore, it is safe to call this method frequently.
84+
static void ensureMatchingBrightness(Brightness currentBrightness) {
85+
if (kIsWeb) return;
86+
if (!Platform.isMacOS) return;
87+
if (currentBrightness == _lastBrightness) return;
88+
89+
WindowManipulator.overrideMacOSBrightness(dark: currentBrightness.isDark);
90+
_lastBrightness = currentBrightness;
91+
}
92+
}

0 commit comments

Comments
 (0)