how to navigate to a list from a category

Hello Everyone,

This is my first post as i'm a beginner in swifUI and in coding. I hope I will be clear enough.

I'm working on a app that can allow me to find easily information about a factory. I have a list of factories where columns are mostly geographic information about the factory and numbers.

I have sorted my list by categories where my variable is "state number - state name" in String. in each category I have a list of factory located in this state.

I have a view (UsineRow) with selected detail from the factory, a view (UsineListe) displaying the list of all the factory's selected detail and another view with all details of the factory (reachable by clicking on one factory from the UsineListe view.

Now I need a view where I will be able to display my categories and after that the list of factories inside my categories.

For the moment, I have a view with all my categories and between directly the list of my factory selected details.

            ForEach(modelData.categories.keys.sorted(), id: \.self) { key in
                CategoryRow(categoryName: key, items: modelData.categories[key]!)

that gives me:

I have also an alternative view with only the list of my categories:

obtained by:

            ForEach(modelData.categories.keys.sorted(), id: \.self) { key in
                Button(action: {}, label: {
                    Text(key)
                })

This is the view I would prefer. BUT, I don't know how to make it clickable to the view of the list of selected details linked to the category only.

I hope someone can help me and I hope to gave you clear information.

Many thanks for your help.

BR

Julien

how to navigate to a list from a category
 
 
Q