macosui / macos_ui

Flutter widgets and themes implementing the current macOS design language.
https://macosui.github.io/macos_ui/#/
MIT License
1.84k stars 177 forks source link

Resolve #445 #471

Closed Adrian-Samoticha closed 1 year ago

Adrian-Samoticha commented 1 year ago

This PR resolves #445.

PushButton now more closely mimics the look and feel of native macOS buttons:

Screenshot 2023-08-07 at 15 41 01

In addition to featuring gradients and specular highlights, it also becomes greyed out when the window loses its focus …

Screenshot 2023-08-07 at 15 42 44

… and correctly responds to the user’s preferred accent color:

image

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

mattsrobot commented 1 year ago

Amazing work!