mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-06-12 21:11:01 +00:00
Camera settings (#234)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -10,6 +10,21 @@ import { LEDGER_CONN, LEDGER_CONN_DEFAULT } from './ledger';
|
||||
import { PREFIXES, PREFIX_DEFAULT } from './ss58';
|
||||
import { ICON_DEFAULT, ICON_DEFAULT_HOST, ICONS, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './ui';
|
||||
|
||||
const CAMERA_DEFAULT = 'on';
|
||||
|
||||
const CAMERA: Option[] = [
|
||||
{
|
||||
info: 'on',
|
||||
text: 'Allow camera access',
|
||||
value: 'on'
|
||||
},
|
||||
{
|
||||
info: 'off',
|
||||
text: 'Do not allow camera access',
|
||||
value: 'off'
|
||||
}
|
||||
];
|
||||
|
||||
const LANGUAGE_DEFAULT = 'default';
|
||||
|
||||
const LANGUAGES: Option[] = [
|
||||
@@ -36,6 +51,8 @@ const LOCKING: Option[] = [
|
||||
];
|
||||
|
||||
export {
|
||||
CAMERA_DEFAULT,
|
||||
CAMERA,
|
||||
CRYPTOS,
|
||||
ENDPOINT_DEFAULT,
|
||||
ENDPOINTS,
|
||||
|
||||
@@ -11,6 +11,7 @@ export type Option = {
|
||||
|
||||
export interface SettingsStruct {
|
||||
apiUrl: string;
|
||||
camera: string;
|
||||
i18nLang: string;
|
||||
icon: string;
|
||||
ledgerConn: string;
|
||||
|
||||
Reference in New Issue
Block a user