Skip to main content
Version: 7.2.0

Using Android & iOS specific properties

Using Android & iOS specific properties

In Smartface, you can use Android & iOS specific properties to control the behavior of the application.

import AlertView from "@smartface/native/ui/alertview";
const myAlertView = new AlertView({
title: "Alert Title",
message: "Alert Message",
android:{
cancellable: true
}
});
import FlexLayout from '@smartface/native/ui/flexlayout';
import Color from '@smartface/native/ui/color';

const myFlexLayout = new FlexLayout({ backgroundColor: Color.RED,
android:{
elevation:5
},
shadowColor: Color.BLUE
});

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.

import AlertView from "@smartface/native/ui/alertview";

const myAlertView = new AlertView({
title: "Alert Title",
message: "Alert Message",
android: {
cancellable: false
}
});

// 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();