toolbar kinda workin

This commit is contained in:
Adam Bradley
2015-05-13 11:56:35 -05:00
parent 62aafe43af
commit 533cb12559
3 changed files with 29 additions and 14 deletions

View File

@@ -13,24 +13,25 @@ export class NavItem {
this.params = params;
this.id = util.nextUid();
this.headers = [];
this.created = false;
}
setup() {
if (!this.created) {
return this.create();
}
return Promise.resolve();
}
create() {
this.created = true;
let resolve;
let promise = new Promise((res) => { resolve = res; });
let injector = this.nav.injector.resolveAndCreateChild([
bind(NavController).toValue(this.nav.navCtrl),
bind(NavParams).toValue(new NavParams(this.params))
bind(NavParams).toValue(new NavParams(this.params)),
bind(NavItem).toValue(this)
]);
this.nav.loader.loadNextToExistingLocation(this.Class, this.nav.itemContent.elementRef, injector).then((componentRef) => {
@@ -41,21 +42,26 @@ export class NavItem {
this.domElement.classList.add('nav-item');
this.domElement.setAttribute('data-nav-item-id', this.id);
this.created = true;
for (let i = 0; i < this.headers.length; i++) {
this.createToolbar(this.headers[i], injector);
}
resolve();
});
// let vc = new ViewContainerRef(this.nav.viewManager, this.nav.elementRef);
// debugger
// let view = vc.create(this.Class, -1, this.nav.itemContent.elementRef, injector);
return promise;
}
createToolbar(ToolbarClass, injector) {
let vc = new ViewContainerRef(this.nav.viewManager, this.nav.itemHeader.elementRef);
let protoViewRef = ToolbarClass.protoViewRef;
let view = vc.create(protoViewRef, -1, this.nav.itemHeader.elementRef, injector);
}
addToolbar(position, toolbar) {
headers.push(toolbar);
this.headers.push(toolbar);
}
destroy() {

View File

@@ -1,6 +1,7 @@
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
import {ElementRef} from 'angular2/src/core/compiler/element_ref';
import {ViewContainerRef} from 'angular2/angular2';
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
import {ProtoViewRef} from 'angular2/src/core/compiler/view_ref';
import * as dom from 'ionic/util/dom'
import {IonicComponent} from 'ionic/config/component';
@@ -17,11 +18,13 @@ import {Platform} from 'ionic/platform/platform';
export class Toolbar {
constructor(
viewContainer: ViewContainerRef,
viewContainerRef: ViewContainerRef,
protoViewRef: ProtoViewRef,
elementRef: ElementRef,
navItem: NavItem
) {
this.viewContainer = viewContainer;
this.viewContainerRef = viewContainerRef;
this.protoViewRef = protoViewRef;
this.elementRef = elementRef;
this.navItem = navItem;

View File

@@ -1,4 +1,10 @@
/// HACK
header {
background: white;
}
// Toolbar
// --------------------------------------------------