Integrating shell and native views.

55 views
Skip to first unread message

kedziers...@gmail.com

unread,
Jun 25, 2013, 11:50:19 AM6/25/13
to calatrav...@googlegroups.com
Hi Guys,

I have a newbie question about integrating shell and native UI for iOS application.

I have created one shell view (extending WebViewController) with HAML file and one native page (extending BaseUIViewController) - separate each page can be displayed correctly.

Now I am considering how can I display a native page after clicking a button at shell view?

As far as I have checked, native views are using one shared browser instance (in WebRuntime), but shell view has its own browser (created by WebViewController). The result is one browser does not have the access to JavaScript files loaded by the other one. How can I solve this problem?


And one more question: is it possible to write scripts using pure JavaScript instead of CoffeScript?
After I have put my JS files in ${PROJECT_DIR}/kernel/app/MODULE_NAME/, they have not been copied to iOS application by building script.

Thanks in advance for your help,
Damian

Priyank Gupta

unread,
Jul 2, 2013, 11:17:07 PM7/2/13
to calatrav...@googlegroups.com, kedziers...@gmail.com
Hey Damian,

My knowledge around iOS is limited however from what I understand you want to bind a button to invoke a native page from a shell UI (page object extending WebViewController). A simple way to go about doing that is to "bind" to an event so that controller gets the callback from the view. On receiving that callback in your controller you'll trigger an action on the page object (extending WebViewController). Since this is objective C code, you have flexibility of navigate to the native View Controller. I can probably help you better if you have some sample code to share.

Also, we are working on few examples that will highlight a mix and match of native and shell views for both android and iOS. Once they are available I'll add that information to this thread as well.

As to your last question around writing controller code in javascript only; it isn't possible just as yet to use existing build tasks to copy over JS only resources. There are two options that you have, if you really don't want to use coffeescript:
  • You can write custom build steps in a tasks folder which can be run with rake. These tasks can internally orchestrate the tasks needed from calatrava and then copy over your js files as needed. (This will be cleaner in short term since you don't need modifications at Calatrava level)
  • Another option is to fork calatrava for short term and use this pull request to able to do so. https://github.com/calatrava/calatrava/pull/30 
Hopefully that helps.

Giles Alexander

unread,
Jul 3, 2013, 6:27:51 AM7/3/13
to kedziers...@gmail.com, calatrav...@googlegroups.com
Hi Damian,

Once you've implemented the controller behind your feature in CoffeeScript, not Obj-C, then you no longer need to worry about which technology the page you're changing to is implemented in. How are you getting the shell view and the native view on screen? You're calling calatrava.bridge.changePage(), right? Well, as long as you have the pages registered by name correctly you can then pass that name to the right page handler.

Using the example currency converter, inside the file kernel/app/converter/controller.converter.coffee, imagine there was a separate page for displaying the converted result, called 'conversionResult'. Then, in 'performConversion()', instead of these two lines at the end:

        views.conversionForm.render
          out_amount: (Math.round(amount * (outRate / inRate) * 100)) / 100

You could have the following:

        views.conversionResults.render
          out_amount: (Math.round(amount * (outRate / inRate) * 100)) / 100
        calatrava.bridge.changePage('conversionResults')

That's how you change the page, and then conversionResults could be with a web view, or a native view. Also, note the change in the render call. We're now passing the converted amount to the conversionResults view.

Hope this helps,
Giles



--
You received this message because you are subscribed to the Google Groups "calatrava-mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to calatrava-mobi...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Reply all
Reply to author
Forward
0 new messages