Update Material 3 bottom sheet#120855
Conversation
chrisbobbe
left a comment
There was a problem hiding this comment.
I'm glad to see this in progress! 🙂 Here are some small comments informed by my work putting together a bottom sheet for an app I'm working on.
I'm curious for anyone's thoughts on how scrollable content (e.g. with DraggableScrollableSheet) should work. From reading this revision, I think callers that ask for a drag handle will see the scrollable content get clipped at an artificial line below the drag handle, right, instead of getting clipped as it crosses the top edge of the sheet?
There was a problem hiding this comment.
This differs slightly from the Material spec in that it puts 15dp between the top of the drag handle and the top of the sheet, right, instead of 22dp?
Something that seems to work well in my project, where I'm building a custom drag handle for before this lands (zulip/zulip-flutter#12), is a SizedBox with height kMinInteractiveDimension (48dp) and the drag handle vertically centered in that. Here's a comment I've written in my draft:
// In the spec, this is expressed as 22 logical pixels of top/bottom
// padding on the drag handle:
// https://m3.material.io/components/bottom-sheets/specs#e69f3dfb-e443-46ba-b4a8-aabc718cf335
// The drag handle is specified with height 4 logical pixels, so we can
// get the same result by vertically centering the handle in a box with
// height 22 + 4 + 22 = 48. We have another way to say 48 --
// kMinInteractiveDimension -- which is actually not a bad way to
// express it, since the feature was announced as "an optional drag
// handle with an accessible 48dp hit target":
// https://m3.material.io/components/bottom-sheets/overview#2cce5bae-eb83-40b0-8e52-5d0cfaa9b795For an interface that exposes dragHandleSize, that could be a nice way to conserve vertical space. I guess it would behave badly for callers that want a dragHandleSize taller than 48dp. But I think callers that depart that much from the specified height of 4dp aren't really using the interface as intended.
There was a problem hiding this comment.
(In my case, the advantage I found was that kMinInteractiveDimension was a convenient constant to refer back to elsewhere in my code, where I needed to express the space belonging to the drag handle. In particular, I wanted the scrollable content of the sheet (in a DraggableScrollableSheet) to start out below the drag handle in the y-direction, but then be scrollable under the drag handle in the z-direction, with help from a Stack. So then the contents get clipped when they scroll off the top of the sheet, instead of getting clipped by an artificial-looking line below the drag handle.)
There was a problem hiding this comment.
Thanks for the suggestion! I do agree using kMinInteractiveDimension here is better than hardcode 22
There was a problem hiding this comment.
Great! 🙂 I see in the current revision 5f47c77fd a variable _kMinInteractiveSize has been added; is there a reason for using that instead of the existing global kMinInteractiveDimension?
There was a problem hiding this comment.
Hi Chris, I didn't realize that there is a existing global kMinInteractiveDimension, thanks for pointing it out to me! I will use it.
d69ce6e to
261058e
Compare
There was a problem hiding this comment.
The implication here is that each time dragHandleMaterialState changes, the entire BottomSheet, along with the _DragHandle gets rebuilt. Is that true?
There was a problem hiding this comment.
Yes, that's true and I think it's acceptable.
Although we added dragHandle in M3, the bottom sheet is draggable as a whole, so for dragHandleMaterialState MaterialState.focused, I use the _handleDragStart and _handleDragEnd functions in the bottom sheet class to define whether dragHandle is focused.
|
It would help future historians and bisectors if this PR's description was a little more comprehensive about what's changing. |
HansMuller
left a comment
There was a problem hiding this comment.
Only non-trivial thing remaining to sort out is https://github.com/flutter/flutter/pull/120855/files#r1123885042
gnprice
left a comment
There was a problem hiding this comment.
Thanks! Small docs and formatting nits.
|
Also it would be good to add to the class's docs a reference to the Material 3 version of the spec. Perhaps as another item in the "See also" list, replacing the last item with two items, like: /// * The Material 2 spec at <https://m2.material.io/components/sheets-bottom>.
/// * The Material 3 spec at <https://m3.material.io/components/bottom-sheets/overview>.That way there's something for people to refer to if they want to understand what a "drag handle" is. |
gnprice
left a comment
There was a problem hiding this comment.
Looking good! Small comment-only comments.
(I had the same question as @HansMuller at https://github.com/flutter/flutter/pull/120855/files#r1123885042 , but I'll leave that subthread to him.)
…-size `. Fixes flutter#122229 (flutter#122230) fix devtool instructional messages after `flutter build ... --analyze-size `. Fixes flutter#122229
Remove another reference to BindingBase.window
…er#122347) Updates `flutter/test/rendering` to no longer use `TestWindow`
…r#121850) Document on ScrollPhysics the requirement to override applyTo
* Revert "Remove references to BindingBase.window (flutter#122119)" This reverts commit c7681f0. * Revert "Remove another reference to BindingBase.window (flutter#122341)" This reverts commit 6ec4445. * Revert "Reland (2): Removes single window assumptions from `flutter_test` (flutter#122233)" This reverts commit eb3d317. * Revert "Remove single view assumption from TestViewConfiguration (flutter#122352)" This reverts commit 927289f. * Revert "Updates `flutter/test/cupertino` to no longer use `TestWindow` (flutter#122325)" This reverts commit 67e17e4. * Revert "Updates `flutter/test/gestures` to no longer reference `TestWindow` (flutter#122327)" This reverts commit c2a5111. * Revert "Updates `flutter/test/rendering` to no longer use `TestWindow` (flutter#122347)" This reverts commit 28b65e0. * Revert "Updates `flutter_localizations/test` to stop using `TestWindow` (flutter#122321)" This reverts commit 01367d5.
…eller redux. (flutter#122340)" (flutter#122362) Revert "[Impeller] Temporary flag flip for devicelab tests to use Impeller redux."
…irements (flutter#122380) Manually landing to fix the Engine rolls. The change will not affect Google Testing.
Fix Gradle 7 warnings that are now errors in Gradle 8
SelectionChangedCause for iOS keyboard-select
…tter#122352)" (flutter#122414) Reland "Remove single view assumption from TestViewConfiguration (flutter#122352)"
Introduce the PipelineOwner tree
Clean up scrollable.dart for 2D
…#120827) Constrain date picker to max width to avoid bending outwards
…utter#122430) Manual roll Flutter Engine from e9ca7b2 to 7572fe5 (16 revisions)
|
Closing this and starting a new one( #122445) because I messed up with the commits |
|
It's unclear to me whether this is the right relationship with enableDrag. It seems to me that if a handle is present, it should always be draggable, independently of enableDrag, and that enableDrag should only apply to the contents of the bottom sheet, excluding the handle.
|
|
I think it can be clarified that |
issue:#111448
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.