mapcomplete/UI/MoreScreen.ts

83 lines
2.9 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 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";
import {VariableUiElement} from "./Base/VariableUIElement";
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 {
2020-07-29 15:48:21 +02:00
const tr = Translations.t.general.morescreen;
const els: UIElement[] = []
els.push(new VariableUiElement(
State.state.osmConnection.userDetails.map(userDetails => {
if (userDetails.csCount < State.userJourney.themeGeneratorUnlock) {
return tr.requestATheme.Render();
}
return new SubtleButton("./assets/pencil.svg", tr.createYourOwnTheme, {
url: "https://pietervdvn.github.io/MapComplete/customGenerator.html",
newTab: false
}).Render();
})
));
2020-07-29 15:48:21 +02:00
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 <
State.userJourney.customLayoutUnlock) {
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,
new VerticalCombine(els),
tr.streetcomplete
2020-07-29 15:48:21 +02:00
]).Render();
}
}