UNPKG

11.9 kBTypeScriptView Raw
1import { OpaqueToken } from '@angular/core';
2/**
3* @ngdoc service
4* @name Config
5* @module ionic
6* @description
7* Config allows you to set the modes of your components
8*/
9import { Platform } from '../platform/platform';
10/**
11 * @name Config
12 * @demo /docs/demos/src/config/
13 * @description
14 * The Config lets you configure your entire app or specific platforms.
15 * You can set the tab placement, icon mode, animations, and more here.
16 *
17 * ```ts
18 * import { IonicApp, IonicModule } from 'ionic-angular';
19 *
20 * @NgModule({
21 * declarations: [ MyApp ],
22 * imports: [
23 * BrowserModule,
24 * IonicModule.forRoot(MyApp, {
25 * backButtonText: 'Go Back',
26 * iconMode: 'ios',
27 * modalEnter: 'modal-slide-in',
28 * modalLeave: 'modal-slide-out',
29 * tabsPlacement: 'bottom',
30 * pageTransition: 'ios-transition'
31 * }, {}
32 * )],
33 * bootstrap: [IonicApp],
34 * entryComponents: [ MyApp ],
35 * providers: []
36 * })
37 * ```
38 *
39 *
40 * Config can be overwritten at multiple levels allowing for more granular configuration.
41 * Below is an example where an app can override any setting we want based on a platform.
42 *
43 * ```ts
44 * import { IonicModule } from 'ionic-angular';
45 *
46 * @NgModule({
47 * ...
48 * imports: [
49 * BrowserModule,
50 * IonicModule.forRoot(MyApp, {
51 * tabsPlacement: 'bottom',
52 * platforms: {
53 * ios: {
54 * tabsPlacement: 'top',
55 * }
56 * }
57 * }, {}
58 * )],
59 * ...
60 * })
61 * ```
62 *
63 * We could also configure these values at a component level. Take `tabsPlacement`,
64 * we can configure this as a property on our `ion-tabs`.
65 *
66 * ```html
67 * <ion-tabs tabsPlacement="top">
68 * <ion-tab tabTitle="Dash" tabIcon="pulse" [root]="tabRoot"></ion-tab>
69 * </ion-tabs>
70 * ```
71 *
72 * The last way we could configure is through URL query strings. This is useful for testing
73 * while in the browser. Simply add `?ionic<PROPERTYNAME>=<value>` to the url.
74 *
75 * ```bash
76 * http://localhost:8100/?ionicTabsPlacement=bottom
77 * ```
78 *
79 * Any value can be added to config, and looked up at a later in any component.
80 *
81 * ```js
82 * config.set('ios', 'favoriteColor', 'green');
83 *
84 * // from any page in your app:
85 * config.get('favoriteColor'); // 'green' when iOS
86 * ```
87 *
88 *
89 * A config value can come from anywhere and be anything, but there are default
90 * values for each mode. The [theming](../../../theming/platform-specific-styles/)
91 * documentation has a chart of the default mode configuration. The following
92 * chart displays each property with a description of what it controls.
93 *
94 *
95 * | Config Property | Type | Details |
96 * |--------------------------|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
97 * | `activator` | `string` | Used for buttons, changes the effect of pressing on a button. Available options: `"ripple"`, `"highlight"`. |
98 * | `actionSheetEnter` | `string` | The name of the transition to use while an action sheet is presented. |
99 * | `actionSheetLeave` | `string` | The name of the transition to use while an action sheet is dismissed. |
100 * | `alertEnter` | `string` | The name of the transition to use while an alert is presented. |
101 * | `alertLeave` | `string` | The name of the transition to use while an alert is dismissed. |
102 * | `backButtonText` | `string` | The text to display by the back button icon in the navbar. |
103 * | `backButtonIcon` | `string` | The icon to use as the back button icon. |
104 * | `iconMode` | `string` | The mode to use for all icons throughout the application. Available options: `"ios"`, `"md"` |
105 * | `locationStrategy` | `string` | Set to 'path' to remove hashbangs when using Deeplinking. |
106 * | `loadingEnter` | `string` | The name of the transition to use while a loading indicator is presented. |
107 * | `loadingLeave` | `string` | The name of the transition to use while a loading indicator is dismissed. |
108 * | `menuType` | `string` | Type of menu to display. Available options: `"overlay"`, `"reveal"`, `"push"`. |
109 * | `modalEnter` | `string` | The name of the transition to use while a modal is presented. |
110 * | `modalLeave` | `string` | The name of the transition to use while a modal is dismiss. |
111 * | `mode` | `string` | The mode to use throughout the application. |
112 * | `pageTransition` | `string` | The name of the transition to use while changing pages. Available options: `"ios-transition"`, `"md-transition"`, `"wp-transition"`. |
113 * | `pickerEnter` | `string` | The name of the transition to use while a picker is presented. |
114 * | `pickerLeave` | `string` | The name of the transition to use while a picker is dismissed. |
115 * | `popoverEnter` | `string` | The name of the transition to use while a popover is presented. |
116 * | `popoverLeave` | `string` | The name of the transition to use while a popover is dismissed. |
117 * | `spinner` | `string` | The default spinner to use when a name is not defined. |
118 * | `statusbarPadding` | `boolean` | Whether to hide extra padding for statusbar. |
119 * | `swipeBackEnabled` | `boolean` | Whether native iOS swipe to go back functionality is enabled. |
120 * | `tabsHighlight` | `boolean` | Whether to show a highlight line under the tab when it is selected. |
121 * | `tabsLayout` | `string` | The layout to use for all tabs. Available options: `"icon-top"`, `"icon-start"`, `"icon-end"`, `"icon-bottom"`, `"icon-hide"`, `"title-hide"`. |
122 * | `tabsPlacement` | `string` | The position of the tabs relative to the content. Available options: `"top"`, `"bottom"` |
123 * | `tabsHideOnSubPages` | `boolean` | Whether to hide the tabs on child pages or not. If `true` it will not show the tabs on child pages. |
124 * | `toastEnter` | `string` | The name of the transition to use while a toast is presented. |
125 * | `toastLeave` | `string` | The name of the transition to use while a toast is dismissed. |
126 *
127**/
128export declare class Config {
129 private _c;
130 private _s;
131 private _modes;
132 private _trns;
133 /**
134 * @hidden
135 */
136 plt: Platform;
137 /**
138 * @hidden
139 */
140 init(config: any, plt: Platform): void;
141 /**
142 * @name get
143 * @description
144 * Returns a single config value, given a key.
145 *
146 * @param {string} [key] - the key for the config value
147 * @param {any} [fallbackValue] - a fallback value to use when the config
148 * value was not found, or is config value is `null`. Fallback value
149 * defaults to `null`.
150 */
151 get(key: string, fallbackValue?: any): any;
152 /**
153 * @name getBoolean
154 * @description
155 * Same as `get()`, however always returns a boolean value. If the
156 * value from `get()` is `null`, then it'll return the `fallbackValue`
157 * which defaults to `false`. Otherwise, `getBoolean()` will return
158 * if the config value is truthy or not. It also returns `true` if
159 * the config value was the string value `"true"`.
160 * @param {string} [key] - the key for the config value
161 * @param {boolean} [fallbackValue] - a fallback value to use when the config
162 * value was `null`. Fallback value defaults to `false`.
163 */
164 getBoolean(key: string, fallbackValue?: boolean): boolean;
165 /**
166 * @name getNumber
167 * @description
168 * Same as `get()`, however always returns a number value. Uses `parseFloat()`
169 * on the value received from `get()`. If the result from the parse is `NaN`,
170 * then it will return the value passed to `fallbackValue`. If no fallback
171 * value was provided then it'll default to returning `NaN` when the result
172 * is not a valid number.
173 * @param {string} [key] - the key for the config value
174 * @param {number} [fallbackValue] - a fallback value to use when the config
175 * value turned out to be `NaN`. Fallback value defaults to `NaN`.
176 */
177 getNumber(key: string, fallbackValue?: number): number;
178 /**
179 * @name set
180 * @description
181 * Sets a single config value.
182 *
183 * @param {string} [platform] - The platform (either 'ios' or 'android') that the config value should apply to. Leaving this blank will apply the config value to all platforms.
184 * @param {string} [key] - The key used to look up the value at a later point in time.
185 * @param {string} [value] - The config value being stored.
186 */
187 set(...args: any[]): this;
188 /**
189 * @hidden
190 * @name settings()
191 * @description
192 */
193 settings(arg0?: any, arg1?: any): any;
194 /**
195 * @hidden
196 */
197 setModeConfig(modeName: string, modeConfig: any): void;
198 /**
199 * @hidden
200 */
201 getModeConfig(modeName: string): any;
202 /**
203 * @hidden
204 */
205 setTransition(trnsName: string, trnsClass: any): void;
206 /**
207 * @hidden
208 */
209 getTransition(trnsName: string): any;
210}
211/**
212 * @hidden
213 */
214export declare function setupConfig(userConfig: any, plt: Platform): Config;
215/**
216 * @hidden
217 */
218export declare const ConfigToken: OpaqueToken;