Reputation: 715
I want to rebuild a highly interactive RecyclerView based list with a Compose LazyList.
The list is divided into categories, and these categories represent required options for a single selection. These sections can be split across multiple pages. For example; the first page could be a selection for item size A, B orC. Each of those can be customized; and those customizations are accessible by clicking on the first selection; lets say B, which will open a new page. Until the selections are made selection B and the category header for selection B will be highlighted.
On the nested page; you'll see a variety of categories/options (each with a header and then selections for that category); and those selection items could be radio buttons; checkboxes or quantity steppers.
Here is where things get complicated; the UI state of the category header will depend on selections, the selection UI will depend on state of the entire section. (The text stays the same but there are different highlight states for different elements) and these state relationships can exist across pages. The state itself is best represented by a tree of requirements and selections; where user actions will trigger a check events that will go up the tree; and then that will trigger updates that will go down the tree. (Most of the tree will not be visible on screen).
Finally we get to the question! How will mutableStateOf track the states of this tree? The tree will be built from a collection with nested collections. What is the best approach to this scenario?
What about using a Flow? I thought I could use a Flow to propagate 'state' events, and that state is what will be tracked with a remember { mutableStateOf(state) }; and then that will get replaced when the new state doesn't match the old state.
If this is doable? Can I just replace the state variable; or do I have to change the object parameters?
Is this even necessary? If each Compose view is remembering the state of the object; and the object gets updated through actions on the collection to which each is a member of; will mutabeStateOf recompose/update the view just by tracking the properties of the collection member to which it is bound to?
Upvotes: 0
Views: 103