Home Reference Source
import {View} from 'arva-js/core/View.js'
public class | source

View

Extends:

famous/core/View.js~FamousView → View

An Arva View. Can be constructed explicitly by using new View() but is more commonly used as a base class for views used by the app.

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public

layout: *

public
this member was deprecated. ` The old way of setting the spec of the renderables created by adding renderables through `this.renderables.myRenderable = ....
public

A copy of the options that were passed in the constructor

public

The renderables "outputted" by the view that are passed to the underlying famous-flex layer

Method Summary

Public Methods
public

addRenderable(renderable: Renderable, renderableName: String, Decorator: Decorator): Renderable

Adds a renderable to the layout.

public

build(): void

this method was deprecated.

Deprecated, it is no longer required to call build() from within your View instances.

public

cancelRepeatFlowState(renderableName: *)

Cancel a repeating renderable.

public

Returns true if the view contains uncalculated surfaces

public

decorateRenderable(renderableName: String)

Decorates a renderable with other decorators.

public

Gets the name of a flow state of a renderable.

public

getResolvedSize(renderableOrName: Renderable/Name): *

Gets the size used when displaying a renderable on the screen the last tick

public

Gets the scroll view that was set if @layout.scrollable was used on the view

public

getSize(): *[]

getSize() is called by this view and by layoutControllers.

public

Gets the name of the flow state of a view.

public

hideRenderable(renderableName: *): Promise

Hides a renderable that has been declared with @layout.animate

public

onNewSize(callback: Function)

Passes a callback that gets called every time the context size changes.

public

Gets a (new) context size of the view.

public

prioritiseDockAfter(renderableName: String, prevRenderableName: String): *

public

prioritiseDockBefore(renderableName: String, nextRenderableName: String): *

Rearranges the order in which docked renderables are parsed for rendering, ensuring that 'renderableName' is processed before 'nextRenderableName'.

public

Reflows the layout while also informing any subscribing parents that a reflow has to take place

public

removeRenderable(renderableName: String)

Removes the renderable from the view

public

repeatFlowState(renderableName: *, stateName: *): Promise

Repeat a certain flowState indefinitely

public

replaceRenderable(newRenderable: *)

Replaces an existing decorated renderable with a new renderable, preserving all necessary state and decorations

public

setDefaultState(renderableName: *, stateName: *)

Initiate a renderable to a default flow state.

public

Sets a renderable flow state as declared in the @flow.stateStep, or @flow.defaultState

public

Sets a renderable flow state as declared in the @flow.viewState

public

showRenderable(renderableName: String): Promise

Public Constructors

public constructor source

Params:

NameTypeAttributeDescription
options. Object

The options passed to the view will be stored in this.options, but won't change any behaviour of the core functionality of the view. Instead, configuration of the View is done by decorators.

Example:

HomeController extends Controller {
     Index() {
         let view = new View();
         view.add(new Surface({properties: {backgroundColor: 'red'}}));
         return view
     }
}
class HomeView extends View {
     @layout.size(100, 100)
     @layout.place.center()
     mySurface = new Surface({properties: {backgroundColor: 'red'}})
}

Public Members

public decorations: * source

public layout: * source

public layouts: Array | Function source

this member was deprecated. ` The old way of setting the spec of the renderables created by adding renderables through `this.renderables.myRenderable = ....

public options: Object source

A copy of the options that were passed in the constructor

public renderables: Object source

The renderables "outputted" by the view that are passed to the underlying famous-flex layer

Public Methods

public addRenderable(renderable: Renderable, renderableName: String, Decorator: Decorator): Renderable source

Adds a renderable to the layout.

Params:

NameTypeAttributeDescription
renderable Renderable

The renderable to be added

renderableName String

The name (key) of the renderable

Decorator Decorator

Any decorator(s) to apply to the renderable

Return:

Renderable

The renderable that was assigned

public build(): void source

this method was deprecated.

Deprecated, it is no longer required to call build() from within your View instances.

Return:

void

public cancelRepeatFlowState(renderableName: *) source

Cancel a repeating renderable. This will cancel the animation for next flow-cycle, it won't interject the current animation cycle.

Params:

NameTypeAttributeDescription
renderableName *

public containsUncalculatedSurfaces(): Boolean source

Returns true if the view contains uncalculated surfaces

Return:

Boolean

public decorateRenderable(renderableName: String) source

Decorates a renderable with other decorators. Using the same decorators as used previously will override the old ones.

Params:

NameTypeAttributeDescription
renderableName String

The name of the renderable

...decorators *

The decorators that should be applied

Example:

this.decorateRenderable('myRenderable',layout.size(100, 100));

public getRenderableFlowState(renderableName: String): String source

Gets the name of a flow state of a renderable.

Params:

NameTypeAttributeDescription
renderableName String

the name of the renderable of which the flow state is concerned

Return:

String

stateName the name of the state that the renderable is in

public getResolvedSize(renderableOrName: Renderable/Name): * source

Gets the size used when displaying a renderable on the screen the last tick

Params:

NameTypeAttributeDescription
renderableOrName Renderable/Name

The renderable or the name of the renderable of which you need the size

Return:

*

public getScrollView(): ReflowingScrollView source

Gets the scroll view that was set if @layout.scrollable was used on the view

public getSize(): *[] source

getSize() is called by this view and by layoutControllers. For lazy people that don't want to specifiy their own getSize() function, we provide a fallback. This function can be performance expensive when using non-docked renderables, but for docked renderables it is efficient and convenient]

Return:

*[]

public getViewFlowState(): String source

Gets the name of the flow state of a view.

Return:

String

stateName the name of the state that this view is in.

public hideRenderable(renderableName: *): Promise source

Hides a renderable that has been declared with @layout.animate

Params:

NameTypeAttributeDescription
renderableName *

Return:

Promise

when the renderable has finished its animation

public onNewSize(callback: Function) source

Passes a callback that gets called every time the context size changes.

Params:

NameTypeAttributeDescription
callback Function

a callback with arguments (width, height)

public onceNewSize(): Promise source

Gets a (new) context size of the view. This will always happen at least once immediately after the view is constructed. Hence, it can safely be used in the constructor to get the (initial) size of the view.

Return:

Promise

Resolves when there's a new size

Example:

constructor(options){
 super(options);
 onceNewSize.then((width, height) => {
     console.log(width, height);
 });
}

public prioritiseDockAfter(renderableName: String, prevRenderableName: String): * source

Params:

NameTypeAttributeDescription
renderableName String
prevRenderableName String

Return:

*

public prioritiseDockBefore(renderableName: String, nextRenderableName: String): * source

Rearranges the order in which docked renderables are parsed for rendering, ensuring that 'renderableName' is processed before 'nextRenderableName'.

Params:

NameTypeAttributeDescription
renderableName String
nextRenderableName String

Return:

*

public reflowRecursively() source

Reflows the layout while also informing any subscribing parents that a reflow has to take place

public removeRenderable(renderableName: String) source

Removes the renderable from the view

Params:

NameTypeAttributeDescription
renderableName String

The name of the renderable

public repeatFlowState(renderableName: *, stateName: *): Promise source

Repeat a certain flowState indefinitely

Params:

NameTypeAttributeDescription
renderableName *
stateName *
persistent. Boolean

If true, then it will keep on repeating until explicitly cancelled by cancelRepeatFlowState. If false, it will be interrupted automatically by any interrput to another state. Defaults to true

Return:

Promise

resolves to false if the flow state can't be repeated due to an existing running repeat

public replaceRenderable(newRenderable: *) source

Replaces an existing decorated renderable with a new renderable, preserving all necessary state and decorations

Params:

NameTypeAttributeDescription
renderableName. String

The name of the renderable

newRenderable *

public setDefaultState(renderableName: *, stateName: *) source

Initiate a renderable to a default flow state.

Params:

NameTypeAttributeDescription
renderableName *
stateName *

public setRenderableFlowState(): * source

Sets a renderable flow state as declared in the @flow.stateStep, or @flow.defaultState

Params:

NameTypeAttributeDescription
renderableName. String

The name of the renderable

stateName. String

The name of the state as declared in the first argument of the decorator

Return:

*

public setViewFlowState(): * source

Sets a renderable flow state as declared in the @flow.viewState

Params:

NameTypeAttributeDescription
renderableName. String

The name of the renderable

stateName. String

The name of the state as declared in the first argument of the decorator

Return:

*

public showRenderable(renderableName: String): Promise source

Params:

NameTypeAttributeDescription
renderableName String
show. Boolean

Whether to show or not

Return:

Promise

when the renderable has finished its animation