I know we’ve mentioned that a lot :-), but DukeScript really has a clean separation
of view and logic. This is not only helpful for the collaboration of designers and developers,
it’s also really helpful if you want to provide platform specific views.
Here are some little tricks, how you can provide separate views for iOS and Android.
Let’s assume your designers have created three different files for you: index.html for the desktop app,
index_android.html for Android, and index_ios.html for iOS. All of them link to different
CSS files and resources.
I’ve created a demo project from the Maven Archetype to simulate this.
For now I’ve simply copied and renamed index.html and changed the header message in the files (
We’ll have a closer look hwo to make your apps look more native in a separate article).
When you create a new application, you get separate projects for the individual
platforms. These modules contain platform specific configuration files and tasks for
running, debugging and deploying to the specific platform. In Android projects there’s
for example “src/main/AndroidManifest.xml”. If you open this file it shows you what
html page is used as a view:
You can customize this and point the loadPage to index_android.html:
This will launch your app with an alternative view on Android.
On iOS we can use the constructor to pass the file as an argument. Just modify
the Main class in your “General Client Code” like this:
Now go back to the “Client for iOS” and modify iOSMain:
That’s it, you now have three different views for the different platforms. In our
next blog we’ll show you, how you can style the individual views to look more native.