chore(navbar): rename nav-bar files to navbar

This commit is contained in:
Adam Bradley
2015-11-02 16:52:52 -06:00
parent e0645daab4
commit c19fcd5bed
12 changed files with 10 additions and 10 deletions

View File

@@ -0,0 +1,14 @@
// iOS Navbar
// --------------------------------------------------
$navbar-ios-height: 4.4rem !default;
ion-navbar-section {
min-height: $navbar-ios-height;
}
.back-button {
transform: translateZ(0px);
}

View File

@@ -0,0 +1,23 @@
// Material Design Navbar
// --------------------------------------------------
$navbar-md-height: 5.6rem !default;
ion-navbar-section {
min-height: $navbar-md-height;
}
.toolbar .back-button {
margin: 0 0 0 12px;
box-shadow: none;
}
.toolbar .back-button-icon {
margin: 0;
min-width: 44px;
font-size: 2.4rem;
font-weight: normal;
text-align: left;
}

View File

@@ -0,0 +1,22 @@
// Navbar
// --------------------------------------------------
ion-navbar.toolbar {
display: flex;
}
.back-button {
order: map-get($toolbar-order, backButton);
display: none;
&.show-back-button {
display: flex;
}
}
.back-button-text {
display: flex;
align-items: center;
}

View File

@@ -0,0 +1,147 @@
import {Component, Directive, Optional, ElementRef, Renderer, TemplateRef, forwardRef, Inject, ViewContainerRef} from 'angular2/angular2';
import {Ion} from '../ion';
import {Icon} from '../icon/icon';
import {ToolbarBase} from '../toolbar/toolbar';
import {Config} from '../../config/config';
import {Page} from '../../config/decorators';
import {IonicApp} from '../app/app';
import {ViewController} from '../nav/view-controller';
import {NavController} from '../nav/nav-controller';
@Directive({
selector: '.back-button',
host: {
'(click)': 'goBack($event)'
}
})
class BackButton extends Ion {
constructor(
@Optional() navCtrl: NavController,
elementRef: ElementRef,
@Optional() @Inject(forwardRef(() => Navbar)) navbar: Navbar
) {
super(elementRef, null);
this.navCtrl = navCtrl;
navbar && navbar.setBackButtonRef(elementRef);
}
goBack(ev) {
ev.stopPropagation();
ev.preventDefault();
this.navCtrl && this.navCtrl.pop();
}
}
@Directive({
selector: '.back-button-text'
})
class BackButtonText extends Ion {
constructor(
elementRef: ElementRef,
@Optional() @Inject(forwardRef(() => Navbar)) navbar: Navbar
) {
super(elementRef, null);
navbar && navbar.setBackButtonTextRef(elementRef);
}
}
@Component({
selector: 'ion-navbar',
template:
'<div class="toolbar-inner">' +
'<button class="back-button" [hidden]="hideBackButton">' +
'<icon class="back-button-icon" [name]="bbIcon"></icon>' +
'<span class="back-button-text">' +
'<span class="back-default">{{bbDefault}}</span>' +
'</span>' +
'</button>' +
'<ng-content select="[menu-toggle]"></ng-content>' +
'<ng-content select="ion-title"></ng-content>' +
'<ng-content select="ion-nav-items[primary]"></ng-content>' +
'<ng-content select="ion-nav-items[secondary]"></ng-content>' +
'</div>' +
'<div class="toolbar-background"></div>',
host: {
'[hidden]': '_hidden'
},
inputs: [
'hideBackButton'
],
directives: [BackButton, BackButtonText, Icon]
})
export class Navbar extends ToolbarBase {
constructor(
app: IonicApp,
@Optional() viewCtrl: ViewController,
elementRef: ElementRef,
config: Config,
renderer: Renderer
) {
super(elementRef, config);
renderer.setElementClass(elementRef, 'toolbar', true);
this.app = app;
viewCtrl && viewCtrl.setNavbar(this);
this.bbIcon = config.get('backButtonIcon');
this.bbDefault = config.get('backButtonText');
}
onInit() {
let hideBackButton = this.hideBackButton;
if (typeof hideBackButton === 'string') {
this.hideBackButton = (hideBackButton === '' || hideBackButton === 'true');
}
}
getBackButtonRef() {
return this.bbRef;
}
setBackButtonRef(backButtonElementRef) {
this.bbRef = backButtonElementRef;
}
getBackButtonTextRef() {
return this.bbtRef;
}
setBackButtonTextRef(backButtonTextElementRef) {
this.bbtRef = backButtonTextElementRef;
}
didEnter() {
this.app.setTitle(this.getTitleText());
}
setHidden(isHidden) {
this._hidden = isHidden
}
}
/*
Used to find and register headers in a view, and this directive's
content will be moved up to the common navbar location, and created
using the same context as the view's content area.
*/
@Directive({
selector: 'template[navbar]'
})
export class NavbarTemplate {
constructor(
viewContainerRef: ViewContainerRef,
templateRef: TemplateRef,
@Optional() viewCtrl: ViewController
) {
if (viewCtrl) {
viewCtrl.setNavbarTemplateRef(templateRef);
viewCtrl.setNavbarViewRef(viewContainerRef);
}
}
}