Large Numbers of Conditional Components

I have run across a familiar programming pattern needed in creating my app “Lexington by Foot and Phone”. (tourlex.glideapp.io) This is an app that offers multiple walking tours for my home town.

In the app, there are at least two collections of similar objects:

LexByFootAndPhione is a collection of Tours. A Tour is a collection of Stops.

As a result, I have at least three types of layouts: one for each of the App, the Tours, and the Stops.

Let’s consider the layout for showing Tours. Here are three (of the current five) Tour screens:


Here is the initial layout for each of the five tours (three of which are shown):

Notice that there are 5 buttons that are replications of the same Button component type all with the label “Show list of tour stops”. To get the proper set stops to be selected each of the five conditionally appearing buttons has a different item selection filter.

This pattern is needed at several places in the app. The problem I am having is imagining what is going to happen when I expand the number of Tours from 5 to 15. Managing those 15 button components is going to be difficult.

I am sure other developers must have faced the same problem and so I am asking if anyone solves this problem using some construct in Glide that I am not aware of.

Regards,

– Harry

1 Like

You should only create one “Show list of tour stops” button, and it should link to a screen showing the stops for the current tour, using a multiple relation. Does each tour have relation to many stops?

6 Likes

David: Thank you so much for translating my issue to the appropriate Glide concept. I will go and study relations again to understand exactly how to map my data into a multiple relation.

Even after all of Jack’s fact packed videos on lots of Glide concepts, I do still find that relations are still a hard concept for me to understand. Perhaps it is because I never really mastered relational databases. I’m pretty good at most concepts in programming, but there are still a couple that evade me. Another one is programming language “closures”, such as are in Javascript – but that doesn’t appear to be a concept in Glide – at least yet. As I’m getting on in years, it may be that I’m going to have to resort to less intellectual ways of understanding this stuff – like having a collection of example problems and a pattern solution that I can apply to situations that match my example problems. Sigh.