macosui / macos_ui

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

Provide conveniences for avoiding and positioning traffic light buttons #437

Open matthew-carroll opened 1 year ago

matthew-carroll commented 1 year ago

Every Mac desktop window has three little window control buttons, often called "traffic lights".

These buttons have a default appearance, but their location can be changed by the developer.

I filed https://github.com/macosui/macos_window_utils.dart/issues/27 to provide access to this info and behavior from Flutter.

In addition to that lower level control, the macos_ui package could provide a couple widgets that remove most of the onus from end-users.

First, a special version of SafeArea could be added to easily avoid the traffic lights:

// Imagine that this row is positioning things across the top of the window
Row(
  children: [
     // Adjust the first item so that its content is pushed away from
     // the traffic lights.
     TrafficLightsSafeArea(
       child: Text("First"),
     ),
     Text("Second"),
     Text("Third"),
  ],
);

Second, an app bar container can simultaneously position the traffic lights, and avoid them:

MacAppBar(
  height: // optional height, defers to intrinsic child size if not provided
  background: // optional background widget that fills the space (including behind the traffic lights)
  foreground: // optional foreground widget that fills the space (including in front of the traffic lights)
  child: MyToolbar,
);