Using Android & iOS specific properties

Using Android & iOS specific properties

Smartface doesn't support platform specific properties settings on constructor yet. The platform specific property can be set after the instance is created. You should use like below example.

JavaScript
JavaScript
const AlertView = require('sf-core/ui/alertview');
var myAlertView = new AlertView({
title: "Alert Title",
message: "Alert Message"
});
myAlertView.android.cancellable = false;

Smartface doesn't support getting or setting the platform specific property as objects.

JavaScript
JavaScript
const AlertView = require('sf-core/ui/alertview');
var myAlertView = new AlertView({
title: "Alert Title",
message: "Alert Message"
});
// This usage is not supported. It returns an empty object.
alert(JSON.stringify(myAlertView.android));
// This usage is not supported.
myAlertView.android = {
cancellable: false
}

Coding convention of Android & iOS specific properties

Smartface follows an easy coding convention for platform specific properties and types to make them more predictable. Coding convention rules are defined below.

Platform specific properties of an object are inside a platform object named "android" or "ios". Platform specific types are inside a platform namespace named "Android" or "iOS". Following example demonstrates how these rules are applied in Smartface.

Example
Example
const AlertView = require('sf-core/ui/alertview');
var myAlertView = new AlertView({
title: "Alert Title",
message: "Alert Message"
});
// Note how platform specific property "cancellable" is kept in object
myAlertView.android.cancellable = false;
// Note how platform specific type "ButtonType" is kept in namespace
myAlertView.addButton({
type: AlertView.Android.ButtonType.NEGATIVE,
text: "Cancel"
});
myAlertView.show();