-
-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move
MacOSBrightnessOverrideHandler
to separate file
- Loading branch information
1 parent
ef8c156
commit 7fa0f23
Showing
2 changed files
with
26 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:flutter/foundation.dart'; | ||
import 'package:macos_ui/macos_ui.dart'; | ||
|
||
/// 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters