mapcomplete/UI/MoreScreen.ts

72 lines
2.5 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";
import {State} from "../State";
2020-07-31 16:17:16 +02:00
import {CustomLayout} from "../Logic/CustomLayers";
2020-07-29 15:48:21 +02:00
export class MoreScreen extends UIElement {
constructor() {
super(State.state.locationControl);
2020-07-31 16:17:16 +02:00
this.ListenTo(State.state.osmConnection.userDetails);
2020-07-29 15:48:21 +02:00
}
InnerRender(): string {
const tr = Translations.t.general.morescreen;
const els: UIElement[] = []
for (const k in AllKnownLayouts.allSets) {
const layout = AllKnownLayouts.allSets[k]
2020-07-31 16:17:16 +02:00
if (layout.hideFromOverview && State.state.osmConnection.userDetails.data.name !== "Pieter Vander Vennet") {
continue
}
if (layout.name === State.state.layoutToUse.data.name) {
2020-07-29 20:09:25 +02:00
continue;
}
2020-07-31 16:17:16 +02:00
if (layout.name === CustomLayout.NAME) {
if (!State.state.osmConnection.userDetails.data.loggedIn) {
continue;
}
if (State.state.osmConnection.userDetails.data.csCount < 50) {
2020-07-31 16:17:16 +02:00
continue;
}
}
2020-07-29 15:48:21 +02:00
const currentLocation = State.state.locationControl.data;
2020-07-29 15:48:21 +02:00
const linkText =
`https://pietervdvn.github.io/MapComplete/${layout.name}.html?z=${currentLocation.zoom}&lat=${currentLocation.lat}&lon=${currentLocation.lon}`
2020-08-22 16:00:33 +02:00
let description = Translations.W(layout.description);
if(description !== undefined){
description = new Combine(["<br/>", description]);
}
const link =
new SubtleButton(layout.icon,
new Combine([
"<b>",
Translations.W(layout.title),
"</b>",
2020-08-22 16:00:33 +02:00
description ?? "",
]), {url: linkText, newTab: false});
2020-07-29 15:48:21 +02:00
els.push(link)
}
return new VerticalCombine([
tr.intro,
tr.requestATheme,
2020-07-29 15:48:21 +02:00
new VerticalCombine(els),
tr.streetcomplete
2020-07-29 15:48:21 +02:00
]).Render();
}
}