mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
tabs wip
This commit is contained in:
@@ -74,22 +74,22 @@ export class NavRouter extends RouterOutlet {
|
||||
// viewCtrl is Ionic's ViewController class, which has the properties "componentType" and "params"
|
||||
|
||||
// only do an update if there's an actual view change
|
||||
if (!viewCtrl || this._activeViewId === viewCtrl.id) return;
|
||||
this._activeViewId = viewCtrl.id;
|
||||
// if (!viewCtrl || this._activeViewId === viewCtrl.id) return;
|
||||
// this._activeViewId = viewCtrl.id;
|
||||
|
||||
// get the best PathRecognizer for this view's componentType
|
||||
let pathRecognizer = this.getPathRecognizerByComponent(viewCtrl.componentType);
|
||||
if (pathRecognizer) {
|
||||
// // get the best PathRecognizer for this view's componentType
|
||||
// let pathRecognizer = this.getPathRecognizerByComponent(viewCtrl.componentType);
|
||||
// if (pathRecognizer) {
|
||||
|
||||
// generate a componentInstruction from the view's PathRecognizer and params
|
||||
let componentInstruction = pathRecognizer.generate(viewCtrl.params.data);
|
||||
// // generate a componentInstruction from the view's PathRecognizer and params
|
||||
// let componentInstruction = pathRecognizer.generate(viewCtrl.params.data);
|
||||
|
||||
// create an Instruction from the componentInstruction
|
||||
let instruction = new Instruction(componentInstruction, null);
|
||||
// // create an Instruction from the componentInstruction
|
||||
// let instruction = new Instruction(componentInstruction, null);
|
||||
|
||||
// update the browser's URL
|
||||
this._parentRouter.navigateInstruction(instruction);
|
||||
}
|
||||
// // update the browser's URL
|
||||
// this._parentRouter.navigateInstruction(instruction);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -181,12 +181,12 @@ export class Nav extends NavController {
|
||||
// this gets or creates the Pane which similar nav items live in
|
||||
// Nav items with just a navbar/content would all use the same Pane
|
||||
// Tabs and view's without a navbar would get a different Panes
|
||||
let structure = this.inspectStructure(hostProtoViewRef);
|
||||
let structure = this.getStructure(hostProtoViewRef);
|
||||
|
||||
if (structure.tabs) {
|
||||
// the component being loaded is an <ion-tabs>
|
||||
// Tabs is essentially a pane, cuz it has its own navbar and content containers
|
||||
let contentContainerRef = this.viewMngr.getViewContainer(this.anchorElementRef());
|
||||
let contentContainerRef = this._viewManager.getViewContainer(this.anchorElementRef());
|
||||
let viewComponetRef = this.createViewComponetRef(componentType, hostProtoViewRef, contentContainerRef, this.getBindings(viewCtrl));
|
||||
viewComponetRef.instance._paneView = true;
|
||||
|
||||
@@ -308,32 +308,40 @@ export class Nav extends NavController {
|
||||
* @param {TODO} componentProtoViewRef TODO
|
||||
* @return {TODO} TODO
|
||||
*/
|
||||
inspectStructure(componentProtoViewRef) {
|
||||
let navbar = false;
|
||||
let tabs = false;
|
||||
let key = '_';
|
||||
getStructure(componentProtoViewRef) {
|
||||
let templateCmds = componentProtoViewRef._protoView.templateCmds;
|
||||
let compiledTemplateData, directives;
|
||||
let i, ii, j, jj, k, kk;
|
||||
|
||||
componentProtoViewRef._protoView.elementBinders.forEach(rootElementBinder => {
|
||||
if (!rootElementBinder.componentDirective || !rootElementBinder.nestedProtoView) return;
|
||||
for (i = 0, ii = templateCmds.length; i < ii; i++) {
|
||||
if (templateCmds[i].template) {
|
||||
compiledTemplateData = templateCmds[i].template.getData(templateCmds[i].templateId);
|
||||
if (compiledTemplateData) {
|
||||
for (j = 0, jj = compiledTemplateData.commands.length; j < jj; j++) {
|
||||
directives = compiledTemplateData.commands[j].directives;
|
||||
|
||||
if (directives && (kk = directives.length)) {
|
||||
|
||||
for (k = 0; k < kk; k++) {
|
||||
|
||||
if (directives[k].name == 'NavbarTemplate') {
|
||||
return { navbar: true };
|
||||
}
|
||||
|
||||
if (directives[k].name == 'Tabs') {
|
||||
return { tabs: true };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
rootElementBinder.nestedProtoView.elementBinders.forEach(nestedElementBinder => {
|
||||
if ( isComponent(nestedElementBinder, 'Tabs') ) {
|
||||
tabs = true;
|
||||
}
|
||||
if (!nestedElementBinder.componentDirective && nestedElementBinder.nestedProtoView) {
|
||||
nestedElementBinder.nestedProtoView.elementBinders.forEach(templatedElementBinder => {
|
||||
if ( isComponent(templatedElementBinder, 'Navbar') ) {
|
||||
navbar = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
navbar,
|
||||
tabs
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ class Tab3Page1 {}
|
||||
|
||||
@App()
|
||||
@RouteConfig([
|
||||
{ path: '/', component: SignIn, as: 'signin' },
|
||||
{ path: '/tabs', component: TabsPage, as: 'tabs' },
|
||||
{ path: '/', component: SignIn, as: 'Signin' },
|
||||
{ path: '/tabs', component: TabsPage, as: 'Tabs' },
|
||||
])
|
||||
class E2EApp {}
|
||||
|
||||
Reference in New Issue
Block a user