Skip to main content
Version: 7.2.0

Direction

API Reference: UI.FlexLayout.Direction

Direction is used to align objects right-to-left or left-to-right.

info

Direction.INHERIT is based on the language settings of the mobile device. If the the device language is a left-to-right language (such as English), the direction will be LTR. If the the device language is a right-to-left language (such as Arabic), the direction will be RTL.

note

The components in the example are added from the code for better showcase purposes. To learn more about the subject you can refer to:

Adding Component From Code

As a best practice, Smartface recommends using the WYSIWYG editor in order to add components and styles to your page or library. To learn how to use UI Editor better, please refer to this documentation

UI Editor Basics
import PageSampleDesign from "generated/pages/pageSample";
import { Route, Router } from "@smartface/router";
import Application from "@smartface/native/application";
import { styleableComponentMixin, styleableContainerComponentMixin } from "@smartface/styling-context";
import FlexLayout from "@smartface/native/ui/flexlayout";
import Label from "@smartface/native/ui/label";

class StyleableLabel extends styleableComponentMixin(Label) {}
class StyleableFlexLayout extends styleableContainerComponentMixin(FlexLayout) {}

//You should create new Page from UI-Editor and extend with it.
export default class Sample extends PageSampleDesign {
myFlexLayout: StyleableFlexLayout;
label1: StyleableLabel;
label2: StyleableLabel;

constructor(private router?: Router, private route?: Route) {
super({});
}

// The page design has been made from the code for better
// showcase purposes. As a best practice, remove this and
// use WYSIWYG editor to style your pages.
centerizeTheChildrenLayout() {
this.dispatch({
type: "updateUserStyle",
userStyle: {
flexProps: {
flexDirection: 'ROW',
justifyContent: 'CENTER',
alignItems: 'CENTER'
}
}
})
}

onShow() {
super.onShow();
const { headerBar } = this;
Application.statusBar.visible = false;
headerBar.visible = false;

}

onLoad() {
super.onLoad();
this.centerizeTheChildrenLayout();

this.myFlexLayout = new StyleableFlexLayout();

this.addChild(this.myFlexLayout, "myFlexLayout", ".sf-flexLayout", {
width: null,
height: null,
top: 0,
left: 0,
bottom: 0,
right: 0,
flexProps: {
positionType: "ABSOLUTE",
direction: "LTR",
},
backgroundColor: "#FFFFFF",
});

this.label1 = new StyleableLabel({
text: "1",
});
this.label2 = new StyleableLabel({
text: "2",
});

this.myFlexLayout.addChild(this.label1, "label1", ".sf-flexLayout", {
width: 80,
height: 80,
textAlignment: "MIDCENTER",
backgroundColor: "#32a80b",
});

this.myFlexLayout.addChild(this.label2, "label2", ".sf-flexLayout", {
width: 80,
height: 80,
textAlignment: "MIDCENTER",
backgroundColor: "#8f44ad",
});
}
}

Direction.LTR

Direction.RTL

Direction.INHERIT