Cross Platform Mobile Development with Crosslight – Part 2

This is the second post of cross-platform mobile development with Crosslight series. Continuing from the previous post , I am most pleased to share two of the exciting features shipped with Crosslight: unified navigation framework and powerful data binding.

Unified Navigation Framework

As navigation differs from one mobile framework to another, it’s a challenging task for mobile developers to streamline the navigation logic all in one place that can work consistently between platforms. Take iOS, Android, Windows Phone, and WinRT for example. iOS uses push navigation while Android uses Intent-based navigation while Windows Phone and WinRT use Page-based navigation. Gone are the days you will have to worry about these troubles with Crosslight. This section will outline the features supported by Crosslight navigation framework.

Basic Navigation

Crosslight navigation supports basic navigation to a page using the view model.  This is achieved using the navigation service from the view model and calling the Navigate method then specify the desired view model to navigate. It’s as simple as that.

Basic Navigation on iOS

At its simplest form, basic navigation can simply be done with the following simple calls from the view model:

Note that you can also navigate to the same view model but consumed by different views using the NavigationParameter as shown above.

List Navigation (Push Navigation)

Crosslight navigation service enables you to perform navigation from within the view model. You can navigate to a view model by providing the type, or a known identifier.

Unified List Navigation on WIndows Phone

The navigation view model looks as simple as this:

Modal Navigation

The integrated navigation service supports a special navigation type called as modal navigation. It is particularly useful to present a view that waits for user input; you can return a navigation result indicating whether the user provided the input or cancelled the input, as well as capturing additional data as the result of the modal navigation.

Modal Navigation on Android

To execute a modal navigation, in the view model, we can specify as follows:

Notice that after modal navigation is executed, you can handle the result of the modal navigation through action callbacks.

Nested Modal Navigation

In addition to basic modal navigation, the Crosslight navigation service also supports advanced modal navigation that allows you to perform navigation within the modal view context. Called Nested Modal Navigation, this feature is particularly useful when you need to capture numerous data input that are split to multiple views (wizard-like).

Nested Modal Navigation on WIndows Phone

The navigation service manages the navigation stack made during the modal session. When the Close method is called, it automatically discards the entire modal navigation stack, and return to the initiator view.

Nested Modal Navigation Result on Windows Phone

It is quite simple to execute a nested modal navigation:

Similar to the previous modal navigation, you can handle the result of the nested modal navigation through action callbacks through the nested modal view initiator.

Master-Detail Navigation

The Crosslight navigation service supports master-detail navigation, both when deployed to a phone device or a tablet device. On a phone device, the navigation would be interpreted as push navigation while on a tablet it would be treated differently based on the targeted platform.

On phone, it will look like this:

Master Detail Navigation on Phone

While on tablet:

Master Detail Navigation on Tablet

For iOS and Android, you would need a binding provider that specifies the detail view model when the item is tapped.

Tab Navigation

The navigation service also supports tab navigation using selected index. By inheriting a special view model called MultiPageViewModelBase, you can perform navigation setting the selected index of the navigation items. You can also send parameters and custom objects during tab navigation.

Tabbed Navigation on iOS

The TabViewModel that enables tab navigation:

Powerful Data-Binding Features

Crosslight was designed with the powerful MVVM design pattern in mind. The MVVM design pattern itself is almost always associated with data-binding concept. .NET developers targeting Silverlight and WPF will be at home with the concept. However, this post will not cover the concepts of data-binding itself, but more on how Crosslight leverages this concept to the mobile development world, which were only available to platforms such as Silverlight and WPF. If you would like to learn more about data-binding concept, Microsoft has detailed a very good article here that covers the topic in-depth.

Property-to-Property Binding

Crosslight data-binding framework supports the very basic property-to-property data binding, enabling you to bind a property to another property using various information contained in BindingDescription using a BindingProvider class.

Universal Data Management

Crosslight data binding framework supports automatic UI updates when bound to a collection. This allows for easier data management as well as saving you the trouble of updating the UI when the underlying data model changes. Consider the following view model:

After you have finished inserting items to the model, the view updates accordingly.

Universal Data Management on iPhone

Binding to Nested Property

Aside from binding to a top-level property, you can also bind to a nested property.

Binding to Nested Property on WinRT

Case 1: Loan Calculator

Loan Calculator

A simple app that can be made using the data-binding framework is the loan calculator where you would input the amount of loan, the loan term in years, and the interest rate per year.

Loan Calculator Result on Android

Each of the textboxes and the button is bound using a BindingProvider.

After inputting the specified amount, loan term, and interest rate, and hit calculate, it calculates the monthly payment by calling the command specified in the view model, as follows:

Case 2: Currency Converter

Another simple example would be to make an offline currency converter. This example demonstrates Crosslight support for binding with full converter and UpdateSourceTrigger support.

Currency Converter

Full Converter Support

Just like the native binding found in Silverlight and WPF platforms, Crosslight also supports binding with converter, complete with converter parameter and converter culture.

UpdateSourceTrigger Support

Intersoft Crosslight provides four predefined UpdateSourceTrigger values, namely Default, Explicit, LostFocus, and PropertyChanged. By default, the update process to the bound property will be done after lost focus event is triggered. The following code shows how you can use the two-way BindingMode as well as setting the UpdateSourceTrigger to PropertyChanged.

As a result, the respective currencies will be converted in real time when the text is changed.

Currency Converter on iOS

StringFormat Support

Crosslight BindingProvider also supports binding with StringFormat support.

StringFormat Support on Windows Phone

Wrap-up

Navigation and data-binding are just some of the features Crosslight introduced to the mobile development world. It is important to note while all these features are shown platform specific, they work consistently across multiple platforms. The diverse pictures shown in this blog post is to give you an overview about the features described earlier were not platform-specific; they can be applied cross-platform. Some of the Crosslight API outlined in the code snippets are not explained in detail here; they will be covered comprehensively in our product documentation upon release. You might wonder, while these features sound too good to be true, in fact, they really are. These magical features will be available as soon as we hit our 2013 R1 milestone, which is going to be released very soon in early September.

Regards,

Nicholas Lie

Comments

  1. Can you provide a listing of all the components that Intersoft is going to have for Mobile development? And , are these components work the same on all three platforms?

    Secondly, are you going to provide a global theme that same app “can” look the same on all three platforms?
    Thanks!
    ..Ben

    1. Hi Ben,

      Thank you for your interest in Mobile Studio. Yes, we are going to provide templates that will work consistently across multiple platforms. However, it is important to note that since you will be building apps on a native level, the UI experience that Mobile Studio has provided will conform to each platform UI design guidelines. We are pleased to tell you that you can get a copy of Mobile Studio immediately at http://www.intersoftpt.com/RequestTrial. For more information on what Mobile Studio has to offer, check out: http://www.intersoftpt.com/Studio/Mobile. Have a great day!

      Cheers,

      Nicholas

    2. Hi Ben,

      Yes, we do provide 80+ MVVM-enabled controls that spans over 4 platforms : iOS, Android, Windows Phone, and WinRT. The covered editors comprises of MVVM-enabled controls such as date pickers, buttons, text fields, labels, time pickers, and you can even add your own custom controls. For more details, see here: http://www.intersoftpt.com/Crosslight. The built-in editors for forms are declared using metadata definition; which be translated by the framework automatically. Unlike previous experience in using custom controls, we no longer explicitly declare the use of controls in cross-platform mobile development. This is an integrated feature of Crosslight form builder.

      Cheers,

      Nicholas Lie

      1. *Unlike previous experience in using custom controls, we no longer explicitly declare the use of controls in cross-platform mobile development. This is an integrated feature of Crosslight form builder.*

        Ah, that was exactly why I was asking that question, how you managed to have all the controls for four platform.
        Could you please make a video how a control is used as “metadata” during development, let’s say iOS and Android and how it looks at runtime?

  2. I’m also interested in what Ben said.
    And, would also like to know more about Client UI, mostly WPF not Silverlight (which I care less since the announcement of the cease of support by MS).

    Thanks,
    Dave

Leave a Reply to David De Smet Cancel reply