mapcomplete/UI/WelcomeMessage.ts

61 lines
1.7 KiB
TypeScript
Raw Normal View History

import {UIElement} from "./UIElement";
import Locale from "../UI/i18n/Locale";
import State from "../State";
import Translations from "./i18n/Translations";
import Combine from "./Base/Combine";
2020-11-06 01:58:26 +01:00
import LanguagePicker from "./LanguagePicker";
export class WelcomeMessage extends UIElement {
private languagePicker: UIElement;
private readonly description: UIElement;
private readonly plzLogIn: UIElement;
private readonly welcomeBack: UIElement;
private readonly tail: UIElement;
constructor() {
super(State.state.osmConnection.userDetails);
this.ListenTo(Locale.language);
2020-11-11 16:23:49 +01:00
this.languagePicker = LanguagePicker.CreateLanguagePicker(State.state.layoutToUse.data.language, Translations.t.general.pickLanguage);
const layout = State.state.layoutToUse.data;
2020-11-11 16:23:49 +01:00
this.description = new Combine([
"<h3>", layout.title, "</h3>",
layout.description
])
layout.descriptionTail
2020-11-11 16:23:49 +01:00
this.plzLogIn =
2020-11-11 16:23:49 +01:00
Translations.t.general.loginWithOpenStreetMap
.onClick(() => {
State.state.osmConnection.AttemptLogin()
});
2020-11-11 16:23:49 +01:00
this.welcomeBack = Translations.t.general.welcomeBack;
this.tail = layout.descriptionTail;
}
InnerRender(): string {
let loginStatus = undefined;
if (State.state.featureSwitchUserbadge.data) {
loginStatus = (State.state.osmConnection.userDetails.data.loggedIn ? this.welcomeBack :
this.plzLogIn);
}
return new Combine([
this.description,
"<br/><br/>",
loginStatus,
this.tail,
"<br/>",
this.languagePicker
]).Render()
}
}