Reputation: 813
If I have an iphone app in titanium and then want to also have that same app working on android and ipad, to have it working nicely on each platform is it just a matter of making some UI changes or does it require rewriting a significant amount of code?
Upvotes: 3
Views: 266
Reputation: 1914
First thing I would do it just try it in the Android emulator. Does it work? Titanium will map UI elements to the target platforms functionality so it might just work, though it will look different. Each platform has their different ways of displaying information on the screen.
Titanium Mobile is a write once, adapt everywhere model. So you write the main functionality for the app and then adapt the UI to the platform. You can generally reuse a large portion of your back-end management code for the device if you structured it properly. In my situation, I'm writing a reasonable large application and I can reuse all my networking code and database interaction code. The way you setup a project allows you to substitute platform specific files where needed in a platform specific folder. For example, if your form1.js doesn't work on Android, but works in iPhone, you place the form1.js file that works into the Android folder matching the folder structure and it will pull the file from there during compilation, but continue to use the database.js file for the data store from the common code.
A good example of some cross-platform code is the RSS Reader sample code you can get through the IDE (lower left panel in the IDE). You may figure out the minor changes you need to make to get your app working on Android from that. I also like the Tweetanium app source code, because it is a larger project and has similar cross-platform effort for making the app look similar on both OSes.
Also, do a search for Titanium Mobile Titans for the 'App' source code. Actually here is the link: https://github.com/appcelerator-titans/App. This is an example of a cross-platform interface taking in the considerations for the UI.
I believe all of these examples have tablet (iPad/Android) detection code as well, so you can see how the code branches for those screen sizes.
Upvotes: 2
Reputation: 76
While Titanium can technically be a "write once, deploy everywhere" platform, I think it is best for a developer to create the same codebase for each platform while slightly altering the development to suit the specific target platform.
For instance, the needs you have while targeting Android devices (with ranges anywhere from high-end smartphones like the Galaxy Nexus to tablets like the Nexus 7) differ greatly from needs that are best-practices for iOS applications.
I wouldn't want the exact same application being targeted for members of the same device family even. Take iOS for example - the most well-designed applications for both iPhone and iPad have strong UI/UX differences that should be accounted for due to their greatly different look-and-feel and use.
A good example of an application that does not adhere to the "write once, deploy everywhere" model is the Wunderlist application developed by 6wunderkinder. While they used Titanium to develop their iOS application, they did not use Titanium also for their Android app, and instead decided to drop Titanium completely and develop natively.
This is not to say that you can't stick with Titanium for both platforms (I have made applications on both iOS and Android adapted from the same code), but it was a completely understandable choice that the 6wunderkinder team decided to make. While it would have been fairly easy for them to use much of their existing iOS Titanium codebase for their Android application, there were likely many sacrifices that they would have had to make in order for it to be displayed the way they envisioned it on Android.
So yes, if going for a great-looking application (getting it exactly the way you want it on both device families) it is often a great deal of code that you have to change.
Upvotes: 0