GithubHelp home page GithubHelp logo

Comments (4)

jackdevey avatar jackdevey commented on August 26, 2024 1

Thanks for your help, I have looked again at my code and it the Bottom Sheet is then shown on a button click. Changing my code so that the sheet is recreated and shown each time the button is pressed has fixed this now. The issue seems to be calling show() on a bottom sheet instance that has already been shown once before.

from sheets.

maxkeppeler avatar maxkeppeler commented on August 26, 2024

Thank you for reporting.

I just copied your setup and replaced the closeButtonDrawable. But I can't replicate this behavior.

I noticed you used the build(...)method. Where do you currently call moreOptions.show()?

Does it behave the same for you, if you use the show(...)method and immediately display it?

from sheets.

russellbanks avatar russellbanks commented on August 26, 2024

Hey! Sorry for all the issues recently but I'm the other developer that is working on this app.

We were calling moreOptions.show() just below that chunk of code like this:

// Shows the options bottom sheet
binding.more.setOnClickListener {
   moreOptions.show()
}

It seems doing OptionSheet.show() rather than building it first fixes the issue

     // Shows the options bottom sheet
     binding.more.setOnClickListener {
         OptionsSheet().show(requireContext()) {
             displayMode(DisplayMode.LIST)
             title("More")
             closeButtonDrawable(R.drawable.ic_down_arrow)
             with(
                 Option(R.drawable.ic_share, "Share"),
                 Option(R.drawable.ic_add_circle, "Add to list")
             )
             onPositive { index: Int, option: Option ->
                 binding.root.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
                 if (index == 0) {
                     val sendIntent: Intent = Intent().apply {
                         action = Intent.ACTION_SEND
                         val text = binding.quote.text.toString() + "\n\n~Gautama Buddha"
                         putExtra(Intent.EXTRA_TEXT, text)
                         type = "text/plain"
                     }
                     val shareIntent = Intent.createChooser(sendIntent, null)
                     startActivity(shareIntent)
                 } else {
                     dismiss()
                 }
             }
         }
     }

Therefore, the issue seems to arise when the bottom sheet is built and then shown rather than just using .show()

from sheets.

maxkeppeler avatar maxkeppeler commented on August 26, 2024

You should just create a new instance of the OptionsSheet and show it everytime you need it.

As in the example from @Fennec-exe. You can just extract it into a method showMoreSheet() and execute it there.

Using build(...) + show(...) should be used in cases where you don't want to display a bottom sheet immediately.

I don't think it's a good idea to automatically reset the instance when using
show() multiple times.

It's easier and cleaner to just create a new instance.

I will close this issue since it works as intended.

from sheets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.