material-components / material-components-android

Modular and customizable Material Design UI components for Android
Apache License 2.0
16.38k stars 3.07k forks source link

[BottomSheetDialog] Allow using native bottom sheet animation on enter transition #3476

Open OxygenCobalt opened 1 year ago

OxygenCobalt commented 1 year ago

Is your feature request related to a problem? Please describe. BottomSheetDialog provides a way to make it's exit transition a less janky slide-down animation through setDismissWithAnimation(true). However, the same behavior is not available for an enter transition, despite the dialog seemingly still sliding in as a bottom sheet. This feels inconsistent and makes the dialog as a lot less "slick".

I don't quite know if the current sliding behavior is from the bottom sheet or whatever stock window animation is driving this transition. I'm under the impression that it's the latter, since if I disable it with window.setWindowAnimations(0) it makes the dialog appear instantly, with no animation.

Describe the solution you'd like Another flag (setEnterWithAnimation?) that is functionally the same as setDismissWithAnimation, but with the bottom sheet sliding into view without any opacity changes. The scrim transition should remain, ideally.

Describe alternatives you've considered Doing it myself, but it probably requires something like overriding the default window translation to preserve the scrim, but not affect the dialog itself, which sounds unpleasant. An MDC implementation would probably work a lot better.

Additional context I've attached a brief demonstration in the catalog below:

https://github.com/material-components/material-components-android/assets/65370175/168041bc-d9b3-41b9-9ad6-df30089e3911

Here's a frame that shows clearly that it does have partial opacity during it's transition. image

OxygenCobalt commented 1 year ago

I did figure out the source of this behavior, apparently MDC uses it's own custom transition for bottom sheets in anim/m3_bottom_sheet_slide_in and anim/m3_bottom_sheet_slide_out. I'm really not sure why this is the case since bottom sheets already have intrinsic animations.

OxygenCobalt commented 1 year ago

In the case that it actually isn't feasible to use the native transitions, I'd just request changing anim/m3_bottom_sheet_slide_in and anim/m3_bottom_sheet_slide_out to have no alpha transitions and to translate the view 100% instead of 20%.