Skip to content

Update Material 3 bottom sheet#120855

Closed
hannah-hyj wants to merge 115 commits intoflutter:masterfrom
hannah-hyj:bottom-sheet-2
Closed

Update Material 3 bottom sheet#120855
hannah-hyj wants to merge 115 commits intoflutter:masterfrom
hannah-hyj:bottom-sheet-2

Conversation

@hannah-hyj
Copy link
Member

@hannah-hyj hannah-hyj commented Feb 16, 2023

issue:#111448

  1. Added a default max width as 640
  2. Added a drag handle, the user can also tap it to dismiss bottom sheet in a11y mode. Added drag handle color and size to bottom sheet theme.

571677645837_ pic

581677646439_ pic

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. c: contributor-productivity Team-specific productivity, code health, technical debt. labels Feb 16, 2023
Copy link
Contributor

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment on lines 347 to 349
Copy link
Contributor

@chrisbobbe chrisbobbe Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-5d0cfaa9b795

For 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(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.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion! I do agree using kMinInteractiveDimension here is better than hardcode 22

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Chris, I didn't realize that there is a existing global kMinInteractiveDimension, thanks for pointing it out to me! I will use it.

@hannah-hyj hannah-hyj requested a review from HansMuller March 2, 2023 23:49
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implication here is that each time dragHandleMaterialState changes, the entire BottomSheet, along with the _DragHandle gets rebuilt. Is that true?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@HansMuller
Copy link
Contributor

It would help future historians and bisectors if this PR's description was a little more comprehensive about what's changing.

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only non-trivial thing remaining to sort out is https://github.com/flutter/flutter/pull/120855/files#r1123885042

Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Small docs and formatting nits.

@gnprice
Copy link
Member

gnprice commented Mar 4, 2023

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.

@hannah-hyj hannah-hyj requested a review from HansMuller March 6, 2023 23:25
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.)

timmaffett and others added 23 commits March 10, 2023 16:22
…-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
)

Remove single view assumption from TestViewConfiguration
* 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
…#120827)

Constrain date picker to max width to avoid bending outwards
@hannah-hyj hannah-hyj requested a review from keyonghan as a code owner March 11, 2023 00:22
@hannah-hyj hannah-hyj closed this Mar 11, 2023
@hannah-hyj
Copy link
Member Author

hannah-hyj commented Mar 11, 2023

Closing this and starting a new one( #122445) because I messed up with the commits

@hannah-hyj
Copy link
Member Author

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.

  1. enableDrag = true, showDragHandle=true, ----> draggable bottom sheet with drag handle
  2. enableDrag = true, showDragHandle=false. ----> draggable bottom sheet without drag handle
  3. enableDrag = false, showDragHandle=false --> non-draggable bottom sheet
  4. enableDrag = false, showDragHandle=true, This is the only controversial case, imo if the enableDrag is false, showDragHandle should be ignored, otherwise it's also confusing, why is bottomSheet still draggable when enableDrag is false?

@guidezpl
Copy link
Member

I think it can be clarified that enableDrag only applies to the bottom contents (i.e. not the optional handle) of the bottom sheet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.