mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
chore(navbar): rename nav-bar files to navbar
This commit is contained in:
14
ionic/components/navbar/modes/ios.scss
Normal file
14
ionic/components/navbar/modes/ios.scss
Normal 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);
|
||||
}
|
||||
23
ionic/components/navbar/modes/md.scss
Normal file
23
ionic/components/navbar/modes/md.scss
Normal 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;
|
||||
}
|
||||
22
ionic/components/navbar/navbar.scss
Normal file
22
ionic/components/navbar/navbar.scss
Normal 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;
|
||||
}
|
||||
147
ionic/components/navbar/navbar.ts
Normal file
147
ionic/components/navbar/navbar.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user