1
00:00:06,550 --> 00:00:10,210
HEY WHAT'S UP GUYS I'M Jacob Blitzer with slopes dot com.

2
00:00:10,330 --> 00:00:16,250
And we're we're pretty much like starting to get to the end of this app.

3
00:00:16,480 --> 00:00:24,220
We need to just add this one view that shows our last run on the map screen if it exists otherwise we

4
00:00:24,220 --> 00:00:25,600
shouldn't show it.

5
00:00:25,600 --> 00:00:32,800
So we're going to be making that this lesson and then we also are going to be adding a the map route

6
00:00:32,890 --> 00:00:33,590
overlay.

7
00:00:33,610 --> 00:00:38,650
So I mean we still have a little bit to do we have to add to the realm we had to make another realm

8
00:00:38,650 --> 00:00:47,860
model and we're going to have to go through how to make a room configuration file so you don't use the

9
00:00:47,860 --> 00:00:51,180
default configuration anymore to deal with data migrations.

10
00:00:51,190 --> 00:00:57,730
Because if you just change a data model and RELM it will crash unless you delete the whole relm file

11
00:00:57,730 --> 00:01:01,130
which would consist of deleting the app and then running it again.

12
00:01:01,270 --> 00:01:03,080
And we don't want to run into those issues.

13
00:01:03,220 --> 00:01:10,690
But for now let's just worry about this previous run view on our main map screen our begin run visi.

14
00:01:10,720 --> 00:01:12,450
So let's go ahead and go there.

15
00:01:12,460 --> 00:01:21,100
But first we pull up our terminal and do a get check out dash B and I will make less than 15 here and

16
00:01:21,100 --> 00:01:22,630
now we are good to go.

17
00:01:22,630 --> 00:01:30,100
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

18
00:01:33,630 --> 00:01:35,620
inspector window.

19
00:01:35,640 --> 00:01:45,540
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

20
00:01:45,540 --> 00:01:56,060
just kind of make it look like what we think it needs to be and we'll make this black and then we want

21
00:01:56,060 --> 00:02:00,110
to set an alpha probably to like point four or five.

22
00:02:00,560 --> 00:02:03,760
And that looks good for like a little overlay.

23
00:02:04,280 --> 00:02:06,370
And we need a couple labels.

24
00:02:06,380 --> 00:02:09,150
We needed a previous run.

25
00:02:09,320 --> 00:02:11,180
I think we should call it last to run.

26
00:02:11,210 --> 00:02:16,730
To be clear and we need a pace and distance and duration.

27
00:02:16,730 --> 00:02:19,350
So let's go ahead and add all those labels.

28
00:02:19,500 --> 00:02:20,270
So

29
00:02:22,800 --> 00:02:27,870
forgot to do not disturb my computer.

30
00:02:27,870 --> 00:02:30,490
All right so let's add some labels here.

31
00:02:31,320 --> 00:02:37,710
And actually I'm going to copy and paste the wrong label so we don't have to

32
00:02:43,420 --> 00:02:49,000
find the fonts and all that annoying stuff that I don't like doing.

33
00:02:49,310 --> 00:02:56,590
Let me just see here real quick.

34
00:02:56,750 --> 00:03:00,260
So let's go ahead and call this label last to Ron

35
00:03:04,940 --> 00:03:07,630
and let's drag it a little bigger.

36
00:03:09,260 --> 00:03:09,810
All right.

37
00:03:09,830 --> 00:03:12,220
And let's copy and paste this one again.

38
00:03:13,940 --> 00:03:16,130
And this will be pace.

39
00:03:16,160 --> 00:03:22,020
And then we need distance and duration so pace and we can make this smaller.

40
00:03:22,430 --> 00:03:23,430
And this just entered.

41
00:03:23,440 --> 00:03:28,550
So we don't want this to enter the view because then the opacity will change.

42
00:03:28,550 --> 00:03:29,960
So let's drag that out.

43
00:03:34,010 --> 00:03:44,370
And it's going to be an annoyance so we're probably going to have to use our arrow keys or the inspector.

44
00:03:44,390 --> 00:03:45,000
All right.

45
00:03:45,020 --> 00:03:49,770
And let's see let's offset this to the left.

46
00:03:49,810 --> 00:03:51,310
We don't need it Center.

47
00:03:51,580 --> 00:03:57,170
And let's make this text smaller 14 is probably good.

48
00:03:57,170 --> 00:03:58,740
14 looks good.

49
00:03:58,740 --> 00:04:01,510
And I would say that this one is a little big.

50
00:04:01,620 --> 00:04:03,130
Let's make it 16.

51
00:04:03,450 --> 00:04:08,620
And now let's copy and paste the pace again and again.

52
00:04:09,300 --> 00:04:17,220
And now let's just select all four of these labels and put them in a stack right now.

53
00:04:17,250 --> 00:04:17,510
All right.

54
00:04:17,520 --> 00:04:18,810
There we go.

55
00:04:19,020 --> 00:04:22,860
And alignment we want to be leading.

56
00:04:22,860 --> 00:04:23,480
We don't want it.

57
00:04:23,470 --> 00:04:31,750
Center because we can at will add another label in a stack view with this one.

58
00:04:31,930 --> 00:04:37,320
Actually we need to do that before we do this next step.

59
00:04:37,540 --> 00:04:43,930
So I'm going to undo the stack here and I'm just going to throw this guy down

60
00:04:46,960 --> 00:04:55,610
arrow this guide and let's go ahead and just copy and paste these as well and just put them next to

61
00:04:55,670 --> 00:05:03,220
because we want all the values to be in stack views next to their parents view.

62
00:05:07,880 --> 00:05:13,430
OK now that we have all of our labels let's just go ahead and select the two next to each other.

63
00:05:13,550 --> 00:05:20,540
Put those in a stack view and then let's select two more next to each other horizontally and then the

64
00:05:20,540 --> 00:05:24,280
two middle ones stack views.

65
00:05:24,320 --> 00:05:31,320
And now if we do last drawing and all three of these stack views and put them in one big stack you are

66
00:05:31,370 --> 00:05:32,350
perfect.

67
00:05:32,660 --> 00:05:40,340
And if we open up the stack view let's elect one at a time and make the spacing between them like two

68
00:05:40,340 --> 00:05:57,600
or three two or three and then two or three and we want pace to we want this label to say like zero

69
00:05:57,800 --> 00:06:02,190
and zero zero and that's going to be the pace.

70
00:06:02,220 --> 00:06:08,150
And then we want this one to be oh wait I'm sorry.

71
00:06:08,170 --> 00:06:09,850
Pace This is distance.

72
00:06:09,900 --> 00:06:13,480
So this one's going to be like zero point zero zero.

73
00:06:13,860 --> 00:06:23,240
And then the last one is duration and that is going to look the same as pace but we'll put ours in for

74
00:06:23,930 --> 00:06:24,620
now.

75
00:06:24,620 --> 00:06:31,520
There we go and we probably want all these labels to

76
00:06:37,480 --> 00:06:39,680
this one should be distance.

77
00:06:39,790 --> 00:06:40,270
Whoops

78
00:06:44,240 --> 00:06:45,410
distance.

79
00:06:45,440 --> 00:06:49,890
And then this label should be duration.

80
00:06:50,400 --> 00:06:54,480
Call an OK.

81
00:06:54,880 --> 00:07:00,580
I'm trying to think what the best Let's call pace average pace just to make it a little longer and a

82
00:07:00,580 --> 00:07:03,800
little more clear that it's average not.

83
00:07:04,330 --> 00:07:09,060
OK so let's just click on each stack view and get these figured out.

84
00:07:09,070 --> 00:07:15,970
I think if we do like equal spacing so proportionally There we go.

85
00:07:16,450 --> 00:07:26,520
And then if we just click them both of them proportionally and fill proportionally Okay great.

86
00:07:26,530 --> 00:07:33,640
And now it's click on the big one and fill equally or just fill.

87
00:07:33,640 --> 00:07:36,300
We want our duration level a little bigger.

88
00:07:37,100 --> 00:07:38,180
Not sure.

89
00:07:38,330 --> 00:07:49,500
Let's see set to 14.

90
00:07:49,530 --> 00:07:53,050
You know I guess that's not horrible of duration.

91
00:07:53,050 --> 00:07:57,360
Smaller we can always mess with it later if it bothers us.

92
00:07:57,360 --> 00:08:04,890
Let's make this level is left aligned and then let's go out to the outer stack view that has all of

93
00:08:04,890 --> 00:08:08,040
these stacked views in them and we will win these.

94
00:08:08,040 --> 00:08:18,790
Now we'll pinnate I would say we want this let's do like 16 from the left

95
00:08:22,370 --> 00:08:24,490
and I want to just one moment.

96
00:08:24,500 --> 00:08:27,710
I want to drag these to this so I'm going to control drag.

97
00:08:27,710 --> 00:08:35,270
So it goes to this view vertical space saying and then control drag to this view vertical spacing.

98
00:08:35,360 --> 00:08:41,180
Why is it that one moment let's leave these constraints.

99
00:08:42,110 --> 00:08:42,430
All right.

100
00:08:42,440 --> 00:08:50,340
So this Steck view I'm going to try to make a little smaller just shrink it down

101
00:08:56,020 --> 00:08:58,420
oh I know what's going on.

102
00:08:58,620 --> 00:09:00,230
We have to set a height to this.

103
00:09:00,270 --> 00:09:04,110
So let's go ahead and pin or height or make it like 90

104
00:09:06,670 --> 00:09:13,360
and I'm not sure if we have any others constraints on here let's look.

105
00:09:13,360 --> 00:09:14,410
No we don't.

106
00:09:14,410 --> 00:09:21,360
So we at the pinless as well so it's pinless to the right and left and 20 from the top should be good.

107
00:09:21,550 --> 00:09:24,430
OK now let's see if we can

108
00:09:28,640 --> 00:09:37,320
do our vertical space saying that's a big and then our stack view actually I'm going to delete this

109
00:09:37,770 --> 00:09:44,890
and I just want to center our stack you in this in in this view.

110
00:09:45,250 --> 00:09:47,290
Let's see center vertically.

111
00:09:47,500 --> 00:09:49,630
Perfect.

112
00:09:49,640 --> 00:09:53,850
All right so that's done now we need our button to close this.

113
00:09:53,870 --> 00:09:55,750
So it's put a button on here.

114
00:09:56,860 --> 00:09:58,390
Drag it over here.

115
00:09:59,970 --> 00:10:09,320
And go into the I always forget the names of the attributes Inspektor delete the text and lets just

116
00:10:09,320 --> 00:10:14,420
select the let's see close button.

117
00:10:14,430 --> 00:10:20,530
There we go and let's make sure this is

118
00:10:23,840 --> 00:10:32,990
vertically center and then let's also just pin it to the right side by 10 points.

119
00:10:34,090 --> 00:10:34,470
All right.

120
00:10:34,480 --> 00:10:36,050
So that's done.

121
00:10:36,160 --> 00:10:40,880
And now let's go ahead and just hook up our IAB outlets and then we can get some code done.

122
00:10:40,900 --> 00:10:46,630
So let's go ahead and hit our assistant editor and let's close the inspectors so we have a little more

123
00:10:46,630 --> 00:10:50,680
space and we have a run log VC we don't want that.

124
00:10:50,680 --> 00:11:01,370
We want our begin run VC right and let's go ahead and hook up an IB action to our close button.

125
00:11:03,620 --> 00:11:10,350
So we'll say last run close.

126
00:11:10,400 --> 00:11:20,360
Button pressed It's a long name but at least Oops I accidentally made an IB outlet not an action.

127
00:11:20,840 --> 00:11:26,090
Let's go ahead and right click our Visi here and delete that IB action.

128
00:11:26,090 --> 00:11:32,660
If you copied me and let's drag that again and make sure you change outlook to action and then this

129
00:11:32,660 --> 00:11:38,050
will be last run close button pressed.

130
00:11:38,750 --> 00:11:49,870
OK so we have that there and then let's also make an Ivy outlet and this will be a last run close button.

131
00:11:50,990 --> 00:11:51,470
Right.

132
00:11:51,530 --> 00:11:52,330
That's done.

133
00:11:52,340 --> 00:11:55,870
And now we need our average pace label.

134
00:11:56,120 --> 00:12:03,240
So select just the average pace and make an Ivy outlet and we'll call this our our pace level.

135
00:12:03,260 --> 00:12:05,580
And now we need our distance level.

136
00:12:05,780 --> 00:12:12,740
So go ahead and connect that and this will be our distance level and then our duration level control

137
00:12:12,740 --> 00:12:19,320
drag and this will be our duration label and connect that.

138
00:12:19,410 --> 00:12:20,730
Okay great.

139
00:12:20,750 --> 00:12:23,420
Now everything is connected that we need to do.

140
00:12:23,420 --> 00:12:32,250
So let's go ahead and close the assistant inspector and open up begin a run and we'll begin run open.

141
00:12:32,420 --> 00:12:36,470
There are a few things we probably should do.

142
00:12:38,460 --> 00:12:44,250
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

143
00:12:44,310 --> 00:12:45,240
is a last run.

144
00:12:45,240 --> 00:12:45,770
OK.

145
00:12:46,020 --> 00:12:47,700
So we'll make a function

146
00:12:50,870 --> 00:12:55,570
last run.

147
00:12:55,810 --> 00:13:08,070
And I don't think we need to return anything it last run and let's see we'll make a guard statement.

148
00:13:08,070 --> 00:13:18,270
So guard let last run equals run dot get all runs and we'll say Dot first so that will return the top

149
00:13:18,270 --> 00:13:19,110
in the list right.

150
00:13:19,110 --> 00:13:20,950
So that will be our most recent run.

151
00:13:20,970 --> 00:13:27,560
Else we will just return nothing.

152
00:13:27,560 --> 00:13:30,030
We just want to get out of this statement.

153
00:13:30,030 --> 00:13:34,770
If there are no last runs right.

154
00:13:36,780 --> 00:13:41,740
Actually if there aren't no class Franzl to answer this down let's give some space.

155
00:13:41,760 --> 00:13:51,150
And before the return we can actually hide everything so we should oh you know what I forgot one IAB

156
00:13:51,150 --> 00:13:54,980
outlet that we need we need the view on here so we can hide it.

157
00:13:54,990 --> 00:13:57,480
We need to hide everything.

158
00:13:57,510 --> 00:13:58,730
Let's open our s.

159
00:13:58,830 --> 00:14:00,410
Let's go to the storyboard.

160
00:14:01,350 --> 00:14:05,940
And open our assistant inspector again and we need the view.

161
00:14:05,940 --> 00:14:13,240
So select the view and drag it to the Ivy outlet and this will be called last run background view.

162
00:14:13,410 --> 00:14:14,130
Okay.

163
00:14:14,430 --> 00:14:19,000
And then let's also do the stacked view so we can just hide the whole stack view.

164
00:14:19,200 --> 00:14:21,900
And this will be the last to run.

165
00:14:21,900 --> 00:14:24,350
Stack Okay great.

166
00:14:24,350 --> 00:14:27,610
Now let's close the inspector and go back to begin run.

167
00:14:27,890 --> 00:14:37,590
So if no last run exists let's go ahead and say last run view is hidden equals true.

168
00:14:38,060 --> 00:14:47,330
And then last run background background that is hidden equals true.

169
00:14:48,110 --> 00:14:54,510
And we also want to make sure the run the run button is hidden.

170
00:14:54,630 --> 00:15:07,070
And I thought we were last run last run close button that is hidden equals true OK.

171
00:15:07,090 --> 00:15:17,650
If that doesn't happen obviously we want to set all of our labels right so let's go ahead and say let's

172
00:15:17,660 --> 00:15:20,310
see our paste label.

173
00:15:20,420 --> 00:15:34,160
That text should equal last to run dot pace and then we want to format duration to string cool.

174
00:15:34,200 --> 00:15:47,640
And then we need our do our distance level text equals last run dot distance and we need meters to Miles.

175
00:15:47,670 --> 00:15:53,070
And we want to decimal places and we're going to have to

176
00:15:57,660 --> 00:16:00,420
cast this as a stringer.

177
00:16:00,570 --> 00:16:02,340
There we go once.

178
00:16:02,460 --> 00:16:05,400
All right so let's go ahead and do that.

179
00:16:06,590 --> 00:16:12,680
And we also probably should add a mile of this just so everyone knows it's in miles or kilometers whatever

180
00:16:12,680 --> 00:16:13,400
you're doing.

181
00:16:13,700 --> 00:16:14,240
And then

182
00:16:18,220 --> 00:16:32,080
let's do the duration level duration labeled that TX equals last run duration duration that format to

183
00:16:32,080 --> 00:16:32,620
string

184
00:16:35,440 --> 00:16:36,880
and that should do that.

185
00:16:36,880 --> 00:16:45,520
So let's call and then our close button needs to do everything that we're doing here.

186
00:16:47,470 --> 00:16:56,060
So we can probably just for now we can just copy and paste this here and hide that.

187
00:16:56,260 --> 00:17:02,540
And then every time we come back to this view we want this to.

188
00:17:03,040 --> 00:17:12,580
We want this view to show so let's set all these to false because we want to if we hide this and then

189
00:17:12,610 --> 00:17:16,630
do a run and then come back to the main screen we want to see our last run.

190
00:17:16,630 --> 00:17:18,580
So then view will appear.

191
00:17:18,580 --> 00:17:20,990
Let's go ahead and say get Plast run.

192
00:17:22,700 --> 00:17:23,200
All right.

193
00:17:23,240 --> 00:17:26,790
Let's try this and see if it works.

194
00:17:31,280 --> 00:17:38,750
All right so there it is our last run shows our average pace our distance and our duration.

195
00:17:38,750 --> 00:17:44,990
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

196
00:17:44,990 --> 00:17:50,360
it different than 16 just to make sure and let's end it like right now six second.

197
00:17:50,370 --> 00:17:54,740
Ron and there we go our last run is six seconds.

198
00:17:54,870 --> 00:17:59,610
So it's pointed straight from Rome which is really cool and it's showing all of our data there.

199
00:17:59,880 --> 00:18:08,980
So we'll call this this one done and in the next in the next video we'll get our.

200
00:18:08,990 --> 00:18:10,770
Let's get our map overlays showing.

201
00:18:10,770 --> 00:18:12,440
So that'll be really cool.

202
00:18:12,510 --> 00:18:20,400
So when we finish this run we will have our map overlay there and you can see what your last run was.

203
00:18:20,430 --> 00:18:24,990
And then you could also hit the center button and it'll find your actual location.

204
00:18:25,020 --> 00:18:28,500
But if you just come to this screen it will be centered on your last run.

205
00:18:28,560 --> 00:18:30,020
I think that'll be really cool.

206
00:18:30,240 --> 00:18:34,310
And then we still have this and I will see you in the next lesson.

207
00:18:34,320 --> 00:18:40,160
But before we do that let's make sure we do a get ad period and get commit dash am.

208
00:18:40,260 --> 00:18:51,630
And this was let's see show last run view added to begin run visi.

209
00:18:51,660 --> 00:18:52,790
All right great.

210
00:18:52,800 --> 00:18:54,680
And I will see you guys in the next video.
