From 3b4b745386af817ee4bcb9ff6639598d2537ce35 Mon Sep 17 00:00:00 2001 From: Adrian Samoticha <86920182+Adrian-Samoticha@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:56:26 +0100 Subject: [PATCH 1/4] =?UTF-8?q?add=20method=20for=20overriding=20the=20`Wi?= =?UTF-8?q?ndowMainStateListener`=E2=80=99s=20`isMainWindow`=20property?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/utils/window_main_state_listener.dart | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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; From 4445293233d157f5344e3ecfc556a39c425e1cda Mon Sep 17 00:00:00 2001 From: Adrian Samoticha <86920182+Adrian-Samoticha@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:56:40 +0100 Subject: [PATCH 2/4] expose window main state listener --- lib/macos_ui.dart | 1 + 1 file changed, 1 insertion(+) 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'; From f6fd5bb84bd95afae30e4417187b9a7b0d1a2cd7 Mon Sep 17 00:00:00 2001 From: Adrian Samoticha <86920182+Adrian-Samoticha@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:56:52 +0100 Subject: [PATCH 3/4] bump version to 2.1.7 --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From 211e08a2bbb74308b6013333cce10fcf9a22e35e Mon Sep 17 00:00:00 2001 From: Adrian Samoticha <86920182+Adrian-Samoticha@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:57:01 +0100 Subject: [PATCH 4/4] add changelog entry for version 2.1.7 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) 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)).