macosui / macos_ui

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

`MacosScaffold` should not add a `SizedBox` to the top of `Sidebar` 🐛 #150

Closed GroovinChip closed 3 years ago

GroovinChip commented 3 years ago

Description

Currently, MacosScaffold builds a SizedBox(height: titleBarHeight - 1), and adds it to the top of the sidebar. It results in undesired behavior. See the following screenshot:

Screen Shot 2021-07-12 at 9 57 20 AM

Steps To Reproduce

  1. Create a new Flutter project and add macos_ui to pubspec.yaml
  2. Replace the contents of main.dart with the following:
import 'package:flutter/material.dart';
import 'package:macos_ui/macos_ui.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MacosApp(
      home: MacosHome(),
    );
  }
}

class MacosHome extends StatelessWidget {
  const MacosHome({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MacosScaffold(
      sidebar: Sidebar(
        minWidth: 200,
        maxWidth: 300,
        builder: (context, scrollController) {
          return Column(
            children: [
              Text('Test'),
            ],
          );
        },
      ),
    );
  }
}

Expected behavior

The expected behavior is that Text('Test') should be flush with the window titlebar.

Screenshots

See above

Logs

No logs to report

GroovinChip commented 3 years ago

@lesliearkorful What's the rationale for having this SizedBox at the top of the Sidebar?

lesliearkorful commented 3 years ago

It's the top padding (or safe area) for sidebars when the native title bar is hidden or transparent. That top padding is equal to the height of the title bar in macos

You're seeing it like this because your app is showing the native macos title bar.

I guess we'll need a property to add or remove the top padding for the side bar.

I attached a screenshot of the Apple music app image

GroovinChip commented 3 years ago

It happens in projects where I hide the native titlebar as well: Screen Shot 2021-07-12 at 10 29 10 AM