123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. import { ChangeDetectorRef, ComponentFactoryResolver, ComponentRef, ElementRef, ErrorHandler, EventEmitter, NgZone, Renderer, ViewContainerRef } from '@angular/core';
  2. import { App } from '../app/app';
  3. import { Config } from '../../config/config';
  4. import { DeepLinker } from '../../navigation/deep-linker';
  5. import { DomController } from '../../platform/dom-controller';
  6. import { GestureController } from '../../gestures/gesture-controller';
  7. import { Tab as ITab } from '../../navigation/nav-interfaces';
  8. import { NavControllerBase } from '../../navigation/nav-controller-base';
  9. import { NavOptions, NavSegment } from '../../navigation/nav-util';
  10. import { Platform } from '../../platform/platform';
  11. import { TabButton } from './tab-button';
  12. import { Tabs } from './tabs';
  13. import { TransitionController } from '../../transitions/transition-controller';
  14. import { ViewController } from '../../navigation/view-controller';
  15. /**
  16. * @name Tab
  17. * @description
  18. * The Tab component, written `<ion-tab>`, is styled based on the mode and should
  19. * be used in conjunction with the [Tabs](../Tabs/) component.
  20. *
  21. * Each `ion-tab` is a declarative component for a [NavController](../../../navigation/NavController/).
  22. * Basically, each tab is a `NavController`. For more information on using
  23. * navigation controllers take a look at the [NavController API Docs](../../../navigation/NavController/).
  24. *
  25. * See the [Tabs API Docs](../Tabs/) for more details on configuring Tabs.
  26. *
  27. * @usage
  28. *
  29. * To add a basic tab, you can use the following markup where the `root` property
  30. * is the page you want to load for that tab, `tabTitle` is the optional text to
  31. * display on the tab, and `tabIcon` is the optional [icon](../../icon/Icon/).
  32. *
  33. * ```html
  34. * <ion-tabs>
  35. * <ion-tab [root]="chatRoot" tabTitle="Chat" tabIcon="chat"></ion-tab>
  36. * </ion-tabs>
  37. * ```
  38. *
  39. * Then, in your class you can set `chatRoot` to an imported class:
  40. *
  41. * ```ts
  42. * import { ChatPage } from '../chat/chat';
  43. *
  44. * export class Tabs {
  45. * // here we'll set the property of chatRoot to
  46. * // the imported class of ChatPage
  47. * chatRoot = ChatPage;
  48. *
  49. * constructor() {
  50. *
  51. * }
  52. * }
  53. * ```
  54. *
  55. * You can also pass some parameters to the root page of the tab through
  56. * `rootParams`. Below we pass `chatParams` to the Chat tab:
  57. *
  58. * ```html
  59. * <ion-tabs>
  60. * <ion-tab [root]="chatRoot" [rootParams]="chatParams" tabTitle="Chat" tabIcon="chat"></ion-tab>
  61. * </ion-tabs>
  62. * ```
  63. *
  64. * ```ts
  65. * export class Tabs {
  66. * chatRoot = ChatPage;
  67. *
  68. * // set some user information on chatParams
  69. * chatParams = {
  70. * user1: 'admin',
  71. * user2: 'ionic'
  72. * };
  73. *
  74. * constructor() {
  75. *
  76. * }
  77. * }
  78. * ```
  79. *
  80. * And in `ChatPage` you can get the data from `NavParams`:
  81. *
  82. * ```ts
  83. * export class ChatPage {
  84. * constructor(navParams: NavParams) {
  85. * console.log('Passed params', navParams.data);
  86. * }
  87. * }
  88. * ```
  89. *
  90. * Sometimes you may want to call a method instead of navigating to a new
  91. * page. You can use the `(ionSelect)` event to call a method on your class when
  92. * the tab is selected. Below is an example of presenting a modal from one of
  93. * the tabs.
  94. *
  95. * ```html
  96. * <ion-tabs>
  97. * <ion-tab (ionSelect)="chat()" tabTitle="Show Modal"></ion-tab>
  98. * </ion-tabs>pop
  99. * ```
  100. *
  101. * ```ts
  102. * export class Tabs {
  103. * constructor(public modalCtrl: ModalController) {
  104. *
  105. * }
  106. *
  107. * chat() {
  108. * let modal = this.modalCtrl.create(ChatPage);
  109. * modal.present();
  110. * }
  111. * }
  112. * ```
  113. *
  114. *
  115. * @demo /docs/demos/src/tabs/
  116. * @see {@link /docs/components#tabs Tabs Component Docs}
  117. * @see {@link ../../tabs/Tabs Tabs API Docs}
  118. * @see {@link ../../nav/Nav Nav API Docs}
  119. * @see {@link ../../nav/NavController NavController API Docs}
  120. */
  121. export declare class Tab extends NavControllerBase implements ITab {
  122. private _cd;
  123. private linker;
  124. private _dom;
  125. /**
  126. * @hidden
  127. */
  128. _isInitial: boolean;
  129. /**
  130. * @hidden
  131. */
  132. _isEnabled: boolean;
  133. /**
  134. * @hidden
  135. */
  136. _isShown: boolean;
  137. /**
  138. * @hidden
  139. */
  140. _tabId: string;
  141. /**
  142. * @hidden
  143. */
  144. _btnId: string;
  145. /**
  146. * @hidden
  147. */
  148. _loaded: boolean;
  149. /**
  150. * @hidden
  151. */
  152. isSelected: boolean;
  153. /**
  154. * @hidden
  155. */
  156. btn: TabButton;
  157. /**
  158. * @hidden
  159. */
  160. _tabsHideOnSubPages: boolean;
  161. /**
  162. * @hidden
  163. */
  164. _segment: NavSegment;
  165. /**
  166. * @input {Page} Set the root page for this tab.
  167. */
  168. root: any;
  169. /**
  170. * @input {object} Any nav-params to pass to the root page of this tab.
  171. */
  172. rootParams: any;
  173. /**
  174. * @input {string} The URL path name to represent this tab within the URL.
  175. */
  176. tabUrlPath: string;
  177. /**
  178. * @input {string} The title of the tab button.
  179. */
  180. tabTitle: string;
  181. /**
  182. * @input {string} The icon for the tab button.
  183. */
  184. tabIcon: string;
  185. /**
  186. * @input {string} The badge for the tab button.
  187. */
  188. tabBadge: string;
  189. /**
  190. * @input {string} The badge color for the tab button.
  191. */
  192. tabBadgeStyle: string;
  193. /**
  194. * @input {boolean} If true, enable the tab. If false,
  195. * the user cannot interact with this element.
  196. * Default: `true`.
  197. */
  198. enabled: boolean;
  199. /**
  200. * @input {boolean} If true, the tab button is visible within the
  201. * tabbar. Default: `true`.
  202. */
  203. show: boolean;
  204. /**
  205. * @input {boolean} If true, hide the tabs on child pages.
  206. */
  207. tabsHideOnSubPages: boolean;
  208. /**
  209. * @output {Tab} Emitted when the current tab is selected.
  210. */
  211. ionSelect: EventEmitter<Tab>;
  212. constructor(parent: Tabs, app: App, config: Config, plt: Platform, elementRef: ElementRef, zone: NgZone, renderer: Renderer, cfr: ComponentFactoryResolver, _cd: ChangeDetectorRef, gestureCtrl: GestureController, transCtrl: TransitionController, linker: DeepLinker, _dom: DomController, errHandler: ErrorHandler);
  213. /**
  214. * @hidden
  215. */
  216. _vp: ViewContainerRef;
  217. /**
  218. * @hidden
  219. */
  220. ngOnInit(): void;
  221. /**
  222. * @hidden
  223. */
  224. load(opts: NavOptions): Promise<any>;
  225. /**
  226. * @hidden
  227. */
  228. resize(): void;
  229. /**
  230. * @hidden
  231. */
  232. _viewAttachToDOM(viewCtrl: ViewController, componentRef: ComponentRef<any>, viewport: ViewContainerRef): void;
  233. /**
  234. * @hidden
  235. */
  236. setSelected(isSelected: boolean): void;
  237. /**
  238. * @hidden
  239. */
  240. readonly index: number;
  241. /**
  242. * @hidden
  243. */
  244. updateHref(component: any, data: any): void;
  245. /**
  246. * @hidden
  247. */
  248. ngOnDestroy(): void;
  249. /**
  250. * @hidden
  251. */
  252. getType(): string;
  253. goToRoot(opts: NavOptions): Promise<any>;
  254. }