Skip to content

Commit 1b085e3

Browse files
committed
feat(tabs): enabled and show inputs
Closes #5768
1 parent f972908 commit 1b085e3

File tree

3 files changed

+50
-7
lines changed

3 files changed

+50
-7
lines changed

ionic/components/tabs/tab.ts

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {EventEmitter, Input, Output} from 'angular2/core';
33

44
import {IonicApp} from '../app/app';
55
import {Config} from '../../config/config';
6+
import {isTrueProperty} from '../../util/util';
67
import {Keyboard} from '../../util/keyboard';
78
import {NavController, NavOptions} from '../nav/nav-controller';
89
import {ViewController} from '../nav/view-controller';
@@ -133,6 +134,8 @@ export class Tab extends NavController {
133134
*/
134135
public isSelected: boolean;
135136
private _isInitial: boolean;
137+
private _isEnabled: boolean = true;
138+
private _isShown: boolean = true;
136139
private _panelId: string;
137140
private _btnId: string;
138141
private _loaded: boolean;
@@ -144,35 +147,61 @@ export class Tab extends NavController {
144147
btn: TabButton;
145148

146149
/**
147-
* @input {Page} Set the root page for this tab
150+
* @input {Page} Set the root page for this tab.
148151
*/
149152
@Input() root: Type;
150153

151154
/**
152-
* @input {object} Any nav-params you want to pass to the root page of the tab
155+
* @input {object} Any nav-params to pass to the root page of this tab.
153156
*/
154157
@Input() rootParams: any;
155158

156159
/**
157-
* @input {string} Set the title of this tab
160+
* @input {string} The title of the tab button.
158161
*/
159162
@Input() tabTitle: string;
160163

161164
/**
162-
* @input {string} Set the icon for this tab
165+
* @input {string} The icon for the tab button.
163166
*/
164167
@Input() tabIcon: string;
165168

166169
/**
167-
* @input {string} Set the badge for this tab
170+
* @input {string} The badge for the tab button.
168171
*/
169172
@Input() tabBadge: string;
170173

171174
/**
172-
* @input {string} Set the badge color for this tab
175+
* @input {string} The badge color for the tab button.
173176
*/
174177
@Input() tabBadgeStyle: string;
175178

179+
/**
180+
* @input {boolean} If the tab is enabled or not. If the tab
181+
* is not enabled then the tab button will still show, however,
182+
* the button will appear grayed out and will not be clickable.
183+
* Defaults to `true`.
184+
*/
185+
@Input()
186+
get enabled(): boolean {
187+
return this._isEnabled;
188+
}
189+
set enabled(val: boolean) {
190+
this._isEnabled = isTrueProperty(val);
191+
}
192+
193+
/**
194+
* @input {boolean} If the tab button is visible within the
195+
* tabbar or not. Defaults to `true`.
196+
*/
197+
@Input()
198+
get show(): boolean {
199+
return this._isShown;
200+
}
201+
set show(val: boolean) {
202+
this._isShown = isTrueProperty(val);
203+
}
204+
176205
/**
177206
* @output {Tab} Method to call when the current tab is selected
178207
*/

ionic/components/tabs/tabs.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ tabbar {
8484
cursor: pointer;
8585
}
8686

87+
.tab-disabled {
88+
pointer-events: none;
89+
90+
ion-badge,
91+
ion-icon,
92+
span {
93+
opacity: 0.4;
94+
}
95+
}
96+
97+
.tab-hidden {
98+
display: none;
99+
}
100+
87101
.tab-button-text {
88102
margin-top: 3px;
89103
margin-bottom: 2px;

ionic/components/tabs/tabs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ import {isBlank, isTrueProperty} from '../../util/util';
140140
'</ion-navbar-section>' +
141141
'<ion-tabbar-section>' +
142142
'<tabbar role="tablist">' +
143-
'<a *ngFor="#t of _tabs" [tab]="t" class="tab-button" role="tab">' +
143+
'<a *ngFor="#t of _tabs" [tab]="t" class="tab-button" [class.tab-disabled]="!t.enabled" [class.tab-hidden]="!t.show" role="tab">' +
144144
'<ion-icon *ngIf="t.tabIcon" [name]="t.tabIcon" [isActive]="t.isSelected" class="tab-button-icon"></ion-icon>' +
145145
'<span *ngIf="t.tabTitle" class="tab-button-text">{{t.tabTitle}}</span>' +
146146
'<ion-badge *ngIf="t.tabBadge" class="tab-badge" [ngClass]="\'badge-\' + t.tabBadgeStyle">{{t.tabBadge}}</ion-badge>' +

0 commit comments

Comments
 (0)