Top
craft-uikit
craft-widget-

DefaultViewController

DefaultViewController

Default ViewContoller.

Supports:

  • Tap event (can be listen via NotificationCenter by name of 'ContentTapped')
  • Automatically register this to the appended Component
  • Width and height fit to the viewport

Constructor

new DefaultViewController()

Source:

DefaultViewController Constructor

Example
class PageController extends Craft.UI.DefaultViewController {
    constructor(){
        super();
        this.tags = '';
        this.items = '';
    }
    viewDidLoad(callback){
        this.appendView(new Header());
        this.appendView(new Container());
        this.appendView(new Footer());
    }
    style(componentId){
        return `
            * { box-sizing:border-box; margin:0; padding:0; }
            .root { display:flex; flex-direction:column; width:75%; margin-left:auto; margin-right:auto; }
        `;
    }
    template(componentId){
        return `<div id="root" class="root"></div>`;
    }
}

Classes

DefaultViewController

Methods

viewDidLoad(callback)

Source:

overriding viewDidLoad with 'ContentTapped' event on this.view

When you override this method, you have to call super.viewDidLoad() at the start of yours,
and you have to call callback at the end of yours.
But if you don't want to enable 'ContentTapped' event, don't call super.viewDidLoad.

Example
viewDidLoad(callback){
    super.viewDidLoad();
    // your original logic
    if(callback){ callback(); }
}
Parameters:
Name Type Description
callback function

callback

(protected) enableContentTapped()

Source:

Append 'ContentTapped' event on this.view

appendSubView(options)

Source:

ovverride appendView: with viewController cascading

Parameters:
Name Type Description
options Object

options|component

Properties
Name Type Description
component Craft.Core.Component

component (auto setViewController)

(protected) style()

Source:

style

(protected) template()

Source:

template