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

BottomSheetDialogFragment ShapeAppearance bug #325

Closed Zeliret closed 2 years ago

Zeliret commented 5 years ago

I have discovered a strange behavior. If I set this snipped as a shapeAppearanceOverlay to the bottom sheet, I get a glitch. When I try to close the bottom sheet by dragging to the bottom I can see that rounded corners animate out for a moment and return back after that. I think it should be rounded all the way while I'm dragging the dialog and became square only in full height mode, shouldn't it?

<style name="ShapeAppearanceOverlay.App.BottomSheet.Modal" parent="ShapeAppearanceOverlay.MaterialComponents.BottomSheet.Modal">
        <item name="cornerSizeTopLeft">@dimen/custom_corner_large</item>
        <item name="cornerSizeTopRight">@dimen/custom_corner_large</item>
    </style>
gsajith commented 5 years ago

Could you please provide some more context for this bug? Specifically, any relevant XML for this bottom sheet, as well as any code you're using to programmatically initialize, modify, or show the bottom sheet.

Zeliret commented 5 years ago

@gsajith Sure. Thanks for the replying.

My bottom sheet superclass. I just inherit it and show with ::show(childFragmentManager)

abstract class BaseBottomSheetDialogFragment
    : BottomSheetDialogFragment(),
        HasSupportFragmentInjector {
    @Inject
    lateinit var viewModelFactory: ViewModelFactory
    @Inject
    lateinit var childFragmentInjector: DispatchingAndroidInjector<Fragment>

    protected open val skipCollapsed = false

    override fun onAttach(context: Context) {
        AndroidSupportInjection.inject(this)
        super.onAttach(context)
    }

    override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
        val dialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog
        dialog.setOnShowListener { dialogInterface ->
            val d = dialogInterface as BottomSheetDialog
            val bottomSheet = d.findViewById<View>(com.google.android.material.R.id.design_bottom_sheet) as FrameLayout
            val behavior = BottomSheetBehavior.from(bottomSheet)
            behavior.skipCollapsed = skipCollapsed
            if (skipCollapsed)
                behavior.state = BottomSheetBehavior.STATE_EXPANDED

//            d.window?.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION)
//            d.window?.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
//            d.window?.navigationBarColor = ContextCompat.getColor(requireContext(), R.color.white)
        }

        return dialog
    }

    override fun supportFragmentInjector(): AndroidInjector<Fragment>? {
        return childFragmentInjector
    }

    override fun onSaveInstanceState(outState: Bundle) {
        StateSaver.saveInstanceState(this, outState)
        super.onSaveInstanceState(outState)
    }

    @CallSuper
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        StateSaver.restoreInstanceState(this, savedInstanceState)
    }

    protected open fun getTagLabel(): String {
        return TAG
    }

    fun show(manager: FragmentManager) {
        show(manager, getTagLabel())
    }

    companion object {
        private const val TAG = "dialog"
    }
}

The layout:

<layout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto">

    <data>

    </data>

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <androidx.core.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fillViewport="true"
            android:scrollbarStyle="insideOverlay"
            android:scrollbars="vertical">

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:padding="@dimen/padding_16">
            </androidx.constraintlayout.widget.ConstraintLayout>
        </androidx.core.widget.NestedScrollView>
    </androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>

Video: https://www.evernote.com/l/AmiRaAtmJ-FHdI2Maaw_lP3F63_E5HErteY

hrach commented 5 years ago

Having exactly the same issue 👍

melaniegoetz commented 5 years ago

Hi @Zeliret, thanks for bringing this to our attention! Someone internally noticed a similar issue and is contributing a fix -- I'll comment back here when that fix is synced out!

Zeliret commented 5 years ago

Alpha09 is here but still no fix for that issue ;(

ogoons commented 5 years ago

I need this. Please fix it as soon as possible.

touficbatache commented 5 years ago

Happens to me too!

h6ah4i commented 4 years ago

Same here. I'm using v1.2.0-alpha03 😭

ThanosFisherman commented 4 years ago

I'm facing a similar issue. When I click a list item of rounded cornered BottomSheetDialogFragment, then the rounded corners turn into a squared corners. See the video attached.

https://drive.google.com/open?id=1iO8ljZXsHEOkttsoQo9lgm0cyIaTivvr

julaee commented 4 years ago

I have the same issue!

keciciler commented 4 years ago

Same issue whenever the bottom sheet content takes focus, round corners have gone completely.

darwind commented 3 years ago

Any news on this bug?

It seems like the issue is a bit different in the current version of the Material Design library (1.3.0-rc01), where the rounded corners only gets removed (animated) when the bottom sheet reaches its full height.

When the bottom sheet reaches its full height on its own (the user release the bottom sheet before it's at full heigh), the rounded/cut corners doesn't transform, however if you swipe the bottom sheet all the way to the full height of the bottom sheet, the corners transform.

See the attached video: https://drive.google.com/file/d/1D2lrW7axTEE-aPqElmiq9SXXBKgRKPrt/view

Jnthndjgr commented 2 years ago

Any update on this? Still encountering the issue

drchen commented 2 years ago

I couldn't manage to reproduce it. Can you provide more details like screen recording and your theme/style settings if it's still reproducible?

drchen commented 2 years ago

I'll close this issue for now due to no further info available. Please feel free to reopen it if this is still happening.