mapcomplete/UI/FullScreenMessageBoxHandler.ts

66 lines
2.2 KiB
TypeScript
Raw Normal View History

import {UIElement} from "./UIElement";
import Translations from "./i18n/Translations";
import State from "../State";
import Combine from "./Base/Combine";
/**
* Handles the full screen popup on mobile
*/
export class FullScreenMessageBox extends UIElement {
2020-09-12 21:15:17 +00:00
private readonly returnToTheMap: UIElement;
2020-11-15 13:56:20 +00:00
private _content: UIElement;
constructor(onClear: (() => void)) {
2020-11-16 00:59:30 +00:00
super(State.state.fullScreenMessage);
this.HideOnEmpty(true);
2020-06-29 01:12:44 +00:00
2020-09-12 21:15:17 +00:00
this.returnToTheMap =
new Combine([Translations.t.general.returnToTheMap.Clone().SetStyle("font-size:xx-large")])
.SetStyle("background:var(--catch-detail-color);" +
"position: fixed;" +
"z-index: 10000;" +
"bottom: 0;" +
"left: 0;" +
2020-11-16 00:59:30 +00:00
`height: var(--return-to-the-map-height);` +
2020-09-12 21:15:17 +00:00
"width: 100vw;" +
"color: var(--catch-detail-color-contrast);" +
2020-09-12 21:15:17 +00:00
"font-weight: bold;" +
"pointer-events: all;" +
"cursor: pointer;" +
"padding-top: 1.2em;" +
"text-align: center;" +
"padding-bottom: 1.2em;" +
"box-sizing:border-box")
2020-07-20 22:07:04 +00:00
.onClick(() => {
State.state.fullScreenMessage.setData(undefined);
2020-07-20 22:07:04 +00:00
onClear();
});
2020-06-29 01:12:44 +00:00
}
2020-06-29 01:12:44 +00:00
InnerRender(): string {
2020-09-12 21:15:17 +00:00
if (State.state.fullScreenMessage.data === undefined) {
return "";
}
2020-11-15 13:56:20 +00:00
this._content = State.state.fullScreenMessage.data;
const uielement = new Combine([this._content]).SetStyle(
"display:block;" +
"padding: 1em;" +
"padding-bottom:6em;" +
2020-11-16 00:59:30 +00:00
`margin-bottom: var(--return-to-the-map-height);` +
"box-sizing:border-box;" +
2020-11-16 00:59:30 +00:00
`height:calc(100vh - var(--return-to-the-map-height));` +
"overflow-y: auto;" +
"max-width:100vw;" +
"overflow-x:hidden;" +
"background:var(--background-color);" +
"color: var(--foreground-color);"
);
return new Combine([uielement, this.returnToTheMap])
2020-09-12 21:15:17 +00:00
.Render();
}
}