RIBs icon indicating copy to clipboard operation
RIBs copied to clipboard

[Question] Handle when a child becomes the parent of it's parent

Open Edhoru opened this issue 5 years ago • 2 comments

I want to ask for input in a navigation logic I'm facing. I show a list of products as a RIB (it has networking, filtering and so on), from that I can open the details of a product which is another RIB (since there is logic to mark as favorite and networking) and from that details view I can see sellers that sell the same thing (sellers are also a RIB) and finally from the sellers details I can see a list of all the products so it basically becomes and infinite loop of: ProductDetails -> SellerDetails -> ProductDetails -> ...

My question is if this is the right way to handle things or there is a better logic than just keep adding ribs on top of each other. I made a project that shows this loop https://github.com/Edhoru/RIBsChildBecomesParent

Thanks

Edhoru avatar Oct 10 '20 16:10 Edhoru

Keep your navigation history in sequence of data objects (array of type-prefixed IDs Product:134 or any other uniquely identifiable object, for example it could be the Seller and Product data itself), and have a RIB without presentable use it to allow going backwards and forwards.

Every time user "loops" it just means that old ProductDetails RIB will be detached and new one attaches "on top".

You can also create an animation for adding and removing ViewControllers using UIKit APIs (or android equivalent) to give user an illusion of a visual stack — i.e. when they swipe a "page" back, they can see the "previous page" underneath. This increases your attached RIB count by 1 (you have to keep current and previous RIB in memory to facilitate smooth navigation UX)

ermik avatar Oct 11 '20 11:10 ermik

I'll give it a try to have the history instead off all the RIBs attached.

Thanks

Edhoru avatar Oct 19 '20 20:10 Edhoru