mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 04:14:21 +08:00
@ -1,19 +1,62 @@
|
||||
|
||||
export interface IonicConfig {
|
||||
isDevice?: boolean;
|
||||
statusbarPadding?: boolean;
|
||||
inputShims?: boolean;
|
||||
backButtonIcon?: string;
|
||||
backButtonText?: string;
|
||||
spinner?: string;
|
||||
loadingSpinner?: string;
|
||||
menuIcon?: string;
|
||||
animate?: boolean;
|
||||
pickerSpinner?: string;
|
||||
refreshingIcon?: string;
|
||||
refreshingSpinner?: string;
|
||||
mode?: string;
|
||||
menuType?: string;
|
||||
scrollPadding?: string;
|
||||
inputBlurring?: string;
|
||||
scrollAssist?: string;
|
||||
hideCaretOnScroll?: string;
|
||||
infiniteLoadingSpinner?: string;
|
||||
keyboardHeight?: number;
|
||||
swipeBackEnabled?: boolean;
|
||||
|
||||
tabbarPlacement?: string;
|
||||
tabbarLayout?: string;
|
||||
tabbarHighlight?: boolean;
|
||||
|
||||
actionSheetEnter?: string;
|
||||
alertEnter?: string;
|
||||
loadingEnter?: string;
|
||||
modalEnter?: string;
|
||||
popoverEnter?: string;
|
||||
toastEnter?: string;
|
||||
pickerEnter?: string;
|
||||
|
||||
actionSheetLeave?: string;
|
||||
alertLeave?: string;
|
||||
loadingLeave?: string;
|
||||
modalLeave?: string;
|
||||
popoverLeave?: string;
|
||||
toastLeave?: string;
|
||||
pickerLeave?: string;
|
||||
}
|
||||
|
||||
export class Config {
|
||||
|
||||
private m: Map<string, any>;
|
||||
|
||||
constructor(configObj: {[key: string]: any}) {
|
||||
this.m = new Map<string, any>(Object.entries(configObj));
|
||||
private m: Map<keyof IonicConfig, any>;
|
||||
|
||||
constructor(configObj: IonicConfig) {
|
||||
this.m = new Map<keyof IonicConfig, any>(Object.entries(configObj) as any);
|
||||
}
|
||||
|
||||
get(key: string, fallback?: any): any {
|
||||
get(key: keyof IonicConfig, fallback?: any): any {
|
||||
const value = this.m.get(key);
|
||||
return (value !== undefined) ? value : fallback;
|
||||
}
|
||||
|
||||
getBoolean(key: string, fallback = false): boolean {
|
||||
getBoolean(key: keyof IonicConfig, fallback = false): boolean {
|
||||
const val = this.m.get(key);
|
||||
if (val === undefined) {
|
||||
return fallback;
|
||||
@ -24,12 +67,12 @@ export class Config {
|
||||
return !!val;
|
||||
}
|
||||
|
||||
getNumber(key: string, fallback?: number): number {
|
||||
getNumber(key: keyof IonicConfig, fallback?: number): number {
|
||||
const val = parseFloat(this.m.get(key));
|
||||
return isNaN(val) ? (fallback !== undefined ? fallback : NaN) : val;
|
||||
}
|
||||
|
||||
set(key: string, value: any) {
|
||||
set(key: keyof IonicConfig, value: any) {
|
||||
this.m.set(key, value);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user