Skip to content

Commit

Permalink
Merge branch 'stable' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	example/pubspec.lock
#	lib/src/buttons/push_button.dart
#	pubspec.lock
#	pubspec.yaml
#	test/theme/push_button_theme_test.dart
  • Loading branch information
GroovinChip committed Oct 12, 2023
2 parents 328f9cb + cbdf95b commit b3a8e53
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## [2.0.1]
### 🔄 Updated 🔄
* `PushButton` has received a facelift. It now mimics the look and feel of native macOS buttons more closely.
* **Note:** As a result, its `pressedOpacity` property and the `PushButtonTheme` class have been deprecated.
* **Note:** As a result, its `pressedOpacity` property and the `PushButtonTheme` class have been deprecated.

## [2.0.0]
### 🚨 Breaking Changes 🚨
Expand Down
24 changes: 24 additions & 0 deletions lib/src/utils/utils.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:macos_ui/macos_ui.dart';
import 'package:macos_ui/src/library.dart';

Expand Down Expand Up @@ -66,3 +69,24 @@ class Unsupported {

final String message;
}

/// A class that ensures that the application's macOS window's brightness
/// matches the given brightness.
class MacOSBrightnessOverrideHandler {
static Brightness? _lastBrightness;

/// Ensures that the application's macOS window's brightness matches
/// [currentBrightness].
///
/// For performance reasons, the brightness setting will only be overridden if
/// [currentBrightness] differs from the value it had when this method was
/// previously called. Therefore, it is safe to call this method frequently.
static void ensureMatchingBrightness(Brightness currentBrightness) {
if (kIsWeb) return;
if (!Platform.isMacOS) return;
if (currentBrightness == _lastBrightness) return;

WindowManipulator.overrideMacOSBrightness(dark: currentBrightness.isDark);
_lastBrightness = currentBrightness;
}
}

0 comments on commit b3a8e53

Please sign in to comment.