Code Monkey home page Code Monkey logo

Comments (3)

catalinghita8 avatar catalinghita8 commented on July 24, 2024 1

First, thank you for your feedback.
Secondly, this is a great catch. I investigated and there are actually 2 issues causing the loading bar to not appear anymore:

  1. The layout is broken for the FoodCategoriesScreen in the sense that the loading bar can never appear on top of the list if it's populated. This can be fixed by replacing the parent Surface with a Box to allow overlay behaviour.
  2. The state is being published through the compose runtime MutableState. If you define a state as a data class (in our case the FoodCategoriesContract.State) and inherit a field i.e. isLoading from an abstract class ViewState, any changes on the fields that are inherited from the ViewState abstraction will not make the UI recompose.

This is something I didn't expect and I'm not really sure why Compose is behaving this way. To fix it, I removed the abstract isLoading field and added it manually to the FoodCategoriesContract.State. At this moment, this is the only fix I could find.

The issues are addressed in this PR which I will merge soon.
If you want to test your above behavior, check out the just-jerem-delay-test.

from android-compose-mvvm-foodies.

catalinghita8 avatar catalinghita8 commented on July 24, 2024 1
  1. Yes you can use that. The issue with that approach is that if you toggle the loading, the content (the list) will not be visible again until you hide the loading again.

Since the PR is merged, I will close this issue. Thanks again!

from android-compose-mvvm-foodies.

JustJerem avatar JustJerem commented on July 24, 2024

Thank you for testing.

  1. Is something like this not possible in the end?
     if (state.isLoading)
                LoadingBar()
else
            FoodCategoriesList(...)
  1. And yes, while doing my tests, I came to the same conclusion that Compose did not recompose itself in the case of a legacy. It's a waste, let's see how it evolves because it's a good approach.

Thanks again ;)

from android-compose-mvvm-foodies.

Related Issues (8)

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.