I’ve merged the results of my UIControls branch on github into my master branch. I think my little experiment went well, and I’d love to get feedback from people on how this new API works for you. I still have some great plans for it, but before I get ahead of myself, let me cover what I’ve done:
- Refactored the command call API to allow for a richer set of arguments to PhoneGap commands
- Moved some commands around to more appropriate classes (e.g. Alert and Vibrate both moved to Notifications)
- Reorganized the XCode project so commands are clearly separated from PhoneGap infrastructure
- Renamed the Settings.plist PhoneGap config file to PhoneGap.plist, and created a new Settings.plist file that contains custom application-specific configuration.
- Made all PhoneGap commands inherit from a common base-class that auto-loads its own Dictionary of configuration from the main PhoneGap.plist file.
- Updated the demo to show off tabs and toolbars
All that looks like a big change, but almost all of it was infrastructure changes that were necessary to get UIControls to work. Previously, all PhoneGap commands were class method calls, meaning it was very difficult to maintain state between command calls. Now that commands are actually called on an instance of a given command class, it’s easier to maintain state. So when a tab bar is created, multiple calls can be made, each to construct different aspects of the UI. Without all this, the following example would have been much more complicated:
uicontrols.createTabBarItem("toprated", "Top Rated", "tabButton:TopRated");
uicontrols.createTabBarItem("recents", "Recents", "tabButton:Recents");
uicontrols.createTabBarItem("more", "More", "tabButton:More");
uicontrols.showTabBarItems("toprated", "recents", "history", "more");
The changes to the PhoneGap configuration were necessary because now, when a PhoneGapCommand subclass is constructed, it will look in the PhoneGap.plist configuration file to see if there’s anything pertaining to it. So if there’s a key in the dictionary with the same name as the class being constructed, it will use that as a local configuration dictionary influencing just that one class. That way, if you don’t use a feature of PhoneGap, or you have to configure a lot of options for a single type of command, these options won’t be cluttered alongside the standard global PhoneGap settings.
So please, try out my PhoneGap updates and let me know what you think of it. I think the integration of the JSON framework will make things like Contacts much simpler to implement.
Before I go though, I want to give a little “wish list” of features I’m planning on adding in the near future. I’ll get to them whenever I can, since my own app development takes priority of course.
- Toolbar buttons
- Tabbar show/hide animations
- File support (read / write local files)
- Camera and photo library support (POST to a server, save to a local file, etc)
- Native “Flip / Slide” transitions (no more having to mimic them in CSS)
- 3rd party API integration, like AdMob and Medialets (I already have both of these done, but I’m in discussions with both companies to determine if the terms of their license allows me to redistribute it)