Make many views do the work of one

I’m continuing to work on a flashcard app with a view I call “D to W” (definition to word). “D to W” appears to the viewer as one primary view (that is, a view on the bottom menu) but, depending on the circumstances, takes the user to one of the following three views:

  1. A deck view of vocabulary cards to study. This is a slice, the contents of which vary from day to day and decrease as the user continues to study. It can empty for one of two reasons – hence the need for the other two views.

  2. A detail view that is displayed after all of the cards in the deck view have been completed.

  3. A detail view that is displayed when the deck is empty from the outset because the user has not added enough cards.

To the user, the app seems to function as follows:

Screen Shot 2020-01-21 at 20.31.26

Though it looks to the user like the contents of one view change depending on the situation, what is really happening is that one of the following three views is appearing in the same position on the bottom menu:

You can’t actually give different views the same name (they need to have unique names within the editor) but you can use the “Display name” to make it appear that each view has the same name.

Then the expression in the “Show if” slot governs when each view will be shown.

Screen Shot 2020-01-21 at 18.57.54

If there is no overlap between the conditions, the effect is that the menu appears to be stable while the contents change.

Sometimes things aren’t quite what they seem to be. :wink:

3 Likes