79768566

Date: 2025-09-18 14:27:57
Score: 0.5
Natty:
Report link

I've made a simple BaseTopSheetDialog with overridable contentView, you can see a full solution here.

In comparison to the original BottomSheet the behaviour is limited but enough for most use cases, including nested recyclers and complex gesture handling.

Example usage:

class ExampleTopSheetFragment : BaseTopSheetDialogFragment() {

    override val contentLayoutId: Int = R.layout.layout_example_dialog_content
    private val binding by binding(R.id.content) { LayoutExampleDialogContentBinding::bind } // change according to how you handle viewBinding
    
    override fun isDraggable(): Boolean = true
    override fun isCancelableOnTouchOutside(): Boolean = true

    override fun onContentViewCreated(view: View, savedInstanceState: Bundle?) {
        binding.close.handleDoubleClick { hide() }
        binding.title.text = "Hello, World!"
    }
    
    /** Use as any other fragment dialog
    private fun showTopSheet() {
        ExampleTopSheetFragment().show(supportFragmentManager, ExampleTopSheetFragment::class.java.name)
    }
    */
}
Reasons:
  • Contains signature (1):
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: zzemlyanaya