diff --git a/CHANGELOG.md b/CHANGELOG.md index cf9edf5f..7db6c310 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [2.1.7] +### 🔄 Updated 🔄 +* Expose `WindowMainStateListener` and implement `overrideIsMainWindow` method to allow for the window’s main state to be overridden. + ## [2.1.6] ### 🔄 Updated 🔄 * add `section` parameter to `SidebarItem` to display an unclickable widget in the sidebar as a section header (thanks, [@whirlun](https://github.com/whirlun)). diff --git a/lib/macos_ui.dart b/lib/macos_ui.dart index d47a163a..f444deac 100644 --- a/lib/macos_ui.dart +++ b/lib/macos_ui.dart @@ -89,3 +89,4 @@ export 'src/theme/time_picker_theme.dart'; export 'src/theme/tooltip_theme.dart'; export 'src/theme/typography.dart'; export 'src/enums/accent_color.dart'; +export 'src/utils/window_main_state_listener.dart'; diff --git a/lib/src/utils/window_main_state_listener.dart b/lib/src/utils/window_main_state_listener.dart index c926f2b3..7d50da15 100644 --- a/lib/src/utils/window_main_state_listener.dart +++ b/lib/src/utils/window_main_state_listener.dart @@ -42,12 +42,23 @@ class WindowMainStateListener { /// Whether the window is currently the main window. bool _isMainWindow = true; + /// Overrides the value of [_isMainWindow]. + bool? _isMainWindowOverride; + /// Whether the window is currently the main window. - bool get isMainWindow => _isMainWindow; + bool get isMainWindow => _isMainWindowOverride ?? _isMainWindow; /// Notifies listeners when the window’s main state changes. final _windowMainStateStreamController = StreamController.broadcast(); + /// Overrides the value of [isMainWindow]. + /// + /// Passing `null` will remove the override. + void overrideIsMainWindow(bool? value) { + _isMainWindowOverride = value; + _windowMainStateStreamController.add(isMainWindow); + } + /// A stream of the window’s main state. Emits a new value whenever the state /// changes. Stream get onChanged => _windowMainStateStreamController.stream; diff --git a/pubspec.yaml b/pubspec.yaml index 158a7a29..602bfec7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: macos_ui description: Flutter widgets and themes implementing the current macOS design language. -version: 2.1.6 +version: 2.1.7 homepage: "https://macosui.dev" repository: "https://github.com/GroovinChip/macos_ui"