Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Drawer to support Material 3 #103551

Closed
Tracked by #91605
darrenaustin opened this issue May 12, 2022 · 15 comments · Fixed by #115668
Closed
Tracked by #91605

Update Drawer to support Material 3 #103551

darrenaustin opened this issue May 12, 2022 · 15 comments · Fixed by #115668
Assignees
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Comments

@darrenaustin
Copy link
Contributor

As part of the Material 3 specification there are updates to the Navigation drawer visuals:

Screen Shot 2022-05-11 at 5 15 20 PM

Currently Flutter only has the Drawer widget, but it is pretty bare-bones. We should look into possibly creating a new NavigationDrawer. It would be good if that could be integrated with the NavigationDestination used by the NavigationBar as well.

@darrenaustin darrenaustin added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels May 12, 2022
@rydmike
Copy link
Contributor

rydmike commented May 13, 2022

@darrenaustin even the current Drawer container widget has some challenges when it comes to being able to deliver a M3 themed version of it.

The M3 spec says the border radius on it should be "0,16,16,0dp corner radii", basically the visible corners should be rounded 16dp.

The current Drawer widget container is however used in Scaffold in both drawer and endDrawer property, and currently I see no way to make a DrawerThemeData that could correctly consider both the directionality of the ambient app and if the Drawer is being used in a Scaffold as a drawer or endDrawer and always get the M3 or desired border rounding on the correct visible corners.

Imo the visible edge corner shape should also be themeable ,so we can change the border radius, of course default would be M3 spec, when opting in on M3. Currently there is no way to correctly do this with its current theming capabilities, or perhaps I'm missing something.

@ArishSultan
Copy link
Contributor

@rydmike @darrenaustin I think we will need to redesign the existing Scaffold or make a new Scaffold with material 3 capabilities since the current Scaffold is only capable of showing an elevated Drawer, since the drawer gets wrapped with DrawerController behind the scenes. there is no way to implement an always visible drawer using Theme only, the new Scaffold should also have support for NavigationRail.

Share your thoughts.

@bernaferrari
Copy link
Contributor

bernaferrari commented May 14, 2022

@ArishSultan if you want to be radical, deprecate drawer and add sideMenu/navigationMenu to the Scaffold, which can be a Drawer that gets automatically expanded/shrinked depending on the screen size, or a rail that becomes navigation on phone.

@guidezpl guidezpl changed the title Update Drawer to support Material 3 Update Drawer to support Material 3 May 24, 2022
@mhoad
Copy link

mhoad commented Jun 22, 2022

Just to quickly speak to the point @bernaferrari mentioned, just went through that process of getting that to work and it was much more painful than I would have anticipated for such a fundamental but of functionality, it feels like there is a lot of room here to improve the DX and the idea they mentioned is ultimately what I wish I could have done in the first place.

@elbeicktalat
Copy link
Contributor

elbeicktalat commented Jun 25, 2022

@darrenaustin even the current Drawer container widget has some challenges when it comes to being able to deliver a M3 themed version of it.

I don't think that is an issue caused by the actual Drawer, this issue is related to the Scaffold.

What I have tried:

  • Use Directionality widget, but it doesn't works since it change the text direction also.

To solve this issue I suggest the following:
Edit: Since the drawers are a widget, so the first solution cannot work.

  1. Add border radius property in the Drawer.
  2. Add a new property to the Scaffold to determine the border radius of both drawers.

Thanks!

@elbeicktalat
Copy link
Contributor

@rydmike I don't agree with you, the drawer widget is a very simple widget so to me it doesn't make a sense having a new one.

Yes it's more easy but not the best solution to me.

@rydmike
Copy link
Contributor

rydmike commented Jun 26, 2022

@elbeicktalat I actually agree with you, it was @bernaferrari that suggested making a new one. Still a new additional drawer/menu widget with more out of the box features would also be useful, but for different reasons. In that case I think the existing simple Drawer container should still exist and be available as starting point for own custom menus, like today.

My comment was only concerning making the current Drawer have more theming properties. Could be something like visible corner radius, and screen edge corner radius (in addition to current general border radius, well Shape actually). Then when those widget props or theme props are used, let the widget figure out which corners should be rounded based on current directionality or if it is used in Scaffold drawer or endDrawer property. The last one might be tricky, since the widget itself or theme for it has no knowledge of that.

TLDR:
I just want to be able to Shape theme the Drawer border radius for its visible side, so correct side is rounded regardless of if Drawer is used in Scaffold drawer or endDrawer, and be directionality aware as well for these cases.

About theming widgets
There are a few widgets around that cannot be themed to get the same design and behaviour as their default un-themed design, because some of the default design behaviour is linked to logic when its theme is null, and that logic cannot be replicated when the theme is not null. This is imo poor design that should be avoided. The border radius on the FAB is an example of such a case, SnackBar is another one, they will need fixes for it. Can we please not make this widget such a case too.

@elbeicktalat
Copy link
Contributor

I don't know if we could integrate the Navigation Destination used by the Navigation Bar only in one PR. since there is a lot to do.

@elbeicktalat
Copy link
Contributor

This requires #108162

@hangyujin
Copy link
Contributor

I created a doc to discuss about drawer/navigationDrawer in M3 , please feel free to comment!

https://docs.google.com/document/d/1tlgCIN5VYGM8LBT08y29OyeLb9EIhg2HgSo5UgmhXfk/edit?usp=sharing&resourcekey=0-FN54My8BuIgqRHhpshaEfg

@MarcusWichelmann
Copy link

MarcusWichelmann commented Nov 24, 2022

@hangyujin Thanks for implementing this. But I think one important thing is missing here:

Is it possible to make the children of NavigationDrawer scrollable? I have more NavigationDrawerDestinations than might fit on every screen.

As the implementation looks like, this is not supported?

@MarcusWichelmann
Copy link

MarcusWichelmann commented Nov 25, 2022

I also wonder how safe areas should be correctly handled in regard to scroling? Maybe the widget should provide a good default behavior for this?

@MarcusWichelmann
Copy link

Now reported here: #116782

@darrenaustin
Copy link
Contributor Author

This drawer issue is fixed with #115668. The scrolling issue will be tracked in #116782.

@github-actions
Copy link

github-actions bot commented Mar 5, 2023

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
No open projects
Status: Done
8 participants