UI Container Suggestions...

Looking for a little design advise. I am developing a gym app where my main screen is a list of major muscle groups (e.g., shoulders, back, biceps,...). After selecting one of these, the user will be presented with a listing of several workouts.

I am trying to figure out the best decision to make in terms of that last screen example. The top box with History, Instrut - I want that to be a view container (I think) and make it common and just read the specific data into that container. I guess the Alternate workouts can be a table view. My question is how best to make this scale across say 50 different workouts to minimize the storyboard and code that I have to manage.


Thanks,

tekgeek1

Replies

It depends on how the different workouts look like.


For all similar workout (I mean, a similar set of informations to display, may be with plus or minus some specific), you can have a single view.


Create an enum with all your workouts (I am inventing workout names, just to illustrate)

enum Workouts {
     case shoulderStretch
     case shoulderRelax
     case backRoll
     case backStrengthen
     case biceps
     // etc
}


In WorkOutView, create

var workoutToPresent : Workouts?

Then, in viewDidLoad, set the different fields values depending on workoutToPresent


To go from tableView to this WorkoutView, create the segue from the main view (control-drag from the toplet icon at the top of viewController in IB to the WorkoutView controller. Give an ID to this segue.


In MainViewController create a var to hold the selectedWorkout (an item of the enum with all your workouts)

Then, in tableViewDidSelect, you will

- set selectedWorkout, such as selectedWorkout = .shoulderRelax

- call performSegue


In prepare for segue, you pass the selectedWorkout value

     destVC.workoutToPresent = selectedWorkout


You can hide / show some fields if there is some specifics for this workout.


If you have really different workouts types (for instance 3, for top of boddy, for middle, for bottom) then you can create a 3 different views for workouts : WorkoutTopViewController, WorkoutMiddleViewController, WorkoutBottomViewController, create 3 segues from Main to each of the 3 VC.


And proceed as above for each.