mapcomplete/UI/MoreScreen.ts

60 lines
2.1 KiB
TypeScript
Raw Normal View History

2020-07-29 15:48:21 +02:00
import {UIElement} from "./UIElement";
import {VerticalCombine} from "./Base/VerticalCombine";
import Translations from "./i18n/Translations";
import {AllKnownLayouts} from "../Customizations/AllKnownLayouts";
import {FixedUiElement} from "./Base/FixedUiElement";
import {Utils} from "../Utils";
import {link} from "fs";
import {UIEventSource} from "./UIEventSource";
import {VariableUiElement} from "./Base/VariableUIElement";
import Combine from "./Base/Combine";
import {SubtleButton} from "./Base/SubtleButton";
2020-07-29 15:48:21 +02:00
export class MoreScreen extends UIElement {
private currentLocation: UIEventSource<{ zoom: number, lat: number, lon: number }>;
2020-07-29 20:09:25 +02:00
private currentLayout: string;
2020-07-29 15:48:21 +02:00
2020-07-29 20:09:25 +02:00
constructor(currentLayout: string, currentLocation: UIEventSource<{ zoom: number, lat: number, lon: number }>) {
2020-07-29 15:48:21 +02:00
super(currentLocation);
2020-07-29 20:09:25 +02:00
this.currentLayout = currentLayout;
2020-07-29 15:48:21 +02:00
this.currentLocation = currentLocation;
}
InnerRender(): string {
const tr = Translations.t.general.morescreen;
const els: UIElement[] = []
for (const k in AllKnownLayouts.allSets) {
const layout = AllKnownLayouts.allSets[k]
if (layout.hideFromOverview) {
continue
}
2020-07-29 20:09:25 +02:00
if (layout.name === this.currentLayout) {
continue;
}
2020-07-29 15:48:21 +02:00
const linkText =
`https://pietervdvn.github.io/MapComplete/${layout.name}.html?z=${this.currentLocation.data.zoom}&lat=${this.currentLocation.data.lat}&lon=${this.currentLocation.data.lon}`
const link =
new SubtleButton(layout.icon,
new Combine([
"<b>",
Translations.W(layout.title),
"</b>",
"<br/>",
Translations.W(layout.description),
]), {url: linkText, newTab: false});
2020-07-29 15:48:21 +02:00
els.push(link)
}
return new VerticalCombine([
tr.intro,
new VerticalCombine(els),
tr.streetcomplete
]).Render();
}
}