1
00:00:08,050 --> 00:00:13,410
Hey everybody welcome to the last video in the firebase section.

2
00:00:13,420 --> 00:00:17,530
Amazing work so far building this app we just have one last video to go.

3
00:00:17,530 --> 00:00:23,680
And in this one we're basically just going to do a quick view controller extension that's going to change

4
00:00:23,680 --> 00:00:26,180
the way that view controller is present.

5
00:00:26,230 --> 00:00:31,690
If you choose to use this function from the extension and it's going to simulate the same kind of transition

6
00:00:32,470 --> 00:00:38,410
as a navigation controller where it will animate from left to right and right to left instead of popping

7
00:00:38,410 --> 00:00:40,330
up straight over the front it's pretty cool.

8
00:00:40,330 --> 00:00:42,900
Very efficient and we're going to go ahead and build it now.

9
00:00:42,910 --> 00:00:51,120
So open up your X code project right click on extensions and click new file swift file is fine and we're

10
00:00:51,120 --> 00:00:59,290
going to call this UI View Controller for extension click Create and we're going to go ahead and we

11
00:00:59,290 --> 00:01:04,760
need to import kit because this actually has to do with you view controller which is part of it.

12
00:01:04,990 --> 00:01:05,500
Next.

13
00:01:05,500 --> 00:01:12,390
Go ahead and type extension you view controller and we're going to write two functions OK.

14
00:01:12,580 --> 00:01:18,400
Function one is going to be called phunk present detail case meaning like present a detail controller

15
00:01:19,180 --> 00:01:26,760
and we're going to basically pass in a View Controller to present of type you I view controller.

16
00:01:26,770 --> 00:01:32,620
Now if this looks familiar to you that's because this comes from Normally in you view controller you

17
00:01:32,620 --> 00:01:37,230
can call present and you can present another view controller on top of it.

18
00:01:37,270 --> 00:01:43,790
We're going to use the same parameter as present does but this is this is going to be for present detail.

19
00:01:43,960 --> 00:01:51,100
Now we need to make a custom transition of type C.A. transition and C.A. comes from Core Animation.

20
00:01:51,130 --> 00:01:56,260
So let's go ahead and let's create a constant that's going to hold this animation.

21
00:01:56,260 --> 00:01:58,650
Go ahead and type let transition.

22
00:01:58,990 --> 00:02:01,010
Equal equals.

23
00:02:01,050 --> 00:02:03,130
See a transition.

24
00:02:03,130 --> 00:02:04,240
Go ahead and instantiate it.

25
00:02:04,240 --> 00:02:08,930
And now we need to set up the settings we want this transition to take 0.3 seconds.

26
00:02:08,950 --> 00:02:11,100
Just like a UI navigation controller.

27
00:02:11,320 --> 00:02:13,620
So go ahead and type transition.

28
00:02:14,110 --> 00:02:17,890
Duration equals zero point three.

29
00:02:17,890 --> 00:02:21,070
Next we're going to ask it to set its type.

30
00:02:21,100 --> 00:02:28,750
So we're going to type transition type and it's going to be equal to KCA K meaning it's coming from

31
00:02:29,650 --> 00:02:34,450
Core Animation transition and you can see there's a ton of different ones you can do a lot of really

32
00:02:34,450 --> 00:02:36,880
cool transitions with this and you can play around with it if you want.

33
00:02:36,880 --> 00:02:42,890
But I'm just going to go with push because that's going to push the view controller from a certain direction.

34
00:02:42,970 --> 00:02:44,380
Now we need to tell it what direction.

35
00:02:44,380 --> 00:02:50,980
So we're going to call it transition subtype and the subtype is KCA transition from.

36
00:02:50,980 --> 00:02:51,670
Right.

37
00:02:51,970 --> 00:02:52,350
OK.

38
00:02:52,420 --> 00:02:57,360
Because when we present it we wanted it to present from the right side and slide over to the left side.

39
00:02:57,520 --> 00:02:58,090
OK.

40
00:02:58,330 --> 00:02:59,730
Very cool.

41
00:02:59,730 --> 00:03:05,350
And then we're going to go ahead and add this transition to the layer of The View Controller window.

42
00:03:05,350 --> 00:03:15,510
So go ahead and call self view meaning the view of The View Controller window the UI window layer add

43
00:03:15,840 --> 00:03:16,610
and you'll see there.

44
00:03:16,630 --> 00:03:21,380
You can add an animation that animation is transition.

45
00:03:21,460 --> 00:03:24,890
It's a type of C-A animation if you look closely.

46
00:03:24,970 --> 00:03:31,830
So the key this is just from deep within iOS we can call K. s.a.a transition.

47
00:03:31,840 --> 00:03:36,940
And that tells it that this is a transition of type s.a.a transition.

48
00:03:36,940 --> 00:03:40,030
So now we have successfully added the transition.

49
00:03:40,030 --> 00:03:47,410
Now we're just going to go ahead and call the default present controller from Iowa us and the view controller

50
00:03:47,410 --> 00:03:49,210
to present will be the one we pass in.

51
00:03:49,210 --> 00:03:51,910
So go ahead and give it a controller to present.

52
00:03:51,910 --> 00:03:53,490
We want it to be animated.

53
00:03:53,500 --> 00:03:59,260
But the interesting thing is we've already set up the animation so we're going to dismiss or we're going

54
00:03:59,260 --> 00:04:06,230
to not include the default iOS animation and we're just going to go ahead and call false to completion.

55
00:04:06,250 --> 00:04:08,330
We don't care we're not going to use it.

56
00:04:08,410 --> 00:04:12,910
So that is how we're going to present our detailed controller and I'm so excited I want to go try it

57
00:04:12,910 --> 00:04:13,530
right now.

58
00:04:13,840 --> 00:04:18,280
Let's go into groups Visi and where we called present.

59
00:04:18,280 --> 00:04:18,880
We're going to check.

60
00:04:18,880 --> 00:04:25,300
Now we should have the ability to call present detail the view controller to present will just be group

61
00:04:25,300 --> 00:04:26,790
feed visi.

62
00:04:27,310 --> 00:04:33,490
So let's try that with our new extension Let's see how it works and let's build and run and try it out

63
00:04:33,820 --> 00:04:35,700
in our simulator.

64
00:04:36,040 --> 00:04:37,710
Here we go.

65
00:04:40,110 --> 00:04:42,710
Sweet it's installing OK it's opening.

66
00:04:42,750 --> 00:04:49,530
Now when I select my table you sell here you should see it slide over instead of sliding up.

67
00:04:49,530 --> 00:04:51,330
Let's try it.

68
00:04:51,330 --> 00:04:51,780
Look at that.

69
00:04:51,780 --> 00:04:54,270
That's just like a UI navigation controller.

70
00:04:54,270 --> 00:05:00,120
Now of course if I click this it's still going to dismiss it like it used to but we get a cool UI navigation

71
00:05:00,120 --> 00:05:01,850
controller styled animation.

72
00:05:01,950 --> 00:05:03,420
Very very cool.

73
00:05:03,420 --> 00:05:07,780
Now we're going to go set up the other function which is going to allow us to dismiss it to the left.

74
00:05:07,920 --> 00:05:08,410
OK.

75
00:05:08,550 --> 00:05:09,600
So go back to you.

76
00:05:09,720 --> 00:05:14,930
You controller extension and we're going to go ahead and write another function called dismiss detail.

77
00:05:14,960 --> 00:05:18,870
Go ahead and type phunk dismiss detail.

78
00:05:19,230 --> 00:05:24,780
And inside this function we're basically going to do the exact same thing except we're going to dismiss

79
00:05:24,840 --> 00:05:26,730
the view controller instead of presenting it.

80
00:05:26,730 --> 00:05:33,270
So I'm actually just going to copy this and paste it and then I'm going to change from right to from

81
00:05:33,600 --> 00:05:37,800
left because that's basically what we're doing is the same thing just from the left.

82
00:05:37,800 --> 00:05:44,310
Now instead of calling present we're instead going to call dismiss and just like before we're going

83
00:05:44,310 --> 00:05:49,200
to override the default transition style so we're just going to call false because otherwise it will

84
00:05:49,200 --> 00:05:51,290
try to present it like Iowa does.

85
00:05:51,510 --> 00:05:54,780
And for the completion we don't care we're going to say nil.

86
00:05:54,780 --> 00:06:00,750
Now we can dismiss any view controller just like a UI navigation controller so to do this we have to

87
00:06:00,750 --> 00:06:08,050
go to group feed Visi and we need to look to see where our cancel button or our back button goes.

88
00:06:08,520 --> 00:06:15,720
Earlier we called just a regular iOS standard dismiss but now we can call dismiss.

89
00:06:16,140 --> 00:06:16,710
Oh you know what.

90
00:06:16,710 --> 00:06:20,220
Looks like we might need to build this to show for it to show up.

91
00:06:20,220 --> 00:06:21,910
Looks like it's not yet there.

92
00:06:22,200 --> 00:06:22,650
OK good.

93
00:06:22,650 --> 00:06:23,060
There it is.

94
00:06:23,070 --> 00:06:25,260
Dismiss detail that's all.

95
00:06:25,260 --> 00:06:27,360
Let's build and run it let's see how it works.

96
00:06:27,480 --> 00:06:31,070
And guys after that we can call this app finished.

97
00:06:31,080 --> 00:06:36,800
Totally done for the most part with exception of what I will challenge you to do in the next video.

98
00:06:36,810 --> 00:06:38,610
But let's go into groups.

99
00:06:38,700 --> 00:06:39,980
Click on nerd herd.

100
00:06:40,050 --> 00:06:43,790
And when I click this button it should transition back to the left like we want.

101
00:06:44,260 --> 00:06:45,800
Oh look at that.

102
00:06:46,080 --> 00:06:48,200
So cool.

103
00:06:48,330 --> 00:06:49,560
So it looks like it works.

104
00:06:49,560 --> 00:06:51,420
We can open our groups.

105
00:06:51,420 --> 00:06:55,010
We can load our feed we can make a post from our account.

106
00:06:55,110 --> 00:06:58,140
We have a profile page with an unfinished table view.

107
00:06:58,170 --> 00:06:59,340
Wink wink.

108
00:06:59,340 --> 00:07:04,740
In the next video I'm going to give you a challenge to see how you can extend this app and make it even

109
00:07:04,740 --> 00:07:06,110
more incredible.

110
00:07:06,270 --> 00:07:09,090
Thank you guys so much for going through this section of the course.

111
00:07:09,090 --> 00:07:14,760
Amazing work this app would be an amazing portfolio piece by the way to show a potential employer so

112
00:07:15,030 --> 00:07:16,920
I would highly recommend that you do that.

113
00:07:16,920 --> 00:07:19,260
Let's head over to the next video for your challenge.
