jhselvik / AlertView

Will slide out an alert view from a location on the current view
0 stars 0 forks source link

How to structure where create an AlertViewController #1

Open jhselvik opened 10 years ago

jhselvik commented 10 years ago

@tylrtrmbl

To display the view for the alertVC it will need to be a child to whichever current view is displayed. Top of this tutorial goes over the basic methods needed to complete this. http://nscookbook.com/2013/08/ios-programming-recipe-28-view-controller-containment-transitioning/

So this raises the question how/where to create an alertVC in Balto-iOS? The best way I can think of off the top of my head is to have a shared instance of the alertVC class and use it like the service controller to create an alert wherever needed. I am attempting this now in a branch. I believe we might run into issues though when our majors views switch around; login, map, chat, reservation, ext. Still trying to abstract all the alertVC parts into its own class to attempt this though. Interesting error is on the branch commit for where I had to stop for the night.

Another option might be to build the alert view into our custom navigation bar. This is what I originally tried to do with the frame animations.

Once created closing the alertView is easier. I have a hacky way implemented now on master which allows for multiple alertVC to be created and have their views show on top of each other and have each instances close button kill itself properly.

jhselvik commented 10 years ago

I believe I have have solved most of this. several decisions to make though:

1 - When you move to a new screen the alert will stay at the old one. I think it is expectable that every time we perform a segue though we check if an alert view is displayed and then send it on to the next view.

2 - I have a bit of a hack in the alertVC in the create alert message method. I make a dummy Nav bar for measurements. This approach okay?

3 - is passing the currentVC to the alertVC class okay whenever we want to make one? It works well now, but I can imagine some scenarios which might break this.

taylortrimble commented 10 years ago

Thoughts from your message yesterday:

So this raises the question how/where to create an alertVC in Balto-iOS?

Consider making a master view: one that has the navigation controller as a child view controller all the time, and adds the alert view controller over the top when it wants to.

The best way I can think of off the top of my head is to have a shared instance of the alertVC class and use it like the service controller to create an alert wherever needed.

Some mixed concepts here: you don't want a shared instance of the view controller; you might want a general alert controller, but you'll need to think of (and probably document before you build) the interface this would provide.

I believe we might run into issues though when our majors views switch around; login, map, chat, reservation, ext. Still trying to abstract all the alertVC parts into its own class to attempt this though.

Yeah, we should definitely have the alertVC not presented from any of those application view controllers.

Another option might be to build the alert view into our custom navigation bar. This is what I originally tried to do with the frame animations.

Yes, this.

I have a hacky way implemented now on master which allows for multiple alertVC to be created and have their views show on top of each other and have each instances close button kill itself properly.

The multiple views case is interesting. What behavior do you expect when we present multiple alerts?

taylortrimble commented 10 years ago

1 - When you move to a new screen the alert will stay at the old one. I think it is expectable that every time we perform a segue though we check if an alert view is displayed and then send it on to the next view.

I can imagine cases where this is acceptable and when it's not acceptable. What if the network goes out and we want to display an alert until the network comes back?

2 - I have a bit of a hack in the alertVC in the create alert message method. I make a dummy Nav bar for measurements. This approach okay?

Probably not: Apple should provide a method for querying that for just this purpose.

3 - is passing the currentVC to the alertVC class okay whenever we want to make one? It works well now, but I can imagine some scenarios which might break this.

How is it being passed? It sounds like we should probably be assigning a delegate in this case.

taylortrimble commented 10 years ago

I'll take a look at what code you have by the end of tonight tomorrow. Just tell me what branch to check out.

Thanks @JoeSelvik! Getting there.

jhselvik commented 10 years ago

Yeah, we should definitely have the alertVC not presented from any of those application view controllers.

I wouldn't say definitely yet. This is working now and at some point we might just need to move on if the Master view over the Navigation view is taking too long.

What if the network goes out and we want to display an alert until the network comes back?

We can make a NetworkAlertViewController, a subclass of AlertViewController. We can have the service controller or something control when to remove the Network Alert View and remove the close button. Another option is to have the instance of the Network alertVC to check itself if the network is back up and then dismiss itself. It is not over the navigation bar but it is front an center for the user to see.

If they switch views we might have to check each time a new view goes to the top to check if the network is available asynchronously while the view loads.

Point is we have other options if the Master View takes too long, options that could be acceptable and quicker to implement at the cost of some extra code on our part.

Apple should provide a method for querying that for just this purpose.

I will try and find this again. I assumed there should be something like this.

How is it being passed? It sounds like we should probably be assigning a delegate in this case.

Duh. I blanked here... Thanks

Both my branches are pretty self explanatory now. I will start a second branch from master to work at the master view tomorrow. Any tips on this would be useful. I spent today reading up on all the details of the UINav Bar and Controllers. I am getting it but still have some doubts.

taylortrimble commented 10 years ago

Okay: I do want to shy away from the application view controller presentation of alerts. Save that for if things get really rough, but I think that once you have a good set of view controller fundamentals (you're almost 100% there) the master VC will end up being the easiest. You want to learn VC fundamentals anyway. :smiley:

I'm going to look at your branches: let me know any questions you have left!