Cross Platform Nav Controller Compatible with Ti 3.2

Happy new year, dear readers! Boy, the past month has been a little crazy. Appcelerator recently deprecated the Titanium.UI.iPhone.NavigationGroup API as of Titanium 3.2. As a result, cross platform navigation controllers, like the ones that I’ve been writing and posting on my github account, just stopped working. And that’s when people all over just lost their s*@$!. I started getting emails and comments from people, on this website, and on my github account, some DEMANDING that I fix my navigation controller ASAP.

Now, as some of you are aware, and I’m afraid this bears repeating, the code I post on my github account is free/open source. This means I work on this stuff and share it with the world in my “free” time, when I’m not busy working on other things. So, I’ve decided to post some rules for making code requests, in hopes of heading off these crazy antics in the future.

But first, let me explain briefly how the deprecated API impacted the Navigation Controller and what changes I made to fix it.

Github Repo to Navigation Controller here

As I’ve explained in past posts, Titanium has a different way of managing stacks of windows for iOS and for Android. If you’re writing a cross platform mobile app, you COULD put branching statements all over your code, wherever you’re opening or closing a window in your app, and have that branching code handle it differently depending on whether it’s an Android or iOS app. OR, you can write your own API/interface that handles this code branching for you, and just use that API. That’s what my Navigation Controller is: an API, to handle this specific use case. It is only useful for managing stacks of windows in the same screen; it is not needed for displaying windows in different tabs of the same app.

For iOS, before Titanium version 3.2, you needed to use the Ti.UI.iPhone.NavigationGroup to manage your stack of windows. But since Ti 3.2 came out and deprecated that API, you now need to use Ti.UI.iOS.NavigationWindow. The second change is what to call when you’re opening/closing a window and this one’s a little confusing. To open a window within your NavigationWindow group, you need to call openWindow(), unless it’s the first window in your group, then you just call open(). To close a window within your NavigationWindow group, you need to call the closeWindow() function, unless it is the only window left in your group to close, in which case you call close(). Clear as mud? 🙂 These changes affect the iOS part of the Navigation Controller only; the Android part of the code continues to function as before.

Hope you find this new Navigation Controller useful. I’d like to thank Kevin Whinnery, former developer evangelist of Appcelerator, who wrote the first Navigation Controller and to Matt Lanham for improving on it. The first version of my Nav Controller was based on their code. And thanks to Mike (never got his last name) for posting his version on github, which this current version of mine is mostly based on (I’ve just been modifying it for my own use ever since :)). And thanks to Manuel Conde, for also kindly sharing his version of the Nav Controller for all my dear readers to use.

And now, before I close, some rules moving forward on how I’m going to manage code requests from now on.

First of all, the main reason I post code on github is to share what I’ve learned with others, and I hope to encourage other people to do the same. If we can help and learn from one another, then we can all become better Ti programmers in the process, no? But how can I do that without causing myself undue amounts of stress?

So, here are the new rules for making code requests:

Good – Ask nicely for updates or post questions for myself or others to answer. The key here is to be nice: ask for help (don’t demand it, this is free/open source code after all); if you briefly introduce yourself and say hello, that would be a nice touch; and remember there is no guarantee on when/if anyone will be able to answer your question. Rude comments and requests will simply be removed from the website.

Better – Post your own solution in a github repo and post the link to that repo here, in the comments. I decided this was better than asking for pull requests and managing those. It turns out that people have different ways of implementing the same things, and some people have their own style or way of writing code, which is just fine. So, rather than telling people, “This is the only way to write a cross-platform navigation controller,” I’d like to invite people to share their own versions.

Best – If you have no questions and nothing to add, but you find my contributions or those of others who post here useful, please share your compliments and thanks here. People often comment online to complain or demand things, but not enough people write to say ‘thank you’.

Here’s to a kinder, gentler year in 2014. Enjoy the new, updated Navigation Controller, and if you have anything to add, please make sure to follow the new rules posted here.

All my best,
Vui, @sunfishgurl

Advertisements

26 thoughts on “Cross Platform Nav Controller Compatible with Ti 3.2

  1. Pingback: This Week in Titanium Mobile Development: 3 Feb 2014 | TiDev

      • My project was written in the Alloy framework. The NavigationController.js file itself is a CommonJS module (it’s in the app/lib folder), which can be used in either the CommonJS (also known as “Classic”) or the Alloy framework.

        I don’t have time to write and maintain the NavigationController for both the CommonJS and Alloy frameworks. But if someone is interested in giving an example of using the NavigationController in the CommonJS framework, you’re welcome to post the link to your github project here. 🙂 All the best!

  2. Pingback: This Week in Titanium Mobile Development: 3 Feb 2014 | Geeks Inc.

  3. I am using Navigation controller for Ti 3.2. I need pass the data between windows

    For Example
    In first window I have employee list. on click of employee list. I want to open second window for display details of employee which was selected on first window. In second window I need employee ID which was selected in first window.

    How to Pass data between windows?

  4. Thanks for this nav controller! I’ve implemented this in my app, and it works great. The only question i have is the following scenario:
    When you’re a few pages deep into a flow and hit the home button (calling the .home() method) it shows you each window in the stack as it closes them. Is there a way to have it hide all the windows and close them behind the scenes opening just the home screen without seeing the complete history? It’s entirely possible i’ve missed something.

    Thanks for your help!
    Jason

    • Hi Jason. You’re correct, that is exactly how the Nav Controller currently works. I don’t have much time to work on your proposed feature (this is after all, open source/free code). However, if you or someone else, would like to take a crack at implementing the solution and post the link to it in the comments here, it would be greatly appreciated! Good luck!

  5. Manuel, I’m using 3.3.0 but the navigationwindow for ios doesn’t have home capability without writing something myself. and the default toolbar didn’t seem to be sufficiently customizable so i have been working on building a toolbar with the look and functionality i need. But if there is something i’m missing, i’d love to hear how i can improve what i’m building.

    thanks for your help,
    Jason

Leave a Reply. Note that comments are moderated on this blog.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s