PushButton now more closely mimics the look and feel of native macOS buttons:
In addition to featuring gradients and specular highlights, it also becomes greyed out when the window loses its focus …
… and correctly responds to the user’s preferred accent color:
It does currently not respect the user’s choice of the “Increase contrast” setting in the Accessibility Settings. I’d suggest tackling that point in a future issue.
Technical Details
The utils.dart file now contains a WindowMainStateListener class, allowing listening to focus changes in the window. ~It currently has a minor issue: It assumes that the window is focused during startup and doesn’t check if it actually is. This is likely true in a released application but may be incorrect during testing (since the app can be restarted from within VS Code or the terminal). This issue will be fixed once https://github.com/macosui/macos_window_utils.dart/issues/31 lands.~ EDIT: This is now fixed.
Additionally, there now exists an AccentColorListener class. It is used by PushButton to retrieve the current accent color and listen to changes performed by the user.
The push-button’s pressedOpacity property and PushButtonTheme have also been deprecated, however, not all references to PushButtonTheme have been removed from the MacosThemeData class to ensure backward compatibility. I suppose they should be removed in the next breaking release, though.
Pre-launch Checklist
[x] I have incremented the package version as appropriate and updated CHANGELOG.md with my changes
[x] I have added/updated relevant documentation
[x] I have run "optimize/organize imports" on all changed files
[x] I have addressed all analyzer warnings as best I could
This PR resolves #445.
PushButton
now more closely mimics the look and feel of native macOS buttons:In addition to featuring gradients and specular highlights, it also becomes greyed out when the window loses its focus …
… and correctly responds to the user’s preferred accent color:
It does currently not respect the user’s choice of the “Increase contrast” setting in the Accessibility Settings. I’d suggest tackling that point in a future issue.
Technical Details
The
utils.dart
file now contains aWindowMainStateListener
class, allowing listening to focus changes in the window. ~It currently has a minor issue: It assumes that the window is focused during startup and doesn’t check if it actually is. This is likely true in a released application but may be incorrect during testing (since the app can be restarted from within VS Code or the terminal). This issue will be fixed once https://github.com/macosui/macos_window_utils.dart/issues/31 lands.~ EDIT: This is now fixed.Additionally, there now exists an
AccentColorListener
class. It is used byPushButton
to retrieve the current accent color and listen to changes performed by the user.The push-button’s
pressedOpacity
property andPushButtonTheme
have also been deprecated, however, not all references toPushButtonTheme
have been removed from theMacosThemeData
class to ensure backward compatibility. I suppose they should be removed in the next breaking release, though.Pre-launch Checklist
CHANGELOG.md
with my changes