Let's make our UI as smooth as butter.
What I mean by that is you don't want the users pressing login or register or forgot password twice
because that's going to be a very big pain.
So what we're going to do is drop in an activity indicator view and we're going to sort of wedge this
maybe where are we going to put it?
Let's put it actually above the login button and then control click it down to vertical spacing and
then control, kick it down to center horizontally.
OK, so that should just about do it.
It's going to be roughly somewhere they're.
And if we tap it, we are going to have Hydes when stopped.
And currently, it's not animating, so if I play this when the authentication screen appears, that
shouldn't actually appear yet until we explicitly started.
OK, so the way we're going to explicitly start it is go into our auth view controller.
And we get to have a function disable UI.
And we're also going to have actually, before we create their function, will just fill in this one
so we don't have a reference to the buttons.
We do have the output.
So what we're going to do is first go back to the main storyboard and get a reference to all the things
that we need.
So let's go top right click.
Let's go to our orfeu controller and let's scroll around and find our storyboard.
There we go.
So I need a reference to the activity indicator.
I'll just call activity end and the reference to the button.
Now, this is a reference, an outlet, not an action, so be careful of that.
Same with the register button.
And then, of course, the same with the forgot password button, because we don't want them clicking
that either.
OK, so now we have references to everything we can go ahead and close all of that and go back to our
overview controller.
Not the UI one, we go to the off one, thank you very much.
OK, so to disable the UI, we are going to disable the login button.
Is enabled equal, whatever.
So the way I'm going to actually do this is enabled is going to be sent over as a boolean.
So what we're going to do.
He's actually renamed this Activate UI.
So I can just set that boolean, right, I can have register button, dot enabled, oops.
Is enabled, is equal to enabled for got.
What did we call the forget button forgot password button?
There it is, DOT is enabled is exactly the same, right?
So that's the three lines that we need.
There is actually a way to shorten these three lines to one, I believe.
But we're not going to do that.
Keep it nice and obvious, even though it creates more lines of code, obviously, I believe is much
better then we need the activity indicator DOT.
And what is the thing is animating.
Stop animating.
Start animating now, this is going to need to be if enabled.
OK, if if it's enabled, then we're actually going to stop animating.
Else activity indicator don't start animating, and that should also take care of the disappearing as
well.
So let's hit play on that.
Now, this might actually happen quite quickly.
So what I'm going to do is turn the Wi-Fi off.
And then it should take quite a while, so I've got my user that's already registered when I log in,
which can network error, so I will put that wi fi back on.
It's get my Hesselbach and guest.
Can you guess what city I am in?
Hustle back in is a hotel in the city, OK, so I'm going to click login.
This is going to happen quickly.
Watch carefully.
That happened much quicker than I was expecting, you know.
I think we need to set this activity indicator to white or we won't be able to see it.
So now let's hit play.
And again, we'll have to watch this very carefully and quickly.
So that oh, wait, you know what?
Of course, nothing worked because we haven't activated the UI, have we?
If Log-in is tapped and we get through the first hurdle, we're going to activate the UI as false.
OK, and then if the authentication works or doesn't work, we're going to activate the UI anyway because
we've gone through the process.
So again, with registered tapped and of course, we need a cell phone that.
And down here, we're going to have activate UI as false.
And then self-drive activate UI as true, and we're going to have the same for Forgot Tapped, but we're
not doing that just yet.
So let's play let's see what we get out of this.
All right, when I said watch carefully, maybe I meant watch carefully my code, because it wasn't
that good at that point.
So paste that in oops trophy and whatever else, I'm going to do the wrong password here.
Here we go.
There we go.
So it tried to log in.
It deactivated the buttons.
Now the buttons didn't dim.
It just stopped the user from pressing them up to you.
If you want to add the dimming effect to them, you can do that fairly easily.
But I'm not going to bother with that right now.
So what happens if we get everything right?
Let's log in.
And we're in.
OK, so that's just a nice way to butter up the UA, make it a bit more user friendly and to stop them
from tapping those buttons twice, because I believe you and me, that is what users do.
They press things all the time.