API Reference 0.7.1rikulo_layoutTileLayout

TileLayout class

The title layout (not implemented yet). It arranges the child views of the associated view in rows and columns.

Based on the given width, minWidth and maxWidth, it arranges views from left to right, and starts a new row when there is no enough zoom for a view.

LayoutDeclaration of the associated view provides the default width and height for each child view, while ProfileDeclaration of each child view, if specified, controls how a child view is arranged different including width, minWidth, minHeight, maxWidth and so on.

In additions, you can control the alignment and spacing with the align, spacing and gap properties. If you want to arrange a view as the first or lat view of a row, you can control it with the clear property. Please refer to ProfileDeclaration for more information.

TileLayout arranges views row-by-row and then cell-by-cell. When calculating and deciding how many of views can be placed in the given row, it first check the width (of ProfileDeclaration and then LayoutDeclaration). If a fixed value is specified (excluding flex and ratio), it will be used. Otherwise, it checked the minWidth of ProfileDeclaration.

After deciding which views to place in the given row, it distributes the width based on the criteria specified in ProfileDeclaration and LayoutDeclaration.

It is useful for responsive Web design, since the tile layout will arrange child views in additional rows, if they can't fit into a row.

class TileLayout extends AbstractLayout {
 void doLayout_(MeasureContext mctx, View view, List<View> children) {
   final clientWidth = () => view.clientWidth,
     clientHeight = () => view.clientHeight;
   int sum = 0;
   for (final View child in children) {
     if (!view.shallLayout_(child)) {
       mctx.setWidthByProfile(child, clientWidth);
       mctx.setHeightByProfile(child, clientHeight);
       continue;
     }
   }
 }

 int measureWidth(MeasureContext ctx, View view) {
   throw new UIError("'content' not allowed in tile layout");
 }
 int measureHeight(MeasureContext ctx, View view) {
   throw new UIError("'content' not allowed in tile layout");
 }
 bool get isFlex => true;
}

Extends

Layout > AbstractLayout > TileLayout

Properties

final bool isFlex #

Default: false.

docs inherited from AbstractLayout
bool get isFlex => true;

final bool isProfileInherited #

inherited from AbstractLayout

Default: true.

bool get isProfileInherited => true;

Methods

void doLayout(MeasureContext mctx, View view) #

inherited from AbstractLayout

Handles the layout of the given view.

docs inherited from Layout
void doLayout(MeasureContext mctx, View view) {
 if (view.firstChild != null) {
   final AnchorRelation ar = new AnchorRelation(view);
   for (final View child in ar.indeps) {
     mctx.preLayout(child);
     //unlike View.onLayout_, the layout shall invoke mctx.preLayout
   }

   //1) layout independents
   doLayout_(mctx, view, ar.indeps);

   //2) do anchored
   ar.layoutAnchored(mctx);

   //3) pass control to children
   for (final View child in view.children) {
     if (child.visible)
       child.doLayout_(mctx); //no matter shallLayout_(child)
   }
 }
}

void doLayout_(MeasureContext mctx, View view, List<View> children) #

Arranges the layout of non-anchored views. Instead of overriding doLayout, it is simpler to override this method.

docs inherited from AbstractLayout
void doLayout_(MeasureContext mctx, View view, List<View> children) {
 final clientWidth = () => view.clientWidth,
   clientHeight = () => view.clientHeight;
 int sum = 0;
 for (final View child in children) {
   if (!view.shallLayout_(child)) {
     mctx.setWidthByProfile(child, clientWidth);
     mctx.setHeightByProfile(child, clientHeight);
     continue;
   }
 }
}

int measureHeight(MeasureContext ctx, View view) #

Measure the height of the given view.

docs inherited from Layout
int measureHeight(MeasureContext ctx, View view) {
 throw new UIError("'content' not allowed in tile layout");
}

int measureWidth(MeasureContext ctx, View view) #

Measure the width of the given view.

docs inherited from Layout
int measureWidth(MeasureContext ctx, View view) {
 throw new UIError("'content' not allowed in tile layout");
}