From 9ddcc44f67771508ac13307c3f8b948cf83d5109 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Wed, 11 Nov 2015 11:27:08 -0600 Subject: [PATCH] refactor(toolbar): allow any content in the center --- ionic/components/nav/view-controller.ts | 37 +----------- ionic/components/navbar/navbar.ts | 58 +++++++++++++------ ionic/components/segment/modes/md.scss | 1 - ionic/components/tabs/test/basic/index.ts | 8 ++- ionic/components/tabs/test/ghost/e2e.ts | 1 - ionic/components/tap-click/tap-click.ts | 2 +- ionic/components/toolbar/modes/ios.scss | 4 +- .../toolbar/test/scenarios/main.html | 31 ++++++++-- ionic/components/toolbar/toolbar.scss | 19 +++--- ionic/components/toolbar/toolbar.ts | 14 ++--- ionic/config/modes.ts | 2 +- ionic/ionic.core.scss | 4 -- ionic/ionic.ios.scss | 3 +- ionic/platform/cordova-ios.scss | 23 ++++++++ ionic/platform/cordova.scss | 21 ------- ionic/platform/registry.ts | 31 +++++----- 16 files changed, 135 insertions(+), 124 deletions(-) delete mode 100644 ionic/components/tabs/test/ghost/e2e.ts create mode 100644 ionic/platform/cordova-ios.scss delete mode 100644 ionic/platform/cordova.scss diff --git a/ionic/components/nav/view-controller.ts b/ionic/components/nav/view-controller.ts index 02470fa1d3..3de4aa5ed7 100644 --- a/ionic/components/nav/view-controller.ts +++ b/ionic/components/nav/view-controller.ts @@ -30,10 +30,6 @@ export class ViewController { return false; } - /** - * TODO - * @param {TODO} instance TODO - */ setInstance(instance) { this.instance = instance; } @@ -50,9 +46,6 @@ export class ViewController { this._destroys.push(destroyFn); } - /** - * TODO - */ destroy() { for (let i = 0; i < this._destroys.length; i++) { this._destroys[i](); @@ -108,66 +101,38 @@ export class ViewController { return this._nbDir; } - /** - * TODO - * @returns {TODO} TODO - */ hasNavbar() { return !!this.getNavbar(); } - /** - * TODO - * @returns {TODO} TODO - */ navbarRef() { let navbar = this.getNavbar(); return navbar && navbar.getElementRef(); } - /** - * TODO - * @returns {TODO} TODO - */ titleRef() { let navbar = this.getNavbar(); return navbar && navbar.getTitleRef(); } - /** - * TODO - * @returns {TODO} TODO - */ navbarItemRefs() { let navbar = this.getNavbar(); return navbar && navbar.getItemRefs(); } - /** - * TODO - * @returns {TODO} TODO - */ backBtnRef() { let navbar = this.getNavbar(); return navbar && navbar.getBackButtonRef(); } - /** - * TODO - * @returns {TODO} TODO - */ backBtnTextRef() { let navbar = this.getNavbar(); return navbar && navbar.getBackButtonTextRef(); } - /** - * TODO - * @returns {TODO} TODO - */ navbarBgRef() { let navbar = this.getNavbar(); - return navbar && navbar.getNativeElement().querySelector('.toolbar-background'); + return navbar && navbar.getBackgroundRef(); } hideBackButton(shouldHide) { diff --git a/ionic/components/navbar/navbar.ts b/ionic/components/navbar/navbar.ts index 425ab07c7a..6f54900dd4 100644 --- a/ionic/components/navbar/navbar.ts +++ b/ionic/components/navbar/navbar.ts @@ -38,13 +38,25 @@ class BackButton extends Ion { @Directive({ selector: '.back-button-text' }) -class BackButtonText extends Ion { +class BackButtonText { constructor( elementRef: ElementRef, - @Optional() @Inject(forwardRef(() => Navbar)) navbar: Navbar + @Inject(forwardRef(() => Navbar)) navbar: Navbar ) { - super(elementRef, null); - navbar && navbar.setBackButtonTextRef(elementRef); + navbar.setBackButtonTextRef(elementRef); + } +} + + +@Directive({ + selector: 'toolbar-background' +}) +class ToolbarBackground { + constructor( + elementRef: ElementRef, + @Inject(forwardRef(() => Navbar)) navbar: Navbar + ) { + navbar.setBackgroundRef(elementRef); } } @@ -52,19 +64,19 @@ class BackButtonText extends Ion { @Component({ selector: 'ion-navbar', template: - '
' + - '' + - '' + - '' + - '' + - '' + - '
' + - '
', + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '', host: { '[hidden]': '_hidden' }, @@ -72,7 +84,7 @@ class BackButtonText extends Ion { 'hideBackButton', 'navbarStyle' ], - directives: [BackButton, BackButtonText, Icon] + directives: [BackButton, BackButtonText, Icon, ToolbarBackground] }) export class Navbar extends ToolbarBase { constructor( @@ -105,7 +117,7 @@ export class Navbar extends ToolbarBase { if (typeof hideBackButton === 'string') { this.hideBackButton = (hideBackButton === '' || hideBackButton === 'true'); } - + if (this.navbarStyle) { this.renderer.setElementAttribute(this.elementRef, this.navbarStyle, ''); } @@ -127,6 +139,14 @@ export class Navbar extends ToolbarBase { this.bbtRef = backButtonTextElementRef; } + setBackgroundRef(backgrouneElementRef) { + this.bgRef = backgrouneElementRef; + } + + getBackgroundRef() { + return this.bgRef; + } + didEnter() { this.app.setTitle(this.getTitleText()); } diff --git a/ionic/components/segment/modes/md.scss b/ionic/components/segment/modes/md.scss index b201f690c3..cf7e4d37d1 100644 --- a/ionic/components/segment/modes/md.scss +++ b/ionic/components/segment/modes/md.scss @@ -38,7 +38,6 @@ ion-segment { .toolbar { ion-segment { - width: 95%; margin: 0 auto; } diff --git a/ionic/components/tabs/test/basic/index.ts b/ionic/components/tabs/test/basic/index.ts index f144c2393f..ba372eacaa 100644 --- a/ionic/components/tabs/test/basic/index.ts +++ b/ionic/components/tabs/test/basic/index.ts @@ -99,12 +99,16 @@ class Tab3 {} - + - ` + `, + config: { + navbarStyle: 'secondary', + tabbarStyle: 'secondary' + } }) export class TabsPage { constructor() { diff --git a/ionic/components/tabs/test/ghost/e2e.ts b/ionic/components/tabs/test/ghost/e2e.ts deleted file mode 100644 index 8b13789179..0000000000 --- a/ionic/components/tabs/test/ghost/e2e.ts +++ /dev/null @@ -1 +0,0 @@ - diff --git a/ionic/components/tap-click/tap-click.ts b/ionic/components/tap-click/tap-click.ts index e4c87542d2..eeabd463e3 100644 --- a/ionic/components/tap-click/tap-click.ts +++ b/ionic/components/tap-click/tap-click.ts @@ -25,7 +25,7 @@ export function initTapClick(windowInstance, documentInstance, appInstance, conf activator = new RippleActivator(app, config, fastdom); } else if (config.get('activator') == 'highlight') { - activator = new Activator(app, config, fastdom)); + activator = new Activator(app, config, fastdom); } isTapPolyfill = (config.get('tapPolyfill') === true); diff --git a/ionic/components/toolbar/modes/ios.scss b/ionic/components/toolbar/modes/ios.scss index f1b10aa69e..52f87ac4bf 100644 --- a/ionic/components/toolbar/modes/ios.scss +++ b/ionic/components/toolbar/modes/ios.scss @@ -71,7 +71,7 @@ $toolbar-ios-title-font-size: 1.7rem !default; } -.toolbar .toolbar-background { +.toolbar toolbar-background { border-bottom-width: 1px; border-bottom-style: solid; } @@ -105,6 +105,6 @@ ion-nav-items[secondary] { order: map-get($toolbar-order-ios, secondary); } -&.hairlines .toolbar .toolbar-background { +&.hairlines .toolbar toolbar-background { border-bottom-width: 0.55px; } diff --git a/ionic/components/toolbar/test/scenarios/main.html b/ionic/components/toolbar/test/scenarios/main.html index 7467222d5e..1500da91e4 100644 --- a/ionic/components/toolbar/test/scenarios/main.html +++ b/ionic/components/toolbar/test/scenarios/main.html @@ -1,9 +1,6 @@ - - - - menu-toggle left. This is the title that never ends. It just goes on and on my friend. + This is the title that never ends. It just goes on and on my friend. @@ -168,6 +165,32 @@ + + + + + + + + Left side menu toggle + + + + + + + + Right side menu toggle + + + + + +