Camera settings (#234)

This commit is contained in:
Jaco Greeff
2019-10-24 15:08:29 +02:00
committed by GitHub
parent ff351a0f31
commit d9cc92db14
9 changed files with 89 additions and 19 deletions
+14 -1
View File
@@ -6,7 +6,7 @@ import EventEmitter from 'eventemitter3';
import store from 'store';
import { isUndefined } from '@polkadot/util';
import { CRYPTOS, ENDPOINT_DEFAULT, ENDPOINTS, ICON_DEFAULT, ICONS, LANGUAGE_DEFAULT, LANGUAGES, LEDGER_CONN, LEDGER_CONN_DEFAULT, LOCKING_DEFAULT, LOCKING, PREFIX_DEFAULT, PREFIXES, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './defaults';
import { CAMERA_DEFAULT, CAMERA, CRYPTOS, ENDPOINT_DEFAULT, ENDPOINTS, ICON_DEFAULT, ICONS, LANGUAGE_DEFAULT, LANGUAGES, LEDGER_CONN, LEDGER_CONN_DEFAULT, LOCKING_DEFAULT, LOCKING, PREFIX_DEFAULT, PREFIXES, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './defaults';
import { Option, SettingsStruct } from './types';
type ChangeCallback = (settings: SettingsStruct) => void;
@@ -15,6 +15,8 @@ type OnTypes = 'change';
export class Settings implements SettingsStruct {
private _apiUrl: string;
private _camera: string;
private _emitter: EventEmitter;
private _i18nLang: string;
@@ -37,6 +39,7 @@ export class Settings implements SettingsStruct {
this._emitter = new EventEmitter();
this._apiUrl = settings.apiUrl || process.env.WS_URL || ENDPOINT_DEFAULT;
this._camera = settings.camera || CAMERA_DEFAULT;
this._ledgerConn = settings.ledgerConn || LEDGER_CONN_DEFAULT;
this._i18nLang = settings.i18nLang || LANGUAGE_DEFAULT;
this._icon = settings.icon || ICON_DEFAULT;
@@ -46,6 +49,10 @@ export class Settings implements SettingsStruct {
this._uiTheme = settings.uiTheme || UITHEME_DEFAULT;
}
public get camera (): string {
return this._camera;
}
public get apiUrl (): string {
return this._apiUrl;
}
@@ -78,6 +85,10 @@ export class Settings implements SettingsStruct {
return this._uiTheme;
}
public get availableCamera (): Option[] {
return CAMERA;
}
public get availableCryptos (): Option[] {
return CRYPTOS;
}
@@ -117,6 +128,7 @@ export class Settings implements SettingsStruct {
public get (): SettingsStruct {
return {
apiUrl: this._apiUrl,
camera: this._camera,
i18nLang: this._i18nLang,
icon: this._icon,
ledgerConn: this._ledgerConn,
@@ -129,6 +141,7 @@ export class Settings implements SettingsStruct {
public set (settings: Partial<SettingsStruct>): void {
this._apiUrl = settings.apiUrl || this._apiUrl;
this._camera = settings.camera || this._camera;
this._ledgerConn = settings.ledgerConn || this._ledgerConn;
this._i18nLang = settings.i18nLang || this._i18nLang;
this._icon = settings.icon || this._icon;