mapcomplete/Customizations/Layout.ts

83 lines
2.9 KiB
TypeScript
Raw Normal View History

2020-07-05 18:59:47 +02:00
import {LayerDefinition} from "./LayerDefinition";
import {UIElement} from "../UI/UIElement";
2020-07-21 01:37:48 +02:00
import Translations from "../UI/i18n/Translations";
import Combine from "../UI/Base/Combine";
import State from "../State";
2020-10-10 14:09:12 +02:00
import Translation from "../UI/i18n/Translation";
2020-07-05 18:59:47 +02:00
/**
* A layout is a collection of settings of the global view (thus: welcome text, title, selection of layers).
*/
export class Layout {
public id: string;
public icon: string = "./assets/logo.svg";
2020-07-20 12:39:43 +02:00
public title: UIElement;
public maintainer: string;
public version: string;
2020-07-29 15:48:21 +02:00
public description: string | UIElement;
public changesetMessage: string;
public socialImage: string = "";
public layers: (LayerDefinition | string)[];
2020-07-20 12:39:43 +02:00
public welcomeMessage: UIElement;
2020-07-21 01:37:48 +02:00
public gettingStartedPlzLogin: UIElement;
public welcomeBackMessage: UIElement;
public welcomeTail: UIElement;
2020-07-05 18:59:47 +02:00
2020-07-21 00:07:04 +02:00
public supportedLanguages: string[];
public startzoom: number;
2020-07-05 18:59:47 +02:00
public startLon: number;
public startLat: number;
public enableAdd: boolean = true;
public enableUserBadge: boolean = true;
public enableSearch: boolean = true;
public enableLayers: boolean = true;
public enableBackgroundLayers: boolean = true;
2020-08-07 00:45:33 +02:00
public enableMoreQuests: boolean = true;
public enableShareScreen: boolean = true;
public enableGeolocation: boolean = true;
2020-08-07 00:45:33 +02:00
public hideFromOverview: boolean = false;
2020-07-15 11:23:35 +02:00
/**
* The BBOX of the currently visible map are widened by this factor, in order to make some panning possible.
* This number influences this
*/
2020-08-07 00:45:33 +02:00
public widenFactor: number = 0.07;
public defaultBackground: string = "osm";
2020-07-05 18:59:47 +02:00
constructor(
id: string,
2020-07-21 00:07:04 +02:00
supportedLanguages: string[],
2020-10-10 14:09:12 +02:00
title: Translation | string,
layers: (LayerDefinition | string)[],
2020-07-05 18:59:47 +02:00
startzoom: number,
startLat: number,
startLon: number,
2020-10-11 18:22:04 +02:00
welcomeMessage: UIElement | string,
gettingStartedPlzLogin: UIElement | string = new Combine([
Translations.t.general.getStartedLogin
.SetClass("soft")
.onClick(() => {State.state.osmConnection.AttemptLogin()}),
Translations.t.general.getStartedNewAccount
]),
welcomeBackMessage: UIElement | string = Translations.t.general.welcomeBack,
welcomeTail: UIElement | string = "",
2020-07-05 18:59:47 +02:00
) {
2020-07-21 00:07:04 +02:00
this.supportedLanguages = supportedLanguages;
2020-10-10 14:09:12 +02:00
this.title = Translations.WT(title)
2020-07-05 18:59:47 +02:00
this.startLon = startLon;
this.startLat = startLat;
this.startzoom = startzoom;
this.id = id;
2020-07-05 18:59:47 +02:00
this.layers = layers;
this.welcomeMessage = Translations.W(welcomeMessage)
2020-07-21 01:37:48 +02:00
this.gettingStartedPlzLogin = Translations.W(gettingStartedPlzLogin);
this.welcomeBackMessage = Translations.W(welcomeBackMessage);
this.welcomeTail = Translations.W(welcomeTail);
2020-07-05 18:59:47 +02:00
}
}