API Reference 0.7.1rikulo_viewLayoutDeclaration

LayoutDeclaration class

The layout declaration of a view.

class LayoutDeclaration extends Declaration {
 final View _owner;
 Layout _handler;

 LayoutDeclaration(View owner): _owner = owner;

 /** The type of the layout.
  *
  * Syntax: `type: none | linear`
  *
  * Default: *an empty string*. It means no layout required at all (i.e., `none`)
  *
  * Notice you can plug in addition custom layouts. Refer to [LayoutManager]
  * for details.
  */
 String get type => getPropertyValue("type");
 /** The type of the layout.
  *
  * Alternatively, you can assign the layout handler directly with [handler].
  * It is useful if you'd like a view to be handled with a custom layout.
  */
 void set type(String value) {
   setProperty("type", value);
 }
 /** The handler for handling this layout.
  *
  * Note: this method will check if [handler] was set. If not, it will
  * return the handler of the given type specified in [type].
  * If there is no built-in handler for the given type, [UIError]  will
  * be thrown. In other words, this method won't return null.
  */
 Layout get handler {
   if (_handler != null)
     return _handler;

   final Layout handler = layoutManager.getLayout(type);
   if (handler == null)
     throw new UIError("Unknown type, ${type}");
   return handler;
 }
 /** The handler for handling this layout.
  * Instead of assigning one of standard types with [type], you can assign
  * a custom layout handler directly with this method.
  */
 void set handler(Layout layout) {
   _handler = layout;
   type = layout != null ? layoutManager.getType(layout): null;
 }

 /** The orientation.
  *
  * Syntax: `orient: horizontal | vertical`
  *
  * Default: *an empty string*. It means `horizontal`.
  */
 String get orient => getPropertyValue("orient");
 /// The orientation.
 void set orient(String value) {
   setProperty("orient", value);
 }
 /** The alignment.
  *
  * Syntax: `align: start | center | end`
  *
  * Default: *an empty string*. It means `start`.
  */
 String get align => getPropertyValue("align");
 /// The alignment.
 void set align(String value) {
   setProperty("align", value);
 }
 /** The spacing between two adjacent child views and
  * between a child view and the border.
  * It can be overriden by child view's [View.profile.spacing].
  *
  * Syntax: `spacing: #n1 [#n2 [#n3 #n4]]`
  *
  * Default: *an empty string*. It means `8` in *touch* devices
  * (i.e., `Browser.touch` is true), or `4` otherwise.
  *
  * If the spacing at the left and at the right is different,
  * the horizontal spacing of two adjacent views is the maximal value of them.
  * Similarly, the vertical spacing is the maximal
  * value of the spacing at the top and at the bottom.
  * If you prefer a different value, specify it in [gap].
  */
 String get spacing => getPropertyValue("spacing");
 /** The spacing between two adjacent child views and
  * between a child view and the border.
  */
 void set spacing(String value) {
   setProperty("spacing", value);
 }
 /** The gap between two adjacent child views.
  * If not specified, the value specified at [spacing] will be used.
  *
  * Syntax: `gap: #n1 [#n2]`
  *
  * Default: *an empty string*. It means dependong on [spacing].
  *
  * If you prefer to have a value other than [spacing], you can
  * specify [gap]. Then, [spacing] controls only the spacing between
  * a child view and the border, while [gap] controls the spacing
  * between two child views.
  */
 String get gap => getPropertyValue("gap");
 /// The gap between two adjacent child views.
 void set gap(String value) {
   setProperty("gap", value);
 }
 /** The width of each child view.
  * It can be overriden by child view's [View.profile.width].
  *
  * Syntax: `width: #n | content | flex | flex #n | #n %`
  *
  * Default: *an empty string*. It means `content`.
  */
 String get width => getPropertyValue("width");
 /// The width of each child view.
 void set width(String value) {
   setProperty("width", value);
 }
 /** The width of each child view.
  * It can be overriden by child view's [View.profile.height].
  *
  * Syntax: `height: #n | content | flex | flex #n | #n %`
  *
  * Default: *an empty string*. It means `content`.
  */
 String get height => getPropertyValue("height");
 /// The width of each child view.
 void set height(String value) {
   setProperty("height", value);
 }
}

Extends

Declaration > LayoutDeclaration

Constructors

new LayoutDeclaration(View owner) #

Creates a new Object instance.

Object instances have no meaningful state, and are only useful through their identity. An Object instance is equal to itself only.

docs inherited from Object
LayoutDeclaration(View owner): _owner = owner;

Properties

String get align #

The alignment.

Syntax: align: start | center | end

Default: an empty string. It means start.

String get align => getPropertyValue("align");

void set align(String value) #

The alignment.

void set align(String value) {
 setProperty("align", value);
}

String get gap #

The gap between two adjacent child views. If not specified, the value specified at spacing will be used.

Syntax: gap: #n1 [#n2]

Default: an empty string. It means dependong on spacing.

If you prefer to have a value other than spacing, you can specify gap. Then, spacing controls only the spacing between a child view and the border, while gap controls the spacing between two child views.

String get gap => getPropertyValue("gap");

void set gap(String value) #

The gap between two adjacent child views.

void set gap(String value) {
 setProperty("gap", value);
}

Layout get handler #

The handler for handling this layout.

Note: this method will check if handler was set. If not, it will return the handler of the given type specified in type. If there is no built-in handler for the given type, UIError will be thrown. In other words, this method won't return null.

Layout get handler {
 if (_handler != null)
   return _handler;

 final Layout handler = layoutManager.getLayout(type);
 if (handler == null)
   throw new UIError("Unknown type, ${type}");
 return handler;
}

void set handler(Layout layout) #

The handler for handling this layout. Instead of assigning one of standard types with type, you can assign a custom layout handler directly with this method.

void set handler(Layout layout) {
 _handler = layout;
 type = layout != null ? layoutManager.getType(layout): null;
}

String get height #

The width of each child view. It can be overriden by child view's View.profile.height.

Syntax: height: #n | content | flex | flex #n | #n %

Default: an empty string. It means content.

String get height => getPropertyValue("height");

void set height(String value) #

The width of each child view.

void set height(String value) {
 setProperty("height", value);
}

String get orient #

The orientation.

Syntax: orient: horizontal | vertical

Default: an empty string. It means horizontal.

String get orient => getPropertyValue("orient");

void set orient(String value) #

The orientation.

void set orient(String value) {
 setProperty("orient", value);
}

final Iterable<String> propertyNames #

inherited from Declaration

Returns a collection of properties that are assigned with a non-empty value.

Iterable<String> get propertyNames {
 return _props.keys;
}

String get spacing #

The spacing between two adjacent child views and between a child view and the border. It can be overriden by child view's View.profile.spacing.

Syntax: spacing: #n1 [#n2 [#n3 #n4]]

Default: an empty string. It means 8 in touch devices (i.e., Browser.touch is true), or 4 otherwise.

If the spacing at the left and at the right is different, the horizontal spacing of two adjacent views is the maximal value of them. Similarly, the vertical spacing is the maximal value of the spacing at the top and at the bottom. If you prefer a different value, specify it in gap.

String get spacing => getPropertyValue("spacing");

void set spacing(String value) #

The spacing between two adjacent child views and between a child view and the border.

void set spacing(String value) {
 setProperty("spacing", value);
}

String get text #

inherited from Declaration

The text representation of the declaration block. Setting this attribute will reset all properties.

String get text {
 final StringBuffer sb = new StringBuffer();
 for (final String key in _props.keys)
   sb..write(key)..write(':')..write(_props[key])..write(';');
 return sb.toString();
}

void set text(String text) #

inherited from Declaration

Sets the text representation of the declaration block.

void set text(String text) {
 _props.clear();

 for (String pair in _s(text).split(';')) {
   pair = pair.trim();
   if (pair.isEmpty)
     continue;
   final int j = pair.indexOf(':');
   if (j > 0) {
     final String key = pair.substring(0, j).trim();
     final String value = pair.substring(j + 1).trim();
     if (!key.isEmpty) {
       setProperty(key, value);
       continue;
     }
   }
   throw new UIError("Unknown declaration: ${pair}");
 }
}

String get type #

The type of the layout.

Syntax: type: none | linear

Default: an empty string. It means no layout required at all (i.e., none)

Notice you can plug in addition custom layouts. Refer to LayoutManager for details.

String get type => getPropertyValue("type");

void set type(String value) #

The type of the layout.

Alternatively, you can assign the layout handler directly with handler. It is useful if you'd like a view to be handled with a custom layout.

void set type(String value) {
 setProperty("type", value);
}

String get width #

The width of each child view. It can be overriden by child view's View.profile.width.

Syntax: width: #n | content | flex | flex #n | #n %

Default: an empty string. It means content.

String get width => getPropertyValue("width");

void set width(String value) #

The width of each child view.

void set width(String value) {
 setProperty("width", value);
}

Methods

String getPropertyValue(String propertyName) #

inherited from Declaration

Retrieves the property's value.

String getPropertyValue(String propertyName) {
 final String value = _props[propertyName];
 return value != null ? value: "";
}

String removeProperty(String propertyName) #

inherited from Declaration

Removes the property of the given name.

String removeProperty(String propertyName) {
 _props.remove(propertyName);
}

void setProperty(String propertyName, String value) #

inherited from Declaration

Sets the value of the given property. If the given value is null or empty, the property will be removed.

Notice: the value will be trimmed before saving.

void setProperty(String propertyName, String value) {
 if (value == null || value.isEmpty)
   removeProperty(propertyName);
 else
   _props[propertyName] = value.trim();
}