UNPKG

12.1 kBTypeScriptView Raw
1import { InjectionToken } 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 * | `scrollAssist` | `boolean` | Used to avoid the input to be hidden by the keyboard if it's near the bottom of the page.
118 * | `scrollPadding` | `boolean` | Used to remove the extra padding on ion-content when keyboard is displayed.
119 * | `spinner` | `string` | The default spinner to use when a name is not defined. |
120 * | `statusbarPadding` | `boolean` | Whether to hide extra padding for statusbar. |
121 * | `swipeBackEnabled` | `boolean` | Whether native iOS swipe to go back functionality is enabled. |
122 * | `tabsHighlight` | `boolean` | Whether to show a highlight line under the tab when it is selected. |
123 * | `tabsLayout` | `string` | The layout to use for all tabs. Available options: `"icon-top"`, `"icon-start"`, `"icon-end"`, `"icon-bottom"`, `"icon-hide"`, `"title-hide"`. |
124 * | `tabsPlacement` | `string` | The position of the tabs relative to the content. Available options: `"top"`, `"bottom"` |
125 * | `tabsHideOnSubPages` | `boolean` | Whether to hide the tabs on child pages or not. If `true` it will not show the tabs on child pages. |
126 * | `toastEnter` | `string` | The name of the transition to use while a toast is presented. |
127 * | `toastLeave` | `string` | The name of the transition to use while a toast is dismissed. |
128 *
129**/
130export declare class Config {
131 private _c;
132 private _s;
133 private _modes;
134 private _trns;
135 /**
136 * @hidden
137 */
138 plt: Platform;
139 /**
140 * @hidden
141 */
142 init(config: any, plt: Platform): void;
143 /**
144 * @name get
145 * @description
146 * Returns a single config value, given a key.
147 *
148 * @param {string} [key] - the key for the config value
149 * @param {any} [fallbackValue] - a fallback value to use when the config
150 * value was not found, or is config value is `null`. Fallback value
151 * defaults to `null`.
152 */
153 get(key: string, fallbackValue?: any): any;
154 /**
155 * @name getBoolean
156 * @description
157 * Same as `get()`, however always returns a boolean value. If the
158 * value from `get()` is `null`, then it'll return the `fallbackValue`
159 * which defaults to `false`. Otherwise, `getBoolean()` will return
160 * if the config value is truthy or not. It also returns `true` if
161 * the config value was the string value `"true"`.
162 * @param {string} [key] - the key for the config value
163 * @param {boolean} [fallbackValue] - a fallback value to use when the config
164 * value was `null`. Fallback value defaults to `false`.
165 */
166 getBoolean(key: string, fallbackValue?: boolean): boolean;
167 /**
168 * @name getNumber
169 * @description
170 * Same as `get()`, however always returns a number value. Uses `parseFloat()`
171 * on the value received from `get()`. If the result from the parse is `NaN`,
172 * then it will return the value passed to `fallbackValue`. If no fallback
173 * value was provided then it'll default to returning `NaN` when the result
174 * is not a valid number.
175 * @param {string} [key] - the key for the config value
176 * @param {number} [fallbackValue] - a fallback value to use when the config
177 * value turned out to be `NaN`. Fallback value defaults to `NaN`.
178 */
179 getNumber(key: string, fallbackValue?: number): number;
180 parseNumber(value: string, fallbackValue?: number): number;
181 /**
182 * @name set
183 * @description
184 * Sets a single config value.
185 *
186 * @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.
187 * @param {string} [key] - The key used to look up the value at a later point in time.
188 * @param {string} [value] - The config value being stored.
189 */
190 set(...args: any[]): this;
191 /**
192 * @hidden
193 * @name settings()
194 * @description
195 */
196 settings(arg0?: any, arg1?: any): any;
197 /**
198 * @hidden
199 */
200 setModeConfig(modeName: string, modeConfig: any): void;
201 /**
202 * @hidden
203 */
204 getModeConfig(modeName: string): any;
205 /**
206 * @hidden
207 */
208 setTransition(trnsName: string, trnsClass: any): void;
209 /**
210 * @hidden
211 */
212 getTransition(trnsName: string): any;
213}
214/**
215 * @hidden
216 */
217export declare function setupConfig(userConfig: any, plt: Platform): Config;
218/**
219 * @hidden
220 */
221export declare const ConfigToken: InjectionToken<any>;