HEY WHAT'S UP GUYS I'M Jacob Blitzer with slopes dot com.
And we're we're pretty much like starting to get to the end of this app.
We need to just add this one view that shows our last run on the map screen if it exists otherwise we
shouldn't show it.
So we're going to be making that this lesson and then we also are going to be adding a the map route
overlay.
So I mean we still have a little bit to do we have to add to the realm we had to make another realm
model and we're going to have to go through how to make a room configuration file so you don't use the
default configuration anymore to deal with data migrations.
Because if you just change a data model and RELM it will crash unless you delete the whole relm file
which would consist of deleting the app and then running it again.
And we don't want to run into those issues.
But for now let's just worry about this previous run view on our main map screen our begin run visi.
So let's go ahead and go there.
But first we pull up our terminal and do a get check out dash B and I will make less than 15 here and
now we are good to go.
So the first thing that we need to do is drag a view on the map view so down here in our over in your
inspector window.
Let's go ahead and type you I view down here and let's drag a view out right on the map view and we'll
just kind of make it look like what we think it needs to be and we'll make this black and then we want
to set an alpha probably to like point four or five.
And that looks good for like a little overlay.
And we need a couple labels.
We needed a previous run.
I think we should call it last to run.
To be clear and we need a pace and distance and duration.
So let's go ahead and add all those labels.
So
forgot to do not disturb my computer.
All right so let's add some labels here.
And actually I'm going to copy and paste the wrong label so we don't have to
find the fonts and all that annoying stuff that I don't like doing.
Let me just see here real quick.
So let's go ahead and call this label last to Ron
and let's drag it a little bigger.
All right.
And let's copy and paste this one again.
And this will be pace.
And then we need distance and duration so pace and we can make this smaller.
And this just entered.
So we don't want this to enter the view because then the opacity will change.
So let's drag that out.
And it's going to be an annoyance so we're probably going to have to use our arrow keys or the inspector.
All right.
And let's see let's offset this to the left.
We don't need it Center.
And let's make this text smaller 14 is probably good.
14 looks good.
And I would say that this one is a little big.
Let's make it 16.
And now let's copy and paste the pace again and again.
And now let's just select all four of these labels and put them in a stack right now.
All right.
There we go.
And alignment we want to be leading.
We don't want it.
Center because we can at will add another label in a stack view with this one.
Actually we need to do that before we do this next step.
So I'm going to undo the stack here and I'm just going to throw this guy down
arrow this guide and let's go ahead and just copy and paste these as well and just put them next to
because we want all the values to be in stack views next to their parents view.
OK now that we have all of our labels let's just go ahead and select the two next to each other.
Put those in a stack view and then let's select two more next to each other horizontally and then the
two middle ones stack views.
And now if we do last drawing and all three of these stack views and put them in one big stack you are
perfect.
And if we open up the stack view let's elect one at a time and make the spacing between them like two
or three two or three and then two or three and we want pace to we want this label to say like zero
and zero zero and that's going to be the pace.
And then we want this one to be oh wait I'm sorry.
Pace This is distance.
So this one's going to be like zero point zero zero.
And then the last one is duration and that is going to look the same as pace but we'll put ours in for
now.
There we go and we probably want all these labels to
this one should be distance.
Whoops
distance.
And then this label should be duration.
Call an OK.
I'm trying to think what the best Let's call pace average pace just to make it a little longer and a
little more clear that it's average not.
OK so let's just click on each stack view and get these figured out.
I think if we do like equal spacing so proportionally There we go.
And then if we just click them both of them proportionally and fill proportionally Okay great.
And now it's click on the big one and fill equally or just fill.
We want our duration level a little bigger.
Not sure.
Let's see set to 14.
You know I guess that's not horrible of duration.
Smaller we can always mess with it later if it bothers us.
Let's make this level is left aligned and then let's go out to the outer stack view that has all of
these stacked views in them and we will win these.
Now we'll pinnate I would say we want this let's do like 16 from the left
and I want to just one moment.
I want to drag these to this so I'm going to control drag.
So it goes to this view vertical space saying and then control drag to this view vertical spacing.
Why is it that one moment let's leave these constraints.
All right.
So this Steck view I'm going to try to make a little smaller just shrink it down
oh I know what's going on.
We have to set a height to this.
So let's go ahead and pin or height or make it like 90
and I'm not sure if we have any others constraints on here let's look.
No we don't.
So we at the pinless as well so it's pinless to the right and left and 20 from the top should be good.
OK now let's see if we can
do our vertical space saying that's a big and then our stack view actually I'm going to delete this
and I just want to center our stack you in this in in this view.
Let's see center vertically.
Perfect.
All right so that's done now we need our button to close this.
So it's put a button on here.
Drag it over here.
And go into the I always forget the names of the attributes Inspektor delete the text and lets just
select the let's see close button.
There we go and let's make sure this is
vertically center and then let's also just pin it to the right side by 10 points.
All right.
So that's done.
And now let's go ahead and just hook up our IAB outlets and then we can get some code done.
So let's go ahead and hit our assistant editor and let's close the inspectors so we have a little more
space and we have a run log VC we don't want that.
We want our begin run VC right and let's go ahead and hook up an IB action to our close button.
So we'll say last run close.
Button pressed It's a long name but at least Oops I accidentally made an IB outlet not an action.
Let's go ahead and right click our Visi here and delete that IB action.
If you copied me and let's drag that again and make sure you change outlook to action and then this
will be last run close button pressed.
OK so we have that there and then let's also make an Ivy outlet and this will be a last run close button.
Right.
That's done.
And now we need our average pace label.
So select just the average pace and make an Ivy outlet and we'll call this our our pace level.
And now we need our distance level.
So go ahead and connect that and this will be our distance level and then our duration level control
drag and this will be our duration label and connect that.
Okay great.
Now everything is connected that we need to do.
So let's go ahead and close the assistant inspector and open up begin a run and we'll begin run open.
There are a few things we probably should do.
OK so let's go ahead and let's make a function that we can call that we'll look to see if there even
is a last run.
OK.
So we'll make a function
last run.
And I don't think we need to return anything it last run and let's see we'll make a guard statement.
So guard let last run equals run dot get all runs and we'll say Dot first so that will return the top
in the list right.
So that will be our most recent run.
Else we will just return nothing.
We just want to get out of this statement.
If there are no last runs right.
Actually if there aren't no class Franzl to answer this down let's give some space.
And before the return we can actually hide everything so we should oh you know what I forgot one IAB
outlet that we need we need the view on here so we can hide it.
We need to hide everything.
Let's open our s.
Let's go to the storyboard.
And open our assistant inspector again and we need the view.
So select the view and drag it to the Ivy outlet and this will be called last run background view.
Okay.
And then let's also do the stacked view so we can just hide the whole stack view.
And this will be the last to run.
Stack Okay great.
Now let's close the inspector and go back to begin run.
So if no last run exists let's go ahead and say last run view is hidden equals true.
And then last run background background that is hidden equals true.
And we also want to make sure the run the run button is hidden.
And I thought we were last run last run close button that is hidden equals true OK.
If that doesn't happen obviously we want to set all of our labels right so let's go ahead and say let's
see our paste label.
That text should equal last to run dot pace and then we want to format duration to string cool.
And then we need our do our distance level text equals last run dot distance and we need meters to Miles.
And we want to decimal places and we're going to have to
cast this as a stringer.
There we go once.
All right so let's go ahead and do that.
And we also probably should add a mile of this just so everyone knows it's in miles or kilometers whatever
you're doing.
And then
let's do the duration level duration labeled that TX equals last run duration duration that format to
string
and that should do that.
So let's call and then our close button needs to do everything that we're doing here.
So we can probably just for now we can just copy and paste this here and hide that.
And then every time we come back to this view we want this to.
We want this view to show so let's set all these to false because we want to if we hide this and then
do a run and then come back to the main screen we want to see our last run.
So then view will appear.
Let's go ahead and say get Plast run.
All right.
Let's try this and see if it works.
All right so there it is our last run shows our average pace our distance and our duration.
And so this is our 16th second one last go ahead and close it and let's start a new run and we'll make
it different than 16 just to make sure and let's end it like right now six second.
Ron and there we go our last run is six seconds.
So it's pointed straight from Rome which is really cool and it's showing all of our data there.
So we'll call this this one done and in the next in the next video we'll get our.
Let's get our map overlays showing.
So that'll be really cool.
So when we finish this run we will have our map overlay there and you can see what your last run was.
And then you could also hit the center button and it'll find your actual location.
But if you just come to this screen it will be centered on your last run.
I think that'll be really cool.
And then we still have this and I will see you in the next lesson.
But before we do that let's make sure we do a get ad period and get commit dash am.
And this was let's see show last run view added to begin run visi.
All right great.
And I will see you guys in the next video.