Merge branch 'master' into list-border-refactor

Conflicts:
	ionic/components/tabs/test/basic/index.ts
This commit is contained in:
Brandy Carney
2015-11-06 15:43:12 -05:00
20 changed files with 248 additions and 36 deletions

View File

@ -20,7 +20,7 @@ $font-path: '../../dist/fonts';
body, body:hover, body a, body button, body media-switch { body, body:hover, body a, body button, body media-switch {
cursor: url('http://ionicframework.com/img/finger.png'), auto; cursor: url('http://ionicframework.com/img/finger.png') 8 8, auto;
} }
body ion-app { body ion-app {

View File

@ -3,7 +3,7 @@ import {forwardRef} from 'angular2/angular2';
import {AndroidAttribute} from '../../helpers'; import {AndroidAttribute} from '../../helpers';
@Page({ @Page({
templateUrl: 'buttons/block.html', templateUrl: 'buttons/block/block.html',
directives: [forwardRef(() => AndroidAttribute)] directives: [forwardRef(() => AndroidAttribute)]
}) })
export class BlockPage { export class BlockPage {

View File

@ -3,7 +3,7 @@ import {forwardRef} from 'angular2/angular2';
import {AndroidAttribute} from '../../helpers'; import {AndroidAttribute} from '../../helpers';
@Page({ @Page({
templateUrl: 'buttons/clear.html', templateUrl: 'buttons/clear/clear.html',
directives: [forwardRef(() => AndroidAttribute)] directives: [forwardRef(() => AndroidAttribute)]
}) })
export class ClearPage { export class ClearPage {

View File

@ -3,7 +3,7 @@ import {forwardRef} from 'angular2/angular2';
import {AndroidAttribute} from '../../helpers'; import {AndroidAttribute} from '../../helpers';
@Page({ @Page({
templateUrl: 'buttons/components.html', templateUrl: 'buttons/components/components.html',
directives: [forwardRef(() => AndroidAttribute)] directives: [forwardRef(() => AndroidAttribute)]
}) })
export class ComponentsPage { export class ComponentsPage {

View File

@ -3,7 +3,7 @@ import {forwardRef} from 'angular2/angular2';
import {AndroidAttribute} from '../../helpers'; import {AndroidAttribute} from '../../helpers';
@Page({ @Page({
templateUrl: 'buttons/fab.html', templateUrl: 'buttons/fab/fab.html',
directives: [forwardRef(() => AndroidAttribute)] directives: [forwardRef(() => AndroidAttribute)]
}) })
export class FabPage { export class FabPage {

View File

@ -3,7 +3,7 @@ import {forwardRef} from 'angular2/angular2';
import {AndroidAttribute} from '../../helpers'; import {AndroidAttribute} from '../../helpers';
@Page({ @Page({
templateUrl: 'buttons/full.html', templateUrl: 'buttons/full/full.html',
directives: [forwardRef(() => AndroidAttribute)] directives: [forwardRef(() => AndroidAttribute)]
}) })
export class FullPage { export class FullPage {

View File

@ -3,7 +3,7 @@ import {forwardRef} from 'angular2/angular2';
import {AndroidAttribute} from '../../helpers'; import {AndroidAttribute} from '../../helpers';
@Page({ @Page({
templateUrl: 'buttons/icons.html', templateUrl: 'buttons/icons/icons.html',
directives: [forwardRef(() => AndroidAttribute)] directives: [forwardRef(() => AndroidAttribute)]
}) })
export class IconsPage { export class IconsPage {

View File

@ -3,7 +3,7 @@ import {forwardRef} from 'angular2/angular2';
import {AndroidAttribute} from '../../helpers'; import {AndroidAttribute} from '../../helpers';
@Page({ @Page({
templateUrl: 'buttons/outline.html', templateUrl: 'buttons/outline/outline.html',
directives: [forwardRef(() => AndroidAttribute)] directives: [forwardRef(() => AndroidAttribute)]
}) })
export class OutlinePage { export class OutlinePage {

View File

@ -3,7 +3,7 @@ import {forwardRef} from 'angular2/angular2';
import {AndroidAttribute} from '../../helpers'; import {AndroidAttribute} from '../../helpers';
@Page({ @Page({
templateUrl: 'buttons/round.html', templateUrl: 'buttons/round/round.html',
directives: [forwardRef(() => AndroidAttribute)] directives: [forwardRef(() => AndroidAttribute)]
}) })
export class RoundPage { export class RoundPage {

View File

@ -3,7 +3,7 @@ import {forwardRef} from 'angular2/angular2';
import {AndroidAttribute} from '../../helpers'; import {AndroidAttribute} from '../../helpers';
@Page({ @Page({
templateUrl: 'buttons/sizes.html', templateUrl: 'buttons/sizes/sizes.html',
directives: [forwardRef(() => AndroidAttribute)] directives: [forwardRef(() => AndroidAttribute)]
}) })
export class SizesPage { export class SizesPage {

View File

@ -94,10 +94,10 @@ export class Animation {
} }
add(childAnimations) { add(childAnimations) {
childAnimations = Array.isArray(childAnimations) ? childAnimations : arguments; var _childAnimations = Array.isArray(childAnimations) ? childAnimations : arguments;
for (let i = 0; i < childAnimations.length; i++) { for (let i = 0; i < _childAnimations.length; i++) {
childAnimations[i].parent(this); _childAnimations[i].parent(this);
this._chld.push(childAnimations[i]); this._chld.push(_childAnimations[i]);
} }
return this; return this;
} }

View File

@ -1,4 +1,4 @@
import {AppViewManager, ElementRef, Directive} from 'angular2/angular2'; import {AppViewManager, ElementRef, Directive, Renderer} from 'angular2/angular2';
import {IonicApp} from './app'; import {IonicApp} from './app';
@ -47,3 +47,15 @@ export class IdRef {
this.app.unregister(this.id); this.app.unregister(this.id);
} }
} }
@Directive({
selector: '[attr]',
inputs: ['attr']
})
export class Attr {
constructor(private renderer: Renderer, private elementRef: ElementRef) {}
onInit() {
this.renderer.setElementAttribute(this.elementRef, this.attr, '');
}
}

View File

@ -69,7 +69,8 @@ class BackButtonText extends Ion {
'[hidden]': '_hidden' '[hidden]': '_hidden'
}, },
inputs: [ inputs: [
'hideBackButton' 'hideBackButton',
'navbarStyle'
], ],
directives: [BackButton, BackButtonText, Icon] directives: [BackButton, BackButtonText, Icon]
}) })
@ -82,9 +83,16 @@ export class Navbar extends ToolbarBase {
renderer: Renderer renderer: Renderer
) { ) {
super(elementRef, config); super(elementRef, config);
this.app = app;
this.renderer = renderer;
renderer.setElementClass(elementRef, 'toolbar', true); renderer.setElementClass(elementRef, 'toolbar', true);
this.app = app; let navbarStyle = config.get('navbarStyle');
if (navbarStyle) {
renderer.setElementAttribute(elementRef, navbarStyle, '');
}
viewCtrl && viewCtrl.setNavbar(this); viewCtrl && viewCtrl.setNavbar(this);
this.bbIcon = config.get('backButtonIcon'); this.bbIcon = config.get('backButtonIcon');
@ -92,10 +100,15 @@ export class Navbar extends ToolbarBase {
} }
onInit() { onInit() {
super.onInit();
let hideBackButton = this.hideBackButton; let hideBackButton = this.hideBackButton;
if (typeof hideBackButton === 'string') { if (typeof hideBackButton === 'string') {
this.hideBackButton = (hideBackButton === '' || hideBackButton === 'true'); this.hideBackButton = (hideBackButton === '' || hideBackButton === 'true');
} }
if (this.navbarStyle) {
this.renderer.setElementAttribute(this.elementRef, this.navbarStyle, '');
}
} }
getBackButtonRef() { getBackButtonRef() {

View File

@ -88,3 +88,11 @@ ion-tabs[tabbar-placement=top] tabbar {
} }
} }
@each $color-name, $color-value in $colors {
tabbar[#{$color-name}] {
border-color: darken($color-value, 10%);
}
}

View File

@ -87,10 +87,11 @@ tabbar {
border: 0; border: 0;
border-radius: 0; border-radius: 0;
background: none; background: none;
}
&:hover:not(.disable-hover) { .tab-button:hover:not(.disable-hover),
.tab-button[aria-selected=true] {
color: $tab-button-active-color; color: $tab-button-active-color;
}
} }
.tab-button-text { .tab-button-text {
@ -121,10 +122,6 @@ tabbar {
white-space: normal; white-space: normal;
} }
.tab-button[aria-selected=true] {
color: $tab-button-active-color;
}
tab-highlight { tab-highlight {
display: none; display: none;
} }
@ -157,3 +154,24 @@ tab-highlight {
[tabbar-icons=hide] .tab-button-icon { [tabbar-icons=hide] .tab-button-icon {
display: none; display: none;
} }
// Tabbar Color Generation
// --------------------------------------------------
@each $color-name, $color-value in $colors {
tabbar[#{$color-name}] {
background-color: $color-value;
.tab-button {
color: inverse($color-value);
}
.tab-button:hover:not(.disable-hover),
.tab-button[aria-selected=true] {
color: inverse($color-value);
}
}
}

View File

@ -2,6 +2,7 @@ import {Directive, ElementRef, Optional, Host, NgFor, NgIf, forwardRef, ViewCont
import {Ion} from '../ion'; import {Ion} from '../ion';
import {IonicApp} from '../app/app'; import {IonicApp} from '../app/app';
import {Attr} from '../app/id';
import {Config} from '../../config/config'; import {Config} from '../../config/config';
import {ViewController} from '../nav/view-controller'; import {ViewController} from '../nav/view-controller';
import {ConfigComponent} from '../../config/decorators'; import {ConfigComponent} from '../../config/decorators';
@ -63,6 +64,7 @@ import {Icon} from '../icon/icon';
defaultInputs: { defaultInputs: {
'tabbarPlacement': 'bottom', 'tabbarPlacement': 'bottom',
'tabbarIcons': 'top', 'tabbarIcons': 'top',
'tabbarStyle': 'default',
'preloadTabs': true 'preloadTabs': true
}, },
template: template:
@ -70,7 +72,7 @@ import {Icon} from '../icon/icon';
'<template navbar-anchor></template>' + '<template navbar-anchor></template>' +
'</ion-navbar-section>' + '</ion-navbar-section>' +
'<ion-tabbar-section>' + '<ion-tabbar-section>' +
'<tabbar role="tablist">' + '<tabbar role="tablist" [attr]="tabbarStyle">' +
'<a *ng-for="#t of tabs" [tab]="t" class="tab-button" role="tab">' + '<a *ng-for="#t of tabs" [tab]="t" class="tab-button" role="tab">' +
'<icon [name]="t.tabIcon" [is-active]="t.isSelected" class="tab-button-icon"></icon>' + '<icon [name]="t.tabIcon" [is-active]="t.isSelected" class="tab-button-icon"></icon>' +
'<span class="tab-button-text">{{t.tabTitle}}</span>' + '<span class="tab-button-text">{{t.tabTitle}}</span>' +
@ -85,6 +87,7 @@ import {Icon} from '../icon/icon';
Icon, Icon,
NgFor, NgFor,
NgIf, NgIf,
Attr,
forwardRef(() => TabButton), forwardRef(() => TabButton),
forwardRef(() => TabHighlight), forwardRef(() => TabHighlight),
forwardRef(() => TabNavBarAnchor) forwardRef(() => TabNavBarAnchor)
@ -217,15 +220,36 @@ export class Tabs extends Ion {
/** /**
* @private * @private
* "Touch" the active tab, either going back to the root view of the tab * "Touch" the active tab, going back to the root view of the tab
* or scrolling the tab to the top * or optionally letting the tab handle the event
*/ */
touchActive(tab) { touchActive(tab) {
let active = tab.getActive();
if(!active) {
return Promise.resolve();
}
let instance = active.instance;
// If they have a custom tab selected handler, call it
if(instance.tabSelected) {
return instance.tabSelected();
}
// If we're a few pages deep, pop to root
if (tab.length() > 1) { if (tab.length() > 1) {
// Pop to the root view // Pop to the root view
return tab.popToRoot(); return tab.popToRoot();
} }
// Otherwise, if the page we're on is not our real root, reset it to our
// default root type
if(tab.root != active.componentType) {
return tab.setRoot(tab.root);
}
// And failing all of that, we do something safe and secure
return Promise.resolve(); return Promise.resolve();
} }

View File

@ -54,9 +54,7 @@ class Tab1 {
` `
}) })
class Tab2 { class Tab2 {
constructor(nav: NavController) { constructor() {
this.nav = nav;
this.sessions = []; this.sessions = [];
for(var i = 1; i <= 250; i++) { for(var i = 1; i <= 250; i++) {
this.sessions.push({ this.sessions.push({
@ -83,11 +81,8 @@ class Tab2 {
</ion-content> </ion-content>
` `
}) })
class Tab3 { class Tab3 {}
constructor(nav: NavController) {
this.nav = nav;
}
}
@App({ @App({
template: ` template: `
@ -104,7 +99,7 @@ class Tab3 {
</ion-content> </ion-content>
</ion-menu> </ion-menu>
<ion-tabs #content> <ion-tabs #content tabbar-style="secondary">
<ion-tab tab-title="Plain List" tab-icon="star" [root]="root1"></ion-tab> <ion-tab tab-title="Plain List" tab-icon="star" [root]="root1"></ion-tab>
<ion-tab tab-title="Schedule" tab-icon="globe" [root]="root2"></ion-tab> <ion-tab tab-title="Schedule" tab-icon="globe" [root]="root2"></ion-tab>
<ion-tab tab-title="Stopwatch" tab-icon="stopwatch" [root]="root3"></ion-tab> <ion-tab tab-title="Stopwatch" tab-icon="stopwatch" [root]="root3"></ion-tab>

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,133 @@
import {App, Page, NavController, Tab} from 'ionic/ionic';
import {ContentChild, QueryList, ViewChildren} from 'angular2/angular2';
//
// Tab 1
//
@Page({
template: `
<ion-navbar *navbar>
<ion-title>Heart</ion-title>
</ion-navbar>
<ion-content padding>
<h2>Tab 1</h2>
</ion-content>
`
})
class Tab1 {
constructor(nav: NavController) {
this.nav = nav;
}
}
//
// Tab 2
//
@Page({
template: `
<ion-navbar *navbar>
<ion-title>Star</ion-title>
</ion-navbar>
<ion-content padding>
<h2>Tab 2</h2>
</ion-content>
`
})
class Tab2 {
constructor(nav: NavController) {
this.nav = nav;
}
}
//
// Tab 3
//
@Page({
template: `
<ion-navbar *navbar>
<a menu-toggle>
<icon menu></icon>
</a>
<ion-title>Stopwatch</ion-title>
</ion-navbar>
<ion-content padding>
<h2>Tab 3</h2>
</ion-content>
`
})
class Tab3 {
constructor(nav: NavController) {
this.nav = nav;
}
}
//
// Tab 3
//
@Page({
template: `
<ion-navbar *navbar>
<a menu-toggle>
<icon menu></icon>
</a>
<ion-title>Quesarito</ion-title>
</ion-navbar>
<ion-content padding>
<h2>Quesarito</h2>
</ion-content>
`
})
class QuesaritoPage {
constructor(nav: NavController) {
this.nav = nav;
}
}
@App({
template: `
<ion-menu [content]="content">
<ion-toolbar secondary>
<ion-title>Secret Menu</ion-title>
</ion-toolbar>
<ion-content>
<ion-list>
<button ion-item menu-close detail-none (click)="openPage('quesarito')">
Quesarito
</button>
</ion-list>
</ion-content>
</ion-menu>
<ion-tabs #content>
<ion-tab tab-title="Heart" tab-icon="heart" [root]="root1" #tab1></ion-tab>
<ion-tab tab-title="Star" tab-icon="star" [root]="root2"></ion-tab>
<ion-tab tab-title="Stopwatch" tab-icon="stopwatch" [root]="root3"></ion-tab>
</ion-tabs>
`
})
export class TabsPage {
@ViewChildren(Tab) tab : QueryList<Tab>;
afterViewInit() {
console.log('Tab', this.tab);
console.log(this.tab.first.setRoot);
}
openPage(which) {
let pages = {
'quesarito': QuesaritoPage
};
this.tab.first.setRoot(pages[which])
}
constructor() {
this.root1 = Tab1;
this.root2 = Tab2;
this.root3 = Tab3;
}
onInit() {
}
}

View File

@ -59,3 +59,11 @@
<ion-tab tab-title="Indiana Jones and the Temple of Doom"></ion-tab> <ion-tab tab-title="Indiana Jones and the Temple of Doom"></ion-tab>
<ion-tab tab-title="Indiana Jones and the Last Crusade"></ion-tab> <ion-tab tab-title="Indiana Jones and the Last Crusade"></ion-tab>
</ion-tabs> </ion-tabs>
<!-- primary color tabbar -->
<ion-tabs no-navbar tabbar-style="primary">
<ion-tab tab-icon="call"></ion-tab>
<ion-tab tab-icon="heart"></ion-tab>
<ion-tab tab-icon="settings"></ion-tab>
</ion-tabs>